Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:44

0001 #ifndef DQM_L1TMonitor_L1GtHwValidation_h
0002 #define DQM_L1TMonitor_L1GtHwValidation_h
0003 
0004 /**
0005  * \class L1GtHwValidation
0006  * 
0007  * 
0008  * Description: compare hardware records with emulator records for L1 GT records.
0009  *
0010  * Implementation:
0011  *    Get the L1 GT records from data and from emulator.   
0012  *    Compare every board between data and emulator.
0013  *   
0014  * \author: Vasile Mihai Ghete - HEPHY Vienna
0015  * 
0016  * $Date$
0017  *
0018  */
0019 
0020 // system include files
0021 #include <memory>
0022 #include <string>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Utilities/interface/InputTag.h"
0032 
0033 #include "DQMServices/Core/interface/DQMStore.h"
0034 
0035 #include "DataFormats/L1GlobalTrigger/interface/L1GtObject.h"
0036 #include "CondFormats/L1TObjects/interface/L1GtDefinitions.h"
0037 
0038 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0039 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0040 
0041 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0042 
0043 // forward declarations
0044 class L1GtfeWord;
0045 class L1GtFdlWord;
0046 class L1GtPsbWord;
0047 class L1TcsWord;
0048 class L1GtTriggerMenu;
0049 class L1GtPrescaleFactors;
0050 class L1GtTriggerMask;
0051 class L1GtPrescaleFactorsTechTrigRcd;
0052 class L1GtPrescaleFactorsAlgoTrigRcd;
0053 class L1GtTriggerMenuRcd;
0054 class L1GtTriggerMaskTechTrigRcd;
0055 class L1GtTriggerMaskAlgoTrigRcd;
0056 // class declaration
0057 
0058 class L1GtHwValidation : public DQMEDAnalyzer {
0059 public:
0060   explicit L1GtHwValidation(const edm::ParameterSet&);
0061   ~L1GtHwValidation() override;
0062 
0063 private:
0064   /// compare the GTFE board
0065   virtual void compareGTFE(const edm::Event&, const edm::EventSetup&, const L1GtfeWord&, const L1GtfeWord&, const int);
0066 
0067   /// compare the FDL board
0068   virtual void compareFDL(const edm::Event&, const edm::EventSetup&, const L1GtFdlWord&, const L1GtFdlWord&, const int);
0069 
0070   /// compare the PSB board
0071   virtual void comparePSB(const edm::Event&, const edm::EventSetup&, const L1GtPsbWord&, const L1GtPsbWord&);
0072 
0073   /// compare the TCS board
0074   virtual void compareTCS(const edm::Event&, const edm::EventSetup&, const L1TcsWord&, const L1TcsWord&);
0075 
0076   /// L1 GT DAQ record comparison
0077   virtual void compareDaqRecord(const edm::Event&, const edm::EventSetup&);
0078 
0079   /// L1 GT EVM record comparison
0080   virtual void compareEvmRecord(const edm::Event&, const edm::EventSetup&);
0081 
0082   /// compare the GCT collections obtained from L1 GT PSB with the input
0083   /// GCT collections
0084   virtual void compareGt_Gct(const edm::Event&, const edm::EventSetup&);
0085 
0086   /// book all histograms for the module
0087   //void bookhistograms(DQMStore::IBooker &ibooker);
0088 
0089   /// return true if an algorithm has a condition of that category
0090   /// for CondNull, it returns always true
0091   bool matchCondCategory(const L1GtConditionCategory&, const L1GtConditionCategory&);
0092 
0093   /// return true if an algorithm has a condition of that type
0094   /// for TypeNull, it returns always true
0095   bool matchCondType(const L1GtConditionType&, const L1GtConditionType&);
0096 
0097   /// return true if an algorithm has a condition containing that object
0098   /// for ObjNull, it returns always true
0099   bool matchCondL1GtObject(const std::vector<L1GtObject>&, const L1GtObject&);
0100 
0101   /// exclude from comparison some bits with known disagreement - bit list
0102   void excludedAlgoList();
0103 
0104   /// exclusion status for algorithm with bit i
0105   bool excludedAlgo(const int&) const;
0106 
0107   void analyze(const edm::Event&, const edm::EventSetup&) override;
0108 
0109 protected:
0110   void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) override;
0111   //virtual void analyze(DQMStore::IBooker &ibooker, const edm::Event&, const edm::EventSetup&);
0112 
0113 private:
0114   /// input tag for the L1 GT hardware DAQ record
0115   edm::InputTag m_l1GtDataDaqInputTag;
0116 
0117   /// input tag for the L1 GT hardware EVM record
0118   edm::InputTag m_l1GtDataEvmInputTag;
0119 
0120   /// input tag for the L1 GT emulator DAQ record
0121   edm::InputTag m_l1GtEmulDaqInputTag;
0122 
0123   /// input tag for the L1 GT emulator EVM record
0124   edm::InputTag m_l1GtEmulEvmInputTag;
0125 
0126   /// input tag for the L1 GCT hardware record
0127   edm::InputTag m_l1GctDataInputTag;
0128 
0129   /// directory name for L1Extra plots
0130   std::string m_dirName;
0131 
0132   /// exclude algorithm triggers from comparison data - emulator by
0133   /// condition category and / or type
0134   std::vector<edm::ParameterSet> m_excludeCondCategTypeObject;
0135 
0136   /// exclude algorithm triggers from comparison data - emulator by algorithm name
0137   std::vector<std::string> m_excludeAlgoTrigByName;
0138 
0139   /// exclude algorithm triggers from comparison data - emulator by algorithm bit number
0140   std::vector<int> m_excludeAlgoTrigByBit;
0141 
0142 private:
0143   /// excluded condition categories
0144   std::vector<L1GtConditionCategory> m_excludedCondCategory;
0145 
0146   /// excluded condition types
0147   std::vector<L1GtConditionType> m_excludedCondType;
0148 
0149   /// excluded L1 GT objects
0150   std::vector<L1GtObject> m_excludedL1GtObject;
0151 
0152   /// an output stream to print into
0153   /// it can then be directed to whatever log level is desired
0154   std::ostringstream m_myCoutStream;
0155 
0156   /// counters
0157   int m_nrDataEventError;
0158   int m_nrEmulEventError;
0159 
0160   // cached stuff
0161 
0162   /// trigger menu
0163   const L1GtTriggerMenu* m_l1GtMenu;
0164   unsigned long long m_l1GtMenuCacheID;
0165 
0166   /// prescale factors
0167   const L1GtPrescaleFactors* m_l1GtPfAlgo;
0168   unsigned long long m_l1GtPfAlgoCacheID;
0169 
0170   const L1GtPrescaleFactors* m_l1GtPfTech;
0171   unsigned long long m_l1GtPfTechCacheID;
0172 
0173   const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
0174   const std::vector<std::vector<int> >* m_prescaleFactorsTechTrig;
0175 
0176   /// trigger masks
0177   const L1GtTriggerMask* m_l1GtTmAlgo;
0178   unsigned long long m_l1GtTmAlgoCacheID;
0179 
0180   const L1GtTriggerMask* m_l1GtTmTech;
0181   unsigned long long m_l1GtTmTechCacheID;
0182 
0183   std::vector<unsigned int> m_triggerMaskAlgoTrig;
0184   std::vector<unsigned int> m_triggerMaskTechTrig;
0185 
0186 private:
0187   /// internal members
0188 
0189   bool m_agree;
0190   bool m_dataOnly;
0191   bool m_emulOnly;
0192   bool m_dataOnlyMask;
0193   bool m_emulOnlyMask;
0194 
0195 private:
0196   static const int TotalBxInEvent = 5;
0197   static const int NumberOfGtRecords = 2;  // DAQ and EVM
0198 
0199   /// histograms
0200 
0201   /// GTFE
0202   MonitorElement* m_gtfeDataEmul[NumberOfGtRecords];
0203 
0204   /// FDL (0 for DAQ, 1 for EVM record)
0205   MonitorElement* m_fdlDataEmul[TotalBxInEvent][NumberOfGtRecords];
0206   //
0207   MonitorElement* m_fdlDataAlgoDecision[TotalBxInEvent][NumberOfGtRecords];
0208   MonitorElement* m_fdlDataAlgoDecisionPrescaled[TotalBxInEvent][NumberOfGtRecords];
0209   MonitorElement* m_fdlDataAlgoDecisionUnprescaled[TotalBxInEvent][NumberOfGtRecords];
0210   MonitorElement* m_fdlDataAlgoDecisionMask[TotalBxInEvent][NumberOfGtRecords];
0211   MonitorElement* m_fdlDataAlgoDecision_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0212   MonitorElement* m_fdlDataAlgoDecisionPrescaled_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0213   MonitorElement* m_fdlDataAlgoDecisionUnprescaled_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0214   MonitorElement* m_fdlDataAlgoDecisionMask_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0215   MonitorElement* m_fdlDataAlgoDecisionPrescaledMask_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0216   MonitorElement* m_fdlDataAlgoDecisionUnprescaledMask_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0217   MonitorElement* m_fdlDataAlgoDecision_Err[NumberOfGtRecords];
0218 
0219   MonitorElement* m_fdlEmulAlgoDecision[TotalBxInEvent][NumberOfGtRecords];
0220   MonitorElement* m_fdlEmulAlgoDecisionPrescaled[TotalBxInEvent][NumberOfGtRecords];
0221   MonitorElement* m_fdlEmulAlgoDecisionUnprescaled[TotalBxInEvent][NumberOfGtRecords];
0222   MonitorElement* m_fdlEmulAlgoDecisionMask[TotalBxInEvent][NumberOfGtRecords];
0223   MonitorElement* m_fdlEmulAlgoDecision_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0224   MonitorElement* m_fdlEmulAlgoDecisionPrescaled_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0225   MonitorElement* m_fdlEmulAlgoDecisionUnprescaled_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0226   MonitorElement* m_fdlEmulAlgoDecisionMask_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0227   MonitorElement* m_fdlEmulAlgoDecisionPrescaledMask_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0228   MonitorElement* m_fdlEmulAlgoDecisionUnprescaledMask_NoMatch[TotalBxInEvent][NumberOfGtRecords];
0229   MonitorElement* m_fdlEmulAlgoDecision_Err[NumberOfGtRecords];
0230 
0231   //
0232   MonitorElement* m_fdlDataEmulAlgoDecision[TotalBxInEvent][NumberOfGtRecords];
0233   MonitorElement* m_fdlDataEmulAlgoDecisionPrescaled[TotalBxInEvent][NumberOfGtRecords];
0234   MonitorElement* m_fdlDataEmulAlgoDecisionUnprescaled[TotalBxInEvent][NumberOfGtRecords];
0235   MonitorElement* m_fdlDataEmulAlgoDecisionUnprescaledAllowed[TotalBxInEvent][NumberOfGtRecords];
0236   MonitorElement* m_fdlDataEmulAlgoDecisionMask[TotalBxInEvent][NumberOfGtRecords];
0237   MonitorElement* m_fdlDataEmulAlgoDecision_Err[NumberOfGtRecords];
0238   MonitorElement* m_fdlDataEmul_Err[NumberOfGtRecords];
0239 
0240   //
0241   MonitorElement* m_fdlDataTechDecision[TotalBxInEvent][NumberOfGtRecords];
0242   MonitorElement* m_fdlDataTechDecisionMask[TotalBxInEvent][NumberOfGtRecords];
0243   MonitorElement* m_fdlDataTechDecision_Err[NumberOfGtRecords];
0244 
0245   MonitorElement* m_fdlEmulTechDecision[TotalBxInEvent][NumberOfGtRecords];
0246   MonitorElement* m_fdlEmulTechDecisionMask[TotalBxInEvent][NumberOfGtRecords];
0247   MonitorElement* m_fdlEmulTechDecision_Err[NumberOfGtRecords];
0248 
0249   MonitorElement* m_fdlDataEmulTechDecision[TotalBxInEvent][NumberOfGtRecords];
0250   MonitorElement* m_fdlDataEmulTechDecisionMask[TotalBxInEvent][NumberOfGtRecords];
0251   MonitorElement* m_fdlDataEmulTechDecision_Err[NumberOfGtRecords];
0252 
0253   MonitorElement* m_excludedAlgorithmsAgreement;
0254 
0255   /// PSB
0256 
0257   // FIXME add PSB comparison
0258 
0259   /// ErrorFlag a la HardwareValidation
0260   MonitorElement* m_gtErrorFlag;
0261 
0262   ///
0263   int m_nrEvJob;
0264   int m_nrEvRun;
0265 
0266   std::vector<int> m_excludedAlgoList;
0267 
0268   //define Token(-s)
0269   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> m_l1GtDataDaqInputToken_;
0270   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> m_l1GtEmulDaqInputToken_;
0271   edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> m_l1GtDataEvmInputToken_;
0272   edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> m_l1GtEmulEvmInputToken_;
0273   edm::ESGetToken<L1GtPrescaleFactors, L1GtPrescaleFactorsTechTrigRcd> l1gtPrescaleTechToken_;
0274   edm::ESGetToken<L1GtPrescaleFactors, L1GtPrescaleFactorsAlgoTrigRcd> l1gtPrescaleAlgoToken_;
0275   edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> l1gtTrigmenuToken_;
0276   edm::ESGetToken<L1GtTriggerMask, L1GtTriggerMaskTechTrigRcd> l1gtTrigmaskTechToken_;
0277   edm::ESGetToken<L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd> l1gtTrigmaskAlgoToken_;
0278 };
0279 
0280 #endif /*DQM_L1TMonitor_L1GtHwValidation_h*/