Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:34

0001 #ifndef DQMOffline_L1Trigger_L1TSync_Offline_h
0002 #define DQMOffline_L1Trigger_L1TSync_Offline_h
0003 
0004 /*
0005  * \class L1TSync_Offline
0006  *
0007  *
0008  * Description: offline DQM module for L1Trigger/bunchStructure synchronization
0009  * 
0010  * Implementation:
0011  *   <TODO: enter implementation details>
0012  *
0013  * \author: Pietro Vischia - LIP Lisbon pietro.vischia@gmail.com
0014  *
0015  * Changelog:
0016  *    2012/08/10 11:01:01: First creation. Dummy module with actual code commented.
0017  *
0018  * Todo:
0019  *  - implement the module in offline
0020  *  - check if there are user includes specific for offline/online that should be changed
0021  *
0022  *
0023  */
0024 
0025 // System include files
0026 #include <memory>
0027 #include <unistd.h>
0028 
0029 // User include files
0030 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "FWCore/Framework/interface/Event.h"
0033 #include "FWCore/Framework/interface/LuminosityBlock.h"
0034 #include "FWCore/Framework/interface/MakerMacros.h"
0035 
0036 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0037 
0038 #include "DQMServices/Core/interface/DQMStore.h"
0039 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0040 
0041 //L1 includes and dataformats
0042 #include "DQM/L1TMonitor/interface/L1TMenuHelper.h"
0043 #include "DQMOffline/L1Trigger/interface/L1TBeamConfiguration.h"
0044 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0045 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0046 
0047 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0048 
0049 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
0050 
0051 #include <TString.h>
0052 
0053 #include <iostream>
0054 #include <fstream>
0055 #include <string>
0056 #include <vector>
0057 
0058 // Forward declarations
0059 
0060 // Class declaration
0061 namespace ltso {
0062   struct LSValid {
0063     bool lsIsValid = true;
0064   };
0065 }  // namespace ltso
0066 class L1TSync_Offline : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<ltso::LSValid>> {
0067 public:
0068   enum BeamMode {
0069     NOMODE = 1,
0070     SETUP = 2,
0071     INJPILOT = 3,
0072     INJINTR = 4,
0073     INJNOMN = 5,
0074     PRERAMP = 6,
0075     RAMP = 7,
0076     FLATTOP = 8,
0077     QUEEZE = 9,
0078     ADJUST = 10,
0079     STABLE = 11,
0080     UNSTABLE = 12,
0081     BEAMDUMP = 13,
0082     RAMPDOWN = 14,
0083     RECOVERY = 15,
0084     INJDUMP = 16,
0085     CIRCDUMP = 17,
0086     ABORT = 18,
0087     CYCLING = 19,
0088     WBDUMP = 20,
0089     NOBEAM = 21
0090   };
0091 
0092   enum Errors {
0093     UNKNOWN = 1,
0094     WARNING_DB_CONN_FAILED = 2,
0095     WARNING_DB_QUERY_FAILED = 3,
0096     WARNING_DB_INCORRECT_NBUNCHES = 4,
0097     ERROR_UNABLE_RETRIVE_PRODUCT = 5,
0098     ERROR_TRIGGERALIAS_NOTVALID = 6,
0099     ERROR_LSBLOCK_NOTVALID = 7
0100   };
0101 
0102 public:
0103   // Constructor
0104   L1TSync_Offline(const edm::ParameterSet& ps);
0105   // Destructor
0106   ~L1TSync_Offline() override;
0107 
0108 protected:
0109   void analyze(const edm::Event& e, const edm::EventSetup& c) override;  // Analyze
0110   std::shared_ptr<ltso::LSValid> globalBeginLuminosityBlock(edm::LuminosityBlock const& lumiBlock,
0111                                                             edm::EventSetup const& c) const final;
0112   void globalEndLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c) final {}
0113   void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
0114   void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) override;
0115 
0116   // Private Methods
0117 private:
0118   void getBeamConfOffline(const edm::Event&);
0119   // no lumi block //    void doFractionInSync(bool iForce=false, bool iBad=false);
0120   // no lumi block //    void certifyLSBlock  (std::string iTrigger, int iInitLs, int iEndLs ,float iValue);
0121 
0122   // Variables
0123 private:
0124   // Input parameters
0125   edm::ParameterSet m_parameters;
0126 
0127   // bool
0128   bool m_verbose;
0129 
0130   // Int
0131   int m_refPrescaleSet;
0132   //unsigned int                         m_eventLS;
0133   unsigned int m_lhcFill;  //
0134 
0135   // Vectors
0136   L1TBeamConfiguration m_beamConfig;  // Current Bunch Structure
0137 
0138   // Const Vectors
0139   const std::vector<std::vector<int>>* ListsPrescaleFactors;  // Collection os all sets of prescales
0140 
0141   // Maps
0142   std::map<TString, int> m_algoBit;
0143   std::map<TString, unsigned int> m_certFirstLS;  // First uncertified LS
0144   std::map<TString, unsigned int> m_certLastLS;   // Last  uncertified LS
0145   std::map<TString, MonitorElement*> m_algoCertification;
0146   std::map<TString, MonitorElement*> m_algoVsBunchStructure;
0147   std::map<std::string, bool> m_algoAutoSelect;           // Map of categories to monitor
0148   std::map<std::string, std::string> m_selectedTriggers;  // Map of what trigger to monitor for each category
0149 
0150   // MonitorElement
0151   MonitorElement* m_ErrorMonitor;
0152 
0153   // Input tags
0154   edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> m_l1GtEvmSource;
0155   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> m_l1GtDataDaqInputTag;
0156   const edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> m_menuToken;
0157   L1TMenuHelper::Tokens m_helperTokens;
0158 
0159   L1GtUtils m_l1GtUtils;
0160 };
0161 
0162 #endif