File indexing completed on 2024-04-06 12:04:17
0001 #include "DataFormats/HcalDetId/interface/CastorElectronicsId.h"
0002
0003 CastorElectronicsId::CastorElectronicsId() { castorElectronicsId_ = 0xffffffffu; }
0004
0005 CastorElectronicsId::CastorElectronicsId(uint32_t id) { castorElectronicsId_ = id; }
0006
0007 CastorElectronicsId::CastorElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid) {
0008 castorElectronicsId_ =
0009 (fiberChan & 0x3) | (((fiberIndex - 1) & 0xf) << 2) | ((spigot & 0xF) << 6) | ((dccid & 0xF) << 10);
0010 }
0011
0012 CastorElectronicsId::CastorElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb) {
0013 castorElectronicsId_ = (slbChan & 0x3) | (((slbSite - 1) & 0xf) << 2) | ((spigot & 0xF) << 6) | ((dccid & 0xF) << 10);
0014 castorElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
0015 castorElectronicsId_ |= 0x02000000;
0016 }
0017
0018 std::string CastorElectronicsId::slbChannelCode() const {
0019 std::string retval;
0020 if (isTriggerChainId()) {
0021 if (htrTopBottom()) {
0022 switch (slbChannelIndex()) {
0023 case (0):
0024 retval = "A0";
0025 break;
0026 case (1):
0027 retval = "A1";
0028 break;
0029 case (2):
0030 retval = "C0";
0031 break;
0032 case (3):
0033 retval = "C1";
0034 break;
0035 }
0036 } else {
0037 switch (slbChannelIndex()) {
0038 case (0):
0039 retval = "B0";
0040 break;
0041 case (1):
0042 retval = "B1";
0043 break;
0044 case (2):
0045 retval = "D0";
0046 break;
0047 case (3):
0048 retval = "D1";
0049 break;
0050 }
0051 }
0052 }
0053 return retval;
0054 }
0055
0056 void CastorElectronicsId::setHTR(int crate, int slot, int tb) {
0057 castorElectronicsId_ &= 0x3FFF;
0058 castorElectronicsId_ |= ((tb & 0x1) << 19) | ((slot & 0x1f) << 14) | ((crate & 0x3f) << 20);
0059 }
0060
0061 std::ostream& operator<<(std::ostream& os, const CastorElectronicsId& id) {
0062 if (id.isTriggerChainId()) {
0063 return os << id.dccid() << ',' << id.spigot() << ",SLB" << id.slbSiteNumber() << ',' << id.slbChannelIndex()
0064 << " (HTR " << id.readoutVMECrateId() << ":" << id.htrSlot() << ((id.htrTopBottom() == 1) ? ('t') : ('b'))
0065 << ')';
0066
0067 } else {
0068 return os << id.dccid() << ',' << id.spigot() << ',' << id.fiberIndex() << ',' << id.fiberChanId() << " (HTR "
0069 << id.readoutVMECrateId() << ":" << id.htrSlot() << ((id.htrTopBottom() == 1) ? ('t') : ('b')) << ')';
0070 }
0071 }