CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerJSONMonitoring.h
Go to the documentation of this file.
1 #ifndef JSONMonitoring_TriggerJSONMonitoring_h
2 #define JSONMonitoring_TriggerJSONMonitoring_h
3 
22 
28 
31 
33 
41 
42 #include <atomic>
43 
44 namespace hltJson {
45  //Struct for storing variables that must be written and reset every lumi section
46  struct lumiVars {
47  HistoJ<unsigned int> *processed; // # of events processed
48  HistoJ<unsigned int> *hltWasRun; // # of events where HLT[i] was run
49  HistoJ<unsigned int> *hltL1s; // # of events after L1 seed
50  HistoJ<unsigned int> *hltPre; // # of events after HLT prescale
51  HistoJ<unsigned int> *hltAccept; // # of events accepted by HLT[i]
52  HistoJ<unsigned int> *hltReject; // # of events rejected by HLT[i]
53  HistoJ<unsigned int> *hltErrors; // # of events with error in HLT[i]
54  HistoJ<unsigned int> *hltDatasets; // # of events accepted by each dataset
55 
56  unsigned int prescaleIndex; // Prescale index for each lumi section
57 
58  std::string baseRunDir; //Base directory from EvFDaqDirector
59  std::string stHltJsd; //Definition file name for JSON with rates
60 
61  HistoJ<unsigned int> *L1AlgoAccept; // # of events accepted by L1T[i]
62  HistoJ<unsigned int> *L1TechAccept; // # of events accepted by L1 Technical Triggers[i]
63  HistoJ<unsigned int> *L1AlgoAcceptPhysics; // # of Physics events accepted by L1T[i]
64  HistoJ<unsigned int> *L1TechAcceptPhysics; // # of Physics events accepted by L1 Technical Triggers[i]
65  HistoJ<unsigned int> *L1AlgoAcceptCalibration; // # of Calibration events accepted by L1T[i]
66  HistoJ<unsigned int> *L1TechAcceptCalibration; // # of Calibration events accepted by L1 Technical Triggers[i]
67  HistoJ<unsigned int> *L1AlgoAcceptRandom; // # of Random events accepted by L1T[i]
68  HistoJ<unsigned int> *L1TechAcceptRandom; // # of Random events accepted by L1 Technical Triggers[i]
69  HistoJ<unsigned int> *L1Global; // Global # of Phyics, Cailibration and Random L1 triggers
70 
71  std::string stL1Jsd; //Definition file name for JSON with L1 rates
74  };
75  //End lumi struct
76  //Struct for storing variable written once per run
77  struct runVars{
78  mutable std::atomic<bool> wroteFiles;
81  };
82 }//End hltJson namespace
83 
84 //
85 // class declaration
86 //
87 class TriggerJSONMonitoring : public edm::stream::EDAnalyzer <edm::RunCache<hltJson::runVars>, edm::LuminosityBlockSummaryCache<hltJson::lumiVars>>
88 {
89  public:
92  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
93 
94  void analyze(edm::Event const&,
95  edm::EventSetup const&);
96 
97  void beginRun(edm::Run const&,
98  edm::EventSetup const&);
99 
100  static std::shared_ptr<hltJson::runVars> globalBeginRun(edm::Run const&, edm::EventSetup const&, void const*){
101  std::shared_ptr<hltJson::runVars> rv(new hltJson::runVars);
102  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
103  rv->streamHLTDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamHLTRates");
104  rv->streamL1Destination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamL1Rates");
105  }
106  rv->wroteFiles = false;
107  return rv;
108  }
109 
110  static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext){ }
111 
113 
114  static std::shared_ptr<hltJson::lumiVars> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
115  edm::EventSetup const&,
116  LuminosityBlockContext const*);
117 
119  edm::EventSetup const&,
120  hltJson::lumiVars*) const;
121 
122 
124  edm::EventSetup const&,
125  LuminosityBlockContext const*,
127 
128  void resetRun(bool changed); //Reset run-related info
129  void resetLumi(); //Reset all counters
130 
132 
134 
135  //Variables from cfg and associated tokens
136  edm::InputTag triggerResults_; // Input tag for TriggerResults
138 
139  edm::InputTag level1Results_; // Input tag for L1 GT Readout Record
141 
142  //Variables that change at most once per run
143  HLTConfigProvider hltConfig_; // to get configuration for HLT
144  const L1GtTriggerMenu* m_l1GtMenu; // L1 trigger menu
145  AlgorithmMap algorithmMap; // L1 algorithm map
146  AlgorithmMap technicalMap; // L1 technical triggeral map
147 
150 
151  std::string baseRunDir_; //Base directory from EvFDaqDirector
152 
153  // hltIndex_[ds][p] stores the hltNames_ index of the p-th path of the ds-th dataset
154  std::vector<std::vector<unsigned int> > hltIndex_;
155  std::vector<std::string> hltNames_; // list of HLT path names
156  std::vector<std::string> datasetNames_; // list of dataset names
157  std::vector<std::vector<std::string> > datasetContents_; // list of path names for each dataset
158 
159  std::vector<int> posL1s_; // pos # of last L1 seed
160  std::vector<int> posPre_; // pos # of last HLT prescale
161 
162  std::string stHltJsd_; //Definition file name for JSON with rates
163 
164  std::vector<std::string> L1AlgoNames_; // name of each L1 algorithm trigger
165  std::vector<int> L1AlgoBitNumber_; // bit number of each L1 algo trigger
166  std::vector<std::string> L1TechNames_; // name of each L1 technical trigger
167  std::vector<int> L1TechBitNumber_; // bit number of each L1 tech trigger
168  std::vector<std::string> L1GlobalType_; // experimentType: Physics, Calibration, Random
169 
170  std::string stL1Jsd_; //Definition file name for JSON with L1 rates
171 
172  //Variables that need to be reset at lumi section boundaries
173  unsigned int processed_; // # of events processed
174  unsigned int prescaleIndex_; //Prescale index for each lumi section
175 
176  std::vector<unsigned int> hltWasRun_; // # of events where HLT[i] was run
177  std::vector<unsigned int> hltL1s_; // # of events after L1 seed
178  std::vector<unsigned int> hltPre_; // # of events after HLT prescale
179  std::vector<unsigned int> hltAccept_; // # of events accepted by HLT[i]
180  std::vector<unsigned int> hltReject_; // # of events rejected by HLT[i]
181  std::vector<unsigned int> hltErrors_; // # of events with error in HLT[i]
182 
183  std::vector<unsigned int> hltDatasets_; // # of events accepted by each dataset
184 
185  std::vector<unsigned int> L1AlgoAccept_; // # of events accepted by L1T[i]
186  std::vector<unsigned int> L1TechAccept_; // # of events accepted by L1 Technical Triggers[i]
187  std::vector<unsigned int> L1AlgoAcceptPhysics_; // # of Physics events accepted by L1T[i]
188  std::vector<unsigned int> L1TechAcceptPhysics_; // # of Physics events accepted by L1 Technical Triggers[i]
189  std::vector<unsigned int> L1AlgoAcceptCalibration_; // # of Calibration events accepted by L1T[i]
190  std::vector<unsigned int> L1TechAcceptCalibration_; // # of Calibration events accepted by L1 Technical Triggers[i]
191  std::vector<unsigned int> L1AlgoAcceptRandom_; // # of Random events accepted by L1T[i]
192  std::vector<unsigned int> L1TechAcceptRandom_; // # of Random events accepted by L1 Technical Triggers[i]
193  std::vector<unsigned int> L1Global_; // Global # of Physics, Calibration and Random L1 triggers
194 
195  //Variables for confirming that prescale index did not change
196  unsigned int oldLumi;
197  unsigned int oldPrescaleIndex;
198 
199  private:
200 
201 };
202 #endif
std::vector< int > L1TechBitNumber_
TriggerJSONMonitoring(const edm::ParameterSet &)
static std::shared_ptr< hltJson::runVars > globalBeginRun(edm::Run const &, edm::EventSetup const &, void const *)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache > LuminosityBlockContext
Definition: EDAnalyzer.h:46
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1t_results
HistoJ< unsigned int > * L1TechAccept
std::atomic< bool > wroteFiles
HistoJ< unsigned int > * hltReject
std::vector< unsigned int > hltDatasets_
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
static std::shared_ptr< hltJson::lumiVars > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
std::vector< unsigned int > L1AlgoAccept_
std::vector< unsigned int > L1AlgoAcceptPhysics_
HistoJ< unsigned int > * hltErrors
std::string streamL1Destination
HistoJ< unsigned int > * L1AlgoAccept
std::vector< unsigned int > hltErrors_
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, hltJson::lumiVars *)
std::vector< unsigned int > L1TechAcceptRandom_
void beginRun(edm::Run const &, edm::EventSetup const &)
HistoJ< unsigned int > * processed
std::vector< unsigned int > hltL1s_
std::vector< unsigned int > L1TechAcceptCalibration_
const L1GtTriggerMenu * m_l1GtMenu
std::vector< unsigned int > L1AlgoAcceptRandom_
std::vector< std::vector< unsigned int > > hltIndex_
HistoJ< unsigned int > * hltAccept
HistoJ< unsigned int > * L1AlgoAcceptCalibration
std::vector< unsigned int > hltAccept_
std::string streamL1Destination
tuple path
else: Piece not in the list, fine.
void endLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, hltJson::lumiVars *) const
std::vector< std::string > hltNames_
HLTConfigProvider hltConfig_
HistoJ< unsigned int > * L1TechAcceptCalibration
std::vector< int > L1AlgoBitNumber_
const L1GtTriggerMask * m_l1tTechMask
std::vector< std::string > datasetNames_
std::vector< std::string > L1GlobalType_
std::vector< unsigned int > hltReject_
HistoJ< unsigned int > * hltPre
HistoJ< unsigned int > * L1AlgoAcceptRandom
std::string streamHLTDestination
std::vector< int > posL1s_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< std::string > L1AlgoNames_
HistoJ< unsigned int > * hltDatasets
HistoJ< unsigned int > * L1TechAcceptRandom
std::vector< unsigned int > L1TechAccept_
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::string streamHLTDestination
const L1GtTriggerMask * m_l1tAlgoMask
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &, RunContext const *iContext)
void writeDefJson(std::string path)
std::vector< unsigned int > L1Global_
std::vector< unsigned int > hltWasRun_
std::vector< std::vector< std::string > > datasetContents_
std::vector< int > posPre_
HistoJ< unsigned int > * hltL1s
std::vector< unsigned int > L1TechAcceptPhysics_
std::vector< std::string > L1TechNames_
HistoJ< unsigned int > * L1TechAcceptPhysics
std::vector< unsigned int > L1AlgoAcceptCalibration_
void analyze(edm::Event const &, edm::EventSetup const &)
HistoJ< unsigned int > * L1Global
HistoJ< unsigned int > * hltWasRun
void writeL1DefJson(std::string path)
HistoJ< unsigned int > * L1AlgoAcceptPhysics
Definition: Run.h:41
std::vector< unsigned int > hltPre_