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 
52 //#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
53 
54 #define MAX_PATHS 200
55 #define MAX_LUMI_SEG_HLT 2400
56 
58 private:
59  std::ofstream textfile_;
60 
61 public:
62  // typedef std::pair<int,double> CountLS_t;
63  // //typedef std::deque<CountLS_t> CountLSFifo_t;
64  // typedef std::map<int,double> CountLSFifo_t;
65 
66  // helper data structures - slightly modified stl objects
67  class CountLS_t : public std::pair<int, double> {
68  public:
69  CountLS_t(int ls, double cnt) : std::pair<int, double>(ls, cnt){};
70  bool operator==(int ls) const { return ls == this->first; }
71  bool operator<(CountLS_t &rhs) { return this->first < rhs.first; };
72  };
73 
74  class CountLSFifo_t : public std::deque<CountLS_t> {
75  private:
76  unsigned int targetSize_;
78 
79  public:
80  // default constructor
81  CountLSFifo_t(unsigned int sz = 3) : std::deque<CountLS_t>(), targetSize_(sz) {}
82  unsigned int targetSize() const { return targetSize_; };
83  double getCount(int ls) {
84  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), ls);
85  if (p != end())
86  return p->second;
87  else
88  return -1;
89  }
90 
91  void update(const CountLS_t &T) {
92  // do we already have data for this LS?
93  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), T.first);
94  if (p != this->end()) { // we already have data for this LS
95  p->second = T.second;
96  } else { // new data
97  this->push_back(T);
98  }
99  trim_();
100  }
101 
102  private:
103  void trim_() {
104  if (this->size() > targetSize_) {
105  std::sort(begin(), end());
106  while (size() > targetSize_) {
107  pop_front();
108  }
109  }
110  }
111  };
112 
113 public:
116 
118  ~HLTScalersClient() override {
119  if (debug_) {
120  textfile_.close();
121  }
122  };
123 
125  void beginJob(void) override;
126 
128  void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
129 
131  void endRun(const edm::Run &run, const edm::EventSetup &c) override;
132 
135  void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override;
136 
137  // unused
138  void analyze(const edm::Event &e, const edm::EventSetup &c) override;
139 
140 private:
142 
143  int nev_; // Number of events processed
144  int nLumi_; // number of lumi blocks
146 
149  std::vector<MonitorElement *> rateHistories_;
150  std::vector<MonitorElement *> countHistories_;
151 
152  std::vector<MonitorElement *> hltCurrentRate_;
153  MonitorElement *hltRate_; // global rate - any accept
154  MonitorElement *hltCount_; // globalCounts
155  // MonitorElement *hltCountN_; // globalCounts normalized
158 
159  // Normalized
160  MonitorElement *hltNormRate_; // global rate - any accept
162  std::vector<MonitorElement *> rateNormHistories_;
163  std::vector<MonitorElement *> hltCurrentNormRate_;
164 
167  unsigned int kRateIntegWindow_;
169  // HLTConfigProvider hltConfig_;
170  std::deque<int> ignores_;
171  std::pair<double, double> getSlope_(const CountLSFifo_t &points);
172 
173 private:
174  bool debug_;
175  int maxFU_;
176  std::vector<CountLSFifo_t> recentPathCountsPerLS_;
178 
179  std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
181 };
182 
183 #endif // HLTSCALERSCLIENT_H
size
Write out results.
std::ofstream textfile_
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
bool operator==(int ls) const
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:20
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_
#define end
Definition: vmac.h:39
~HLTScalersClient() override
Destructor.
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
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_
MonitorElement * hltCount_
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
CountLSFifo_t recentNormedOverallCountsPerLS_
#define begin
Definition: vmac.h:32
MonitorElement * hltNormRate_
long double T
Definition: Run.h:45
unsigned int targetSize() const