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 
54  };
55  //End lumi struct
56  //Struct for storing variable written once per run
57  struct runVars{
58  mutable std::atomic<bool> wroteFiles;
61  };
62 }//End hltJson namespace
63 
64 //
65 // class declaration
66 //
67 class HLTriggerJSONMonitoring : public edm::stream::EDAnalyzer <edm::RunCache<hltJson::runVars>, edm::LuminosityBlockSummaryCache<hltJson::lumiVars>>
68 {
69  public:
72  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
73 
74  void analyze(edm::Event const&,
75  edm::EventSetup const&);
76 
77  void beginRun(edm::Run const&,
78  edm::EventSetup const&);
79 
80  static std::shared_ptr<hltJson::runVars> globalBeginRun(edm::Run const&, edm::EventSetup const&, void const*){
81  std::shared_ptr<hltJson::runVars> rv(new hltJson::runVars);
82  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
83  rv->streamHLTDestination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamHLTRates");
84  rv->streamHLTMergeType = edm::Service<evf::EvFDaqDirector>()->getStreamMergeType("streamHLTRates",evf::MergeTypeJSNDATA);
85 
86  }
87  rv->wroteFiles = false;
88  return rv;
89  }
90 
91  static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext){ }
92 
94 
95  static std::shared_ptr<hltJson::lumiVars> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
96  edm::EventSetup const&,
97  LuminosityBlockContext const*);
98 
100  edm::EventSetup const&,
101  hltJson::lumiVars*) const;
102 
103 
105  edm::EventSetup const&,
106  LuminosityBlockContext const*,
108 
109  void resetRun(bool changed); //Reset run-related info
110  void resetLumi(); //Reset all counters
111 
113 
114  //Variables from cfg and associated tokens
115  edm::InputTag triggerResults_; // Input tag for TriggerResults
117 
118  //Variables that change at most once per run
119  HLTConfigProvider hltConfig_; // to get configuration for HLT
120 
121  std::string baseRunDir_; //Base directory from EvFDaqDirector
122 
123  // hltIndex_[ds][p] stores the hltNames_ index of the p-th path of the ds-th dataset
124  std::vector<std::vector<unsigned int> > hltIndex_;
125  std::vector<std::string> hltNames_; // list of HLT path names
126  std::vector<std::string> datasetNames_; // list of dataset names
127  std::vector<std::vector<std::string> > datasetContents_; // list of path names for each dataset
128 
129  std::vector<int> posL1s_; // pos # of last L1 seed
130  std::vector<int> posPre_; // pos # of last HLT prescale
131 
132  std::string stHltJsd_; //Definition file name for JSON with rates
133 
134  //Variables that need to be reset at lumi section boundaries
135  unsigned int processed_; // # of events processed
136 
137  std::vector<unsigned int> hltWasRun_; // # of events where HLT[i] was run
138  std::vector<unsigned int> hltL1s_; // # of events after L1 seed
139  std::vector<unsigned int> hltPre_; // # of events after HLT prescale
140  std::vector<unsigned int> hltAccept_; // # of events accepted by HLT[i]
141  std::vector<unsigned int> hltReject_; // # of events rejected by HLT[i]
142  std::vector<unsigned int> hltErrors_; // # of events with error in HLT[i]
143 
144  std::vector<unsigned int> hltDatasets_; // # of events accepted by each dataset
145 
146  private:
147 
148 };
149 #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_