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 {
14  namespace quantity
15  {
17  {
18  fFED = 0,
19  fFEDuTCA = 1,
20  fFEDVME = 2,
21  fCrate = 3,
23  fCrateVME = 5,
24  fSlotuTCA = 6,
25  fSlotVME = 7,
26  fSpigot = 8,
28  fFiberVME = 10,
29  fFiberCh = 11,
30 
31  // Complex Quantities
36 
37  // Adding Trigger Quantities for VME
38  fSLB = 16,
39  fSLBCh = 17,
40  fSLBSLBCh = 18,
41 
42  // Adding Trigger Quantities for uTCA
46 
48  };
49 
50  int getValue_FED(HcalElectronicsId const&);
66  int getValue_SLB(HcalElectronicsId const&);
72  uint32_t getBin_FED(HcalElectronicsId const&);
73  uint32_t getBin_FEDuTCA(HcalElectronicsId const&);
74  uint32_t getBin_FEDVME(HcalElectronicsId const&);
75  uint32_t getBin_Crate(HcalElectronicsId const&);
76  uint32_t getBin_CrateuTCA(HcalElectronicsId const&);
77  uint32_t getBin_CrateVME(HcalElectronicsId const&);
78  uint32_t getBin_SlotuTCA(HcalElectronicsId const&);
79  uint32_t getBin_SlotVME(HcalElectronicsId const&);
80  uint32_t getBin_Spigot(HcalElectronicsId const&);
81  uint32_t getBin_FiberuTCA(HcalElectronicsId const&);
82  uint32_t getBin_FiberVME(HcalElectronicsId const&);
83  uint32_t getBin_FiberCh(HcalElectronicsId const&);
84  uint32_t getBin_FEDuTCASlot(HcalElectronicsId const&);
85  uint32_t getBin_FEDVMESpigot(HcalElectronicsId const&);
88  uint32_t getBin_SLB(HcalElectronicsId const&);
89  uint32_t getBin_SLBCh(HcalElectronicsId const&);
90  uint32_t getBin_SLBSLBCh(HcalElectronicsId const&);
91  uint32_t getBin_FiberuTCATP(HcalElectronicsId const&);
92  uint32_t getBin_FiberChuTCATP(HcalElectronicsId const&);
116  std::vector<std::string> getLabels_FED();
117  std::vector<std::string> getLabels_FEDuTCA();
118  std::vector<std::string> getLabels_FEDVME();
119  std::vector<std::string> getLabels_Crate();
120  std::vector<std::string> getLabels_CrateuTCA();
121  std::vector<std::string> getLabels_CrateVME();
122  std::vector<std::string> getLabels_SlotuTCA();
123  std::vector<std::string> getLabels_SlotVME();
124  std::vector<std::string> getLabels_Spigot();
125  std::vector<std::string> getLabels_FiberuTCA();
126  std::vector<std::string> getLabels_FiberVME();
127  std::vector<std::string> getLabels_FiberCh();
128  std::vector<std::string> getLabels_FEDuTCASlot();
129  std::vector<std::string> getLabels_FEDVMESpigot();
130  std::vector<std::string> getLabels_FiberuTCAFiberCh();
131  std::vector<std::string> getLabels_FiberVMEFiberCh();
132  std::vector<std::string> getLabels_SLB();
133  std::vector<std::string> getLabels_SLBCh();
134  std::vector<std::string> getLabels_SLBSLBCh();
135  std::vector<std::string> getLabels_FiberuTCATP();
136  std::vector<std::string> getLabels_FiberChuTCATP();
137  std::vector<std::string> getLabels_FiberuTCATPFiberChuTCATP();
138 
140  typedef uint32_t (*getBinType_eid)(HcalElectronicsId const&);
142  typedef std::vector<std::string> (*getLabels_eid)();
143  const std::map<ElectronicsQuantityType, getValueType_eid> getValue_functions_eid = {
144  {fFED,getValue_FED},
160  {fSLB,getValue_SLB},
166  };
167  const std::map<ElectronicsQuantityType, getBinType_eid> getBin_functions_eid = {
168  {fFED,getBin_FED},
184  {fSLB,getBin_SLB},
190  };
191  const std::map<ElectronicsQuantityType, getEid_eid> getEid_functions_eid = {
192  {fFED,getEid_FED},
208  {fSLB,getEid_SLB},
214  };
215  const std::map<ElectronicsQuantityType, getLabels_eid> getLabels_functions_eid = {
238  };
239  const std::map<ElectronicsQuantityType, std::string> name_eid = {
240  {fFED,"FED"},
241  {fFEDuTCA,"FEDuTCA"},
242  {fFEDVME,"FEDVME"},
243  {fCrate,"Crate"},
244  {fCrateuTCA,"CrateuTCA"},
245  {fCrateVME,"CrateVME"},
246  {fSlotuTCA,"SlotuTCA"},
247  {fSlotVME,"SlotVME"},
248  {fSpigot,"Spigot"},
249  {fFiberuTCA,"FiberuTCA"},
250  {fFiberVME,"FiberVME"},
251  {fFiberCh,"FiberCh"},
252  {fFEDuTCASlot,"FEDuTCASlot"},
253  {fFEDVMESpigot,"FEDVMESpigot"},
254  {fFiberuTCAFiberCh,"FiberuTCAFiberCh"},
255  {fFiberVMEFiberCh,"FiberVMEFiberCh"},
256  {fSLB,"SLB"},
257  {fSLBCh,"SLBCh"},
258  {fSLBSLBCh,"SLB-SLBCh"},
259  {fFiberuTCATP,"TPFiber"},
260  {fFiberChuTCATP,"TPFiberCh"},
261  {fFiberuTCATPFiberChuTCATP,"TPF-TPFCh"},
262  };
263  const std::map<ElectronicsQuantityType, double> min_eid = {
264  {fFED,-0.5},
265  {fFEDuTCA,-0.5},
266  {fFEDVME,-0.5},
267  {fCrate,-0.5},
268  {fCrateuTCA,-0.5},
269  {fCrateVME,-0.5},
270  {fSlotuTCA,0.},
271  {fSlotVME,0.},
272  {fSpigot,0.},
273  {fFiberuTCA,0.},
274  {fFiberVME,0.},
275  {fFiberCh,0.},
276  {fFEDuTCASlot,0.},
277  {fFEDVMESpigot,0.},
278  {fFiberuTCAFiberCh,0.},
279  {fFiberVMEFiberCh,0.},
280  {fSLB,0.},
281  {fSLBCh,0.},
282  {fSLBSLBCh,0.},
283  {fFiberuTCATP,0.},
284  {fFiberChuTCATP,0.},
286  };
287  const std::map<ElectronicsQuantityType, double> max_eid = {
288  {fFED,constants::fedList.size() - 0.5},
289  {fFEDuTCA,constants::fedListuTCA.size() - 0.5},
290  {fFEDVME,constants::fedListVME.size() - 0.5},
291  {fCrate,constants::crateList.size() - 0.5},
292  {fCrateuTCA,constants::crateListuTCA.size() - 0.5},
293  {fCrateVME,constants::crateListVME.size() - 0.5},
300  {fFEDuTCASlot,constants::FED_uTCA_NUM*constants::SLOT_uTCA_NUM},
301  {fFEDVMESpigot,constants::FED_VME_NUM*constants::SPIGOT_NUM},
302  {fFiberuTCAFiberCh,constants::FIBER_uTCA_NUM*constants::FIBERCH_NUM},
303  {fFiberVMEFiberCh,constants::FIBER_VME_NUM*constants::FIBERCH_NUM},
306  {fSLBSLBCh,constants::SLB_NUM*constants::SLBCH_NUM},
309  {fFiberuTCATPFiberChuTCATP,constants::TPFIBER_NUM*constants::TPFIBERCH_NUM},
310  };
311  const std::map<ElectronicsQuantityType, double> nbins_eid = {
312  {fFED,constants::fedList.size()},
315  {fCrate,constants::crateList.size()},
324  {fFEDuTCASlot,constants::FED_uTCA_NUM*constants::SLOT_uTCA_NUM},
325  {fFEDVMESpigot,constants::FED_VME_NUM*constants::SPIGOT_NUM},
326  {fFiberuTCAFiberCh,constants::FIBER_uTCA_NUM*constants::FIBERCH_NUM},
327  {fFiberVMEFiberCh,constants::FIBER_VME_NUM*constants::FIBERCH_NUM},
330  {fSLBSLBCh,constants::SLB_NUM*constants::SLBCH_NUM},
333  {fFiberuTCATPFiberChuTCATP,constants::TPFIBER_NUM*constants::TPFIBERCH_NUM},
334  };
335 
337  {
338  public:
341  bool isLog=false) :
342  Quantity(name_eid.at(type), isLog), _type(type)
343  {}
344  ~ElectronicsQuantity() override {}
346  {return new ElectronicsQuantity(_type, _isLog);}
347 
348  int getValue(HcalElectronicsId const& eid) override
349  {return getValue_functions_eid.at(_type)(eid);}
350  uint32_t getBin(HcalElectronicsId const& eid) override
351  {return getBin_functions_eid.at(_type)(eid);}
352 
354  int nbins() override {return nbins_eid.at(_type);}
355  double min() override {return min_eid.at(_type);}
356  double max() override {return max_eid.at(_type);}
357  bool isCoordinate() override {return true;}
358  std::vector<std::string> getLabels() override
359  {return getLabels_functions_eid.at(_type)();}
360 
361  protected:
363  };
364 
365  // sorted list of FEDs you want to have on the axis
367  {
368  public:
370  FEDQuantity(std::vector<int> const& vFEDs) :
372  {this->setup(vFEDs);}
373  ~FEDQuantity() override {}
374 
375  virtual void setup(std::vector<int> const& vFEDs);
376  int getValue(HcalElectronicsId const&) override;
377  uint32_t getBin(HcalElectronicsId const&) override;
378 
379  int nbins() override {return _feds.size();}
380  double min() override {return 0;}
381  double max() override {return _feds.size();}
382  std::vector<std::string> getLabels() override;
383 
384  protected:
385  typedef boost::unordered_map<int, uint32_t> FEDMap;
386  FEDMap _feds;
387 
388  public:
389  FEDQuantity* makeCopy() override
390  {
391  std::vector<int> vfeds;
392  for(auto const& p : _feds)
393  {
394  vfeds.push_back(p.first);
395  }
396 
397  // MUST SORT BEFORE EXITING!
398  std::sort(vfeds.begin(), vfeds.end());
399  return new FEDQuantity(vfeds);
400  }
401  };
402 
403  // Crate quantity, initialized from emap (because it is not easy to turn a VME crate in an EID)
405  typedef std::map<int, uint32_t> CrateHashMap;
406  public:
409  this->setup(emap);
410  }
411  CrateQuantity(std::vector<int> crates, CrateHashMap crateHashes) : ElectronicsQuantity(fCrate, false) {
412  this->setup(crates, crateHashes);
413  }
414  ~CrateQuantity() override {}
415 
416  virtual void setup(HcalElectronicsMap const * emap);
417  virtual void setup(std::vector<int> crates, CrateHashMap crateHashes);
418  int getValue(HcalElectronicsId const&) override;
419  uint32_t getBin(HcalElectronicsId const&) override;
420 
421  int nbins() override {
422  return _crates.size();
423  }
424  double min() override {return 0;}
425  double max() override {return _crates.size();}
426  std::vector<std::string> getLabels() override;
427 
428  protected:
429  std::vector<int> _crates;
430  CrateHashMap _crateHashes;
431 
432  public:
434  {
435  // Make copies of the crate info
436  std::vector<int> tmpCrates;
437  std::map<int, uint32_t> tmpCrateHashes;
438  for (auto& it_crate : _crates) {
439  tmpCrates.push_back(it_crate);
440  tmpCrateHashes[it_crate] = _crateHashes[it_crate];
441  }
442  return new CrateQuantity(tmpCrates, tmpCrateHashes);
443  }
444 
445  };
446  }
447 }
448 
449 #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:89
const std::map< ElectronicsQuantityType, getValueType_eid > getValue_functions_eid
HcalElectronicsId getEid_FEDuTCASlot(int)
std::vector< unsigned int > const crateListuTCA
Definition: Constants.h:91
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:162
std::vector< std::string > getLabels_FED()
int const FIBERCH_NUM
Definition: Constants.h:153
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:88
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:134
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:87
HcalElectronicsId getEid_FEDVMESpigot(int)
uint32_t getBin_FED(HcalElectronicsId const &)
int const SLB_NUM
Definition: Constants.h:158
HcalElectronicsId getEid_FiberVMEFiberCh(int)
uint32_t getBin_SlotVME(HcalElectronicsId const &)
int const SLBCH_NUM
Definition: Constants.h:166
int const FIBER_VME_NUM
Definition: Constants.h:143
int getValue(HcalElectronicsId const &eid) override
uint32_t getBin_FEDuTCA(HcalElectronicsId const &)
int const FIBER_uTCA_NUM
Definition: Constants.h:148
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:138
std::vector< unsigned int > const crateList
Definition: Constants.h:90
int getValue_CrateVME(HcalElectronicsId const &)
int const FED_uTCA_NUM
Definition: Constants.h:106
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:101
std::vector< std::string > getLabels_FEDuTCASlot()
std::vector< unsigned int > const crateListVME
Definition: Constants.h:92
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:48
HcalElectronicsId getEid_FiberCh(int)
int const SLOT_uTCA_NUM
Definition: Constants.h:126
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:170
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