CMS 3D CMS Logo

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  } // namespace h
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.icc"
57 
62  class HistoDef {
63  private:
66 
67  public:
73  HistoDef(const HistoId p_id) : id(p_id) {}
74 
78  HistoDef(const HistoDef&) = default;
79 
83  virtual ~HistoDef() {}
84 
89  const HistoId getId() const { return id; }
90 
95  const HistoName& getHistoName() const { return h::names[id]; }
96 
103  virtual const std::string getName() const { return getHistoName(); }
104 
110  const std::string getFullPath() const {
112  if (!path.empty())
113  path.append("/");
114  path.append(getName());
115  return path;
116  }
117 
123  const bool operator==(const HistoDef& t) const {
124  if (getId() != t.getId())
125  return false;
126  if (getFEDId() != t.getFEDId())
127  return false;
128  if (getDDUId() != t.getDDUId())
129  return false;
130  if (getCrateId() != t.getCrateId())
131  return false;
132  if (getDMBId() != t.getDMBId())
133  return false;
134  if (getAddId() != t.getAddId())
135  return false;
136  return true;
137  }
138 
144  const HistoDef& operator=(const HistoDef& t) {
145  id = t.getId();
146  return *this;
147  }
148 
154  const bool operator<(const HistoDef& t) const {
155  if (getId() < t.getId())
156  return true;
157  if (getFEDId() < t.getFEDId())
158  return true;
159  if (getDDUId() < t.getDDUId())
160  return true;
161  if (getCrateId() < t.getCrateId())
162  return true;
163  if (getDMBId() < t.getDMBId())
164  return true;
165  if (getAddId() < t.getAddId())
166  return true;
167  return false;
168  }
169 
176  friend std::ostream& operator<<(std::ostream& out, const HistoDef& t) { return out << t.getFullPath(); }
177 
182  virtual const std::string getPath() const { return ""; }
183 
188  virtual const HwId getCrateId() const { return 0; }
189 
194  virtual const HwId getDMBId() const { return 0; }
195 
201  virtual const HwId getAddId() const { return 0; }
202 
207  virtual const HwId getFEDId() const { return 0; }
208 
213  virtual const HwId getDDUId() const { return 0; }
214 
220  virtual const std::string processTitle(const std::string& p_title) const { return p_title; }
221 
228  static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
229  for (HistoId i = 0; i < h::namesSize; i++) {
230  if (p_name == h::names[i]) {
231  p_id = i;
232  return true;
233  }
234  }
235  return false;
236  }
237 
243  static const std::string getHistoKeyById(const HistoId& p_id) { return h::keys[p_id]; }
244 
251  static const std::string processName(const HistoName& p_name, const HwId p_id) {
252  if (Utility::regexMatch(REGEXP_ONDEMAND, p_name)) {
253  return Form(p_name.c_str(), p_id);
254  }
255  return p_name;
256  }
257  };
258 
263  class EMUHistoDef : public HistoDef {
264  public:
270  EMUHistoDef(const HistoId p_id) : HistoDef(p_id) {}
271  };
272 
277  class FEDHistoDef : public HistoDef {
278  private:
280 
281  public:
288  FEDHistoDef(const HistoId p_id, const HwId p_fedId) : HistoDef(p_id), fedId(p_fedId) {}
289  const HwId getFEDId() const override { return fedId; }
290  const std::string getPath() const override { return getPath(fedId); }
291 
297  static const std::string getPath(const HwId p_fedId) { return Form(PATH_FED, p_fedId); }
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 override {
314  return processName(p_title, getFEDId());
315  }
316  };
317 
322  class DDUHistoDef : public HistoDef {
323  private:
325 
326  public:
333  DDUHistoDef(const HistoId p_id, const HwId p_dduId) : HistoDef(p_id), dduId(p_dduId) {}
334  const HwId getDDUId() const override { return dduId; }
335  const std::string getPath() const override { return getPath(dduId); }
336 
342  static const std::string getPath(const HwId p_dduId) { return Form(PATH_DDU, p_dduId); }
343 
351  HistoDef* h1 = const_cast<DDUHistoDef*>(this);
352  const HistoDef* h2 = &t;
353  *h1 = *h2;
354  dduId = t.getDDUId();
355  return *this;
356  }
357 
358  const std::string processTitle(const std::string& p_title) const override {
359  return processName(p_title, getDDUId());
360  }
361  };
362 
367  class CSCHistoDef : public HistoDef {
368  private:
375 
376  public:
386  CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId = 0)
387  : HistoDef(p_id), crateId(p_crateId), dmbId(p_dmbId), addId(p_addId) {}
388 
389  const HwId getCrateId() const override { return crateId; }
390  const HwId getDMBId() const override { return dmbId; }
391  const HwId getAddId() const override { return addId; }
392  const std::string getName() const override { return processName(getHistoName(), getAddId()); }
393  const std::string getPath() const override { return getPath(crateId, dmbId); }
394 
401  static const std::string getPath(const HwId p_crateId, const HwId p_dmbId) {
402  return Form(PATH_CSC, p_crateId, p_dmbId);
403  }
404 
412  HistoDef* h1 = const_cast<CSCHistoDef*>(this);
413  const HistoDef* h2 = &t;
414  *h1 = *h2;
415  crateId = t.getCrateId();
416  dmbId = t.getDMBId();
417  addId = t.getAddId();
418  return *this;
419  }
420 
421  const std::string processTitle(const std::string& p_title) const override {
422  return processName(p_title, getAddId());
423  }
424  };
425 
430  class ParHistoDef : public HistoDef {
431  private:
436 
437  public:
443  ParHistoDef(const HistoName& p_name) : HistoDef(Utility::fastHash(p_name.c_str())), name(p_name) {}
444 
451 
452  const HistoName& getHistoName() const { return name; }
453  };
454 
455  static const std::type_info& EMUHistoDefT = typeid(cscdqm::EMUHistoDef);
456  static const std::type_info& FEDHistoDefT = typeid(cscdqm::FEDHistoDef);
457  static const std::type_info& DDUHistoDefT = typeid(cscdqm::DDUHistoDef);
458  static const std::type_info& CSCHistoDefT = typeid(cscdqm::CSCHistoDef);
459  static const std::type_info& ParHistoDefT = typeid(cscdqm::ParHistoDef);
460 
461 } // namespace cscdqm
462 
463 #endif
virtual const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
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
virtual const HwId getFEDId() const
Get FED ID.
FEDHistoDef(const HistoId p_id, const HwId p_fedId)
Constructor. It calls Base constructor inline.
const std::string getPath() const override
Get path part of the histogram (used only for DDUs and CSCs)
const HistoName HISTO_SKIP
static const HistoName names[]
const HwId getDMBId() const override
Get CSC DMB ID.
virtual ~HistoDef()
Base virtual destructor.
static const std::string getPath(const HwId p_dduId)
Static DDU path formatter.
Abstract Base Histogram Definition.
const HwId getFEDId() const override
Get FED ID.
Parameter Histogram Definition.
const std::string processTitle(const std::string &p_title) const override
Process Title by Adding appropriate ID.
virtual const HwId getDMBId() const
Get CSC DMB 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 std::string processTitle(const std::string &p_title) const override
Process Title by Adding appropriate ID.
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[]
const HistoId getId() const
Get Histogram ID.
virtual const HwId getCrateId() const
Get CSC Crate ID.
static const std::string getPath(const HwId p_crateId, const HwId p_dmbId)
Static CSC path formatter.
static const unsigned int namesSize
static const std::string getPath(const HwId p_fedId)
Static FED path formatter.
const bool operator<(const HistoDef &t) const
Less (<) operator.
unsigned int HistoId
virtual const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
const std::string getPath() const override
Get path part of the histogram (used only for DDUs and CSCs)
static const std::type_info & CSCHistoDefT
EMU Level Histogram Definition.
const std::string getName() const override
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 & ParHistoDefT
DDU Level Histogram Definition.
DDUHistoDef(const HistoId p_id, const HwId p_dduId)
Constructor. It calls Base constructor inline.
const std::string getPath() const override
Get path part of the histogram (used only for DDUs and CSCs)
const std::string processTitle(const std::string &p_title) const override
Process Title by Adding appropriate ID.
const bool operator==(const HistoDef &t) const
Comparison (==) operator.
virtual const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
ParHistoDef(const HistoId p_id)
Constructor. It calls Base constructor inline.
ParHistoDef(const HistoName &p_name)
Constructor. It calls Base constructor inline.
const HistoName & getHistoName() const
Get raw histogram name.
EMUHistoDef(const HistoId p_id)
Constructor. It calls Base constructor inline.
const HwId getAddId() const override
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
static const std::type_info & DDUHistoDefT
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 getFullPath() const
Get full path of the histogram. It is being constructed by appending path and histogam name...
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.
virtual const HwId getDDUId() const
Get DDU ID.
const HwId getDDUId() const override
Get DDU ID.
static const std::type_info & EMUHistoDefT
const HwId getCrateId() const override
Get CSC Crate ID.
static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$")
HistoDef(const HistoId p_id)
Base constructor.
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.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
friend std::ostream & operator<<(std::ostream &out, const HistoDef &t)
Printing (<<) operator that prints hisotgram full path.
const HistoName & getHistoName() const
static const char PATH_CSC[]
static const HistoName keys[]
HistoName name
Parameter name.
const DDUHistoDef & operator=(const DDUHistoDef &t)
Assignment (=) operator. Calls base assignment operator and assigns DDU-related data.