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  using namespace constants;
16  namespace quantity
17  {
19  {
20  fFED = 0,
21  fFEDuTCA = 1,
22  fFEDVME = 2,
23  fCrate = 3,
25  fCrateVME = 5,
26  fSlotuTCA = 6,
27  fSlotVME = 7,
28  fSpigot = 8,
30  fFiberVME = 10,
31  fFiberCh = 11,
32 
33  // Complex Quantities
38 
39  // Adding Trigger Quantities for VME
40  fSLB = 16,
41  fSLBCh = 17,
42  fSLBSLBCh = 18,
43 
44  // Adding Trigger Quantities for uTCA
48 
50  };
51 
52  int getValue_FED(HcalElectronicsId const&);
68  int getValue_SLB(HcalElectronicsId const&);
74  uint32_t getBin_FED(HcalElectronicsId const&);
75  uint32_t getBin_FEDuTCA(HcalElectronicsId const&);
76  uint32_t getBin_FEDVME(HcalElectronicsId const&);
77  uint32_t getBin_Crate(HcalElectronicsId const&);
78  uint32_t getBin_CrateuTCA(HcalElectronicsId const&);
79  uint32_t getBin_CrateVME(HcalElectronicsId const&);
80  uint32_t getBin_SlotuTCA(HcalElectronicsId const&);
81  uint32_t getBin_SlotVME(HcalElectronicsId const&);
82  uint32_t getBin_Spigot(HcalElectronicsId const&);
83  uint32_t getBin_FiberuTCA(HcalElectronicsId const&);
84  uint32_t getBin_FiberVME(HcalElectronicsId const&);
85  uint32_t getBin_FiberCh(HcalElectronicsId const&);
86  uint32_t getBin_FEDuTCASlot(HcalElectronicsId const&);
87  uint32_t getBin_FEDVMESpigot(HcalElectronicsId const&);
90  uint32_t getBin_SLB(HcalElectronicsId const&);
91  uint32_t getBin_SLBCh(HcalElectronicsId const&);
92  uint32_t getBin_SLBSLBCh(HcalElectronicsId const&);
93  uint32_t getBin_FiberuTCATP(HcalElectronicsId const&);
94  uint32_t getBin_FiberChuTCATP(HcalElectronicsId const&);
118  std::vector<std::string> getLabels_FED();
119  std::vector<std::string> getLabels_FEDuTCA();
120  std::vector<std::string> getLabels_FEDVME();
121  std::vector<std::string> getLabels_Crate();
122  std::vector<std::string> getLabels_CrateuTCA();
123  std::vector<std::string> getLabels_CrateVME();
124  std::vector<std::string> getLabels_SlotuTCA();
125  std::vector<std::string> getLabels_SlotVME();
126  std::vector<std::string> getLabels_Spigot();
127  std::vector<std::string> getLabels_FiberuTCA();
128  std::vector<std::string> getLabels_FiberVME();
129  std::vector<std::string> getLabels_FiberCh();
130  std::vector<std::string> getLabels_FEDuTCASlot();
131  std::vector<std::string> getLabels_FEDVMESpigot();
132  std::vector<std::string> getLabels_FiberuTCAFiberCh();
133  std::vector<std::string> getLabels_FiberVMEFiberCh();
134  std::vector<std::string> getLabels_SLB();
135  std::vector<std::string> getLabels_SLBCh();
136  std::vector<std::string> getLabels_SLBSLBCh();
137  std::vector<std::string> getLabels_FiberuTCATP();
138  std::vector<std::string> getLabels_FiberChuTCATP();
139  std::vector<std::string> getLabels_FiberuTCATPFiberChuTCATP();
140 
142  typedef uint32_t (*getBinType_eid)(HcalElectronicsId const&);
144  typedef std::vector<std::string> (*getLabels_eid)();
145  const std::map<ElectronicsQuantityType, getValueType_eid> getValue_functions_eid = {
146  {fFED,getValue_FED},
162  {fSLB,getValue_SLB},
168  };
169  const std::map<ElectronicsQuantityType, getBinType_eid> getBin_functions_eid = {
170  {fFED,getBin_FED},
186  {fSLB,getBin_SLB},
192  };
193  const std::map<ElectronicsQuantityType, getEid_eid> getEid_functions_eid = {
194  {fFED,getEid_FED},
210  {fSLB,getEid_SLB},
216  };
217  const std::map<ElectronicsQuantityType, getLabels_eid> getLabels_functions_eid = {
240  };
241  const std::map<ElectronicsQuantityType, std::string> name_eid = {
242  {fFED,"FED"},
243  {fFEDuTCA,"FEDuTCA"},
244  {fFEDVME,"FEDVME"},
245  {fCrate,"Crate"},
246  {fCrateuTCA,"CrateuTCA"},
247  {fCrateVME,"CrateVME"},
248  {fSlotuTCA,"SlotuTCA"},
249  {fSlotVME,"SlotVME"},
250  {fSpigot,"Spigot"},
251  {fFiberuTCA,"FiberuTCA"},
252  {fFiberVME,"FiberVME"},
253  {fFiberCh,"FiberCh"},
254  {fFEDuTCASlot,"FEDuTCASlot"},
255  {fFEDVMESpigot,"FEDVMESpigot"},
256  {fFiberuTCAFiberCh,"FiberuTCAFiberCh"},
257  {fFiberVMEFiberCh,"FiberVMEFiberCh"},
258  {fSLB,"SLB"},
259  {fSLBCh,"SLBCh"},
260  {fSLBSLBCh,"SLB-SLBCh"},
261  {fFiberuTCATP,"TPFiber"},
262  {fFiberChuTCATP,"TPFiberCh"},
263  {fFiberuTCATPFiberChuTCATP,"TPF-TPFCh"},
264  };
265  const std::map<ElectronicsQuantityType, double> min_eid = {
266  {fFED,0.},
267  {fFEDuTCA,0.},
268  {fFEDVME,0.},
269  {fCrate,0.},
270  {fCrateuTCA,0.},
271  {fCrateVME,0.},
272  {fSlotuTCA,0.},
273  {fSlotVME,0.},
274  {fSpigot,0.},
275  {fFiberuTCA,0.},
276  {fFiberVME,0.},
277  {fFiberCh,0.},
278  {fFEDuTCASlot,0.},
279  {fFEDVMESpigot,0.},
280  {fFiberuTCAFiberCh,0.},
281  {fFiberVMEFiberCh,0.},
282  {fSLB,0.},
283  {fSLBCh,0.},
284  {fSLBSLBCh,0.},
285  {fFiberuTCATP,0.},
286  {fFiberChuTCATP,0.},
288  };
289  const std::map<ElectronicsQuantityType, double> max_eid = {
302  {fFEDuTCASlot,FED_uTCA_NUM*SLOT_uTCA_NUM},
303  {fFEDVMESpigot,FED_VME_NUM*SPIGOT_NUM},
304  {fFiberuTCAFiberCh,FIBER_uTCA_NUM*FIBERCH_NUM},
305  {fFiberVMEFiberCh,FIBER_VME_NUM*FIBERCH_NUM},
306  {fSLB,SLB_NUM},
307  {fSLBCh,SLBCH_NUM},
308  {fSLBSLBCh,SLB_NUM*SLBCH_NUM},
311  {fFiberuTCATPFiberChuTCATP,TPFIBER_NUM*TPFIBERCH_NUM},
312  };
313  const std::map<ElectronicsQuantityType, double> nbins_eid = {
326  {fFEDuTCASlot,FED_uTCA_NUM*SLOT_uTCA_NUM},
327  {fFEDVMESpigot,FED_VME_NUM*SPIGOT_NUM},
328  {fFiberuTCAFiberCh,FIBER_uTCA_NUM*FIBERCH_NUM},
329  {fFiberVMEFiberCh,FIBER_VME_NUM*FIBERCH_NUM},
330  {fSLB,SLB_NUM},
331  {fSLBCh,SLBCH_NUM},
332  {fSLBSLBCh,SLB_NUM*SLBCH_NUM},
335  {fFiberuTCATPFiberChuTCATP,TPFIBER_NUM*TPFIBERCH_NUM},
336  };
337 
339  {
340  public:
343  bool isLog=false) :
344  Quantity(name_eid.at(type), isLog), _type(type)
345  {}
346  virtual ~ElectronicsQuantity() {}
348  {return new ElectronicsQuantity(_type, _isLog);}
349 
350  virtual int getValue(HcalElectronicsId const& eid)
351  {return getValue_functions_eid.at(_type)(eid);}
352  virtual uint32_t getBin(HcalElectronicsId const& eid)
353  {return getBin_functions_eid.at(_type)(eid);}
354 
356  virtual int nbins() {return nbins_eid.at(_type);}
357  virtual double min() {return min_eid.at(_type);}
358  virtual double max() {return max_eid.at(_type);}
359  virtual bool isCoordinate() {return true;}
360  virtual std::vector<std::string> getLabels()
361  {return getLabels_functions_eid.at(_type)();}
362 
363  protected:
365  };
366 
367  // sorted list of FEDs you want to have on the axis
369  {
370  public:
372  FEDQuantity(std::vector<int> const& vFEDs) :
374  {this->setup(vFEDs);}
375  virtual ~FEDQuantity() {}
376 
377  virtual void setup(std::vector<int> const& vFEDs);
378  virtual int getValue(HcalElectronicsId const&);
379  virtual uint32_t getBin(HcalElectronicsId const&);
380 
381  virtual int nbins() {return _feds.size();}
382  virtual double min() {return 0;}
383  virtual double max() {return _feds.size();}
384  virtual std::vector<std::string> getLabels();
385 
386  protected:
387  typedef boost::unordered_map<int, uint32_t> FEDMap;
388  FEDMap _feds;
389 
390  public:
392  {
393  std::vector<int> vfeds;
394  BOOST_FOREACH(FEDMap::value_type &p, _feds)
395  {
396  vfeds.push_back(p.first);
397  }
398 
399  // MUST SORT BEFORE EXITING!
400  std::sort(vfeds.begin(), vfeds.end());
401  return new FEDQuantity(vfeds);
402  }
403  };
404 
405  // Crate quantity, initialized from emap (because it is not easy to turn a VME crate in an EID)
407  typedef std::map<int, uint32_t> CrateHashMap;
408  public:
411  this->setup(emap);
412  }
413  CrateQuantity(std::vector<int> crates, CrateHashMap crateHashes) : ElectronicsQuantity(fCrate, false) {
414  this->setup(crates, crateHashes);
415  }
416  virtual ~CrateQuantity() {}
417 
418  virtual void setup(HcalElectronicsMap const * emap);
419  virtual void setup(std::vector<int> crates, CrateHashMap crateHashes);
420  virtual int getValue(HcalElectronicsId const&);
421  virtual uint32_t getBin(HcalElectronicsId const&);
422 
423  virtual int nbins() {
424  return _crates.size();
425  }
426  virtual double min() {return 0;}
427  virtual double max() {return _crates.size();}
428  virtual std::vector<std::string> getLabels();
429 
430  protected:
431  std::vector<int> _crates;
432  CrateHashMap _crateHashes;
433 
434  public:
436  {
437  // Make copies of the crate info
438  std::vector<int> tmpCrates;
439  std::map<int, uint32_t> tmpCrateHashes;
440  for (auto& it_crate : _crates) {
441  tmpCrates.push_back(it_crate);
442  tmpCrateHashes[it_crate] = _crateHashes[it_crate];
443  }
444  return new CrateQuantity(tmpCrates, tmpCrateHashes);
445  }
446 
447  };
448  }
449 }
450 
451 #endif
std::vector< std::string > getLabels_Crate()
std::vector< std::string > getLabels_Spigot()
type
Definition: HCALResponse.h:21
CrateQuantity(HcalElectronicsMap const *emap)
const std::map< ElectronicsQuantityType, getValueType_eid > getValue_functions_eid
HcalElectronicsId getEid_FEDuTCASlot(int)
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:119
std::vector< std::string > getLabels_FED()
int const FIBERCH_NUM
Definition: Constants.h:110
virtual uint32_t getBin(HcalElectronicsId const &eid)
int getValue_FiberChuTCATP(HcalElectronicsId const &)
virtual std::vector< std::string > getLabels()
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 &)
const std::map< ElectronicsQuantityType, getEid_eid > getEid_functions_eid
virtual int getValue(HcalElectronicsId const &eid)
int const CRATE_uTCA_NUM
Definition: Constants.h:76
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:1
uint32_t getBin_FEDVME(HcalElectronicsId const &)
uint32_t getBin_FiberuTCATP(HcalElectronicsId const &)
uint32_t getBin_FiberChuTCATP(HcalElectronicsId const &)
std::vector< std::string > getLabels_FiberVMEFiberCh()
int getValue_FiberVME(HcalElectronicsId const &)
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:91
std::vector< std::string > getLabels_FEDuTCA()
virtual CrateQuantity * makeCopy()
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)
virtual ElectronicsQuantity * makeCopy()
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 &)
int const CRATE_TOTAL_NUM
Definition: Constants.h:77
std::vector< std::string > getLabels_SlotuTCA()
int getValue_CrateuTCA(HcalElectronicsId const &)
int getValue_FEDVME(HcalElectronicsId const &)
std::vector< std::string > getLabels_FiberuTCATP()
HcalElectronicsId getEid_FEDVMESpigot(int)
uint32_t getBin_FED(HcalElectronicsId const &)
int const SLB_NUM
Definition: Constants.h:115
HcalElectronicsId getEid_FiberVMEFiberCh(int)
uint32_t getBin_SlotVME(HcalElectronicsId const &)
int const SLBCH_NUM
Definition: Constants.h:123
int getBin(double x, std::vector< double > boundaries)
Definition: Utilities.h:512
int const FIBER_VME_NUM
Definition: Constants.h:100
uint32_t getBin_FEDuTCA(HcalElectronicsId const &)
int const FIBER_uTCA_NUM
Definition: Constants.h:105
const std::map< ElectronicsQuantityType, getBinType_eid > getBin_functions_eid
uint32_t getBin_CrateVME(HcalElectronicsId const &)
int getValue_FiberuTCAFiberCh(HcalElectronicsId const &)
std::vector< std::string > getLabels_FiberVME()
std::vector< std::string > getLabels_FiberCh()
int const SPIGOT_NUM
Definition: Constants.h:95
int getValue_CrateVME(HcalElectronicsId const &)
int const FED_uTCA_NUM
Definition: Constants.h:63
std::vector< std::string > getLabels_FEDVMESpigot()
int getValue_SlotuTCA(HcalElectronicsId const &)
uint32_t(* getBinType_eid)(HcalElectronicsId const &)
virtual FEDQuantity * makeCopy()
int const FED_VME_NUM
Definition: Constants.h:58
std::vector< std::string > getLabels_FEDuTCASlot()
int const CRATE_VME_NUM
Definition: Constants.h:71
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 &)
HcalElectronicsId getEid_FiberCh(int)
int const SLOT_uTCA_NUM
Definition: Constants.h:83
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()
int const FED_TOTAL_NUM
Definition: Constants.h:65
uint32_t getBin_FiberCh(HcalElectronicsId const &)
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
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:127
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