File indexing completed on 2024-04-06 12:07:30
0001 #include "DQM/HcalCommon/interface/ElectronicsQuantity.h"
0002
0003 namespace hcaldqm {
0004 using namespace constants;
0005 namespace quantity {
0006 int getValue_FED(HcalElectronicsId const &eid) {
0007 unsigned int fed = utilities::crate2fed(eid.crateId(), eid.slot());
0008 auto it_fed = std::find(std::begin(fedList), std::end(fedList), fed);
0009 return ((it_fed == std::end(fedList)) ? -1 : std::distance(fedList.begin(), it_fed));
0010 }
0011
0012 int getValue_FEDuTCA(HcalElectronicsId const &eid) {
0013 unsigned int fed = utilities::crate2fed(eid.crateId(), eid.slot());
0014 auto it_fed = std::find(std::begin(fedListuTCA), std::end(fedListuTCA), fed);
0015 return ((it_fed == std::end(fedListuTCA)) ? -1 : std::distance(fedListuTCA.begin(), it_fed));
0016 }
0017
0018 int getValue_FEDVME(HcalElectronicsId const &eid) {
0019 unsigned int fed = utilities::crate2fed(eid.crateId(), eid.slot());
0020 auto it_fed = std::find(std::begin(fedListVME), std::end(fedListVME), fed);
0021 return ((it_fed == std::end(fedListVME)) ? -1 : std::distance(fedListVME.begin(), it_fed));
0022 }
0023
0024 int getValue_Crate(HcalElectronicsId const &eid) {
0025 unsigned int crate = eid.crateId();
0026 auto it_crate = std::find(std::begin(crateList), std::end(crateList), crate);
0027 return ((it_crate == std::end(crateList)) ? -1 : std::distance(crateList.begin(), it_crate));
0028 }
0029
0030 int getValue_CrateuTCA(HcalElectronicsId const &eid) {
0031 unsigned int crate = eid.crateId();
0032 auto it_crate = std::find(std::begin(crateListuTCA), std::end(crateListuTCA), crate);
0033 return ((it_crate == std::end(crateListuTCA)) ? -1 : std::distance(crateListuTCA.begin(), it_crate));
0034 }
0035
0036 int getValue_CrateVME(HcalElectronicsId const &eid) {
0037 unsigned int crate = eid.crateId();
0038 auto it_crate = std::find(std::begin(crateListVME), std::end(crateListVME), crate);
0039 return ((it_crate == std::end(crateListVME)) ? -1 : std::distance(crateListVME.begin(), it_crate));
0040 }
0041
0042 int getValue_SlotuTCA(HcalElectronicsId const &eid) { return eid.slot() - SLOT_uTCA_MIN; }
0043
0044 int getValue_SlotVME(HcalElectronicsId const &eid) {
0045 int slot = eid.slot();
0046 if (slot <= SLOT_VME_MAX1)
0047 slot -= SLOT_VME_MIN1;
0048 else
0049 slot = SLOT_VME_NUM1 + slot - SLOT_VME_MIN2;
0050 return slot;
0051 }
0052
0053 int getValue_Spigot(HcalElectronicsId const &eid) { return eid.spigot(); }
0054
0055 int getValue_FiberuTCA(HcalElectronicsId const &eid) {
0056 int fiber = eid.fiberIndex();
0057 if (fiber <= FIBER_uTCA_MAX1)
0058 fiber -= FIBER_uTCA_MIN1;
0059 else
0060 fiber = (FIBER_uTCA_MAX1 - FIBER_uTCA_MIN1 + 1) + fiber - FIBER_uTCA_MIN2;
0061 return fiber;
0062 }
0063
0064 int getValue_FiberVME(HcalElectronicsId const &eid) { return eid.fiberIndex() - 1; }
0065
0066 int getValue_FiberCh(HcalElectronicsId const &eid) { return eid.fiberChanId(); }
0067
0068 int getValue_FEDuTCASlot(HcalElectronicsId const &eid) {
0069 int ifed = getValue_FEDuTCA(eid);
0070 int islot = getValue_SlotuTCA(eid);
0071 return ifed * SLOT_uTCA_NUM + islot;
0072 }
0073
0074 int getValue_FEDVMESpigot(HcalElectronicsId const &eid) {
0075 int ifed = getValue_FEDVME(eid);
0076 int ispigot = getValue_Spigot(eid);
0077 return ifed * SPIGOT_NUM + ispigot;
0078 }
0079
0080 int getValue_FiberuTCAFiberCh(HcalElectronicsId const &eid) {
0081 int ifiber = getValue_FiberuTCA(eid);
0082 int ifch = getValue_FiberCh(eid);
0083 return ifiber * FIBERCH_NUM + ifch;
0084 }
0085
0086 int getValue_FiberVMEFiberCh(HcalElectronicsId const &eid) {
0087 int ifiber = getValue_FiberVME(eid);
0088 int ifch = getValue_FiberCh(eid);
0089 return ifiber * FIBERCH_NUM + ifch;
0090 }
0091
0092 int getValue_SLB(HcalElectronicsId const &eid) {
0093 int slbsite = eid.slbSiteNumber();
0094 return slbsite - SLB_MIN;
0095 }
0096
0097 int getValue_SLBCh(HcalElectronicsId const &eid) { return eid.slbChannelIndex() - SLBCH_MIN; }
0098
0099 int getValue_SLBSLBCh(HcalElectronicsId const &eid) {
0100 int islb = getValue_SLB(eid);
0101 int islbch = getValue_SLBCh(eid);
0102 return islb * SLBCH_NUM + islbch;
0103 }
0104
0105 int getValue_FiberuTCATP(HcalElectronicsId const &eid) { return eid.fiberIndex() - TPFIBER_MIN; }
0106
0107 int getValue_FiberChuTCATP(HcalElectronicsId const &eid) { return eid.fiberChanId() - TPFIBERCH_MIN; }
0108
0109 int getValue_FiberuTCATPFiberChuTCATP(HcalElectronicsId const &eid) {
0110 int ifib = getValue_FiberuTCATP(eid);
0111 int ifibch = getValue_FiberChuTCATP(eid);
0112 return ifib * TPFIBERCH_NUM + ifibch;
0113 }
0114
0115 uint32_t getBin_FED(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FED(eid) + 1); }
0116
0117 uint32_t getBin_FEDuTCA(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FEDuTCA(eid) + 1); }
0118
0119 uint32_t getBin_FEDVME(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FEDVME(eid) + 1); }
0120
0121 uint32_t getBin_Crate(HcalElectronicsId const &eid) { return (uint32_t)(getValue_Crate(eid) + 1); }
0122
0123 uint32_t getBin_CrateuTCA(HcalElectronicsId const &eid) { return (uint32_t)(getValue_CrateuTCA(eid) + 1); }
0124
0125 uint32_t getBin_CrateVME(HcalElectronicsId const &eid) { return (uint32_t)(getValue_CrateVME(eid) + 1); }
0126
0127 uint32_t getBin_SlotuTCA(HcalElectronicsId const &eid) { return (uint32_t)(getValue_SlotuTCA(eid) + 1); }
0128
0129 uint32_t getBin_SlotVME(HcalElectronicsId const &eid) { return (uint32_t)(getValue_SlotVME(eid) + 1); }
0130
0131 uint32_t getBin_Spigot(HcalElectronicsId const &eid) { return (uint32_t)(getValue_Spigot(eid) + 1); }
0132
0133 uint32_t getBin_FiberuTCA(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FiberuTCA(eid) + 1); }
0134
0135 uint32_t getBin_FiberVME(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FiberVME(eid) + 1); }
0136
0137 uint32_t getBin_FiberCh(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FiberCh(eid) + 1); }
0138
0139 uint32_t getBin_FEDuTCASlot(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FEDuTCASlot(eid) + 1); }
0140
0141 uint32_t getBin_FEDVMESpigot(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FEDVMESpigot(eid) + 1); }
0142
0143 uint32_t getBin_FiberuTCAFiberCh(HcalElectronicsId const &eid) {
0144 return (uint32_t)(getValue_FiberuTCAFiberCh(eid) + 1);
0145 }
0146
0147 uint32_t getBin_FiberVMEFiberCh(HcalElectronicsId const &eid) {
0148 return (uint32_t)(getValue_FiberVMEFiberCh(eid) + 1);
0149 }
0150
0151 uint32_t getBin_SLB(HcalElectronicsId const &eid) { return (uint32_t)(getValue_SLB(eid) + 1); }
0152
0153 uint32_t getBin_SLBCh(HcalElectronicsId const &eid) { return (uint32_t)(getValue_SLBCh(eid) + 1); }
0154
0155 uint32_t getBin_SLBSLBCh(HcalElectronicsId const &eid) { return (uint32_t)(getValue_SLBSLBCh(eid) + 1); }
0156
0157 uint32_t getBin_FiberuTCATP(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FiberuTCATP(eid) + 1); }
0158
0159 uint32_t getBin_FiberChuTCATP(HcalElectronicsId const &eid) { return (uint32_t)(getValue_FiberChuTCATP(eid) + 1); }
0160
0161 uint32_t getBin_FiberuTCATPFiberChuTCATP(HcalElectronicsId const &eid) {
0162 return (uint32_t)(getValue_FiberuTCATPFiberChuTCATP(eid) + 1);
0163 }
0164
0165 HcalElectronicsId getEid_FED(int v) {
0166 return v < FED_VME_NUM ? HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, v)
0167 : HcalElectronicsId(utilities::fed2crate(v - FED_VME_NUM + 1100).first,
0168 utilities::fed2crate(v - FED_VME_NUM + 1100).second,
0169 FIBER_uTCA_MIN1,
0170 FIBERCH_MIN,
0171 false);
0172 }
0173
0174 HcalElectronicsId getEid_FEDVME(int v) { return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, v); }
0175
0176 HcalElectronicsId getEid_FEDuTCA(int v) {
0177 return HcalElectronicsId(utilities::fed2crate(v + 1100).first,
0178 utilities::fed2crate(v - FED_VME_NUM + 1100).second,
0179 FIBER_uTCA_MIN1,
0180 FIBERCH_MIN,
0181 false);
0182 }
0183
0184 HcalElectronicsId getEid_Crate(int v) {
0185 return v < CRATE_VME_NUM
0186 ? HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, v)
0187 : HcalElectronicsId(
0188 v - CRATE_VME_NUM + CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false);
0189 }
0190
0191 HcalElectronicsId getEid_CrateVME(int v) { return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, v); }
0192
0193 HcalElectronicsId getEid_CrateuTCA(int v) {
0194 return HcalElectronicsId(v + CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false);
0195 }
0196
0197 HcalElectronicsId getEid_SlotuTCA(int v) {
0198 return HcalElectronicsId(CRATE_uTCA_MIN, v + SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false);
0199 }
0200
0201
0202 HcalElectronicsId getEid_SlotVME(int v) {
0203 return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN);
0204 }
0205
0206 HcalElectronicsId getEid_Spigot(int v) { return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, v, CRATE_VME_MIN); }
0207
0208 HcalElectronicsId getEid_FiberuTCA(int v) {
0209 return HcalElectronicsId(CRATE_uTCA_MIN,
0210 SLOT_uTCA_MIN,
0211 v < (FIBER_uTCA_MAX1 - FIBER_uTCA_MIN1 + 1)
0212 ? v + FIBER_uTCA_MIN1
0213 : v - (FIBER_uTCA_MAX1 - FIBER_uTCA_MIN1 + 1) + FIBER_uTCA_MIN2,
0214 FIBERCH_MIN,
0215 false);
0216 }
0217
0218 HcalElectronicsId getEid_FiberVME(int v) {
0219 return HcalElectronicsId(FIBERCH_MIN, v + 1, SPIGOT_MIN, CRATE_VME_MIN);
0220 }
0221
0222 HcalElectronicsId getEid_FiberCh(int v) {
0223 return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, v, false);
0224 }
0225
0226 HcalElectronicsId getEid_FEDuTCASlot(int v) {
0227 HcalElectronicsId fedeid = getEid_FEDuTCA(v / SLOT_uTCA_NUM);
0228 HcalElectronicsId sloteid = getEid_SlotuTCA(v % SLOT_uTCA_NUM);
0229 return HcalElectronicsId(fedeid.crateId(), sloteid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false);
0230 }
0231
0232 HcalElectronicsId getEid_FEDVMESpigot(int v) {
0233 HcalElectronicsId fedeid = getEid_FEDVME(v / SPIGOT_NUM);
0234 HcalElectronicsId spid = getEid_Spigot(v % SPIGOT_NUM);
0235 return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, spid.spigot(), fedeid.dccid());
0236 }
0237
0238 HcalElectronicsId getEid_FiberuTCAFiberCh(int v) {
0239 HcalElectronicsId fibereid = getEid_FiberuTCA(v / FIBERCH_NUM);
0240 HcalElectronicsId fcheid = getEid_FiberCh(v % FIBERCH_NUM);
0241 return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, fibereid.fiberIndex(), fcheid.fiberChanId(), false);
0242 }
0243
0244 HcalElectronicsId getEid_FiberVMEFiberCh(int v) {
0245 HcalElectronicsId fibereid = getEid_FiberVME(v / FIBERCH_NUM);
0246 HcalElectronicsId fcheid = getEid_FiberCh(v % FIBERCH_NUM);
0247 return HcalElectronicsId(fcheid.fiberChanId(), fibereid.fiberIndex(), SPIGOT_MIN, CRATE_VME_MIN);
0248 }
0249
0250 HcalElectronicsId getEid_SLB(int v) {
0251 return HcalElectronicsId(SLBCH_MIN, v + SLB_MIN, SPIGOT_MIN, CRATE_VME_MIN, CRATE_VME_MIN, SLOT_VME_MIN1, 0);
0252 }
0253
0254 HcalElectronicsId getEid_SLBCh(int v) {
0255 return HcalElectronicsId(v + SLBCH_MIN, SLB_MIN, SPIGOT_MIN, CRATE_VME_MIN, CRATE_VME_MIN, SLOT_VME_MIN1, 0);
0256 }
0257
0258 HcalElectronicsId getEid_SLBSLBCh(int v) {
0259 HcalElectronicsId slbeid = getEid_SLB(v / SLBCH_NUM);
0260 HcalElectronicsId slbcheid = getEid_SLBCh(v % SLBCH_NUM);
0261 return HcalElectronicsId(slbcheid.slbChannelIndex(),
0262 slbeid.slbSiteNumber(),
0263 SPIGOT_MIN,
0264 CRATE_VME_MIN,
0265 CRATE_VME_MIN,
0266 SLOT_VME_MIN1,
0267 0);
0268 }
0269
0270 HcalElectronicsId getEid_FiberuTCATP(int v) {
0271 return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, v + TPFIBER_MIN, TPFIBERCH_MIN, true);
0272 }
0273
0274 HcalElectronicsId getEid_FiberChuTCATP(int v) {
0275 return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, TPFIBER_MIN, v + TPFIBERCH_MIN, true);
0276 }
0277
0278 HcalElectronicsId getEid_FiberuTCATPFiberChuTCATP(int v) {
0279 HcalElectronicsId fibeid = getEid_FiberuTCATP(v / TPFIBERCH_NUM);
0280 HcalElectronicsId fibcheid = getEid_FiberChuTCATP(v % TPFIBERCH_NUM);
0281 return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, fibeid.fiberIndex(), fibcheid.fiberChanId(), true);
0282 }
0283
0284 std::vector<std::string> getLabels_FED() {
0285 std::vector<std::string> labels;
0286 char name[12];
0287 for (int i = 0; i < FED_TOTAL_NUM; i++) {
0288 HcalElectronicsId eid = getEid_FED(i);
0289 sprintf(name, "%d", eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()));
0290 labels.push_back(std::string(name));
0291 }
0292 return labels;
0293 }
0294
0295 std::vector<std::string> getLabels_FEDuTCA() {
0296 std::vector<std::string> labels;
0297 char name[12];
0298 for (int i = 0; i < FED_uTCA_NUM; i++) {
0299 HcalElectronicsId eid = getEid_FEDuTCA(i);
0300 sprintf(name, "%d", utilities::crate2fed(eid.crateId(), eid.slot()));
0301 labels.push_back(std::string(name));
0302 }
0303 return labels;
0304 }
0305
0306 std::vector<std::string> getLabels_FEDVME() {
0307 std::vector<std::string> labels;
0308 char name[12];
0309 for (int i = 0; i < FED_VME_NUM; i++) {
0310 sprintf(name, "%d", getEid_FEDVME(i).dccid() + 700);
0311 labels.push_back(std::string(name));
0312 }
0313 return labels;
0314 }
0315
0316 std::vector<std::string> getLabels_Crate() {
0317 std::vector<std::string> labels;
0318 char name[10];
0319 for (auto &it_crate : hcaldqm::constants::crateList) {
0320 HcalElectronicsId eid = getEid_Crate(it_crate);
0321 sprintf(name, "%d%c", it_crate, eid.isVMEid() ? 'v' : 'u');
0322 labels.push_back(std::string(name));
0323 }
0324 return labels;
0325 }
0326
0327 std::vector<std::string> getLabels_CrateVME() {
0328 std::vector<std::string> labels;
0329 char name[10];
0330 for (auto &it_crate : hcaldqm::constants::crateListVME) {
0331 sprintf(name, "%dv", it_crate);
0332 labels.push_back(std::string(name));
0333 }
0334 return labels;
0335 }
0336
0337 std::vector<std::string> getLabels_CrateuTCA() {
0338 std::vector<std::string> labels;
0339 char name[10];
0340 for (auto &it_crate : hcaldqm::constants::crateListuTCA) {
0341 sprintf(name, "%du", it_crate);
0342 labels.push_back(std::string(name));
0343 }
0344 return labels;
0345 }
0346
0347 std::vector<std::string> getLabels_SlotuTCA() {
0348 std::vector<std::string> labels;
0349 char name[10];
0350 for (int i = 0; i < SLOT_uTCA_NUM; i++) {
0351 HcalElectronicsId eid = getEid_SlotuTCA(i);
0352 sprintf(name, "%d", eid.slot());
0353 labels.push_back(std::string(name));
0354 }
0355 return labels;
0356 }
0357
0358 std::vector<std::string> getLabels_SlotVME() { return std::vector<std::string>(); }
0359
0360 std::vector<std::string> getLabels_Spigot() {
0361 return std::vector<std::string>();
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373 }
0374
0375 std::vector<std::string> getLabels_FiberuTCA() {
0376 std::vector<std::string> labels;
0377 char name[10];
0378 for (int i = 0; i < FIBER_uTCA_NUM; i++) {
0379 HcalElectronicsId eid = getEid_FiberuTCA(i);
0380 sprintf(name, "%d", eid.fiberIndex());
0381 labels.push_back(std::string(name));
0382 }
0383 return labels;
0384 }
0385
0386 std::vector<std::string> getLabels_FiberVME() {
0387 std::vector<std::string> labels;
0388 char name[10];
0389 for (int i = 0; i < FIBER_VME_NUM; i++) {
0390 HcalElectronicsId eid = getEid_FiberVME(i);
0391 sprintf(name, "%d", eid.fiberIndex());
0392 labels.push_back(std::string(name));
0393 }
0394 return labels;
0395 }
0396
0397 std::vector<std::string> getLabels_FiberCh() {
0398 std::vector<std::string> labels;
0399 char name[10];
0400 for (int i = 0; i < FIBERCH_NUM; i++) {
0401 HcalElectronicsId eid = getEid_FiberCh(i);
0402 sprintf(name, "%d", eid.fiberChanId());
0403 labels.push_back(std::string(name));
0404 }
0405 return labels;
0406 }
0407
0408 std::vector<std::string> getLabels_FEDuTCASlot() {
0409 std::vector<std::string> labels;
0410 char name[10];
0411 for (int i = 0; i < FED_uTCA_NUM; i++)
0412 for (int j = 0; j < SLOT_uTCA_NUM; j++) {
0413 if (j > 0) {
0414 labels.push_back(std::string(""));
0415 continue;
0416 }
0417 HcalElectronicsId eid = getEid_FEDuTCASlot(i * SLOT_uTCA_NUM + j);
0418 sprintf(name, "%d-%d", utilities::crate2fed(eid.crateId(), eid.slot()), eid.slot());
0419 labels.push_back(std::string(name));
0420 }
0421 return labels;
0422 }
0423
0424 std::vector<std::string> getLabels_FEDVMESpigot() {
0425 std::vector<std::string> labels;
0426 char name[23];
0427 for (int i = 0; i < FED_VME_NUM; i++)
0428 for (int j = 0; j < SPIGOT_NUM; j++) {
0429 if (j > 0) {
0430 labels.push_back(std::string(""));
0431 continue;
0432 }
0433
0434 HcalElectronicsId eid = getEid_FEDVMESpigot(i * SPIGOT_NUM + j);
0435 sprintf(name, "%d-%d", eid.dccid() + FED_VME_MIN, eid.spigot());
0436 labels.push_back(std::string(name));
0437 }
0438 return labels;
0439 }
0440
0441 std::vector<std::string> getLabels_FiberuTCAFiberCh() {
0442 std::vector<std::string> labels;
0443 char name[23];
0444 for (int i = 0; i < FIBER_uTCA_NUM; i++)
0445 for (int j = 0; j < FIBERCH_NUM; j++) {
0446 if (j > 0) {
0447 labels.push_back(std::string(""));
0448 continue;
0449 }
0450
0451 HcalElectronicsId eid = getEid_FiberuTCAFiberCh(i * FIBERCH_NUM + j);
0452 sprintf(name, "%d-%d", eid.fiberIndex(), eid.fiberChanId());
0453 labels.push_back(std::string(name));
0454 }
0455 return labels;
0456 }
0457
0458 std::vector<std::string> getLabels_FiberVMEFiberCh() {
0459 std::vector<std::string> labels;
0460 char name[23];
0461 for (int i = 0; i < FIBER_VME_NUM; i++)
0462 for (int j = 0; j < FIBERCH_NUM; j++) {
0463 if (j > 0) {
0464 labels.push_back(std::string(""));
0465 continue;
0466 }
0467 HcalElectronicsId eid = getEid_FiberVMEFiberCh(i * FIBERCH_NUM + j);
0468 sprintf(name, "%d-%d", eid.fiberIndex(), eid.fiberChanId());
0469 labels.push_back(std::string(name));
0470 }
0471 return labels;
0472 }
0473
0474 std::vector<std::string> getLabels_SLB() {
0475 std::vector<std::string> labels;
0476 char name[23];
0477 for (int i = 0; i < SLB_NUM; i++) {
0478 HcalElectronicsId eid = getEid_SLB(i);
0479 sprintf(name, "%d", eid.slbSiteNumber());
0480 labels.push_back(std::string(name));
0481 }
0482
0483 return labels;
0484 }
0485
0486 std::vector<std::string> getLabels_SLBCh() {
0487 std::vector<std::string> labels;
0488 char name[23];
0489 for (int i = 0; i < SLBCH_NUM; i++) {
0490 HcalElectronicsId eid = getEid_SLBCh(i);
0491 sprintf(name, "%d", eid.slbChannelIndex());
0492 labels.push_back(std::string(name));
0493 }
0494
0495 return labels;
0496 }
0497
0498 std::vector<std::string> getLabels_SLBSLBCh() {
0499 std::vector<std::string> labels;
0500 char name[23];
0501 for (int i = 0; i < SLB_NUM; i++)
0502 for (int j = 0; j < SLBCH_NUM; j++) {
0503 HcalElectronicsId eid = getEid_SLBSLBCh(i * SLBCH_NUM + j);
0504 sprintf(name, "%d-%d", eid.slbSiteNumber(), eid.slbChannelIndex());
0505 labels.push_back(std::string(name));
0506 }
0507
0508 return labels;
0509 }
0510
0511 std::vector<std::string> getLabels_FiberuTCATP() {
0512 std::vector<std::string> labels;
0513 char name[23];
0514 for (int i = 0; i < TPFIBER_NUM; i++) {
0515 HcalElectronicsId eid = getEid_FiberuTCATP(i);
0516 sprintf(name, "%d", eid.fiberIndex());
0517 labels.push_back(std::string(name));
0518 }
0519
0520 return labels;
0521 }
0522
0523 std::vector<std::string> getLabels_FiberChuTCATP() {
0524 std::vector<std::string> labels;
0525 char name[23];
0526 for (int i = 0; i < TPFIBERCH_NUM; i++) {
0527 HcalElectronicsId eid = getEid_FiberChuTCATP(i);
0528 sprintf(name, "%d", eid.fiberChanId());
0529 labels.push_back(std::string(name));
0530 }
0531
0532 return labels;
0533 }
0534
0535 std::vector<std::string> getLabels_FiberuTCATPFiberChuTCATP() {
0536 std::vector<std::string> labels;
0537 char name[10];
0538 for (int i = 0; i < TPFIBER_NUM; i++)
0539 for (int j = 0; j < TPFIBERCH_NUM; j++) {
0540 HcalElectronicsId eid = getEid_FiberuTCATPFiberChuTCATP(i * TPFIBERCH_NUM + j);
0541 sprintf(name, "%d-%d", eid.fiberIndex(), eid.fiberChanId());
0542 labels.push_back(std::string(name));
0543 }
0544
0545 return labels;
0546 }
0547
0548 void FEDQuantity::setup(std::vector<int> const &vFEDs) {
0549 for (uint32_t i = 0; i < vFEDs.size(); i++)
0550 _feds.insert(std::make_pair(vFEDs[i], i));
0551 }
0552
0553 int FEDQuantity::getValue(HcalElectronicsId const &eid) {
0554 int fed = eid.isVMEid() ? eid.dccid() + FED_VME_MIN : utilities::crate2fed(eid.crateId(), eid.slot());
0555 return _feds[fed];
0556 }
0557
0558 uint32_t FEDQuantity::getBin(HcalElectronicsId const &eid) { return getValue(eid) + 1; }
0559
0560 std::vector<std::string> FEDQuantity::getLabels() {
0561 std::vector<std::string> labels(_feds.size());
0562 char name[5];
0563 for (auto const &v : _feds) {
0564 sprintf(name, "%d", v.first);
0565 labels[v.second] = std::string(name);
0566 }
0567
0568 return labels;
0569 }
0570
0571 void CrateQuantity::setup(HcalElectronicsMap const *emap) {
0572 _crates = utilities::getCrateList(emap);
0573 _crateHashes = utilities::getCrateHashMap(emap);
0574 }
0575
0576 void CrateQuantity::setup(std::vector<int> crates, std::map<int, uint32_t> crateHashes) {
0577 for (auto &it_crate : crates) {
0578 _crates.push_back(it_crate);
0579 _crateHashes[it_crate] = crateHashes[it_crate];
0580 }
0581 }
0582
0583 int CrateQuantity::getValue(HcalElectronicsId const &eid) { return eid.crateId(); }
0584
0585 uint32_t CrateQuantity::getBin(HcalElectronicsId const &eid) {
0586 int crate = eid.crateId();
0587 auto it = std::find(_crates.begin(), _crates.end(), crate);
0588 if (it == _crates.end()) {
0589 return 0;
0590 } else {
0591 return std::distance(_crates.begin(), it) + 1;
0592 }
0593 }
0594
0595 std::vector<std::string> CrateQuantity::getLabels() {
0596 std::vector<std::string> labels;
0597 char name[5];
0598 for (auto &it_crate : _crates) {
0599 HcalElectronicsId eid(_crateHashes[it_crate]);
0600 if (eid.isVMEid()) {
0601 sprintf(name, "%dv", it_crate);
0602 } else {
0603 sprintf(name, "%du", it_crate);
0604 }
0605 labels.push_back(name);
0606 }
0607 return labels;
0608 }
0609
0610 }
0611 }