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  std::string baseRunDir; //Base directory from EvFDaqDirector
57  std::string stHltJsd; //Definition file name for JSON with rates
58 
59  HistoJ<unsigned int> *L1Global; // Global # of Phyics, Cailibration and Random L1 triggers //DS
60  HistoJ<unsigned int> *L1Accept; // # of events accepted by L1T[i] //DS
61  HistoJ<unsigned int> *L1TechAccept; // # of events accepted by L1 Technical Triggers[i] //DS
62 
63  std::string stL1Jsd; //Definition file name for JSON with L1 rates //DS
66  };
67  //End lumi struct
68  //Struct for storing variable written once per run
69  struct runVars{
70  mutable std::atomic<bool> wroteFiles;
73  };
74 }//End hltJson namespace
75 
76 //
77 // class declaration
78 //
79 class TriggerJSONMonitoring : public edm::stream::EDAnalyzer <edm::RunCache<hltJson::runVars>, edm::LuminosityBlockSummaryCache<hltJson::lumiVars>>
80 {
81  public:
84  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
85 
86  void analyze(edm::Event const&,
87  edm::EventSetup const&);
88 
89  void beginRun(edm::Run const&,
90  edm::EventSetup const&);
91 
92  static std::shared_ptr<hltJson::runVars> globalBeginRun(edm::Run const&, edm::EventSetup const&, void const*){
93  std::shared_ptr<hltJson::runVars> rv(new hltJson::runVars);
94  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
95  rv->streamHLTDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamHLTRates");
96  rv->streamL1Destination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamL1Rates");
97  }
98  rv->wroteFiles = false;
99  return rv;
100  }
101 
102  static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext){ }
103 
105 
106  static std::shared_ptr<hltJson::lumiVars> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
107  edm::EventSetup const&,
108  LuminosityBlockContext const*);
109 
111  edm::EventSetup const&,
112  hltJson::lumiVars*) const;
113 
114 
116  edm::EventSetup const&,
117  LuminosityBlockContext const*,
119 
120  void resetRun(bool changed); //Reset run-related info
121  void resetLumi(); //Reset all counters
122 
124 
125  void writeL1DefJson(std::string path); //DS
126 
127  //Variables from cfg and associated tokens
128  edm::InputTag triggerResults_; // Input tag for TriggerResults
130 
131  edm::InputTag level1Results_; // Input tag for L1 GT Readout Record //DS
133 
134  //Variables that change at most once per run
135  HLTConfigProvider hltConfig_; // to get configuration for HLT
136  const L1GtTriggerMenu* m_l1GtMenu; // L1 trigger menu //DS
137  AlgorithmMap algorithmMap; // L1 algorithm map //DS
138  AlgorithmMap technicalMap; // L1 technical triggeral map //DS
139 
142 
143  std::string baseRunDir_; //Base directory from EvFDaqDirector
144 
145  // hltIndex_[ds][p] stores the hltNames_ index of the p-th path of the ds-th dataset
146  std::vector<std::vector<unsigned int> > hltIndex_;
147  std::vector<std::string> hltNames_; // list of HLT path names
148  std::vector<std::string> datasetNames_; // list of dataset names
149  std::vector<std::vector<std::string> > datasetContents_; // list of path names for each dataset
150 
151  std::vector<int> posL1s_; // pos # of last L1 seed
152  std::vector<int> posPre_; // pos # of last HLT prescale
153 
154  std::string stHltJsd_; //Definition file name for JSON with rates
155 
156  std::vector<std::string> L1AlgoNames_; // name of each L1 algorithm trigger //DS
157  std::vector<int> L1AlgoBitNumber_; // bit number of each L1 algo trigger //DS
158  std::vector<std::string> L1TechNames_; // name of each L1 technical trigger //DS
159  std::vector<int> L1TechBitNumber_; // bit number of each L1 tech trigger //DS
160  std::vector<std::string> L1GlobalType_; // experimentType: Physics, Calibration, Random //DS
161 
162  std::string stL1Jsd_; //Definition file name for JSON with L1 rates //DS
163 
164  //Variables that need to be reset at lumi section boundaries
165  unsigned int processed_; // # of events processed
166 
167  std::vector<unsigned int> hltWasRun_; // # of events where HLT[i] was run
168  std::vector<unsigned int> hltL1s_; // # of events after L1 seed
169  std::vector<unsigned int> hltPre_; // # of events after HLT prescale
170  std::vector<unsigned int> hltAccept_; // # of events accepted by HLT[i]
171  std::vector<unsigned int> hltReject_; // # of events rejected by HLT[i]
172  std::vector<unsigned int> hltErrors_; // # of events with error in HLT[i]
173 
174  std::vector<unsigned int> hltDatasets_; // # of events accepted by each dataset
175 
176  std::vector<unsigned int> L1Global_; // Global # of Physics, Calibration and Random L1 triggers //DS
177  std::vector<unsigned int> L1AlgoAccept_; // # of events accepted by L1T[i] //DS
178  std::vector<unsigned int> L1TechAccept_; // # of events accepted by L1 Technical Triggers[i] //DS
179 
180  private:
181 
182 };
183 #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_
HistoJ< unsigned int > * hltErrors
std::string streamL1Destination
std::vector< unsigned int > hltErrors_
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, hltJson::lumiVars *)
void beginRun(edm::Run const &, edm::EventSetup const &)
HistoJ< unsigned int > * processed
std::vector< unsigned int > hltL1s_
const L1GtTriggerMenu * m_l1GtMenu
std::vector< std::vector< unsigned int > > hltIndex_
HistoJ< unsigned int > * hltAccept
std::vector< unsigned int > hltAccept_
std::string streamL1Destination
tuple path
else: Piece not in the list, fine.
HistoJ< unsigned int > * L1Accept
void endLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, hltJson::lumiVars *) const
std::vector< std::string > hltNames_
HLTConfigProvider hltConfig_
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
std::string streamHLTDestination
std::vector< int > posL1s_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< std::string > L1AlgoNames_
HistoJ< unsigned int > * hltDatasets
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< std::string > L1TechNames_
void analyze(edm::Event const &, edm::EventSetup const &)
HistoJ< unsigned int > * L1Global
HistoJ< unsigned int > * hltWasRun
void writeL1DefJson(std::string path)
Definition: Run.h:41
std::vector< unsigned int > hltPre_