CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTScalersClient.h
Go to the documentation of this file.
1 // -*-c++-*-
2 //
3 // Client class for HLT Scalers module.
4 //
5 // $Id: HLTScalersClient.h,v 1.14 2010/04/02 20:48:11 wittich Exp $
6 
7 // $Log: HLTScalersClient.h,v $
8 // Revision 1.14 2010/04/02 20:48:11 wittich
9 // updates to scale entries by received number of FU's
10 //
11 // Revision 1.13 2010/03/17 20:56:18 wittich
12 // Check for good updates based on mergeCount values
13 // add code for rates normalized per FU
14 //
15 // Revision 1.12 2010/03/16 22:19:19 wittich
16 // updates for per-LS normalization for variable
17 // number of FU's sending information back to the clients.
18 //
19 // Revision 1.11 2010/02/15 17:10:45 wittich
20 // Allow for longer length runs (2400 ls)
21 // this is only in the client
22 //
23 // Revision 1.10 2010/02/11 23:55:18 wittich
24 // - adapt to shorter Lumi Section length
25 // - fix bug in how history of counts was filled
26 //
27 // Revision 1.9 2010/02/11 00:11:09 wmtan
28 // Adapt to moved framework header
29 //
30 // Revision 1.8 2010/02/02 11:44:20 wittich
31 // more diagnostics for online scalers
32 //
33 // Revision 1.7 2009/12/15 20:41:16 wittich
34 // better hlt scalers client
35 //
36 // Revision 1.6 2009/11/22 14:17:46 puigh
37 // fix compilation warning
38 //
39 // Revision 1.5 2009/11/22 13:32:38 puigh
40 // clean beginJob
41 //
42 
43 #ifndef HLTSCALERSCLIENT_H
44 #define HLTSCALERSCLIENT_H
45 #include <fstream>
46 #include <vector>
47 #include <deque>
48 #include <utility>
49 
52 
54 
57 //#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
58 
59 #define MAX_PATHS 200
60 #define MAX_LUMI_SEG_HLT 2400
61 
63 {
64 private:
65  std::ofstream textfile_;
66 
67 public:
68 // typedef std::pair<int,double> CountLS_t;
69 // //typedef std::deque<CountLS_t> CountLSFifo_t;
70 // typedef std::map<int,double> CountLSFifo_t;
71 
72  // helper data structures - slightly modified stl objects
73  class CountLS_t: public std::pair<int,double>
74  {
75  public:
76  CountLS_t(int ls, double cnt):
77  std::pair<int,double>(ls,cnt)
78  {};
79  bool operator==(int ls) const
80  {
81  return ls == this->first;
82  }
83  bool operator<(CountLS_t & rhs )
84  {
85  return this->first< rhs.first;
86  };
87 
88  };
89 
90  class CountLSFifo_t: public std::deque<CountLS_t>
91  {
92  private:
93  unsigned int targetSize_;
95  public:
96  // default constructor
97  CountLSFifo_t(unsigned int sz = 3) :
98  std::deque<CountLS_t>(),
99  targetSize_(sz)
100  {}
101  unsigned int targetSize() { return targetSize_; };
102  double getCount(int ls)
103  {
104  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(),
105  ls);
106  if ( p != end() )
107  return p->second;
108  else
109  return -1;
110  }
111 
112 
113  void update( const CountLS_t & T)
114  {
115  // do we already have data for this LS?
116  CountLSFifo_t::iterator p = std::find(this->begin(), this->end(),
117  T.first);
118  if ( p != this->end() ) { // we already have data for this LS
119  p->second = T.second;
120  }
121  else { // new data
122  this->push_back(T);
123  }
124  trim_();
125  }
126  private:
127  void trim_()
128  {
129  if ( this->size() > targetSize_ ) {
130  std::sort(begin(), end());
131  while ( size() > targetSize_ ) {
132  pop_front();
133  }
134  }
135  }
136  };
137 
138 
139 public:
142 
144  virtual ~HLTScalersClient() {
145  if ( debug_ ) {
146  textfile_.close();
147  }
148  };
149 
151  void beginJob(void);
152 
153 
155  void beginRun(const edm::Run& run, const edm::EventSetup& c);
156 
158  void endRun(const edm::Run& run, const edm::EventSetup& c);
159 
160 
163  void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
164  const edm::EventSetup& c);
165 
166  // unused
167  void analyze(const edm::Event& e, const edm::EventSetup& c) ;
168 
169 
170 private:
172 
173  int nev_; // Number of events processed
174  int nLumi_; // number of lumi blocks
176 
179  std::vector<MonitorElement*> rateHistories_;
180  std::vector<MonitorElement*> countHistories_;
181 
182  std::vector<MonitorElement*> hltCurrentRate_;
183  MonitorElement *hltRate_; // global rate - any accept
184  MonitorElement *hltCount_; // globalCounts
185  // MonitorElement *hltCountN_; // globalCounts normalized
188 
189  // Normalized
190  MonitorElement *hltNormRate_; // global rate - any accept
192  std::vector<MonitorElement*> rateNormHistories_;
193  std::vector<MonitorElement*> hltCurrentNormRate_;
194 
196  std::string folderName_;
197  unsigned int kRateIntegWindow_;
198  std::string processName_;
199  //HLTConfigProvider hltConfig_;
200  std::deque<int> ignores_;
201  std::pair<double,double> getSlope_(CountLSFifo_t points);
202 private:
203  bool debug_;
204  int maxFU_;
205  std::vector<CountLSFifo_t> recentPathCountsPerLS_;
207 
208  std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
210 
211 
212 };
213 
214 
215 #endif // HLTSCALERSCLIENT_H
std::pair< double, double > getSlope_(CountLSFifo_t points)
std::ofstream textfile_
void endRun(const edm::Run &run, const edm::EventSetup &c)
EndRun.
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:7
void beginJob(void)
BeginJob.
void analyze(const edm::Event &e, const edm::EventSetup &c)
std::vector< MonitorElement * > hltCurrentNormRate_
std::string folderName_
std::string processName_
MonitorElement * hltRate_
std::vector< MonitorElement * > countHistories_
std::deque< int > ignores_
void beginRun(const edm::Run &run, const edm::EventSetup &c)
BeginRun.
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
#define end
Definition: vmac.h:38
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
bool first
Definition: L1TdeRCT.cc:94
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
bool operator<(CountLS_t &rhs)
void update(const CountLS_t &T)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
MonitorElement * hltCount_
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
virtual ~HLTScalersClient()
Destructor.
CountLSFifo_t recentNormedOverallCountsPerLS_
#define begin
Definition: vmac.h:31
std::vector< MonitorElement * > hltCurrentRate_
MonitorElement * hltNormRate_
long double T
tuple size
Write out results.
Definition: Run.h:33
std::vector< MonitorElement * > rateNormHistories_