File indexing completed on 2024-04-06 12:22:27
0001 #include <iomanip>
0002 #include <iostream>
0003
0004 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0005
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011
0012 #include "L1Trigger/L1TMuonBarrel/interface/L1TMuonBarrelParamsHelper.h"
0013 #include "CondFormats/DataRecord/interface/L1TMuonBarrelParamsRcd.h"
0014 #include "CondFormats/L1TObjects/interface/L1TMuonBarrelParams.h"
0015 #include "FWCore/ServiceRegistry/interface/Service.h"
0016 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0017 #include "CondCore/CondDB/interface/Session.h"
0018
0019 #include <iostream>
0020 using namespace std;
0021
0022 class L1TMuonBarrelParamsViewer : public edm::one::EDAnalyzer<> {
0023 private:
0024 std::string hash(void *buf, size_t len) const;
0025 edm::ESGetToken<L1TMuonBarrelParams, L1TMuonBarrelParamsRcd> token_;
0026 bool printPtaThreshold;
0027
0028 public:
0029 void analyze(const edm::Event &, const edm::EventSetup &) override;
0030
0031 explicit L1TMuonBarrelParamsViewer(const edm::ParameterSet &) : token_{esConsumes()} { printPtaThreshold = false; }
0032 };
0033
0034 #include "Utilities/OpenSSL/interface/openssl_init.h"
0035 #include <cmath>
0036 #include <iostream>
0037 using namespace std;
0038
0039 std::string L1TMuonBarrelParamsViewer::hash(void *buf, size_t len) const {
0040 cms::openssl_init();
0041 EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
0042 const EVP_MD *md = EVP_get_digestbyname("SHA1");
0043 if (!EVP_DigestInit_ex(mdctx, md, nullptr))
0044 throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 initialization error";
0045
0046 if (!EVP_DigestUpdate(mdctx, buf, len))
0047 throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 processing error";
0048
0049 unsigned char hash[EVP_MAX_MD_SIZE];
0050 unsigned int md_len = 0;
0051 if (!EVP_DigestFinal_ex(mdctx, hash, &md_len))
0052 throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 finalization error";
0053
0054 EVP_MD_CTX_free(mdctx);
0055
0056
0057 char tmp[EVP_MAX_MD_SIZE * 2 + 1];
0058 if (md_len > 20)
0059 md_len = 20;
0060 for (unsigned int i = 0; i < md_len; i++)
0061 ::sprintf(&tmp[i * 2], "%02x", hash[i]);
0062
0063 tmp[md_len * 2] = 0;
0064 return std::string(tmp);
0065 }
0066
0067 void L1TMuonBarrelParamsViewer::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
0068 L1TMuonBarrelParams const &ptr = evSetup.getData(token_);
0069
0070 L1TMuonBarrelParamsHelper *ptr1 = (L1TMuonBarrelParamsHelper *)&ptr;
0071
0072 cout << "AssLUTPath: " << ptr1->AssLUTPath() << endl;
0073
0074
0075
0076 size_t k = 0;
0077 for (const auto &lut : ptr1->pta_lut()) {
0078 if (!lut.empty()) {
0079 cout << " pta_lut[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
0080 int lut_[lut.size()], i = 0;
0081 for (const pair<const short, short> &p : lut)
0082 lut_[i++] = p.first * 0xFFFF + p.second;
0083 cout << hash(lut_, sizeof(int) * lut.size()) << endl;
0084 } else {
0085 cout << " pta_lut[" << setw(2) << k << "]= [0] " << endl;
0086 }
0087 k++;
0088 }
0089
0090 cout << " pta_threshold= [" << ptr1->pta_threshold().size() << "] " << flush;
0091 int pta_threshold[ptr1->pta_threshold().size()];
0092 for (unsigned int i = 0; i < ptr1->pta_threshold().size(); i++) {
0093 pta_threshold[i] = ptr1->pta_threshold()[i];
0094 if (printPtaThreshold)
0095 cout << " " << pta_threshold[i] << endl;
0096 }
0097 if (!ptr1->pta_threshold().empty())
0098 cout << hash(pta_threshold, sizeof(int) * ptr1->pta_threshold().size()) << endl;
0099 else
0100 cout << endl;
0101
0102 k = 0;
0103 for (const auto &lut : ptr1->pta_lut()) {
0104 if (!lut.empty()) {
0105 cout << " phi_lut[" << k << "]= [" << lut.size() << "] " << flush;
0106 int lut_[lut.size()], i = 0;
0107 for (const pair<const short, short> &p : lut)
0108 lut_[i++] = p.first * 0xFFFF + p.second;
0109 cout << hash(lut_, sizeof(int) * lut.size()) << endl;
0110 } else {
0111 cout << " phi_lut[" << k << "]= [0] " << endl;
0112 }
0113 k++;
0114 }
0115
0116 k = 0;
0117 for (const auto &lu : ptr1->ext_lut()) {
0118 const auto &lut = lu.low;
0119 if (!lut.empty()) {
0120 cout << " ext_lut_low[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
0121 int lut_[lut.size()], i = 0;
0122 for (const pair<const short, short> &p : lut)
0123 lut_[i++] = p.first * 0xFFFF + p.second;
0124 cout << hash(lut_, sizeof(int) * lut.size()) << endl;
0125 } else {
0126 cout << " ext_lut_low[" << setw(2) << k << "]= [0] " << endl;
0127 }
0128 k++;
0129 }
0130
0131 k = 0;
0132 for (const auto &lu : ptr1->ext_lut()) {
0133 const auto &lut = lu.high;
0134 if (!lut.empty()) {
0135 cout << " ext_lut_high[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
0136 int lut_[lut.size()], i = 0;
0137 for (const pair<const short, short> &p : lut)
0138 lut_[i++] = p.first * 0xFFFF + p.second;
0139 cout << hash(lut_, sizeof(int) * lut.size()) << endl;
0140 } else {
0141 cout << " ext_lut_high[" << setw(2) << k << "]= [0] " << endl;
0142 }
0143 k++;
0144 }
0145
0146
0147 for (const auto &item : ptr1->qp_lut()) {
0148 cout << " qp_lut[" << item.first.first << "," << item.first.second << "]= " << item.second.first << ", ["
0149 << item.second.second.size() << "] " << flush;
0150 if (!item.second.second.empty()) {
0151 int lut_[item.second.second.size()];
0152 for (size_t i = 0; i < item.second.second.size(); i++)
0153 lut_[i] = item.second.second[i];
0154 cout << hash(lut_, sizeof(int) * item.second.second.size()) << endl;
0155 } else {
0156 cout << endl;
0157 }
0158 }
0159
0160
0161 for (const pair<const short, L1MuDTEtaPattern> &item : ptr1->eta_lut())
0162 cout << " eta_lut[" << item.first << "]= " << endl << item.second << endl;
0163
0164 cout << "PT_Assignment_nbits_Phi= " << ptr1->get_PT_Assignment_nbits_Phi() << endl;
0165 cout << "PT_Assignment_nbits_PhiB= " << ptr1->get_PT_Assignment_nbits_PhiB() << endl;
0166 cout << "PHI_Assignment_nbits_Phi= " << ptr1->get_PHI_Assignment_nbits_Phi() << endl;
0167 cout << "PHI_Assignment_nbits_PhiB= " << ptr1->get_PHI_Assignment_nbits_PhiB() << endl;
0168 cout << "Extrapolation_nbits_Phi= " << ptr1->get_Extrapolation_nbits_Phi() << endl;
0169 cout << "Extrapolation_nbits_PhiB= " << ptr1->get_Extrapolation_nbits_PhiB() << endl;
0170 cout << "BX_min= " << ptr1->get_BX_min() << endl;
0171 cout << "BX_max= " << ptr1->get_BX_max() << endl;
0172 cout << "Extrapolation_Filter= " << ptr1->get_Extrapolation_Filter() << endl;
0173 cout << "OutOfTime_Filter_Window= " << ptr1->get_OutOfTime_Filter_Window() << endl;
0174
0175 cout << boolalpha;
0176 cout << "OutOfTime_Filter= " << ptr1->get_OutOfTime_Filter() << endl;
0177 cout << "Open_LUTs= " << ptr1->get_Open_LUTs() << endl;
0178 cout << "EtaTrackFinder= " << ptr1->get_EtaTrackFinder() << endl;
0179 cout << "Extrapolation_21= " << ptr1->get_Extrapolation_21() << endl;
0180 cout << "DisableNewAlgo= " << ptr1->get_DisableNewAlgo() << endl;
0181 cout << noboolalpha;
0182
0183
0184 cout << "fwVersion= " << ptr1->fwVersion() << endl;
0185 cout << "version= " << ptr1->version_ << endl;
0186 }
0187
0188 #include "FWCore/PluginManager/interface/ModuleDef.h"
0189 #include "FWCore/Framework/interface/MakerMacros.h"
0190 #include "FWCore/Framework/interface/ModuleFactory.h"
0191
0192 DEFINE_FWK_MODULE(L1TMuonBarrelParamsViewer);