CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  } // 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  virtual ~HistoDef() {}
79 
84  const HistoId getId() const { return id; }
85 
90  const HistoName& getHistoName() const { return h::names[id]; }
91 
98  virtual const std::string getName() const { return getHistoName(); }
99 
105  const std::string getFullPath() const {
107  if (!path.empty())
108  path.append("/");
109  path.append(getName());
110  return path;
111  }
112 
118  const bool operator==(const HistoDef& t) const {
119  if (getId() != t.getId())
120  return false;
121  if (getFEDId() != t.getFEDId())
122  return false;
123  if (getDDUId() != t.getDDUId())
124  return false;
125  if (getCrateId() != t.getCrateId())
126  return false;
127  if (getDMBId() != t.getDMBId())
128  return false;
129  if (getAddId() != t.getAddId())
130  return false;
131  return true;
132  }
133 
139  const HistoDef& operator=(const HistoDef& t) {
140  id = t.getId();
141  return *this;
142  }
143 
149  const bool operator<(const HistoDef& t) const {
150  if (getId() < t.getId())
151  return true;
152  if (getFEDId() < t.getFEDId())
153  return true;
154  if (getDDUId() < t.getDDUId())
155  return true;
156  if (getCrateId() < t.getCrateId())
157  return true;
158  if (getDMBId() < t.getDMBId())
159  return true;
160  if (getAddId() < t.getAddId())
161  return true;
162  return false;
163  }
164 
171  friend std::ostream& operator<<(std::ostream& out, const HistoDef& t) { return out << t.getFullPath(); }
172 
177  virtual const std::string getPath() const { return ""; }
178 
183  virtual const HwId getCrateId() const { return 0; }
184 
189  virtual const HwId getDMBId() const { return 0; }
190 
196  virtual const HwId getAddId() const { return 0; }
197 
202  virtual const HwId getFEDId() const { return 0; }
203 
208  virtual const HwId getDDUId() const { return 0; }
209 
215  virtual const std::string processTitle(const std::string& p_title) const { return p_title; }
216 
223  static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
224  for (HistoId i = 0; i < h::namesSize; i++) {
225  if (p_name == h::names[i]) {
226  p_id = i;
227  return true;
228  }
229  }
230  return false;
231  }
232 
238  static const std::string getHistoKeyById(const HistoId& p_id) { return h::keys[p_id]; }
239 
246  static const std::string processName(const HistoName& p_name, const HwId p_id) {
247  if (Utility::regexMatch(REGEXP_ONDEMAND, p_name)) {
248  return Form(p_name.c_str(), p_id);
249  }
250  return p_name;
251  }
252  };
253 
258  class EMUHistoDef : public HistoDef {
259  public:
265  EMUHistoDef(const HistoId p_id) : HistoDef(p_id) {}
266  };
267 
272  class FEDHistoDef : public HistoDef {
273  private:
275 
276  public:
283  FEDHistoDef(const HistoId p_id, const HwId p_fedId) : HistoDef(p_id), fedId(p_fedId) {}
284  const HwId getFEDId() const override { return fedId; }
285  const std::string getPath() const override { return getPath(fedId); }
286 
292  static const std::string getPath(const HwId p_fedId) { return Form(PATH_FED, p_fedId); }
293 
301  HistoDef* h1 = const_cast<FEDHistoDef*>(this);
302  const HistoDef* h2 = &t;
303  *h1 = *h2;
304  fedId = t.getFEDId();
305  return *this;
306  }
307 
308  const std::string processTitle(const std::string& p_title) const override {
309  return processName(p_title, getFEDId());
310  }
311  };
312 
317  class DDUHistoDef : public HistoDef {
318  private:
320 
321  public:
328  DDUHistoDef(const HistoId p_id, const HwId p_dduId) : HistoDef(p_id), dduId(p_dduId) {}
329  const HwId getDDUId() const override { return dduId; }
330  const std::string getPath() const override { return getPath(dduId); }
331 
337  static const std::string getPath(const HwId p_dduId) { return Form(PATH_DDU, p_dduId); }
338 
346  HistoDef* h1 = const_cast<DDUHistoDef*>(this);
347  const HistoDef* h2 = &t;
348  *h1 = *h2;
349  dduId = t.getDDUId();
350  return *this;
351  }
352 
353  const std::string processTitle(const std::string& p_title) const override {
354  return processName(p_title, getDDUId());
355  }
356  };
357 
362  class CSCHistoDef : public HistoDef {
363  private:
370 
371  public:
381  CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId = 0)
382  : HistoDef(p_id), crateId(p_crateId), dmbId(p_dmbId), addId(p_addId) {}
383 
384  const HwId getCrateId() const override { return crateId; }
385  const HwId getDMBId() const override { return dmbId; }
386  const HwId getAddId() const override { return addId; }
387  const std::string getName() const override { return processName(getHistoName(), getAddId()); }
388  const std::string getPath() const override { return getPath(crateId, dmbId); }
389 
396  static const std::string getPath(const HwId p_crateId, const HwId p_dmbId) {
397  return Form(PATH_CSC, p_crateId, p_dmbId);
398  }
399 
407  HistoDef* h1 = const_cast<CSCHistoDef*>(this);
408  const HistoDef* h2 = &t;
409  *h1 = *h2;
410  crateId = t.getCrateId();
411  dmbId = t.getDMBId();
412  addId = t.getAddId();
413  return *this;
414  }
415 
416  const std::string processTitle(const std::string& p_title) const override {
417  return processName(p_title, getAddId());
418  }
419  };
420 
425  class ParHistoDef : public HistoDef {
426  private:
431 
432  public:
438  ParHistoDef(const HistoName& p_name) : HistoDef(Utility::fastHash(p_name.c_str())), name(p_name) {}
439 
446 
447  const HistoName& getHistoName() const { return name; }
448  };
449 
450  static const std::type_info& EMUHistoDefT = typeid(cscdqm::EMUHistoDef);
451  static const std::type_info& FEDHistoDefT = typeid(cscdqm::FEDHistoDef);
452  static const std::type_info& DDUHistoDefT = typeid(cscdqm::DDUHistoDef);
453  static const std::type_info& CSCHistoDefT = typeid(cscdqm::CSCHistoDef);
454  static const std::type_info& ParHistoDefT = typeid(cscdqm::ParHistoDef);
455 
456 } // namespace cscdqm
457 
458 #endif
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
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 std::string getPath() const override
Get path part of the histogram (used only for DDUs and CSCs)
virtual const HwId getCrateId() const
Get CSC Crate ID.
const HistoName HISTO_SKIP
static const HistoName names[]
virtual const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
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 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 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[]
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.
unsigned int HistoId
const HistoId getId() const
Get Histogram 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
const bool operator==(const HistoDef &t) const
Comparison (==) operator.
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.
ParHistoDef(const HistoId p_id)
Constructor. It calls Base constructor inline.
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.
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
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...
const HwId getDDUId() const override
Get DDU ID.
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
const HwId getCrateId() const override
Get CSC Crate ID.
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.
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 (&lt;&lt;) operator that prints hisotgram full path.
static const char PATH_CSC[]
static const HistoName keys[]
HistoName name
Parameter name.
virtual const HwId getFEDId() const
Get FED ID.
const DDUHistoDef & operator=(const DDUHistoDef &t)
Assignment (=) operator. Calls base assignment operator and assigns DDU-related data.