Back to home page

Project CMSSW displayed by LXR

 
 

    


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 "CondFormats/DataRecord/interface/L1TMuonGlobalParamsRcd.h"
0013 #include "CondFormats/L1TObjects/interface/L1TMuonGlobalParams.h"
0014 #include "L1Trigger/L1TMuon/interface/L1TMuonGlobalParamsHelper.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 L1TMuonGlobalParamsViewer : public edm::one::EDAnalyzer<> {
0023 private:
0024   //    bool printLayerMap;
0025   std::string hash(void* buf, size_t len) const;
0026   void printLUT(l1t::LUT* lut, const char* name) const;
0027 
0028   edm::ESGetToken<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd> token_;
0029 
0030 public:
0031   void analyze(const edm::Event&, const edm::EventSetup&) override;
0032   //    string hash(void *buf, size_t len) const ;
0033 
0034   explicit L1TMuonGlobalParamsViewer(const edm::ParameterSet& pset) : token_{esConsumes()} {
0035     //       printLayerMap   = pset.getUntrackedParameter<bool>("printLayerMap",  false);
0036   }
0037 };
0038 
0039 #include "Utilities/OpenSSL/interface/openssl_init.h"
0040 #include <cmath>
0041 #include <iostream>
0042 using namespace std;
0043 
0044 string L1TMuonGlobalParamsViewer::hash(void* buf, size_t len) const {
0045   cms::openssl_init();
0046   EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
0047   const EVP_MD* md = EVP_get_digestbyname("SHA1");
0048   if (!EVP_DigestInit_ex(mdctx, md, nullptr))
0049     throw cms::Exception("L1TMuonGlobalParamsViewer::hash") << "SHA1 initialization error";
0050 
0051   if (!EVP_DigestUpdate(mdctx, buf, len))
0052     throw cms::Exception("L1TMuonGlobalParamsViewer::hash") << "SHA1 processing error";
0053 
0054   unsigned char hash[EVP_MAX_MD_SIZE];
0055   unsigned int md_len = 0;
0056   if (!EVP_DigestFinal_ex(mdctx, hash, &md_len))
0057     throw cms::Exception("L1TMuonGlobalParamsViewer::hash") << "SHA1 finalization error";
0058 
0059   EVP_MD_CTX_free(mdctx);
0060 
0061   // re-write bytes in hex
0062   char tmp[EVP_MAX_MD_SIZE * 2 + 1];
0063   if (md_len > 20)
0064     md_len = 20;
0065   for (unsigned int i = 0; i < md_len; i++)
0066     ::sprintf(&tmp[i * 2], "%02x", hash[i]);
0067 
0068   tmp[md_len * 2] = 0;
0069   return string(tmp);
0070 }
0071 
0072 void L1TMuonGlobalParamsViewer::printLUT(l1t::LUT* lut, const char* name) const {
0073   if (!lut->empty()) {
0074     cout << "  " << std::setw(24) << name << "[" << lut->maxSize() << "] " << flush;
0075     int pod[lut->maxSize()];
0076     for (unsigned int i = 0; i < lut->maxSize(); i++)
0077       pod[i] = lut->data(i);
0078     cout << hash(pod, sizeof(int) * lut->maxSize()) << endl;
0079   } else {
0080     cout << "  " << std::setw(24) << name << "[0]" << endl;
0081   }
0082 }
0083 
0084 void L1TMuonGlobalParamsViewer::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0085   // Pull the config from the ES
0086   //   has to be a copy as call non-const methods
0087   L1TMuonGlobalParams ptr1 = evSetup.getData(token_);
0088 
0089   //    cout<<"Some fields in L1TMuonGlobalParams: "<<endl;
0090 
0091   //    ((L1TMuonGlobalParamsHelper*)ptr1.get())->print(cout);
0092 
0093   printLUT(ptr1.absIsoCheckMemLUT(), "absIsoCheckMemLUT");
0094   printLUT(ptr1.absIsoCheckMemLUT(), "absIsoCheckMemLUT");
0095   printLUT(ptr1.relIsoCheckMemLUT(), "relIsoCheckMemLUT");
0096   printLUT(ptr1.idxSelMemPhiLUT(), "idxSelMemPhiLUT");
0097   printLUT(ptr1.idxSelMemEtaLUT(), "idxSelMemEtaLUT");
0098   //l1t::LUT* brlSingleMatchQualLUT();
0099   printLUT(ptr1.fwdPosSingleMatchQualLUT(), "fwdPosSingleMatchQualLUT");
0100   printLUT(ptr1.fwdNegSingleMatchQualLUT(), "fwdNegSingleMatchQualLUT");
0101   printLUT(ptr1.ovlPosSingleMatchQualLUT(), "ovlPosSingleMatchQualLUT");
0102   printLUT(ptr1.ovlNegSingleMatchQualLUT(), "ovlNegSingleMatchQualLUT");
0103   printLUT(ptr1.bOPosMatchQualLUT(), "bOPosMatchQualLUT");
0104   printLUT(ptr1.bONegMatchQualLUT(), "bONegMatchQualLUT");
0105   printLUT(ptr1.fOPosMatchQualLUT(), "fOPosMatchQualLUT");
0106   printLUT(ptr1.fONegMatchQualLUT(), "fONegMatchQualLUT");
0107   printLUT(ptr1.bPhiExtrapolationLUT(), "bPhiExtrapolationLUT");
0108   printLUT(ptr1.oPhiExtrapolationLUT(), "oPhiExtrapolationLUT");
0109   printLUT(ptr1.fPhiExtrapolationLUT(), "fPhiExtrapolationLUT");
0110   printLUT(ptr1.bEtaExtrapolationLUT(), "bEtaExtrapolationLUT");
0111   printLUT(ptr1.oEtaExtrapolationLUT(), "oEtaExtrapolationLUT");
0112   printLUT(ptr1.fEtaExtrapolationLUT(), "fEtaExtrapolationLUT");
0113   printLUT(ptr1.sortRankLUT(), "sortRankLUT");
0114 
0115   std::cout << "absIsoCheckMemLUTPath: " << ptr1.absIsoCheckMemLUTPath() << std::endl;
0116   std::cout << "relIsoCheckMemLUTPath: " << ptr1.relIsoCheckMemLUTPath() << std::endl;
0117   std::cout << "idxSelMemPhiLUTPath: " << ptr1.idxSelMemPhiLUTPath() << std::endl;
0118   std::cout << "idxSelMemEtaLUTPath: " << ptr1.idxSelMemEtaLUTPath() << std::endl;
0119   //std::string brlSingleMatchQualLUTPath() const    { return pnodes_[brlSingleMatchQual].sparams_.size() > spIdx::fname ? pnodes_[brlSingleMatchQual].sparams_[spIdx::fname] : ""; }
0120   std::cout << "fwdPosSingleMatchQualLUTPath: " << ptr1.fwdPosSingleMatchQualLUTPath() << std::endl;
0121   std::cout << "fwdNegSingleMatchQualLUTPath: " << ptr1.fwdNegSingleMatchQualLUTPath() << std::endl;
0122   std::cout << "ovlPosSingleMatchQualLUTPath: " << ptr1.ovlPosSingleMatchQualLUTPath() << std::endl;
0123   std::cout << "ovlNegSingleMatchQualLUTPath: " << ptr1.ovlNegSingleMatchQualLUTPath() << std::endl;
0124   std::cout << "bOPosMatchQualLUTPath: " << ptr1.bOPosMatchQualLUTPath() << std::endl;
0125   std::cout << "bONegMatchQualLUTPath: " << ptr1.bONegMatchQualLUTPath() << std::endl;
0126   std::cout << "fOPosMatchQualLUTPath: " << ptr1.fOPosMatchQualLUTPath() << std::endl;
0127   std::cout << "fONegMatchQualLUTPath: " << ptr1.fONegMatchQualLUTPath() << std::endl;
0128   std::cout << "bPhiExtrapolationLUTPath: " << ptr1.bPhiExtrapolationLUTPath() << std::endl;
0129   std::cout << "oPhiExtrapolationLUTPath: " << ptr1.oPhiExtrapolationLUTPath() << std::endl;
0130   std::cout << "fPhiExtrapolationLUTPath: " << ptr1.fPhiExtrapolationLUTPath() << std::endl;
0131   std::cout << "bEtaExtrapolationLUTPath: " << ptr1.bEtaExtrapolationLUTPath() << std::endl;
0132   std::cout << "oEtaExtrapolationLUTPath: " << ptr1.oEtaExtrapolationLUTPath() << std::endl;
0133   std::cout << "fEtaExtrapolationLUTPath: " << ptr1.fEtaExtrapolationLUTPath() << std::endl;
0134   std::cout << "sortRankLUTPath: " << ptr1.sortRankLUTPath() << std::endl;
0135 
0136   std::cout << "fwdPosSingleMatchQualLUTMaxDR: " << ptr1.fwdPosSingleMatchQualLUTMaxDR() << std::endl;
0137   std::cout << "fwdNegSingleMatchQualLUTMaxDR: " << ptr1.fwdNegSingleMatchQualLUTMaxDR() << std::endl;
0138   std::cout << "ovlPosSingleMatchQualLUTMaxDR: " << ptr1.ovlPosSingleMatchQualLUTMaxDR() << std::endl;
0139   std::cout << "ovlNegSingleMatchQualLUTMaxDR: " << ptr1.ovlNegSingleMatchQualLUTMaxDR() << std::endl;
0140   std::cout << "bOPosMatchQualLUTMaxDR: " << ptr1.bOPosMatchQualLUTMaxDR() << std::endl;
0141   std::cout << "bONegMatchQualLUTMaxDR: " << ptr1.bONegMatchQualLUTMaxDR() << std::endl;
0142   std::cout << "bOPosMatchQualLUTMaxDREtaFine: " << ptr1.bOPosMatchQualLUTMaxDREtaFine() << std::endl;
0143   std::cout << "bONegMatchQualLUTMaxDREtaFine: " << ptr1.bONegMatchQualLUTMaxDREtaFine() << std::endl;
0144   std::cout << "fOPosMatchQualLUTMaxDR: " << ptr1.fOPosMatchQualLUTMaxDR() << std::endl;
0145   std::cout << "fONegMatchQualLUTMaxDR: " << ptr1.fONegMatchQualLUTMaxDR() << std::endl;
0146 
0147   // Sort rank LUT factors for pT and quality
0148   std::cout << "sortRankLUTPtFactor: " << ptr1.sortRankLUTPtFactor() << std::endl;
0149   std::cout << "sortRankLUTQualFactor: " << ptr1.sortRankLUTQualFactor() << std::endl;
0150 }
0151 
0152 #include "FWCore/PluginManager/interface/ModuleDef.h"
0153 #include "FWCore/Framework/interface/MakerMacros.h"
0154 #include "FWCore/Framework/interface/ModuleFactory.h"
0155 
0156 DEFINE_FWK_MODULE(L1TMuonGlobalParamsViewer);