CMS 3D CMS Logo

HLTScalersClient.h
Go to the documentation of this file.
1 // -*-c++-*-
2 //
3 // Client class for HLT Scalers module.
4 //
5 
6 // Revision 1.13 2010/03/17 20:56:18 wittich
7 // Check for good updates based on mergeCount values
8 // add code for rates normalized per FU
9 //
10 // Revision 1.12 2010/03/16 22:19:19 wittich
11 // updates for per-LS normalization for variable
12 // number of FU's sending information back to the clients.
13 //
14 // Revision 1.11 2010/02/15 17:10:45 wittich
15 // Allow for longer length runs (2400 ls)
16 // this is only in the client
17 //
18 // Revision 1.10 2010/02/11 23:55:18 wittich
19 // - adapt to shorter Lumi Section length
20 // - fix bug in how history of counts was filled
21 //
22 // Revision 1.9 2010/02/11 00:11:09 wmtan
23 // Adapt to moved framework header
24 //
25 // Revision 1.8 2010/02/02 11:44:20 wittich
26 // more diagnostics for online scalers
27 //
28 // Revision 1.7 2009/12/15 20:41:16 wittich
29 // better hlt scalers client
30 //
31 // Revision 1.6 2009/11/22 14:17:46 puigh
32 // fix compilation warning
33 //
34 // Revision 1.5 2009/11/22 13:32:38 puigh
35 // clean beginJob
36 //
37 
38 #ifndef HLTSCALERSCLIENT_H
39 #define HLTSCALERSCLIENT_H
40 #include <deque>
41 #include <fstream>
42 #include <utility>
43 #include <vector>
44 
47 
49 
51 //#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
52 
53 #define MAX_PATHS 200
54 #define MAX_LUMI_SEG_HLT 2400
55 
57  : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
58 private:
59  std::ofstream textfile_;
60 
61 public:
64  // typedef std::pair<int,double> CountLS_t;
65  // //typedef std::deque<CountLS_t> CountLSFifo_t;
66  // typedef std::map<int,double> CountLSFifo_t;
67 
68  // helper data structures - slightly modified stl objects
69  class CountLS_t : public std::pair<int, double> {
70  public:
71  CountLS_t(int ls, double cnt) : std::pair<int, double>(ls, cnt){};
72  bool operator==(int ls) const { return ls == this->first; }
73  bool operator<(CountLS_t &rhs) { return this->first < rhs.first; };
74  };
75 
76  class CountLSFifo_t : public std::deque<CountLS_t> {
77  private:
78  unsigned int targetSize_;
80 
81  public:
82  // default constructor
83  CountLSFifo_t(unsigned int sz = 3) : std::deque<CountLS_t>(), targetSize_(sz) {}
84  unsigned int targetSize() const { return targetSize_; };
85  double getCount(int ls) {
86  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), ls);
87  if (p != end())
88  return p->second;
89  else
90  return -1;
91  }
92 
93  void update(const CountLS_t &T) {
94  // do we already have data for this LS?
95  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), T.first);
96  if (p != this->end()) { // we already have data for this LS
97  p->second = T.second;
98  } else { // new data
99  this->push_back(T);
100  }
101  trim_();
102  }
103 
104  private:
105  void trim_() {
106  if (this->size() > targetSize_) {
107  std::sort(begin(), end());
108  while (size() > targetSize_) {
109  pop_front();
110  }
111  }
112  }
113  };
114 
115 public:
118 
120  ~HLTScalersClient() override {
121  if (debug_) {
122  textfile_.close();
123  }
124  };
125 
127  void beginJob(void) override;
128 
130  void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
131 
133  void endRun(const edm::Run &run, const edm::EventSetup &c) override;
134 
137  void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override {}
138  void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override;
139 
140  // unused
141  void analyze(const edm::Event &e, const edm::EventSetup &c) override;
142 
143 private:
145 
146  int nev_; // Number of events processed
147  int nLumi_; // number of lumi blocks
149 
152  std::vector<MonitorElement *> rateHistories_;
153  std::vector<MonitorElement *> countHistories_;
154 
155  std::vector<MonitorElement *> hltCurrentRate_;
156  MonitorElement *hltRate_; // global rate - any accept
157  MonitorElement *hltCount_; // globalCounts
158  // MonitorElement *hltCountN_; // globalCounts normalized
161 
162  // Normalized
163  MonitorElement *hltNormRate_; // global rate - any accept
165  std::vector<MonitorElement *> rateNormHistories_;
166  std::vector<MonitorElement *> hltCurrentNormRate_;
167 
170  unsigned int kRateIntegWindow_;
172  // HLTConfigProvider hltConfig_;
173  std::deque<int> ignores_;
174  std::pair<double, double> getSlope_(const CountLSFifo_t &points);
175 
176 private:
177  bool debug_;
178  int maxFU_;
179  std::vector<CountLSFifo_t> recentPathCountsPerLS_;
181 
182  std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
184 };
185 
186 #endif // HLTSCALERSCLIENT_H
size
Write out results.
std::ofstream textfile_
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
MonitorElement * updates_
CountLS_t(int ls, double cnt)
MonitorElement * currentNormRate_
std::vector< CountLSFifo_t > recentNormedPathCountsPerLS_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< MonitorElement * > hltCurrentNormRate_
bool operator==(int ls) const
std::string folderName_
void beginJob(void) override
BeginJob.
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
BeginRun.
std::string processName_
MonitorElement * hltRate_
std::deque< int > ignores_
void endRun(const edm::Run &run, const edm::EventSetup &c) override
EndRun.
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
std::vector< MonitorElement * > countHistories_
~HLTScalersClient() override
Destructor.
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
bool operator<(CountLS_t &rhs)
def ls(path, rec=False)
Definition: eostools.py:349
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::vector< MonitorElement * > hltCurrentRate_
void update(const CountLS_t &T)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
std::vector< MonitorElement * > rateHistories_
unsigned int targetSize() const
MonitorElement * hltCount_
dqm::legacy::DQMStore DQMStore
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
CountLSFifo_t recentNormedOverallCountsPerLS_
dqm::legacy::MonitorElement MonitorElement
MonitorElement * hltNormRate_
long double T
Definition: Run.h:45