CMS 3D CMS Logo

ElectronicsQuantity.h
Go to the documentation of this file.
1 #ifndef ElectronicsQuantity_h
2 #define ElectronicsQuantity_h
3 
10 #include "boost/unordered_map.hpp"
11 
12 namespace hcaldqm {
13  namespace quantity {
15  fFED = 0,
16  fFEDuTCA = 1,
17  fFEDVME = 2,
18  fCrate = 3,
20  fCrateVME = 5,
21  fSlotuTCA = 6,
22  fSlotVME = 7,
23  fSpigot = 8,
25  fFiberVME = 10,
26  fFiberCh = 11,
27 
28  // Complex Quantities
33 
34  // Adding Trigger Quantities for VME
35  fSLB = 16,
36  fSLBCh = 17,
37  fSLBSLBCh = 18,
38 
39  // Adding Trigger Quantities for uTCA
43 
45  };
46 
47  int getValue_FED(HcalElectronicsId const &);
50  int getValue_Crate(HcalElectronicsId const &);
63  int getValue_SLB(HcalElectronicsId const &);
64  int getValue_SLBCh(HcalElectronicsId const &);
69  uint32_t getBin_FED(HcalElectronicsId const &);
70  uint32_t getBin_FEDuTCA(HcalElectronicsId const &);
71  uint32_t getBin_FEDVME(HcalElectronicsId const &);
72  uint32_t getBin_Crate(HcalElectronicsId const &);
73  uint32_t getBin_CrateuTCA(HcalElectronicsId const &);
74  uint32_t getBin_CrateVME(HcalElectronicsId const &);
75  uint32_t getBin_SlotuTCA(HcalElectronicsId const &);
76  uint32_t getBin_SlotVME(HcalElectronicsId const &);
77  uint32_t getBin_Spigot(HcalElectronicsId const &);
78  uint32_t getBin_FiberuTCA(HcalElectronicsId const &);
79  uint32_t getBin_FiberVME(HcalElectronicsId const &);
80  uint32_t getBin_FiberCh(HcalElectronicsId const &);
81  uint32_t getBin_FEDuTCASlot(HcalElectronicsId const &);
82  uint32_t getBin_FEDVMESpigot(HcalElectronicsId const &);
84  uint32_t getBin_FiberVMEFiberCh(HcalElectronicsId const &);
85  uint32_t getBin_SLB(HcalElectronicsId const &);
86  uint32_t getBin_SLBCh(HcalElectronicsId const &);
87  uint32_t getBin_SLBSLBCh(HcalElectronicsId const &);
88  uint32_t getBin_FiberuTCATP(HcalElectronicsId const &);
89  uint32_t getBin_FiberChuTCATP(HcalElectronicsId const &);
113  std::vector<std::string> getLabels_FED();
114  std::vector<std::string> getLabels_FEDuTCA();
115  std::vector<std::string> getLabels_FEDVME();
116  std::vector<std::string> getLabels_Crate();
117  std::vector<std::string> getLabels_CrateuTCA();
118  std::vector<std::string> getLabels_CrateVME();
119  std::vector<std::string> getLabels_SlotuTCA();
120  std::vector<std::string> getLabels_SlotVME();
121  std::vector<std::string> getLabels_Spigot();
122  std::vector<std::string> getLabels_FiberuTCA();
123  std::vector<std::string> getLabels_FiberVME();
124  std::vector<std::string> getLabels_FiberCh();
125  std::vector<std::string> getLabels_FEDuTCASlot();
126  std::vector<std::string> getLabels_FEDVMESpigot();
127  std::vector<std::string> getLabels_FiberuTCAFiberCh();
128  std::vector<std::string> getLabels_FiberVMEFiberCh();
129  std::vector<std::string> getLabels_SLB();
130  std::vector<std::string> getLabels_SLBCh();
131  std::vector<std::string> getLabels_SLBSLBCh();
132  std::vector<std::string> getLabels_FiberuTCATP();
133  std::vector<std::string> getLabels_FiberChuTCATP();
134  std::vector<std::string> getLabels_FiberuTCATPFiberChuTCATP();
135 
137  typedef uint32_t (*getBinType_eid)(HcalElectronicsId const &);
139  typedef std::vector<std::string> (*getLabels_eid)();
140  const std::map<ElectronicsQuantityType, getValueType_eid> getValue_functions_eid = {
141  {fFED, getValue_FED},
157  {fSLB, getValue_SLB},
163  };
164  const std::map<ElectronicsQuantityType, getBinType_eid> getBin_functions_eid = {
165  {fFED, getBin_FED},
168  {fCrate, getBin_Crate},
181  {fSLB, getBin_SLB},
182  {fSLBCh, getBin_SLBCh},
187  };
188  const std::map<ElectronicsQuantityType, getEid_eid> getEid_functions_eid = {
189  {fFED, getEid_FED},
192  {fCrate, getEid_Crate},
205  {fSLB, getEid_SLB},
206  {fSLBCh, getEid_SLBCh},
211  };
212  const std::map<ElectronicsQuantityType, getLabels_eid> getLabels_functions_eid = {
213  {fFED, getLabels_FED},
229  {fSLB, getLabels_SLB},
235  };
236  const std::map<ElectronicsQuantityType, std::string> name_eid = {
237  {fFED, "FED"},
238  {fFEDuTCA, "FEDuTCA"},
239  {fFEDVME, "FEDVME"},
240  {fCrate, "Crate"},
241  {fCrateuTCA, "CrateuTCA"},
242  {fCrateVME, "CrateVME"},
243  {fSlotuTCA, "SlotuTCA"},
244  {fSlotVME, "SlotVME"},
245  {fSpigot, "Spigot"},
246  {fFiberuTCA, "FiberuTCA"},
247  {fFiberVME, "FiberVME"},
248  {fFiberCh, "FiberCh"},
249  {fFEDuTCASlot, "FEDuTCASlot"},
250  {fFEDVMESpigot, "FEDVMESpigot"},
251  {fFiberuTCAFiberCh, "FiberuTCAFiberCh"},
252  {fFiberVMEFiberCh, "FiberVMEFiberCh"},
253  {fSLB, "SLB"},
254  {fSLBCh, "SLBCh"},
255  {fSLBSLBCh, "SLB-SLBCh"},
256  {fFiberuTCATP, "TPFiber"},
257  {fFiberChuTCATP, "TPFiberCh"},
258  {fFiberuTCATPFiberChuTCATP, "TPF-TPFCh"},
259  };
260  const std::map<ElectronicsQuantityType, double> min_eid = {
261  {fFED, -0.5},
262  {fFEDuTCA, -0.5},
263  {fFEDVME, -0.5},
264  {fCrate, -0.5},
265  {fCrateuTCA, -0.5},
266  {fCrateVME, -0.5},
267  {fSlotuTCA, 0.},
268  {fSlotVME, 0.},
269  {fSpigot, 0.},
270  {fFiberuTCA, 0.},
271  {fFiberVME, 0.},
272  {fFiberCh, 0.},
273  {fFEDuTCASlot, 0.},
274  {fFEDVMESpigot, 0.},
275  {fFiberuTCAFiberCh, 0.},
276  {fFiberVMEFiberCh, 0.},
277  {fSLB, 0.},
278  {fSLBCh, 0.},
279  {fSLBSLBCh, 0.},
280  {fFiberuTCATP, 0.},
281  {fFiberChuTCATP, 0.},
283  };
284  const std::map<ElectronicsQuantityType, double> max_eid = {
285  {fFED, constants::fedList.size() - 0.5},
286  {fFEDuTCA, constants::fedListuTCA.size() - 0.5},
287  {fFEDVME, constants::fedListVME.size() - 0.5},
288  {fCrate, constants::crateList.size() - 0.5},
289  {fCrateuTCA, constants::crateListuTCA.size() - 0.5},
290  {fCrateVME, constants::crateListVME.size() - 0.5},
297  {fFEDuTCASlot, constants::FED_uTCA_NUM *constants::SLOT_uTCA_NUM},
298  {fFEDVMESpigot, constants::FED_VME_NUM *constants::SPIGOT_NUM},
299  {fFiberuTCAFiberCh, constants::FIBER_uTCA_NUM *constants::FIBERCH_NUM},
300  {fFiberVMEFiberCh, constants::FIBER_VME_NUM *constants::FIBERCH_NUM},
303  {fSLBSLBCh, constants::SLB_NUM *constants::SLBCH_NUM},
306  {fFiberuTCATPFiberChuTCATP, constants::TPFIBER_NUM *constants::TPFIBERCH_NUM},
307  };
308  const std::map<ElectronicsQuantityType, double> nbins_eid = {
309  {fFED, constants::fedList.size()},
311  {fFEDVME, constants::fedListVME.size()},
312  {fCrate, constants::crateList.size()},
321  {fFEDuTCASlot, constants::FED_uTCA_NUM *constants::SLOT_uTCA_NUM},
322  {fFEDVMESpigot, constants::FED_VME_NUM *constants::SPIGOT_NUM},
323  {fFiberuTCAFiberCh, constants::FIBER_uTCA_NUM *constants::FIBERCH_NUM},
324  {fFiberVMEFiberCh, constants::FIBER_VME_NUM *constants::FIBERCH_NUM},
327  {fSLBSLBCh, constants::SLB_NUM *constants::SLBCH_NUM},
330  {fFiberuTCATPFiberChuTCATP, constants::TPFIBER_NUM *constants::TPFIBERCH_NUM},
331  };
332 
333  class ElectronicsQuantity : public Quantity {
334  public:
337  : Quantity(name_eid.at(type), isLog), _type(type) {}
338  ~ElectronicsQuantity() override {}
340 
341  int getValue(HcalElectronicsId const &eid) override { return getValue_functions_eid.at(_type)(eid); }
342  uint32_t getBin(HcalElectronicsId const &eid) override { return getBin_functions_eid.at(_type)(eid); }
343 
344  QuantityType type() override { return fElectronicsQuantity; }
345  int nbins() override { return nbins_eid.at(_type); }
346  double min() override { return min_eid.at(_type); }
347  double max() override { return max_eid.at(_type); }
348  bool isCoordinate() override { return true; }
349  std::vector<std::string> getLabels() override { return getLabels_functions_eid.at(_type)(); }
350 
351  protected:
353  };
354 
355  // sorted list of FEDs you want to have on the axis
357  public:
359  FEDQuantity(std::vector<int> const &vFEDs) : ElectronicsQuantity(fFED, false) { this->setup(vFEDs); }
360  ~FEDQuantity() override {}
361 
362  virtual void setup(std::vector<int> const &vFEDs);
363  int getValue(HcalElectronicsId const &) override;
364  uint32_t getBin(HcalElectronicsId const &) override;
365 
366  int nbins() override { return _feds.size(); }
367  double min() override { return 0; }
368  double max() override { return _feds.size(); }
369  std::vector<std::string> getLabels() override;
370 
371  protected:
372  typedef boost::unordered_map<int, uint32_t> FEDMap;
373  FEDMap _feds;
374 
375  public:
376  FEDQuantity *makeCopy() override {
377  std::vector<int> vfeds;
378  for (auto const &p : _feds) {
379  vfeds.push_back(p.first);
380  }
381 
382  // MUST SORT BEFORE EXITING!
383  std::sort(vfeds.begin(), vfeds.end());
384  return new FEDQuantity(vfeds);
385  }
386  };
387 
388  // Crate quantity, initialized from emap (because it is not easy to turn a VME
389  // crate in an EID)
391  typedef std::map<int, uint32_t> CrateHashMap;
392 
393  public:
396  CrateQuantity(std::vector<int> crates, CrateHashMap crateHashes) : ElectronicsQuantity(fCrate, false) {
397  this->setup(crates, crateHashes);
398  }
399  ~CrateQuantity() override {}
400 
401  virtual void setup(HcalElectronicsMap const *emap);
402  virtual void setup(std::vector<int> crates, CrateHashMap crateHashes);
403  int getValue(HcalElectronicsId const &) override;
404  uint32_t getBin(HcalElectronicsId const &) override;
405 
406  int nbins() override { return _crates.size(); }
407  double min() override { return 0; }
408  double max() override { return _crates.size(); }
409  std::vector<std::string> getLabels() override;
410 
411  protected:
412  std::vector<int> _crates;
413  CrateHashMap _crateHashes;
414 
415  public:
416  CrateQuantity *makeCopy() override {
417  // Make copies of the crate info
418  std::vector<int> tmpCrates;
419  std::map<int, uint32_t> tmpCrateHashes;
420  for (auto &it_crate : _crates) {
421  tmpCrates.push_back(it_crate);
422  tmpCrateHashes[it_crate] = _crateHashes[it_crate];
423  }
424  return new CrateQuantity(tmpCrates, tmpCrateHashes);
425  }
426  };
427  } // namespace quantity
428 } // namespace hcaldqm
429 
430 #endif
std::vector< std::string > getLabels_Crate()
std::vector< std::string > getLabels_Spigot()
type
Definition: HCALResponse.h:21
CrateQuantity(HcalElectronicsMap const *emap)
std::vector< unsigned int > const fedListVME
Definition: Constants.h:61
const std::map< ElectronicsQuantityType, getValueType_eid > getValue_functions_eid
HcalElectronicsId getEid_FEDuTCASlot(int)
std::vector< unsigned int > const crateListuTCA
Definition: Constants.h:63
uint32_t getBin_SlotuTCA(HcalElectronicsId const &)
HcalElectronicsId getEid_SLB(int)
uint32_t getBin_SLBSLBCh(HcalElectronicsId const &)
HcalElectronicsId getEid_FiberuTCAFiberCh(int)
int const TPFIBER_NUM
Definition: Constants.h:133
std::vector< std::string > getLabels_FED()
int const FIBERCH_NUM
Definition: Constants.h:124
int getValue_FiberChuTCATP(HcalElectronicsId const &)
int getValue_FED(HcalElectronicsId const &)
uint32_t getBin_CrateuTCA(HcalElectronicsId const &)
int getValue_SLBSLBCh(HcalElectronicsId const &)
int getValue_SlotVME(HcalElectronicsId const &)
int getValue_Spigot(HcalElectronicsId const &)
HcalElectronicsId getEid_FiberuTCA(int)
std::vector< std::string > getLabels_SlotVME()
uint32_t getBin_FiberuTCAFiberCh(HcalElectronicsId const &)
ElectronicsQuantity * makeCopy() override
const std::map< ElectronicsQuantityType, getEid_eid > getEid_functions_eid
std::vector< std::string > getLabels_FiberChuTCATP()
uint32_t getBin_FiberVMEFiberCh(HcalElectronicsId const &)
int getValue_FiberuTCATP(HcalElectronicsId const &)
HcalElectronicsId getEid_SlotVME(int)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
uint32_t getBin_FEDVME(HcalElectronicsId const &)
uint32_t getBin_FiberuTCATP(HcalElectronicsId const &)
std::vector< unsigned int > const fedListuTCA
Definition: Constants.h:58
uint32_t getBin_FiberChuTCATP(HcalElectronicsId const &)
uint32_t getBin(HcalElectronicsId const &eid) override
std::vector< std::string > getLabels_FiberVMEFiberCh()
int getValue_FiberVME(HcalElectronicsId const &)
std::vector< std::string > getLabels() override
uint32_t getBin_FEDuTCASlot(HcalElectronicsId const &)
HcalElectronicsId getEid_CrateVME(int)
std::vector< std::string > getLabels_FiberuTCATPFiberChuTCATP()
std::vector< std::string > getLabels_SLB()
int const SLOT_VME_NUM
Definition: Constants.h:106
FEDQuantity * makeCopy() override
std::vector< std::string > getLabels_FEDuTCA()
const std::map< ElectronicsQuantityType, double > nbins_eid
HcalElectronicsId getEid_SLBCh(int)
HcalElectronicsId getEid_SlotuTCA(int)
FEDQuantity(std::vector< int > const &vFEDs)
HcalElectronicsId getEid_Spigot(int)
int getValue_SLBCh(HcalElectronicsId const &)
std::vector< std::string > getLabels_FEDVME()
HcalElectronicsId getEid_FiberVME(int)
int getValue_FiberCh(HcalElectronicsId const &)
ElectronicsQuantity(ElectronicsQuantityType type, bool isLog=false)
uint32_t getBin_SLB(HcalElectronicsId const &)
int(* getValueType_eid)(HcalElectronicsId const &)
const std::map< ElectronicsQuantityType, double > min_eid
HcalElectronicsId getEid_FiberuTCATPFiberChuTCATP(int)
HcalElectronicsId getEid_FEDuTCA(int)
std::vector< std::string > getLabels_CrateuTCA()
uint32_t getBin_FiberVME(HcalElectronicsId const &)
int getValue_Crate(HcalElectronicsId const &)
std::vector< std::string > getLabels_SlotuTCA()
int getValue_CrateuTCA(HcalElectronicsId const &)
int getValue_FEDVME(HcalElectronicsId const &)
std::vector< std::string > getLabels_FiberuTCATP()
std::vector< unsigned int > const fedList
Definition: Constants.h:55
HcalElectronicsId getEid_FEDVMESpigot(int)
uint32_t getBin_FED(HcalElectronicsId const &)
int const SLB_NUM
Definition: Constants.h:129
HcalElectronicsId getEid_FiberVMEFiberCh(int)
uint32_t getBin_SlotVME(HcalElectronicsId const &)
int const SLBCH_NUM
Definition: Constants.h:137
int const FIBER_VME_NUM
Definition: Constants.h:115
int getValue(HcalElectronicsId const &eid) override
uint32_t getBin_FEDuTCA(HcalElectronicsId const &)
int const FIBER_uTCA_NUM
Definition: Constants.h:120
const std::map< ElectronicsQuantityType, getBinType_eid > getBin_functions_eid
uint32_t getBin_CrateVME(HcalElectronicsId const &)
CrateQuantity * makeCopy() override
int getValue_FiberuTCAFiberCh(HcalElectronicsId const &)
std::vector< std::string > getLabels_FiberVME()
std::vector< std::string > getLabels_FiberCh()
int const SPIGOT_NUM
Definition: Constants.h:110
std::vector< unsigned int > const crateList
Definition: Constants.h:62
int getValue_CrateVME(HcalElectronicsId const &)
int const FED_uTCA_NUM
Definition: Constants.h:78
std::vector< std::string > getLabels_FEDVMESpigot()
int getValue_SlotuTCA(HcalElectronicsId const &)
uint32_t(* getBinType_eid)(HcalElectronicsId const &)
int const FED_VME_NUM
Definition: Constants.h:73
std::vector< std::string > getLabels_FEDuTCASlot()
std::vector< unsigned int > const crateListVME
Definition: Constants.h:64
std::map< int, uint32_t > CrateHashMap
int getValue_FiberVMEFiberCh(HcalElectronicsId const &)
uint32_t getBin_SLBCh(HcalElectronicsId const &)
uint32_t getBin_Spigot(HcalElectronicsId const &)
int getValue_FEDVMESpigot(HcalElectronicsId const &)
std::vector< std::string > getLabels_SLBCh()
int getValue_FEDuTCA(HcalElectronicsId const &)
virtual bool isLog()
Definition: Quantity.h:35
HcalElectronicsId getEid_FiberCh(int)
int const SLOT_uTCA_NUM
Definition: Constants.h:98
HcalElectronicsId getEid_FiberChuTCATP(int)
HcalElectronicsId getEid_FED(int)
const std::map< ElectronicsQuantityType, double > max_eid
int getValue_FiberuTCATPFiberChuTCATP(HcalElectronicsId const &)
std::vector< std::string > getLabels_FiberuTCA()
std::vector< std::string > getLabels_CrateVME()
uint32_t getBin_FiberCh(HcalElectronicsId const &)
uint32_t getBin_Crate(HcalElectronicsId const &)
uint32_t getBin_FEDVMESpigot(HcalElectronicsId const &)
int getValue_FEDuTCASlot(HcalElectronicsId const &)
uint32_t getBin_FiberuTCA(HcalElectronicsId const &)
HcalElectronicsId getEid_CrateuTCA(int)
HcalElectronicsId(* getEid_eid)(int)
uint32_t getBin_FiberuTCATPFiberChuTCATP(HcalElectronicsId const &)
int getValue_SLB(HcalElectronicsId const &)
CrateQuantity(std::vector< int > crates, CrateHashMap crateHashes)
int const TPFIBERCH_NUM
Definition: Constants.h:141
HcalElectronicsId getEid_Crate(int)
HcalElectronicsId getEid_FiberuTCATP(int)
const std::map< ElectronicsQuantityType, getLabels_eid > getLabels_functions_eid
Readout chain identification for Hcal.
boost::unordered_map< int, uint32_t > FEDMap
HcalElectronicsId getEid_SLBSLBCh(int)
int getValue_FiberuTCA(HcalElectronicsId const &)
HcalElectronicsId getEid_FEDVME(int)
std::vector< std::string > getLabels_SLBSLBCh()
std::vector< std::string > getLabels_FiberuTCAFiberCh()
const std::map< ElectronicsQuantityType, std::string > name_eid