CMS 3D CMS Logo

L1TBPTX.h
Go to the documentation of this file.
1 #ifndef L1TBPTX_H
2 #define L1TBPTX_H
3 
4 /*
5  * \file L1TBPTX.h
6  *
7  * \author J. Pela
8  *
9 */
10 
11 // system include files
12 #include <memory>
13 #include <unistd.h>
14 
15 // user include files
22 
24 
28 
30 
31 //Data Formats
35 
37 
38 #include <TString.h>
39 
40 #include <iostream>
41 #include <fstream>
42 #include <string>
43 #include <vector>
44 
45 class RateBuffer {
46 public:
47  void fill(int ls, bool isAlgo, int bit, double rate) {
48  if (isAlgo) {
49  m_lsAlgoRate[std::pair<int, int>(ls, bit)] = rate;
50  } else {
51  m_lsTechRate[std::pair<int, int>(ls, bit)] = rate;
52  }
53  }
54  double getLSRate(int ls, bool isAlgo, int bit, double rate) {
55  if (isAlgo) {
56  return m_lsAlgoRate[std::pair<int, int>(ls, bit)];
57  } else {
58  return m_lsTechRate[std::pair<int, int>(ls, bit)];
59  }
60  }
61  double getLSAlgoRate(int ls, int bit, double rate) { return m_lsAlgoRate[std::pair<int, int>(ls, bit)]; }
62  double getLSTechRate(int ls, int bit, double rate) { return m_lsTechRate[std::pair<int, int>(ls, bit)]; }
63 
64 private:
65  std::map<std::pair<int, int>, double> m_lsAlgoRate;
66  std::map<std::pair<int, int>, double> m_lsTechRate;
67 };
68 
69 class L1TBPTX : public DQMOneEDAnalyzer<edm::one::WatchLuminosityBlocks> {
70 public:
71  enum BeamMode {
72  NOMODE = 1,
73  SETUP = 2,
74  INJPILOT = 3,
75  INJINTR = 4,
76  INJNOMN = 5,
77  PRERAMP = 6,
78  RAMP = 7,
79  FLATTOP = 8,
80  SQUEEZE = 9,
81  ADJUST = 10,
82  STABLE = 11,
83  UNSTABLE = 12,
84  BEAMDUMP = 13,
85  RAMPDOWN = 14,
86  RECOVERY = 15,
87  INJDUMP = 16,
88  CIRCDUMP = 17,
89  ABORT = 18,
90  CYCLING = 19,
91  WBDUMP = 20,
92  NOBEAM = 21
93  };
94 
95  enum Errors {
96  UNKNOWN = 1,
97  WARNING_DB_CONN_FAILED = 2,
98  WARNING_DB_QUERY_FAILED = 3,
99  WARNING_DB_INCORRECT_NBUNCHES = 4,
100  ERROR_UNABLE_RETRIVE_PRODUCT = 5,
101  ERROR_TRIGGERALIAS_NOTVALID = 6,
102  ERROR_LSBLOCK_NOTVALID = 7
103  };
104 
105 public:
106  L1TBPTX(const edm::ParameterSet& ps); // Constructor
107  ~L1TBPTX() override; // Destructor
108 
109 protected:
110  void analyze(const edm::Event& e, const edm::EventSetup& c) override; // Analyze
111  void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) override;
112  void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
113 
114  void beginLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c) override;
115  void endLuminosityBlock(edm::LuminosityBlock const& lumiBlock, edm::EventSetup const& c) override;
116 
117  // Private Methods
118 private:
119  void getBeamConfOMDS();
120  void doFractionInSync(bool iForce = false, bool iBad = false);
121  void certifyLSBlock(std::string iTrigger, int iInitLs, int iEndLs, float iValue);
122 
123  // Variables
124 private:
126  std::vector<edm::ParameterSet> m_monitorBits;
127  std::vector<edm::ParameterSet> m_monitorRates;
128  std::string m_outputFile; // file name for ROOT ouput
129 
130  // bool
131  bool m_verbose;
134 
135  // Int
136  std::map<TString, int> m_effNumerator;
137  std::map<TString, int> m_effDenominator;
138  std::map<TString, int> m_missFireNumerator;
139  std::map<TString, int> m_missFireDenominator;
140 
143  unsigned int m_currentLS; // Current LS
144  unsigned int m_currentGTLS;
145  //unsigned int m_eventLS;
146  unsigned int m_lhcFill; //
147 
148  // Vectors
149  BeamConfiguration m_beamConfig; // Current Bunch Structure
150  std::vector<std::pair<int, int> > m_selAlgoBit;
151  std::vector<std::pair<int, int> > m_selTechBit;
152 
153  // Const Vectors
154  const std::vector<std::vector<int> >* m_prescaleFactorsAlgoTrig;
155  const std::vector<std::vector<int> >* m_prescaleFactorsTechTrig;
156 
157  // Maps
158  std::map<int, TString> m_algoBit_Alias;
159  std::map<int, TString> m_techBit_Alias;
160 
161  std::map<TString, MonitorElement*> m_meAlgoEfficiency;
162  std::map<TString, MonitorElement*> m_meAlgoMissFire;
163  std::map<TString, MonitorElement*> m_meTechEfficiency;
164  std::map<TString, MonitorElement*> m_meTechMissFire;
165 
166  std::map<std::pair<bool, int>, MonitorElement*> m_meRate;
167  std::map<std::pair<bool, int>, double> m_l1Rate;
168 
169  // MonitorElement
171 
172  // Input tags
176 };
177 
178 #endif
unsigned int m_lhcFill
Definition: L1TBPTX.h:146
double getLSTechRate(int ls, int bit, double rate)
Definition: L1TBPTX.h:62
std::string m_outputFile
Definition: L1TBPTX.h:128
std::map< TString, MonitorElement * > m_meTechMissFire
Definition: L1TBPTX.h:164
std::map< TString, MonitorElement * > m_meAlgoEfficiency
Definition: L1TBPTX.h:161
std::vector< std::pair< int, int > > m_selAlgoBit
Definition: L1TBPTX.h:150
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TBPTX.h:175
unsigned int m_currentLS
Definition: L1TBPTX.h:143
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_l1GtEvmSource
Definition: L1TBPTX.h:174
std::map< TString, int > m_missFireDenominator
Definition: L1TBPTX.h:139
BeamConfiguration m_beamConfig
Definition: L1TBPTX.h:149
BeamMode
Definition: L1TBPTX.h:71
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
bool * m_processedLS
Definition: L1TBPTX.h:133
std::map< TString, MonitorElement * > m_meAlgoMissFire
Definition: L1TBPTX.h:162
std::map< std::pair< bool, int >, double > m_l1Rate
Definition: L1TBPTX.h:167
std::map< TString, MonitorElement * > m_meTechEfficiency
Definition: L1TBPTX.h:163
double getLSAlgoRate(int ls, int bit, double rate)
Definition: L1TBPTX.h:61
std::map< TString, int > m_missFireNumerator
Definition: L1TBPTX.h:138
bool m_verbose
Definition: L1TBPTX.h:131
std::map< std::pair< int, int >, double > m_lsAlgoRate
Definition: L1TBPTX.h:65
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
Definition: L1TBPTX.h:155
int m_refPrescaleSet
Definition: L1TBPTX.h:141
edm::ParameterSet m_parameters
Definition: L1TBPTX.h:125
int m_currentPrescalesIndex
Definition: L1TBPTX.h:142
std::map< int, TString > m_techBit_Alias
Definition: L1TBPTX.h:159
double getLSRate(int ls, bool isAlgo, int bit, double rate)
Definition: L1TBPTX.h:54
def ls(path, rec=False)
Definition: eostools.py:349
std::vector< edm::ParameterSet > m_monitorRates
Definition: L1TBPTX.h:127
bool m_currentLSValid
Definition: L1TBPTX.h:132
std::map< std::pair< bool, int >, MonitorElement * > m_meRate
Definition: L1TBPTX.h:166
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
double rate(double x)
Definition: Constants.cc:3
std::vector< edm::ParameterSet > m_monitorBits
Definition: L1TBPTX.h:126
std::map< std::pair< int, int >, double > m_lsTechRate
Definition: L1TBPTX.h:66
unsigned int m_currentGTLS
Definition: L1TBPTX.h:144
std::map< int, TString > m_algoBit_Alias
Definition: L1TBPTX.h:158
Errors
Definition: L1TBPTX.h:95
std::vector< std::pair< int, int > > m_selTechBit
Definition: L1TBPTX.h:151
std::map< TString, int > m_effDenominator
Definition: L1TBPTX.h:137
void fill(int ls, bool isAlgo, int bit, double rate)
Definition: L1TBPTX.h:47
std::map< TString, int > m_effNumerator
Definition: L1TBPTX.h:136
MonitorElement * m_ErrorMonitor
Definition: L1TBPTX.h:170
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
Definition: L1TBPTX.h:154
Definition: Run.h:45
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource
Definition: L1TBPTX.h:173