1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include "DataFormats/HcalDetId/interface/CastorElectronicsId.h"
CastorElectronicsId::CastorElectronicsId() { castorElectronicsId_ = 0xffffffffu; }
CastorElectronicsId::CastorElectronicsId(uint32_t id) { castorElectronicsId_ = id; }
CastorElectronicsId::CastorElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid) {
castorElectronicsId_ =
(fiberChan & 0x3) | (((fiberIndex - 1) & 0xf) << 2) | ((spigot & 0xF) << 6) | ((dccid & 0xF) << 10);
}
CastorElectronicsId::CastorElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb) {
castorElectronicsId_ = (slbChan & 0x3) | (((slbSite - 1) & 0xf) << 2) | ((spigot & 0xF) << 6) | ((dccid & 0xF) << 10);
castorElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
castorElectronicsId_ |= 0x02000000;
}
std::string CastorElectronicsId::slbChannelCode() const {
std::string retval;
if (isTriggerChainId()) {
if (htrTopBottom()) { // top
switch (slbChannelIndex()) {
case (0):
retval = "A0";
break;
case (1):
retval = "A1";
break;
case (2):
retval = "C0";
break;
case (3):
retval = "C1";
break;
}
} else {
switch (slbChannelIndex()) {
case (0):
retval = "B0";
break;
case (1):
retval = "B1";
break;
case (2):
retval = "D0";
break;
case (3):
retval = "D1";
break;
}
}
}
return retval;
}
void CastorElectronicsId::setHTR(int crate, int slot, int tb) {
castorElectronicsId_ &= 0x3FFF; // keep the readout chain info
castorElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
}
std::ostream& operator<<(std::ostream& os, const CastorElectronicsId& id) {
if (id.isTriggerChainId()) {
return os << id.dccid() << ',' << id.spigot() << ",SLB" << id.slbSiteNumber() << ',' << id.slbChannelIndex()
<< " (HTR " << id.readoutVMECrateId() << ":" << id.htrSlot() << ((id.htrTopBottom() == 1) ? ('t') : ('b'))
<< ')';
} else {
return os << id.dccid() << ',' << id.spigot() << ',' << id.fiberIndex() << ',' << id.fiberChanId() << " (HTR "
<< id.readoutVMECrateId() << ":" << id.htrSlot() << ((id.htrTopBottom() == 1) ? ('t') : ('b')) << ')';
}
}
|