test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDQM_HistoDef.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: HistoDef.h
5  *
6  * Description: Histo Type Classes that are being used by EventProcessor
7  * to request histograms.
8  *
9  * Version: 1.0
10  * Created: 10/03/2008 11:54:31 AM
11  * Revision: none
12  * Compiler: gcc
13  *
14  * Author: Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
15  * Company: CERN, CH
16  *
17  * =====================================================================================
18  */
19 
20 #ifndef CSCDQM_HistoDef_H
21 #define CSCDQM_HistoDef_H
22 
23 #include <string>
24 #include <iostream>
25 
26 #include "CSCDQM_Utility.h"
27 #include "CSCDQM_Logger.h"
28 
29 namespace cscdqm {
30 
33 
35  typedef unsigned int HistoId;
36 
38  typedef unsigned int HwId;
39 
40  namespace h {
42  const HistoName HISTO_SKIP = "0";
43  }
44 
46  static const char PATH_FED[] = "FED_%03d";
47 
49  static const char PATH_DDU[] = "DDU_%02d";
50 
52  static const char PATH_CSC[] = "CSC_%03d_%02d";
53 
54  static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$");
55 
56  #include "CSCDQM_HistoNames.h"
57 
62  class HistoDef {
63 
64  private:
65 
68 
69  public:
70 
76  HistoDef(const HistoId p_id) : id(p_id) { }
77 
81  virtual ~HistoDef() { }
82 
87  const HistoId getId() const { return id; }
88 
93  const HistoName& getHistoName() const { return h::names[id]; }
94 
101  virtual const std::string getName() const { return getHistoName(); }
102 
108  const std::string getFullPath() const {
110  if (path.size() > 0) path.append("/");
111  path.append(getName());
112  return path;
113  }
114 
120  const bool operator== (const HistoDef& t) const {
121  if (getId() != t.getId()) return false;
122  if (getFEDId() != t.getFEDId()) return false;
123  if (getDDUId() != t.getDDUId()) return false;
124  if (getCrateId() != t.getCrateId()) return false;
125  if (getDMBId() != t.getDMBId()) return false;
126  if (getAddId() != t.getAddId()) return false;
127  return true;
128  }
129 
135  const HistoDef& operator= (const HistoDef& t) {
136  id = t.getId();
137  return *this;
138  }
139 
145  const bool operator< (const HistoDef& t) const {
146  if (getId() < t.getId()) return true;
147  if (getFEDId() < t.getFEDId()) return true;
148  if (getDDUId() < t.getDDUId()) return true;
149  if (getCrateId() < t.getCrateId()) return true;
150  if (getDMBId() < t.getDMBId()) return true;
151  if (getAddId() < t.getAddId()) return true;
152  return false;
153  }
154 
161  friend std::ostream& operator<<(std::ostream& out, const HistoDef& t) {
162  return out << t.getFullPath();
163  }
164 
169  virtual const std::string getPath() const { return ""; }
170 
175  virtual const HwId getCrateId() const { return 0; }
176 
181  virtual const HwId getDMBId() const { return 0; }
182 
188  virtual const HwId getAddId() const { return 0; }
189 
194  virtual const HwId getFEDId() const { return 0; }
195 
200  virtual const HwId getDDUId() const { return 0; }
201 
207  virtual const std::string processTitle(const std::string& p_title) const {
208  return p_title;
209  }
210 
217  static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
218  for (HistoId i = 0; i < h::namesSize; i++) {
219  if (p_name.compare(h::names[i]) == 0) {
220  p_id = i;
221  return true;
222  }
223  }
224  return false;
225  }
226 
232  static const std::string getHistoKeyById(const HistoId& p_id) {
233  return h::keys[p_id];
234  }
235 
242  static const std::string processName(const HistoName& p_name, const HwId p_id) {
243  if (Utility::regexMatch(REGEXP_ONDEMAND, p_name)) {
244  return Form(p_name.c_str(), p_id);
245  }
246  return p_name;
247  }
248 
249  };
250 
255  class EMUHistoDef : public HistoDef {
256 
257  public:
258 
264  EMUHistoDef(const HistoId p_id) : HistoDef(p_id) { }
265 
266  };
267 
272  class FEDHistoDef : public HistoDef {
273 
274  private:
275 
277 
278  public:
279 
286  FEDHistoDef(const HistoId p_id, const HwId p_fedId) : HistoDef(p_id), fedId(p_fedId) { }
287  const HwId getFEDId() const { return fedId; }
288  const std::string getPath() const { return getPath(fedId); }
289 
295  static const std::string getPath(const HwId p_fedId) {
296  return Form(PATH_FED, p_fedId);
297  }
298 
306  HistoDef *h1 = const_cast<FEDHistoDef*>(this);
307  const HistoDef *h2 = &t;
308  *h1 = *h2;
309  fedId = t.getFEDId();
310  return *this;
311  }
312 
313  const std::string processTitle(const std::string& p_title) const {
314  return processName(p_title.c_str(), getFEDId());
315  }
316 
317  };
318 
323  class DDUHistoDef : public HistoDef {
324 
325  private:
326 
328 
329  public:
330 
337  DDUHistoDef(const HistoId p_id, const HwId p_dduId) : HistoDef(p_id), dduId(p_dduId) { }
338  const HwId getDDUId() const { return dduId; }
339  const std::string getPath() const { return getPath(dduId); }
340 
346  static const std::string getPath(const HwId p_dduId) {
347  return Form(PATH_DDU, p_dduId);
348  }
349 
357  HistoDef *h1 = const_cast<DDUHistoDef*>(this);
358  const HistoDef *h2 = &t;
359  *h1 = *h2;
360  dduId = t.getDDUId();
361  return *this;
362  }
363 
364  const std::string processTitle(const std::string& p_title) const {
365  return processName(p_title.c_str(), getDDUId());
366  }
367 
368  };
369 
374  class CSCHistoDef : public HistoDef {
375 
376  private:
377 
384 
385  public:
386 
396  CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId = 0) :
397  HistoDef(p_id), crateId(p_crateId), dmbId(p_dmbId), addId(p_addId) { }
398 
399  const HwId getCrateId() const { return crateId; }
400  const HwId getDMBId() const { return dmbId; }
401  const HwId getAddId() const { return addId; }
402  const std::string getName() const { return processName(getHistoName(), getAddId()); }
403  const std::string getPath() const { return getPath(crateId, dmbId); }
404 
411  static const std::string getPath(const HwId p_crateId, const HwId p_dmbId) {
412  return Form(PATH_CSC, p_crateId, p_dmbId);
413  }
414 
422  HistoDef *h1 = const_cast<CSCHistoDef*>(this);
423  const HistoDef *h2 = &t;
424  *h1 = *h2;
425  crateId = t.getCrateId();
426  dmbId = t.getDMBId();
427  addId = t.getAddId();
428  return *this;
429  }
430 
431  const std::string processTitle(const std::string& p_title) const {
432  return processName(p_title.c_str(), getAddId());
433  }
434 
435 
436  };
437 
442  class ParHistoDef : public HistoDef {
443 
444  private:
445 
450 
451 
452  public:
453 
459  ParHistoDef(const HistoName& p_name) : HistoDef(Utility::fastHash(p_name.c_str())), name(p_name) { }
460 
466  ParHistoDef(const HistoId p_id) : HistoDef(p_id) {
468  }
469 
470  const HistoName& getHistoName() const { return name; }
471 
472  };
473 
474  static const std::type_info& EMUHistoDefT = typeid(cscdqm::EMUHistoDef);
475  static const std::type_info& FEDHistoDefT = typeid(cscdqm::FEDHistoDef);
476  static const std::type_info& DDUHistoDefT = typeid(cscdqm::DDUHistoDef);
477  static const std::type_info& CSCHistoDefT = typeid(cscdqm::CSCHistoDef);
478  static const std::type_info& ParHistoDefT = typeid(cscdqm::ParHistoDef);
479 
480 }
481 
482 #endif
483 
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
int i
Definition: DBlmapReader.cc:9
CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId=0)
Constructor. It calls Base constructor inline.
unsigned int HwId
static const std::type_info & FEDHistoDefT
const HistoName & getHistoName() const
FEDHistoDef(const HistoId p_id, const HwId p_fedId)
Constructor. It calls Base constructor inline.
const HistoName & getHistoName() const
Get raw histogram name.
const HwId getDMBId() const
Get CSC DMB ID.
virtual const HwId getCrateId() const
Get CSC Crate ID.
const HistoName HISTO_SKIP
static const HistoName names[]
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
virtual ~HistoDef()
Base virtual destructor.
static const std::string getPath(const HwId p_dduId)
Static DDU path formatter.
Abstract Base Histogram Definition.
Parameter Histogram Definition.
const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
virtual const HwId getDDUId() const
Get DDU ID.
static bool regexMatch(const std::string &expression, const std::string &message)
Match RegExp expression string against string message and return result.
General and CSCDQM Framework related utility routines.
CSC Level Histogram Type.
const CSCHistoDef & operator=(const CSCHistoDef &t)
Assignment (=) operator. Calls base assignment operator and assigns CSC-related data.
static const char PATH_DDU[]
static const char PATH_FED[]
static const std::string getPath(const HwId p_crateId, const HwId p_dmbId)
Static CSC path formatter.
static const unsigned int namesSize
const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
static const std::string getPath(const HwId p_fedId)
Static FED path formatter.
unsigned int HistoId
const HistoId getId() const
Get Histogram ID.
static const std::type_info & CSCHistoDefT
const bool operator==(const HistoDef &t) const
Comparison (==) operator.
EMU Level Histogram Definition.
static const std::type_info & ParHistoDefT
DDU Level Histogram Definition.
DDUHistoDef(const HistoId p_id, const HwId p_dduId)
Constructor. It calls Base constructor inline.
const HwId getFEDId() const
Get FED ID.
const std::string getName() const
Get processed histogram name. It can include additional parameter in formated name. This Name is being constructed from raw name and additional parameter.
ParHistoDef(const HistoId p_id)
Constructor. It calls Base constructor inline.
const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
const bool operator<(const HistoDef &t) const
Less (&lt;) operator.
virtual const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
ParHistoDef(const HistoName &p_name)
Constructor. It calls Base constructor inline.
EMUHistoDef(const HistoId p_id)
Constructor. It calls Base constructor inline.
virtual const HwId getDMBId() const
Get CSC DMB ID.
static const std::type_info & DDUHistoDefT
const HwId getDDUId() const
Get DDU ID.
const FEDHistoDef & operator=(const FEDHistoDef &t)
Assignment (=) operator. Calls base assignment operator and assigns FEd-related data.
const HistoDef & operator=(const HistoDef &t)
Assignment (=) operator.
FED Level Histogram Definition.
std::string HistoName
const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
static const std::string processName(const HistoName &p_name, const HwId p_id)
Process name by applying ID to d pattern (pattern is stored in REGEXP_ONDEMAND)
static const std::string getHistoKeyById(const HistoId &p_id)
Get Histogram key name by id.
const std::string getFullPath() const
Get full path of the histogram. It is being constructed by appending path and histogam name...
virtual const std::string getName() const
Get processed histogram name. It can include additional parameter in formated name. This Name is being constructed from raw name and additional parameter.
static const std::type_info & EMUHistoDefT
static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$")
HistoDef(const HistoId p_id)
Base constructor.
virtual const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
friend std::ostream & operator<<(std::ostream &out, const HistoDef &t)
Printing (&lt;&lt;) operator that prints hisotgram full path.
const HwId getCrateId() const
Get CSC Crate ID.
static const char PATH_CSC[]
static const HistoName keys[]
HistoName name
Parameter name.
virtual const HwId getFEDId() const
Get FED ID.
const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
const DDUHistoDef & operator=(const DDUHistoDef &t)
Assignment (=) operator. Calls base assignment operator and assigns DDU-related data.