File indexing completed on 2021-02-14 13:09:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef CSCDQM_HistoDef_H
0021 #define CSCDQM_HistoDef_H
0022
0023 #include <string>
0024 #include <iostream>
0025
0026 #include "CSCDQM_Utility.h"
0027 #include "CSCDQM_Logger.h"
0028
0029 namespace cscdqm {
0030
0031
0032 typedef std::string HistoName;
0033
0034
0035 typedef unsigned int HistoId;
0036
0037
0038 typedef unsigned int HwId;
0039
0040 namespace h {
0041
0042 const HistoName HISTO_SKIP = "0";
0043 }
0044
0045
0046 static const char PATH_FED[] = "FED_%03d";
0047
0048
0049 static const char PATH_DDU[] = "DDU_%02d";
0050
0051
0052 static const char PATH_CSC[] = "CSC_%03d_%02d";
0053
0054 static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$");
0055
0056 #include "CSCDQM_HistoNames.icc"
0057
0058
0059
0060
0061
0062 class HistoDef {
0063 private:
0064
0065 HistoId id;
0066
0067 public:
0068
0069
0070
0071
0072
0073 HistoDef(const HistoId p_id) : id(p_id) {}
0074
0075
0076
0077
0078 virtual ~HistoDef() {}
0079
0080
0081
0082
0083
0084 const HistoId getId() const { return id; }
0085
0086
0087
0088
0089
0090 const HistoName& getHistoName() const { return h::names[id]; }
0091
0092
0093
0094
0095
0096
0097
0098 virtual const std::string getName() const { return getHistoName(); }
0099
0100
0101
0102
0103
0104
0105 const std::string getFullPath() const {
0106 std::string path(getPath());
0107 if (!path.empty())
0108 path.append("/");
0109 path.append(getName());
0110 return path;
0111 }
0112
0113
0114
0115
0116
0117
0118 const bool operator==(const HistoDef& t) const {
0119 if (getId() != t.getId())
0120 return false;
0121 if (getFEDId() != t.getFEDId())
0122 return false;
0123 if (getDDUId() != t.getDDUId())
0124 return false;
0125 if (getCrateId() != t.getCrateId())
0126 return false;
0127 if (getDMBId() != t.getDMBId())
0128 return false;
0129 if (getAddId() != t.getAddId())
0130 return false;
0131 return true;
0132 }
0133
0134
0135
0136
0137
0138
0139 const HistoDef& operator=(const HistoDef& t) {
0140 id = t.getId();
0141 return *this;
0142 }
0143
0144
0145
0146
0147
0148
0149 const bool operator<(const HistoDef& t) const {
0150 if (getId() < t.getId())
0151 return true;
0152 if (getFEDId() < t.getFEDId())
0153 return true;
0154 if (getDDUId() < t.getDDUId())
0155 return true;
0156 if (getCrateId() < t.getCrateId())
0157 return true;
0158 if (getDMBId() < t.getDMBId())
0159 return true;
0160 if (getAddId() < t.getAddId())
0161 return true;
0162 return false;
0163 }
0164
0165
0166
0167
0168
0169
0170
0171 friend std::ostream& operator<<(std::ostream& out, const HistoDef& t) { return out << t.getFullPath(); }
0172
0173
0174
0175
0176
0177 virtual const std::string getPath() const { return ""; }
0178
0179
0180
0181
0182
0183 virtual const HwId getCrateId() const { return 0; }
0184
0185
0186
0187
0188
0189 virtual const HwId getDMBId() const { return 0; }
0190
0191
0192
0193
0194
0195
0196 virtual const HwId getAddId() const { return 0; }
0197
0198
0199
0200
0201
0202 virtual const HwId getFEDId() const { return 0; }
0203
0204
0205
0206
0207
0208 virtual const HwId getDDUId() const { return 0; }
0209
0210
0211
0212
0213
0214
0215 virtual const std::string processTitle(const std::string& p_title) const { return p_title; }
0216
0217
0218
0219
0220
0221
0222
0223 static const bool getHistoIdByName(const std::string& p_name, HistoId& p_id) {
0224 for (HistoId i = 0; i < h::namesSize; i++) {
0225 if (p_name == h::names[i]) {
0226 p_id = i;
0227 return true;
0228 }
0229 }
0230 return false;
0231 }
0232
0233
0234
0235
0236
0237
0238 static const std::string getHistoKeyById(const HistoId& p_id) { return h::keys[p_id]; }
0239
0240
0241
0242
0243
0244
0245
0246 static const std::string processName(const HistoName& p_name, const HwId p_id) {
0247 if (Utility::regexMatch(REGEXP_ONDEMAND, p_name)) {
0248 return Form(p_name.c_str(), p_id);
0249 }
0250 return p_name;
0251 }
0252 };
0253
0254
0255
0256
0257
0258 class EMUHistoDef : public HistoDef {
0259 public:
0260
0261
0262
0263
0264
0265 EMUHistoDef(const HistoId p_id) : HistoDef(p_id) {}
0266 };
0267
0268
0269
0270
0271
0272 class FEDHistoDef : public HistoDef {
0273 private:
0274 HwId fedId;
0275
0276 public:
0277
0278
0279
0280
0281
0282
0283 FEDHistoDef(const HistoId p_id, const HwId p_fedId) : HistoDef(p_id), fedId(p_fedId) {}
0284 const HwId getFEDId() const override { return fedId; }
0285 const std::string getPath() const override { return getPath(fedId); }
0286
0287
0288
0289
0290
0291
0292 static const std::string getPath(const HwId p_fedId) { return Form(PATH_FED, p_fedId); }
0293
0294
0295
0296
0297
0298
0299
0300 const FEDHistoDef& operator=(const FEDHistoDef& t) {
0301 HistoDef* h1 = const_cast<FEDHistoDef*>(this);
0302 const HistoDef* h2 = &t;
0303 *h1 = *h2;
0304 fedId = t.getFEDId();
0305 return *this;
0306 }
0307
0308 const std::string processTitle(const std::string& p_title) const override {
0309 return processName(p_title, getFEDId());
0310 }
0311 };
0312
0313
0314
0315
0316
0317 class DDUHistoDef : public HistoDef {
0318 private:
0319 HwId dduId;
0320
0321 public:
0322
0323
0324
0325
0326
0327
0328 DDUHistoDef(const HistoId p_id, const HwId p_dduId) : HistoDef(p_id), dduId(p_dduId) {}
0329 const HwId getDDUId() const override { return dduId; }
0330 const std::string getPath() const override { return getPath(dduId); }
0331
0332
0333
0334
0335
0336
0337 static const std::string getPath(const HwId p_dduId) { return Form(PATH_DDU, p_dduId); }
0338
0339
0340
0341
0342
0343
0344
0345 const DDUHistoDef& operator=(const DDUHistoDef& t) {
0346 HistoDef* h1 = const_cast<DDUHistoDef*>(this);
0347 const HistoDef* h2 = &t;
0348 *h1 = *h2;
0349 dduId = t.getDDUId();
0350 return *this;
0351 }
0352
0353 const std::string processTitle(const std::string& p_title) const override {
0354 return processName(p_title, getDDUId());
0355 }
0356 };
0357
0358
0359
0360
0361
0362 class CSCHistoDef : public HistoDef {
0363 private:
0364
0365 HwId crateId;
0366
0367 HwId dmbId;
0368
0369 HwId addId;
0370
0371 public:
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381 CSCHistoDef(const HistoId p_id, const HwId p_crateId, const HwId p_dmbId, const HwId p_addId = 0)
0382 : HistoDef(p_id), crateId(p_crateId), dmbId(p_dmbId), addId(p_addId) {}
0383
0384 const HwId getCrateId() const override { return crateId; }
0385 const HwId getDMBId() const override { return dmbId; }
0386 const HwId getAddId() const override { return addId; }
0387 const std::string getName() const override { return processName(getHistoName(), getAddId()); }
0388 const std::string getPath() const override { return getPath(crateId, dmbId); }
0389
0390
0391
0392
0393
0394
0395
0396 static const std::string getPath(const HwId p_crateId, const HwId p_dmbId) {
0397 return Form(PATH_CSC, p_crateId, p_dmbId);
0398 }
0399
0400
0401
0402
0403
0404
0405
0406 const CSCHistoDef& operator=(const CSCHistoDef& t) {
0407 HistoDef* h1 = const_cast<CSCHistoDef*>(this);
0408 const HistoDef* h2 = &t;
0409 *h1 = *h2;
0410 crateId = t.getCrateId();
0411 dmbId = t.getDMBId();
0412 addId = t.getAddId();
0413 return *this;
0414 }
0415
0416 const std::string processTitle(const std::string& p_title) const override {
0417 return processName(p_title, getAddId());
0418 }
0419 };
0420
0421
0422
0423
0424
0425 class ParHistoDef : public HistoDef {
0426 private:
0427
0428
0429
0430 HistoName name;
0431
0432 public:
0433
0434
0435
0436
0437
0438 ParHistoDef(const HistoName& p_name) : HistoDef(Utility::fastHash(p_name.c_str())), name(p_name) {}
0439
0440
0441
0442
0443
0444
0445 ParHistoDef(const HistoId p_id) : HistoDef(p_id) { name = HistoDef::getHistoName(); }
0446
0447 const HistoName& getHistoName() const { return name; }
0448 };
0449
0450 static const std::type_info& EMUHistoDefT = typeid(cscdqm::EMUHistoDef);
0451 static const std::type_info& FEDHistoDefT = typeid(cscdqm::FEDHistoDef);
0452 static const std::type_info& DDUHistoDefT = typeid(cscdqm::DDUHistoDef);
0453 static const std::type_info& CSCHistoDefT = typeid(cscdqm::CSCHistoDef);
0454 static const std::type_info& ParHistoDefT = typeid(cscdqm::ParHistoDef);
0455
0456 }
0457
0458 #endif