CMS 3D CMS Logo

HcalElectronicsId.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_HCALDETID_HCALELECTRONICSID_H
2 #define DATAFORMATS_HCALDETID_HCALELECTRONICSID_H 1
3 
4 #include <string>
5 #include <ostream>
6 #include <cstdint>
7 
33 public:
35  constexpr HcalElectronicsId() : hcalElectronicsId_{0xffffffffu} {}
37  constexpr HcalElectronicsId(uint32_t id) : hcalElectronicsId_{id} {}
39  constexpr HcalElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid)
40  : hcalElectronicsId_((uint32_t)((fiberChan & 0x3) | (((fiberIndex - 1) & 0x7) << 2) | ((spigot & 0xF) << 5) |
41  ((dccid & 0x1F) << 9))) {}
43  constexpr HcalElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb)
45  (uint32_t)((slbChan & 0x3) | (((slbSite)&0x7) << 2) | ((spigot & 0xF) << 5) | ((dccid & 0x1F) << 9))) {
46  hcalElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
47  hcalElectronicsId_ |= 0x02000000;
48  }
50  constexpr HcalElectronicsId(int crate, int slot, int fiber, int fc, bool isTrigger)
51  : hcalElectronicsId_((int)((fc & 0xF) | (((fiber)&0x1F) << 4) | ((slot & 0xF) << 9) | ((crate & 0x3F) << 13))) {
52  if (isTrigger)
53  hcalElectronicsId_ |= 0x02000000;
54  hcalElectronicsId_ |= 0x04000000;
55  }
56 
57  constexpr uint32_t operator()() { return hcalElectronicsId_; }
58 
59  constexpr uint32_t rawId() const { return hcalElectronicsId_; }
60 
61  constexpr bool isVMEid() const { return (hcalElectronicsId_ & 0x04000000) == 0; }
62  constexpr bool isUTCAid() const { return (hcalElectronicsId_ & 0x04000000) != 0; }
63  constexpr bool isTriggerChainId() const { return (hcalElectronicsId_ & 0x02000000) != 0; }
64 
66  constexpr void setHTR(int crate, int slot, int tb) {
67  if (isUTCAid())
68  return; // cannot do this for uTCA
69  hcalElectronicsId_ &= 0x3FFF; // keep the readout chain info
70  hcalElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
71  }
72 
74  constexpr int subtype() const { return (isUTCAid()) ? ((hcalElectronicsId_ >> 21) & 0x1F) : (-1); }
76  constexpr int fiberChanId() const { return (isVMEid()) ? (hcalElectronicsId_ & 0x3) : (hcalElectronicsId_ & 0xF); }
78  constexpr int fiberIndex() const {
79  return (isVMEid()) ? (((hcalElectronicsId_ >> 2) & 0x7) + 1) : ((hcalElectronicsId_ >> 4) & 0x1F);
80  }
82  constexpr int slbChannelIndex() const { return hcalElectronicsId_ & 0x3; }
84  constexpr int slbSiteNumber() const { return ((hcalElectronicsId_ >> 2) & 0x7); }
85 
87  constexpr int htrChanId() const { return isVMEid() ? ((fiberChanId() + 1) + ((fiberIndex() - 1) * 3)) : (0); }
88 
91 
93  constexpr int spigot() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 5) & 0xF) : slot(); }
95  constexpr int dccid() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 9) & 0x1F) : crateId(); }
97  constexpr int htrSlot() const { return slot(); }
99  constexpr int slot() const {
100  return (isVMEid()) ? ((hcalElectronicsId_ >> 14) & 0x1F) : ((hcalElectronicsId_ >> 9) & 0xF);
101  }
103  constexpr int htrTopBottom() const { return (isVMEid()) ? ((hcalElectronicsId_ >> 19) & 0x1) : (-1); }
105  constexpr int readoutVMECrateId() const { return crateId(); }
107  constexpr int crateId() const {
108  return (isVMEid()) ? ((hcalElectronicsId_ >> 20) & 0x1F) : ((hcalElectronicsId_ >> 13) & 0x3F);
109  }
111  constexpr int linearIndex() const {
112  return (isVMEid()) ? ((hcalElectronicsId_)&0x3FFF) : ((hcalElectronicsId_)&0x7FFFF);
113  }
114 
115  static const int maxLinearIndex = 0x7FFFF; //
116  static const int maxDCCId = 31;
117 
119  constexpr int operator==(const HcalElectronicsId& id) const { return id.hcalElectronicsId_ == hcalElectronicsId_; }
121  constexpr int operator!=(const HcalElectronicsId& id) const { return id.hcalElectronicsId_ != hcalElectronicsId_; }
123  constexpr int operator<(const HcalElectronicsId& id) const { return hcalElectronicsId_ < id.hcalElectronicsId_; }
124 
125 private:
127 };
128 
129 std::ostream& operator<<(std::ostream&, const HcalElectronicsId&);
130 
131 #endif
HcalElectronicsId::operator()
constexpr uint32_t operator()()
Definition: HcalElectronicsId.h:57
HcalElectronicsId::setHTR
constexpr void setHTR(int crate, int slot, int tb)
Definition: HcalElectronicsId.h:66
HcalElectronicsId::readoutVMECrateId
constexpr int readoutVMECrateId() const
get the readout VME crate number
Definition: HcalElectronicsId.h:105
HcalElectronicsId::slbSiteNumber
constexpr int slbSiteNumber() const
get the SLB site number (valid only for VME trigger-chain ids)
Definition: HcalElectronicsId.h:84
HcalElectronicsId::htrSlot
constexpr int htrSlot() const
get the htr slot
Definition: HcalElectronicsId.h:97
HcalElectronicsId::slot
constexpr int slot() const
get the htr or uHTR slot
Definition: HcalElectronicsId.h:99
HcalElectronicsId::HcalElectronicsId
constexpr HcalElectronicsId(int crate, int slot, int fiber, int fc, bool isTrigger)
Definition: HcalElectronicsId.h:50
slbChan
static int slbChan(const HcalTriggerPrimitiveSample &theSample)
Definition: CastorUnpacker.cc:72
HcalElectronicsId::HcalElectronicsId
constexpr HcalElectronicsId()
Definition: HcalElectronicsId.h:35
HcalElectronicsId::HcalElectronicsId
constexpr HcalElectronicsId(uint32_t id)
Definition: HcalElectronicsId.h:37
HcalElectronicsId::subtype
constexpr int subtype() const
get subtype for this channel (valid for uTCA only)
Definition: HcalElectronicsId.h:74
HcalElectronicsId::HcalElectronicsId
constexpr HcalElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid)
Definition: HcalElectronicsId.h:39
HcalElectronicsId::fiberIndex
constexpr int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
Definition: HcalElectronicsId.h:78
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
HcalElectronicsId::isVMEid
constexpr bool isVMEid() const
Definition: HcalElectronicsId.h:61
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
benchmark_cfg.fc
fc
Definition: benchmark_cfg.py:15
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalElectronicsId::operator<
constexpr int operator<(const HcalElectronicsId &id) const
Compare the id to another id for use in a map.
Definition: HcalElectronicsId.h:123
operator<<
std::ostream & operator<<(std::ostream &, const HcalElectronicsId &)
Definition: HcalElectronicsId.cc:41
createfilelist.int
int
Definition: createfilelist.py:10
HcalElectronicsId::isUTCAid
constexpr bool isUTCAid() const
Definition: HcalElectronicsId.h:62
HcalElectronicsId::isTriggerChainId
constexpr bool isTriggerChainId() const
Definition: HcalElectronicsId.h:63
HcalElectronicsId::htrTopBottom
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
Definition: HcalElectronicsId.h:103
HcalElectronicsId::maxLinearIndex
static const int maxLinearIndex
Definition: HcalElectronicsId.h:115
HcalElectronicsId::linearIndex
constexpr int linearIndex() const
get a fast, compact, unique index for linear lookups
Definition: HcalElectronicsId.h:111
HcalElectronicsId::rawId
constexpr uint32_t rawId() const
Definition: HcalElectronicsId.h:59
HcalElectronicsId::crateId
constexpr int crateId() const
get the readout VME crate number
Definition: HcalElectronicsId.h:107
HcalElectronicsId::spigot
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
Definition: HcalElectronicsId.h:93
HcalElectronicsId::dccid
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
Definition: HcalElectronicsId.h:95
HcalElectronicsId::hcalElectronicsId_
uint32_t hcalElectronicsId_
Definition: HcalElectronicsId.h:126
HcalElectronicsId::fiberChanId
constexpr int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
Definition: HcalElectronicsId.h:76
HcalElectronicsId::htrChanId
constexpr int htrChanId() const
get the HTR channel id (1-24)
Definition: HcalElectronicsId.h:87
HcalElectronicsId::operator==
constexpr int operator==(const HcalElectronicsId &id) const
Definition: HcalElectronicsId.h:119
HcalElectronicsId::maxDCCId
static const int maxDCCId
Definition: HcalElectronicsId.h:116
HcalElectronicsId::slbChannelIndex
constexpr int slbChannelIndex() const
get the SLB channel index (valid only for VME trigger-chain ids)
Definition: HcalElectronicsId.h:82
HcalElectronicsId::HcalElectronicsId
constexpr HcalElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb)
Definition: HcalElectronicsId.h:43
HcalElectronicsId::slbChannelCode
std::string slbChannelCode() const
get the HTR-wide slb channel code (letter plus number)
Definition: HcalElectronicsId.cc:3
HcalElectronicsId::operator!=
constexpr int operator!=(const HcalElectronicsId &id) const
Definition: HcalElectronicsId.h:121