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