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