Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:32

0001 #ifndef L1TSync_H
0002 #define L1TSync_H
0003 
0004 /*
0005  * \file L1TSync.h
0006  *
0007  * \author J. Pela
0008  *
0009 */
0010 
0011 // system include files
0012 #include <memory>
0013 #include <unistd.h>
0014 
0015 // user include files
0016 #include "FWCore/Framework/interface/Frameworkfwd.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/LuminosityBlock.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020 
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 
0023 #include "DQMServices/Core/interface/DQMStore.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 #include "DQM/L1TMonitor/interface/L1TMenuHelper.h"
0027 #include "DQM/L1TMonitor/interface/L1TOMDSHelper.h"
0028 
0029 //DataFormats
0030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0032 
0033 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0034 
0035 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
0036 
0037 #include <TString.h>
0038 
0039 #include <iostream>
0040 #include <fstream>
0041 #include <string>
0042 #include <vector>
0043 
0044 class L1TSync : public DQMOneEDAnalyzer<edm::one::WatchLuminosityBlocks> {
0045 public:
0046   enum BeamMode {
0047     NOMODE = 1,
0048     SETUP = 2,
0049     INJPILOT = 3,
0050     INJINTR = 4,
0051     INJNOMN = 5,
0052     PRERAMP = 6,
0053     RAMP = 7,
0054     FLATTOP = 8,
0055     QUEEZE = 9,
0056     ADJUST = 10,
0057     STABLE = 11,
0058     UNSTABLE = 12,
0059     BEAMDUMP = 13,
0060     RAMPDOWN = 14,
0061     RECOVERY = 15,
0062     INJDUMP = 16,
0063     CIRCDUMP = 17,
0064     ABORT = 18,
0065     CYCLING = 19,
0066     WBDUMP = 20,
0067     NOBEAM = 21
0068   };
0069 
0070   enum Errors {
0071     UNKNOWN = 1,
0072     WARNING_DB_CONN_FAILED = 2,
0073     WARNING_DB_QUERY_FAILED = 3,
0074     WARNING_DB_INCORRECT_NBUNCHES = 4,
0075     ERROR_UNABLE_RETRIVE_PRODUCT = 5,
0076     ERROR_TRIGGERALIAS_NOTVALID = 6,
0077     ERROR_LSBLOCK_NOTVALID = 7
0078   };
0079 
0080 public:
0081   L1TSync(const edm::ParameterSet& ps);  // Constructor
0082   ~L1TSync() override;                   // Destructor
0083 
0084 protected:
0085   void analyze(const edm::Event& e, const edm::EventSetup& c) override;  // Analyze
0086 
0087   void beginLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c) override;
0088   void endLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c) override;
0089   void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) override;
0090   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0091 
0092   // Private Methods
0093 private:
0094   void getBeamConfOMDS();
0095   void doFractionInSync(bool iForce = false, bool iBad = false);
0096   void certifyLSBlock(std::string iTrigger, int iInitLs, int iEndLs, float iValue);
0097 
0098   // Variables
0099 private:
0100   edm::ParameterSet m_parameters;
0101 
0102   std::string m_outputFile;  // file name for ROOT ouput
0103 
0104   // bool
0105   bool m_verbose;
0106   bool m_currentLSValid;
0107   bool* m_processedLS;
0108 
0109   // Int
0110   int m_refPrescaleSet;
0111   unsigned int m_currentLS;  // Current LS
0112   //unsigned int                         m_eventLS;
0113   unsigned int m_lhcFill;  //
0114 
0115   // Vectors
0116   BeamConfiguration m_beamConfig;  // Current Bunch Structure
0117 
0118   // Const Vectors
0119   const std::vector<std::vector<int> >* ListsPrescaleFactors;  // Collection os all sets of prescales
0120 
0121   // Maps
0122   std::map<TString, int> m_algoBit;
0123   std::map<TString, unsigned int> m_certFirstLS;  // First uncertified LS
0124   std::map<TString, unsigned int> m_certLastLS;   // Last  uncertified LS
0125   std::map<TString, MonitorElement*> m_algoCertification;
0126   std::map<TString, MonitorElement*> m_algoVsBunchStructure;
0127   std::map<std::string, bool> m_algoAutoSelect;           // Map of categories to monitor
0128   std::map<std::string, std::string> m_selectedTriggers;  // Map of what trigger to monitor for each category
0129 
0130   // MonitorElement
0131   MonitorElement* m_ErrorMonitor;
0132 
0133   // Input tags
0134   edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> m_l1GtEvmSource;
0135   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> m_l1GtDataDaqInputTag;
0136   const edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> m_menuToken;
0137   L1TMenuHelper::Tokens m_helperTokens;
0138 
0139   L1GtUtils m_l1GtUtils;
0140 };
0141 
0142 #endif