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