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 <fstream>
41 #include <vector>
42 #include <deque>
43 #include <utility>
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 {
59 private:
60  std::ofstream textfile_;
61 
62 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  {
70  public:
71  CountLS_t(int ls, double cnt):
72  std::pair<int,double>(ls,cnt)
73  {};
74  bool operator==(int ls) const
75  {
76  return ls == this->first;
77  }
78  bool operator<(CountLS_t & rhs )
79  {
80  return this->first< rhs.first;
81  };
82 
83  };
84 
85  class CountLSFifo_t: public std::deque<CountLS_t>
86  {
87  private:
88  unsigned int targetSize_;
90  public:
91  // default constructor
92  CountLSFifo_t(unsigned int sz = 3) :
93  std::deque<CountLS_t>(),
94  targetSize_(sz)
95  {}
96  unsigned int targetSize() const { return targetSize_; };
97  double getCount(int ls)
98  {
99  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(),
100  ls);
101  if ( p != end() )
102  return p->second;
103  else
104  return -1;
105  }
106 
107 
108  void update( const CountLS_t & T)
109  {
110  // do we already have data for this LS?
111  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(),
112  T.first);
113  if ( p != this->end() ) { // we already have data for this LS
114  p->second = T.second;
115  }
116  else { // new data
117  this->push_back(T);
118  }
119  trim_();
120  }
121  private:
122  void trim_()
123  {
124  if ( this->size() > targetSize_ ) {
125  std::sort(begin(), end());
126  while ( size() > targetSize_ ) {
127  pop_front();
128  }
129  }
130  }
131  };
132 
133 
134 public:
137 
139  ~HLTScalersClient() override {
140  if ( debug_ ) {
141  textfile_.close();
142  }
143  };
144 
146  void beginJob(void) override;
147 
148 
150  void beginRun(const edm::Run& run, const edm::EventSetup& c) override;
151 
153  void endRun(const edm::Run& run, const edm::EventSetup& c) override;
154 
155 
158  void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
159  const edm::EventSetup& c) override;
160 
161  // unused
162  void analyze(const edm::Event& e, const edm::EventSetup& c) override ;
163 
164 
165 private:
167 
168  int nev_; // Number of events processed
169  int nLumi_; // number of lumi blocks
171 
174  std::vector<MonitorElement*> rateHistories_;
175  std::vector<MonitorElement*> countHistories_;
176 
177  std::vector<MonitorElement*> hltCurrentRate_;
178  MonitorElement *hltRate_; // global rate - any accept
179  MonitorElement *hltCount_; // globalCounts
180  // MonitorElement *hltCountN_; // globalCounts normalized
183 
184  // Normalized
185  MonitorElement *hltNormRate_; // global rate - any accept
187  std::vector<MonitorElement*> rateNormHistories_;
188  std::vector<MonitorElement*> hltCurrentNormRate_;
189 
192  unsigned int kRateIntegWindow_;
194  //HLTConfigProvider hltConfig_;
195  std::deque<int> ignores_;
196  std::pair<double,double> getSlope_(const CountLSFifo_t& points);
197 private:
198  bool debug_;
199  int maxFU_;
200  std::vector<CountLSFifo_t> recentPathCountsPerLS_;
202 
203  std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
205 
206 
207 };
208 
209 
210 #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)
std::vector< MonitorElement * > rateHistories_
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::vector< MonitorElement * > countHistories_
std::deque< int > ignores_
void endRun(const edm::Run &run, const edm::EventSetup &c) override
EndRun.
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
#define end
Definition: vmac.h:39
~HLTScalersClient() override
Destructor.
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
bool operator<(CountLS_t &rhs)
def ls(path, rec=False)
Definition: eostools.py:348
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void update(const CountLS_t &T)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
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
std::vector< MonitorElement * > hltCurrentRate_
MonitorElement * hltNormRate_
long double T
Definition: Run.h:43
std::vector< MonitorElement * > rateNormHistories_
unsigned int targetSize() const