CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTriggerJSONMonitoring.h
Go to the documentation of this file.
1 #ifndef JSONMonitoring_HLTriggerJSONMonitoring_h
2 #define JSONMonitoring_HLTriggerJSONMonitoring_h
3 
21 
27 
30 
32 
34 
35 #include <atomic>
36 
37 namespace hltJson {
38  //Struct for storing variables that must be written and reset every lumi section
39  struct lumiVars {
41  jsoncollector::HistoJ<unsigned int> *hltWasRun; // # of events where HLT[i] was run
42  jsoncollector::HistoJ<unsigned int> *hltL1s; // # of events after L1 seed
43  jsoncollector::HistoJ<unsigned int> *hltPre; // # of events after HLT prescale
44  jsoncollector::HistoJ<unsigned int> *hltAccept; // # of events accepted by HLT[i]
45  jsoncollector::HistoJ<unsigned int> *hltReject; // # of events rejected by HLT[i]
46  jsoncollector::HistoJ<unsigned int> *hltErrors; // # of events with error in HLT[i]
47  jsoncollector::HistoJ<unsigned int> *hltDatasets; // # of events accepted by each dataset
48 
49  std::string baseRunDir; //Base directory from EvFDaqDirector
50  std::string stHltJsd; //Definition file name for JSON with rates
51 
53  };
54  //End lumi struct
55  //Struct for storing variable written once per run
56  struct runVars{
57  mutable std::atomic<bool> wroteFiles;
59  };
60 }//End hltJson namespace
61 
62 //
63 // class declaration
64 //
65 class HLTriggerJSONMonitoring : public edm::stream::EDAnalyzer <edm::RunCache<hltJson::runVars>, edm::LuminosityBlockSummaryCache<hltJson::lumiVars>>
66 {
67  public:
70  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
71 
72  void analyze(edm::Event const&,
73  edm::EventSetup const&);
74 
75  void beginRun(edm::Run const&,
76  edm::EventSetup const&);
77 
78  static std::shared_ptr<hltJson::runVars> globalBeginRun(edm::Run const&, edm::EventSetup const&, void const*){
79  std::shared_ptr<hltJson::runVars> rv(new hltJson::runVars);
80  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
81  rv->streamHLTDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamHLTRates");
82  }
83  rv->wroteFiles = false;
84  return rv;
85  }
86 
87  static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext){ }
88 
90 
91  static std::shared_ptr<hltJson::lumiVars> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
92  edm::EventSetup const&,
93  LuminosityBlockContext const*);
94 
96  edm::EventSetup const&,
97  hltJson::lumiVars*) const;
98 
99 
101  edm::EventSetup const&,
102  LuminosityBlockContext const*,
104 
105  void resetRun(bool changed); //Reset run-related info
106  void resetLumi(); //Reset all counters
107 
109 
110  //Variables from cfg and associated tokens
111  edm::InputTag triggerResults_; // Input tag for TriggerResults
113 
114  //Variables that change at most once per run
115  HLTConfigProvider hltConfig_; // to get configuration for HLT
116 
117  std::string baseRunDir_; //Base directory from EvFDaqDirector
118 
119  // hltIndex_[ds][p] stores the hltNames_ index of the p-th path of the ds-th dataset
120  std::vector<std::vector<unsigned int> > hltIndex_;
121  std::vector<std::string> hltNames_; // list of HLT path names
122  std::vector<std::string> datasetNames_; // list of dataset names
123  std::vector<std::vector<std::string> > datasetContents_; // list of path names for each dataset
124 
125  std::vector<int> posL1s_; // pos # of last L1 seed
126  std::vector<int> posPre_; // pos # of last HLT prescale
127 
128  std::string stHltJsd_; //Definition file name for JSON with rates
129 
130  //Variables that need to be reset at lumi section boundaries
131  unsigned int processed_; // # of events processed
132 
133  std::vector<unsigned int> hltWasRun_; // # of events where HLT[i] was run
134  std::vector<unsigned int> hltL1s_; // # of events after L1 seed
135  std::vector<unsigned int> hltPre_; // # of events after HLT prescale
136  std::vector<unsigned int> hltAccept_; // # of events accepted by HLT[i]
137  std::vector<unsigned int> hltReject_; // # of events rejected by HLT[i]
138  std::vector<unsigned int> hltErrors_; // # of events with error in HLT[i]
139 
140  std::vector<unsigned int> hltDatasets_; // # of events accepted by each dataset
141 
142  private:
143 
144 };
145 #endif
std::vector< std::string > hltNames_
LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache > LuminosityBlockContext
Definition: EDAnalyzer.h:46
jsoncollector::HistoJ< unsigned int > * hltAccept
void endLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, hltJson::lumiVars *) const
std::atomic< bool > wroteFiles
std::vector< unsigned int > hltDatasets_
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, hltJson::lumiVars *)
HLTriggerJSONMonitoring(const edm::ParameterSet &)
std::vector< unsigned int > hltPre_
std::vector< unsigned int > hltAccept_
std::vector< unsigned int > hltReject_
jsoncollector::HistoJ< unsigned int > * hltWasRun
static std::shared_ptr< hltJson::lumiVars > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
std::vector< std::vector< unsigned int > > hltIndex_
void beginRun(edm::Run const &, edm::EventSetup const &)
jsoncollector::HistoJ< unsigned int > * hltDatasets
static std::shared_ptr< hltJson::runVars > globalBeginRun(edm::Run const &, edm::EventSetup const &, void const *)
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< unsigned int > hltL1s_
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &, RunContext const *iContext)
jsoncollector::HistoJ< unsigned int > * hltPre
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::vector< std::string > datasetNames_
std::string streamHLTDestination
std::vector< unsigned int > hltWasRun_
jsoncollector::HistoJ< unsigned int > * hltErrors
jsoncollector::HistoJ< unsigned int > * processed
void writeHLTDefJson(std::string path)
std::vector< unsigned int > hltErrors_
void analyze(edm::Event const &, edm::EventSetup const &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
jsoncollector::HistoJ< unsigned int > * hltL1s
jsoncollector::HistoJ< unsigned int > * hltReject
Definition: Run.h:43
std::vector< std::vector< std::string > > datasetContents_