Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:38

0001 /** 
0002  *  Compare configuration from DB with Python
0003  *
0004  *  \author S. Dildick - Texas A&M University
0005  */
0006 
0007 #include <iostream>
0008 
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Utilities/interface/ESGetToken.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 // Configuration via EventSetup
0018 #include "CondFormats/CSCObjects/interface/CSCDBL1TPParameters.h"
0019 #include "CondFormats/DataRecord/interface/CSCDBL1TPParametersRcd.h"
0020 
0021 class L1CSCTPEmulatorConfigAnalyzer : public edm::one::EDAnalyzer<> {
0022 public:
0023   L1CSCTPEmulatorConfigAnalyzer(const edm::ParameterSet& pset);
0024 
0025   ~L1CSCTPEmulatorConfigAnalyzer() override {}
0026 
0027   void beginJob() override {}
0028   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0029   void endJob() override {}
0030 
0031 private:
0032   edm::ParameterSet pyConfig;
0033   edm::ESGetToken<CSCDBL1TPParameters, CSCDBL1TPParametersRcd> confHToken;
0034 };
0035 
0036 using namespace std;
0037 L1CSCTPEmulatorConfigAnalyzer::L1CSCTPEmulatorConfigAnalyzer(const edm::ParameterSet& iConfig) {
0038   pyConfig = iConfig;
0039   confHToken = esConsumes<CSCDBL1TPParameters, CSCDBL1TPParametersRcd>();
0040 }
0041 
0042 void L1CSCTPEmulatorConfigAnalyzer::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
0043   edm::ESHandle<CSCDBL1TPParameters> confH = iSetup.getHandle(confHToken);
0044   const CSCDBL1TPParameters* dbConfig = confH.product();
0045 
0046   // python params
0047   edm::ParameterSet tmbParams = pyConfig.getParameter<edm::ParameterSet>("tmbParam");
0048   edm::ParameterSet alctParams = pyConfig.getParameter<edm::ParameterSet>("alctParam07");
0049   edm::ParameterSet clctParams = pyConfig.getParameter<edm::ParameterSet>("clctParam07");
0050 
0051   unsigned int db_alctFifoTbins = dbConfig->alctFifoTbins();
0052   unsigned int db_alctFifoPretrig = dbConfig->alctFifoPretrig();
0053   unsigned int db_alctDriftDelay = dbConfig->alctDriftDelay();
0054   unsigned int db_alctNplanesHitPretrig = dbConfig->alctNplanesHitPretrig();
0055   unsigned int db_alctNplanesHitPattern = dbConfig->alctNplanesHitPattern();
0056   unsigned int db_alctNplanesHitAccelPretrig = dbConfig->alctNplanesHitAccelPretrig();
0057   unsigned int db_alctNplanesHitAccelPattern = dbConfig->alctNplanesHitAccelPattern();
0058   unsigned int db_alctTrigMode = dbConfig->alctTrigMode();
0059   unsigned int db_alctAccelMode = dbConfig->alctAccelMode();
0060   unsigned int db_alctL1aWindowWidth = dbConfig->alctL1aWindowWidth();
0061 
0062   unsigned int db_clctFifoTbins = dbConfig->clctFifoTbins();
0063   unsigned int db_clctFifoPretrig = dbConfig->clctFifoPretrig();
0064   unsigned int db_clctHitPersist = dbConfig->clctHitPersist();
0065   unsigned int db_clctDriftDelay = dbConfig->clctDriftDelay();
0066   unsigned int db_clctNplanesHitPretrig = dbConfig->clctNplanesHitPretrig();
0067   unsigned int db_clctNplanesHitPattern = dbConfig->clctNplanesHitPattern();
0068   unsigned int db_clctPidThreshPretrig = dbConfig->clctPidThreshPretrig();
0069   unsigned int db_clctMinSeparation = dbConfig->clctMinSeparation();
0070 
0071   unsigned int db_tmbMpcBlockMe1a = dbConfig->tmbMpcBlockMe1a();
0072   unsigned int db_tmbAlctTrigEnable = dbConfig->tmbAlctTrigEnable();
0073   unsigned int db_tmbClctTrigEnable = dbConfig->tmbClctTrigEnable();
0074   unsigned int db_tmbMatchTrigEnable = dbConfig->tmbMatchTrigEnable();
0075   unsigned int db_tmbMatchTrigWindowSize = dbConfig->tmbMatchTrigWindowSize();
0076   unsigned int db_tmbL1aWindowSize = dbConfig->tmbTmbL1aWindowSize();
0077 
0078   unsigned int py_alctFifoTbins = alctParams.getParameter<unsigned int>("alctFifoTbins");
0079   unsigned int py_alctFifoPretrig = alctParams.getParameter<unsigned int>("alctFifoPretrig");
0080   unsigned int py_alctDriftDelay = alctParams.getParameter<unsigned int>("alctDriftDelay");
0081   unsigned int py_alctNplanesHitPretrig = alctParams.getParameter<unsigned int>("alctNplanesHitPretrig");
0082   unsigned int py_alctNplanesHitPattern = alctParams.getParameter<unsigned int>("alctNplanesHitPattern");
0083   unsigned int py_alctNplanesHitAccelPretrig = alctParams.getParameter<unsigned int>("alctNplanesHitAccelPretrig");
0084   unsigned int py_alctNplanesHitAccelPattern = alctParams.getParameter<unsigned int>("alctNplanesHitAccelPattern");
0085   unsigned int py_alctTrigMode = alctParams.getParameter<unsigned int>("alctTrigMode");
0086   unsigned int py_alctAccelMode = alctParams.getParameter<unsigned int>("alctAccelMode");
0087   unsigned int py_alctL1aWindowWidth = alctParams.getParameter<unsigned int>("alctL1aWindowWidth");
0088 
0089   unsigned int py_clctFifoTbins = clctParams.getParameter<unsigned int>("clctFifoTbins");
0090   unsigned int py_clctFifoPretrig = clctParams.getParameter<unsigned int>("clctFifoPretrig");
0091   unsigned int py_clctHitPersist = clctParams.getParameter<unsigned int>("clctHitPersist");
0092   unsigned int py_clctDriftDelay = clctParams.getParameter<unsigned int>("clctDriftDelay");
0093   unsigned int py_clctNplanesHitPretrig = clctParams.getParameter<unsigned int>("clctNplanesHitPretrig");
0094   unsigned int py_clctNplanesHitPattern = clctParams.getParameter<unsigned int>("clctNplanesHitPattern");
0095   unsigned int py_clctPidThreshPretrig = clctParams.getParameter<unsigned int>("clctPidThreshPretrig");
0096   unsigned int py_clctMinSeparation = clctParams.getParameter<unsigned int>("clctMinSeparation");
0097 
0098   unsigned int py_tmbMpcBlockMe1a = tmbParams.getParameter<unsigned int>("mpcBlockMe1a");
0099   unsigned int py_tmbAlctTrigEnable = tmbParams.getParameter<unsigned int>("alctTrigEnable");
0100   unsigned int py_tmbClctTrigEnable = tmbParams.getParameter<unsigned int>("clctTrigEnable");
0101   unsigned int py_tmbMatchTrigEnable = tmbParams.getParameter<unsigned int>("matchTrigEnable");
0102   unsigned int py_tmbMatchTrigWindowSize = tmbParams.getParameter<unsigned int>("matchTrigWindowSize");
0103   unsigned int py_tmbL1aWindowSize = tmbParams.getParameter<unsigned int>("tmbL1aWindowSize");
0104 
0105   //check
0106   bool ok_alctFifoTbins = db_alctFifoTbins == py_alctFifoTbins;
0107   bool ok_alctFifoPretrig = db_alctFifoPretrig == py_alctFifoPretrig;
0108   bool ok_alctDriftDelay = db_alctDriftDelay == py_alctDriftDelay;
0109   bool ok_alctNplanesHitPretrig = db_alctNplanesHitPretrig == py_alctNplanesHitPretrig;
0110   bool ok_alctNplanesHitPattern = db_alctNplanesHitPattern == py_alctNplanesHitPattern;
0111   bool ok_alctNplanesHitAccelPretrig = db_alctNplanesHitAccelPretrig == py_alctNplanesHitAccelPretrig;
0112   bool ok_alctNplanesHitAccelPattern = db_alctNplanesHitAccelPattern == py_alctNplanesHitAccelPattern;
0113   bool ok_alctTrigMode = db_alctTrigMode == py_alctTrigMode;
0114   bool ok_alctAccelMode = db_alctAccelMode == py_alctAccelMode;
0115   bool ok_alctL1aWindowWidth = db_alctL1aWindowWidth == py_alctL1aWindowWidth;
0116 
0117   bool ok_clctFifoTbins = db_clctFifoTbins == py_clctFifoTbins;
0118   bool ok_clctFifoPretrig = db_clctFifoPretrig == py_clctFifoPretrig;
0119   bool ok_clctHitPersist = db_clctHitPersist == py_clctHitPersist;
0120   bool ok_clctDriftDelay = db_clctDriftDelay == py_clctDriftDelay;
0121   bool ok_clctNplanesHitPretrig = db_clctNplanesHitPretrig == py_clctNplanesHitPretrig;
0122   bool ok_clctNplanesHitPattern = db_clctNplanesHitPattern == py_clctNplanesHitPattern;
0123   bool ok_clctPidThreshPretrig = db_clctPidThreshPretrig == py_clctPidThreshPretrig;
0124   bool ok_clctMinSeparation = db_clctMinSeparation == py_clctMinSeparation;
0125 
0126   bool ok_tmbMpcBlockMe1a = db_tmbMpcBlockMe1a == py_tmbMpcBlockMe1a;
0127   bool ok_tmbAlctTrigEnable = db_tmbAlctTrigEnable == py_tmbAlctTrigEnable;
0128   bool ok_tmbClctTrigEnable = db_tmbClctTrigEnable == py_tmbClctTrigEnable;
0129   bool ok_tmbMatchTrigEnable = db_tmbMatchTrigEnable == py_tmbMatchTrigEnable;
0130   bool ok_tmbMatchTrigWindowSize = db_tmbMatchTrigWindowSize == py_tmbMatchTrigWindowSize;
0131   bool ok_tmbL1aWindowSize = db_tmbL1aWindowSize == py_tmbL1aWindowSize;
0132 
0133   std::cout << std::endl;
0134   std::cout << "Start Comparing the L1 CSC TP emulator settings between Python and conditions DB." << std::endl;
0135 
0136   std::cout << std::endl;
0137   std::cout << "Parameters different between Py and DB" << std::endl;
0138   std::cout << "- - - - - - - - - - - - - - - - - - - " << std::endl;
0139   std::cout << std::endl;
0140 
0141   if (!ok_alctFifoTbins)
0142     std::cout << "alctFifoTbins: Py = " << py_alctFifoTbins << ", DB = " << db_alctFifoTbins << std::endl;
0143   if (!ok_alctFifoPretrig)
0144     std::cout << "alctFifoPretrig: Py = " << py_alctFifoPretrig << ", DB = " << db_alctFifoPretrig << std::endl;
0145   if (!ok_alctDriftDelay)
0146     std::cout << "alctDriftDelay: Py = " << py_alctDriftDelay << ", DB = " << db_alctDriftDelay << std::endl;
0147   if (!ok_alctNplanesHitPretrig)
0148     std::cout << "alctNplanesHitPretrig: Py = " << py_alctNplanesHitPretrig << ", DB = " << db_alctNplanesHitPretrig
0149               << std::endl;
0150   if (!ok_alctNplanesHitPattern)
0151     std::cout << "alctNplanesHitPattern: Py = " << py_alctNplanesHitPattern << ", DB = " << db_alctNplanesHitPattern
0152               << std::endl;
0153   if (!ok_alctNplanesHitAccelPretrig)
0154     std::cout << "alctNplanesHitAccelPretrig: Py = " << py_alctNplanesHitAccelPretrig
0155               << ", DB = " << db_alctNplanesHitAccelPretrig << std::endl;
0156   if (!ok_alctNplanesHitAccelPattern)
0157     std::cout << "alctNplanesHitAccelPattern: Py = " << py_alctNplanesHitAccelPattern
0158               << ", DB = " << db_alctNplanesHitAccelPattern << std::endl;
0159   if (!ok_alctTrigMode)
0160     std::cout << "alctTrigMode: Py = " << py_alctTrigMode << ", DB = " << db_alctTrigMode << std::endl;
0161   if (!ok_alctAccelMode)
0162     std::cout << "alctAccelMode: Py = " << py_alctAccelMode << ", DB = " << db_alctAccelMode << std::endl;
0163   if (!ok_alctL1aWindowWidth)
0164     std::cout << "alctL1aWindowWidth: Py = " << py_alctL1aWindowWidth << ", DB = " << db_alctL1aWindowWidth
0165               << std::endl;
0166   std::cout << std::endl;
0167 
0168   if (!ok_clctFifoTbins)
0169     std::cout << "clctFifoTbins: Py = " << py_clctFifoTbins << ", DB = " << db_clctFifoTbins << std::endl;
0170   if (!ok_clctFifoPretrig)
0171     std::cout << "clctFifoPretrig: Py = " << py_clctFifoPretrig << ", DB = " << db_clctFifoPretrig << std::endl;
0172   if (!ok_clctHitPersist)
0173     std::cout << "clctHitPersist: Py = " << py_clctHitPersist << ", DB = " << db_clctHitPersist << std::endl;
0174   if (!ok_clctDriftDelay)
0175     std::cout << "clctDriftDelay: Py = " << py_clctDriftDelay << ", DB = " << db_clctDriftDelay << std::endl;
0176   if (!ok_clctNplanesHitPretrig)
0177     std::cout << "clctNplanesHitPretrig: Py = " << py_clctNplanesHitPretrig << ", DB = " << db_clctNplanesHitPretrig
0178               << std::endl;
0179   if (!ok_clctNplanesHitPattern)
0180     std::cout << "clctNplanesHitPattern: Py = " << py_clctNplanesHitPattern << ", DB = " << db_clctNplanesHitPattern
0181               << std::endl;
0182   if (!ok_clctPidThreshPretrig)
0183     std::cout << "clctPidThreshPretrig: Py = " << py_clctPidThreshPretrig << ", DB = " << db_clctPidThreshPretrig
0184               << std::endl;
0185   if (!ok_clctMinSeparation)
0186     std::cout << "clctMinSeparation: Py = " << py_clctMinSeparation << ", DB = " << db_clctMinSeparation << std::endl;
0187   std::cout << std::endl;
0188 
0189   if (!ok_tmbMpcBlockMe1a)
0190     std::cout << "tmbMpcBlockMe1a: Py = " << py_tmbMpcBlockMe1a << ", DB = " << db_tmbMpcBlockMe1a << std::endl;
0191   if (!ok_tmbAlctTrigEnable)
0192     std::cout << "tmbAlctTrigEnable: Py = " << py_tmbAlctTrigEnable << ", DB = " << db_tmbAlctTrigEnable << std::endl;
0193   if (!ok_tmbClctTrigEnable)
0194     std::cout << "tmbClctTrigEnable: Py = " << py_tmbClctTrigEnable << ", DB = " << db_tmbClctTrigEnable << std::endl;
0195   if (!ok_tmbMatchTrigEnable)
0196     std::cout << "tmbMatchTrigEnable: Py = " << py_tmbMatchTrigEnable << ", DB = " << db_tmbMatchTrigEnable
0197               << std::endl;
0198   if (!ok_tmbMatchTrigWindowSize)
0199     std::cout << "tmbMatchTrigWindowSize: Py = " << py_tmbMatchTrigWindowSize << ", DB = " << db_tmbMatchTrigWindowSize
0200               << std::endl;
0201   if (!ok_tmbL1aWindowSize)
0202     std::cout << "tmbL1aWindowSize: Py = " << py_tmbL1aWindowSize << ", DB = " << db_tmbL1aWindowSize << std::endl;
0203 
0204   std::cout << std::endl;
0205   std::cout << "Parameters same in Py and DB" << std::endl;
0206   std::cout << "- - - - - - - - - - - - - - " << std::endl;
0207   std::cout << std::endl;
0208 
0209   if (ok_alctFifoTbins)
0210     std::cout << "alctFifoTbins: " << py_alctFifoTbins << std::endl;
0211   if (ok_alctFifoPretrig)
0212     std::cout << "alctFifoPretrig: " << py_alctFifoPretrig << std::endl;
0213   if (ok_alctDriftDelay)
0214     std::cout << "alctDriftDelay: " << py_alctDriftDelay << std::endl;
0215   if (ok_alctNplanesHitPretrig)
0216     std::cout << "alctNplanesHitPretrig: " << py_alctNplanesHitPretrig << std::endl;
0217   if (ok_alctNplanesHitPattern)
0218     std::cout << "alctNplanesHitPattern: " << py_alctNplanesHitPattern << std::endl;
0219   if (ok_alctNplanesHitAccelPretrig)
0220     std::cout << "alctNplanesHitAccelPretrig: " << py_alctNplanesHitAccelPretrig << std::endl;
0221   if (ok_alctNplanesHitAccelPattern)
0222     std::cout << "alctNplanesHitAccelPattern: " << py_alctNplanesHitAccelPattern << std::endl;
0223   if (ok_alctTrigMode)
0224     std::cout << "alctTrigMode: " << py_alctTrigMode << std::endl;
0225   if (ok_alctAccelMode)
0226     std::cout << "alctAccelMode: " << py_alctAccelMode << std::endl;
0227   if (ok_alctL1aWindowWidth)
0228     std::cout << "alctL1aWindowWidth: " << py_alctL1aWindowWidth << std::endl;
0229   std::cout << std::endl;
0230 
0231   if (ok_clctFifoTbins)
0232     std::cout << "clctFifoTbins: " << py_clctFifoTbins << std::endl;
0233   if (ok_clctFifoPretrig)
0234     std::cout << "clctFifoPretrig: " << py_clctFifoPretrig << std::endl;
0235   if (ok_clctHitPersist)
0236     std::cout << "clctHitPersist: " << py_clctHitPersist << std::endl;
0237   if (ok_clctDriftDelay)
0238     std::cout << "clctDriftDelay: " << py_clctDriftDelay << std::endl;
0239   if (ok_clctNplanesHitPretrig)
0240     std::cout << "clctNplanesHitPretrig: " << py_clctNplanesHitPretrig << std::endl;
0241   if (ok_clctNplanesHitPattern)
0242     std::cout << "clctNplanesHitPattern: " << py_clctNplanesHitPattern << std::endl;
0243   if (ok_clctPidThreshPretrig)
0244     std::cout << "clctPidThreshPretrig: " << py_clctPidThreshPretrig << std::endl;
0245   if (ok_clctMinSeparation)
0246     std::cout << "clctMinSeparation: " << py_clctMinSeparation << std::endl;
0247   std::cout << std::endl;
0248 
0249   if (ok_tmbMpcBlockMe1a)
0250     std::cout << "tmbMpcBlockMe1a: " << py_tmbMpcBlockMe1a << std::endl;
0251   if (ok_tmbAlctTrigEnable)
0252     std::cout << "tmbAlctTrigEnable: " << py_tmbAlctTrigEnable << std::endl;
0253   if (ok_tmbClctTrigEnable)
0254     std::cout << "tmbClctTrigEnable: " << py_tmbClctTrigEnable << std::endl;
0255   if (ok_tmbMatchTrigEnable)
0256     std::cout << "tmbMatchTrigEnable: " << py_tmbMatchTrigEnable << std::endl;
0257   if (ok_tmbMatchTrigWindowSize)
0258     std::cout << "tmbMatchTrigWindowSize: " << py_tmbMatchTrigWindowSize << std::endl;
0259   if (ok_tmbL1aWindowSize)
0260     std::cout << "tmbL1aWindowSize: " << py_tmbL1aWindowSize << std::endl;
0261   std::cout << std::endl;
0262 
0263   std::cout << "Done." << std::endl;
0264 }
0265 
0266 //define this as a plug-in
0267 #include "FWCore/Framework/interface/MakerMacros.h"
0268 DEFINE_FWK_MODULE(L1CSCTPEmulatorConfigAnalyzer);