CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 private:
58  std::ofstream textfile_;
59 
60 public:
63  // typedef std::pair<int,double> CountLS_t;
64  // //typedef std::deque<CountLS_t> CountLSFifo_t;
65  // typedef std::map<int,double> CountLSFifo_t;
66 
67  // helper data structures - slightly modified stl objects
68  class CountLS_t : public std::pair<int, double> {
69  public:
70  CountLS_t(int ls, double cnt) : std::pair<int, double>(ls, cnt){};
71  bool operator==(int ls) const { return ls == this->first; }
72  bool operator<(CountLS_t &rhs) { return this->first < rhs.first; };
73  };
74 
75  class CountLSFifo_t : public std::deque<CountLS_t> {
76  private:
77  unsigned int targetSize_;
79 
80  public:
81  // default constructor
82  CountLSFifo_t(unsigned int sz = 3) : std::deque<CountLS_t>(), targetSize_(sz) {}
83  unsigned int targetSize() const { return targetSize_; };
84  double getCount(int ls) {
85  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), ls);
86  if (p != end())
87  return p->second;
88  else
89  return -1;
90  }
91 
92  void update(const CountLS_t &T) {
93  // do we already have data for this LS?
94  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), T.first);
95  if (p != this->end()) { // we already have data for this LS
96  p->second = T.second;
97  } else { // new data
98  this->push_back(T);
99  }
100  trim_();
101  }
102 
103  private:
104  void trim_() {
105  if (this->size() > targetSize_) {
106  std::sort(begin(), end());
107  while (size() > targetSize_) {
108  pop_front();
109  }
110  }
111  }
112  };
113 
114 public:
117 
119  ~HLTScalersClient() override {
120  if (debug_) {
121  textfile_.close();
122  }
123  };
124 
126  void beginJob(void) override;
127 
129  void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
130 
132  void endRun(const edm::Run &run, const edm::EventSetup &c) override;
133 
136  void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override;
137 
138  // unused
139  void analyze(const edm::Event &e, const edm::EventSetup &c) override;
140 
141 private:
143 
144  int nev_; // Number of events processed
145  int nLumi_; // number of lumi blocks
147 
150  std::vector<MonitorElement *> rateHistories_;
151  std::vector<MonitorElement *> countHistories_;
152 
153  std::vector<MonitorElement *> hltCurrentRate_;
154  MonitorElement *hltRate_; // global rate - any accept
155  MonitorElement *hltCount_; // globalCounts
156  // MonitorElement *hltCountN_; // globalCounts normalized
159 
160  // Normalized
161  MonitorElement *hltNormRate_; // global rate - any accept
163  std::vector<MonitorElement *> rateNormHistories_;
164  std::vector<MonitorElement *> hltCurrentNormRate_;
165 
168  unsigned int kRateIntegWindow_;
170  // HLTConfigProvider hltConfig_;
171  std::deque<int> ignores_;
172  std::pair<double, double> getSlope_(const CountLSFifo_t &points);
173 
174 private:
175  bool debug_;
176  int maxFU_;
177  std::vector<CountLSFifo_t> recentPathCountsPerLS_;
179 
180  std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
182 };
183 
184 #endif // HLTSCALERSCLIENT_H
std::ofstream textfile_
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
bool operator==(int ls) const
MonitorElement * updates_
const edm::EventSetup & c
CountLS_t(int ls, double cnt)
MonitorElement * currentNormRate_
def ls
Definition: eostools.py:349
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_
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_
bool operator<(CountLS_t &rhs)
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_
MonitorElement * hltCount_
dqm::legacy::DQMStore DQMStore
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
CountLSFifo_t recentNormedOverallCountsPerLS_
string end
Definition: dataset.py:937
dqm::legacy::MonitorElement MonitorElement
MonitorElement * hltNormRate_
long double T
tuple size
Write out results.
Definition: Run.h:45
unsigned int targetSize() const