test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TriggerJSONMonitoring.h
Go to the documentation of this file.
1 #ifndef JSONMonitoring_L1TriggerJSONMonitoring_h
2 #define JSONMonitoring_L1TriggerJSONMonitoring_h
3 
22 
28 
31 
37 
38 #include <atomic>
39 
40 namespace l1Json {
41  //Struct for storing variables that must be written and reset every lumi section
42  struct lumiVars {
43 
44  unsigned int prescaleIndex; // Prescale index for each lumi section
45 
46  std::string baseRunDir; //Base directory from EvFDaqDirector
47 
49  jsoncollector::HistoJ<unsigned int> *L1AlgoAccept; // # of events accepted by L1T[i]
50  jsoncollector::HistoJ<unsigned int> *L1AlgoAcceptPhysics; // # of Physics events accepted by L1T[i]
51  jsoncollector::HistoJ<unsigned int> *L1AlgoAcceptCalibration; // # of Calibration events accepted by L1T[i]
52  jsoncollector::HistoJ<unsigned int> *L1AlgoAcceptRandom; // # of Random events accepted by L1T[i]
53  jsoncollector::HistoJ<unsigned int> *L1Global; // Global # of Phyics, Cailibration and Random L1 triggers
54 
55  std::string stL1Jsd; //Definition file name for JSON with L1 rates
58  };
59  //End lumi struct
60  //Struct for storing variable written once per run
61  struct runVars{
62  mutable std::atomic<bool> wroteFiles;
65  };
66 }//End l1Json namespace
67 
68 //
69 // class declaration
70 //
71 class L1TriggerJSONMonitoring : public edm::stream::EDAnalyzer <edm::RunCache<l1Json::runVars>, edm::LuminosityBlockSummaryCache<l1Json::lumiVars>>
72 {
73  public:
76  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
77 
78  void analyze(edm::Event const&,
79  edm::EventSetup const&);
80 
81  void beginRun(edm::Run const&,
82  edm::EventSetup const&);
83 
84  static std::shared_ptr<l1Json::runVars> globalBeginRun(edm::Run const&, edm::EventSetup const&, void const*){
85  std::shared_ptr<l1Json::runVars> rv(new l1Json::runVars);
86  if (edm::Service<evf::EvFDaqDirector>().isAvailable()) {
87  rv->streamL1Destination = edm::Service<evf::EvFDaqDirector>()->getStreamDestinations("streamL1Rates");
88  rv->streamL1MergeType = edm::Service<evf::EvFDaqDirector>()->getStreamMergeType("streamL1Rates",evf::MergeTypeJSNDATA);
89  }
90  rv->wroteFiles = false;
91  return rv;
92  }
93 
94  static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext){ }
95 
97 
98  static std::shared_ptr<l1Json::lumiVars> globalBeginLuminosityBlockSummary(edm::LuminosityBlock const&,
99  edm::EventSetup const&,
100  LuminosityBlockContext const*);
101 
103  edm::EventSetup const&,
104  l1Json::lumiVars*) const;
105 
106 
108  edm::EventSetup const&,
109  LuminosityBlockContext const*,
111 
112  void resetLumi(); //Reset all counters
113 
115 
116  //Variables from cfg and associated tokens
117  edm::InputTag level1Results_; // Input tag for L1 Global collection
119 
120  //Variables that change at most once per run
121  std::string baseRunDir_; //Base directory from EvFDaqDirector
122 
123  std::vector<std::string> L1AlgoNames_; // name of each L1 algorithm trigger
124  std::vector<int> L1AlgoBitNumber_; // bit number of each L1 algo trigger
125  std::vector<std::string> L1GlobalType_; // experimentType: Physics, Calibration, Random
126 
127  std::string stL1Jsd_; //Definition file name for JSON with L1 rates
128 
129  //Variables that need to be reset at lumi section boundaries
130  unsigned int processed_; // # of events processed
131  unsigned int prescaleIndex_; //Prescale index for each lumi section
132 
133  std::vector<unsigned int> L1AlgoAccept_; // # of events accepted by L1T[i]
134  std::vector<unsigned int> L1AlgoAcceptPhysics_; // # of Physics events accepted by L1T[i]
135  std::vector<unsigned int> L1AlgoAcceptCalibration_; // # of Calibration events accepted by L1T[i]
136  std::vector<unsigned int> L1AlgoAcceptRandom_; // # of Random events accepted by L1T[i]
137  std::vector<unsigned int> L1Global_; // Global # of Physics, Calibration and Random L1 triggers
138 
139  //Variables for confirming that prescale index did not change
140  unsigned int oldLumi;
141  unsigned int oldPrescaleIndex;
142 
143  private:
144 
145 };
146 #endif
LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache > LuminosityBlockContext
Definition: EDAnalyzer.h:46
void endLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, l1Json::lumiVars *) const
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &, RunContext const *iContext)
std::vector< unsigned int > L1AlgoAcceptRandom_
std::vector< unsigned int > L1AlgoAccept_
void writeL1DefJson(std::string path)
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptCalibration
std::string streamL1Destination
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::atomic< bool > wroteFiles
std::vector< std::string > L1AlgoNames_
std::vector< unsigned int > L1Global_
void analyze(edm::Event const &, edm::EventSetup const &)
edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
std::vector< std::string > L1GlobalType_
std::vector< unsigned int > L1AlgoAcceptPhysics_
std::vector< unsigned int > L1AlgoAcceptCalibration_
void beginRun(edm::Run const &, edm::EventSetup const &)
jsoncollector::HistoJ< unsigned int > * L1Global
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
jsoncollector::HistoJ< unsigned int > * L1AlgoAccept
jsoncollector::HistoJ< unsigned int > * processed
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptRandom
static std::shared_ptr< l1Json::runVars > globalBeginRun(edm::Run const &, edm::EventSetup const &, void const *)
L1TriggerJSONMonitoring(const edm::ParameterSet &)
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, l1Json::lumiVars *)
jsoncollector::HistoJ< unsigned int > * L1AlgoAcceptPhysics
std::vector< int > L1AlgoBitNumber_
static std::shared_ptr< l1Json::lumiVars > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
Definition: Run.h:43