File indexing completed on 2024-04-06 12:02:16
0001 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0002 #include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
0003 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0004
0005 #include "CondFormats/HcalObjects/interface/HcalMappingEntry.h"
0006
0007 #include <iostream>
0008 #include <fstream>
0009 #include <sstream>
0010 #include <cstdio>
0011 #include <string>
0012 #include <cstring>
0013
0014 using namespace std;
0015
0016
0017
0018 HBHEHFLogicalMapEntry::HBHEHFLogicalMapEntry(int in_fi_ch,
0019 int in_htr_fi,
0020 int in_spig,
0021 int in_fed,
0022 int in_cr,
0023 int in_htr,
0024 std::string in_s_fpga,
0025 std::string in_s_det,
0026 int in_sid,
0027 int in_et,
0028 int in_ph,
0029 int in_dep,
0030 int in_dph,
0031 int in_wed,
0032 int in_rm,
0033 int in_rm_fi,
0034 int in_pix,
0035 int in_qie,
0036 int in_adc,
0037 int in_slb,
0038 int in_rctcra,
0039 int in_rctcar,
0040 int in_rctcon,
0041 std::string in_s_rbx,
0042 std::string in_s_slb,
0043 std::string in_s_slb2,
0044 std::string in_s_slnam,
0045 std::string in_s_rctnam) {
0046 int mytopbot;
0047 (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
0048
0049 mydphi_ = in_dph;
0050 mywedge_ = in_wed;
0051 myslb_ = in_slb;
0052 myrctcra_ = in_rctcra;
0053 myrctcar_ = in_rctcar;
0054 myrctcon_ = in_rctcon;
0055
0056
0057 myslbin_ = in_s_slb;
0058 myslbin2_ = in_s_slb2;
0059 myslnam_ = in_s_slnam;
0060 myrctnam_ = in_s_rctnam;
0061
0062
0063 HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spig, in_fed - 700);
0064 heid.setHTR(in_cr, in_htr, mytopbot);
0065
0066 HcalSubdetector mysubdet = HcalEmpty;
0067 if (in_s_det == "HB")
0068 mysubdet = HcalBarrel;
0069 else if (in_s_det == "HE")
0070 mysubdet = HcalEndcap;
0071 else if (in_s_det == "HF")
0072 mysubdet = HcalForward;
0073
0074 HcalDetId hdid(mysubdet, in_sid * in_et, in_ph, in_dep);
0075
0076 HcalFrontEndId hrbx(in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc);
0077
0078
0079 hcalEID_ = heid.rawId();
0080 hcalDetID_ = hdid.rawId();
0081 hcalFrontEndID_ = hrbx.rawId();
0082 }
0083
0084 char* HBHEHFLogicalMapEntry::printLMapLine() {
0085 static char myline[512];
0086
0087 HcalElectronicsId hcaleid(hcalEID_);
0088 HcalDetId hcaldid(hcalDetID_);
0089 HcalGenericDetId hcalgenid(hcalDetID_);
0090 HcalFrontEndId rbxid(hcalFrontEndID_);
0091
0092 int mydcc_sl = 0;
0093 int mydcc = 0;
0094 if ((hcaleid.dccid() % 2) == 1) {
0095 mydcc_sl = 20;
0096 mydcc = 2;
0097 } else {
0098 mydcc_sl = 10;
0099 mydcc = 1;
0100 }
0101
0102 string myfpga = "";
0103 string mydet = "";
0104 HcalSubdetector mysubdet = hcaldid.subdet();
0105 (mysubdet == 1)
0106 ? mydet = "HB"
0107 : ((mysubdet == 2) ? mydet = "HE"
0108 : ((mysubdet == 3) ? mydet = "HO" : ((mysubdet == 4) ? mydet = "HF" : mydet = "invalid")));
0109
0110 (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
0111
0112 sprintf(myline,
0113 "%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",
0114 0,
0115 hcaldid.zside(),
0116 hcaldid.ietaAbs(),
0117 hcaldid.iphi(),
0118 mydphi_,
0119 hcaldid.depth(),
0120 mydet.c_str(),
0121 rbxid.rbx().c_str(),
0122 mywedge_,
0123 rbxid.rm(),
0124 rbxid.pixel());
0125 sprintf(myline + strlen(myline),
0126 "%6d %6d %6d %6d %6d %6d %6s",
0127 rbxid.qieCard(),
0128 rbxid.adc(),
0129 rbxid.rmFiber(),
0130 hcaleid.fiberChanId(),
0131 hcaleid.readoutVMECrateId(),
0132 hcaleid.htrSlot(),
0133 myfpga.c_str());
0134 sprintf(myline + strlen(myline),
0135 "%8d %7d %6d %6d %6d %6s",
0136 hcaleid.fiberIndex(),
0137 mydcc_sl,
0138 hcaleid.spigot(),
0139 mydcc,
0140 myslb_,
0141 myslbin_.c_str());
0142 sprintf(myline + strlen(myline),
0143 "%8s %15s %6d %6d %6d %20s %6d\n",
0144 myslbin2_.c_str(),
0145 myslnam_.c_str(),
0146 myrctcra_,
0147 myrctcar_,
0148 myrctcon_,
0149 myrctnam_.c_str(),
0150 hcaleid.dccid() + 700);
0151
0152 return myline;
0153 }
0154
0155
0156
0157 HOHXLogicalMapEntry::HOHXLogicalMapEntry(int in_fi_ch,
0158 int in_htr_fi,
0159 int in_spig,
0160 int in_fed,
0161 int in_cr,
0162 int in_htr,
0163 std::string in_s_fpga,
0164 std::string in_s_det,
0165 int in_sid,
0166 int in_et,
0167 int in_ph,
0168 int in_dep,
0169 int in_dph,
0170 int in_sec,
0171 int in_rm,
0172 int in_rm_fi,
0173 int in_pix,
0174 int in_qie,
0175 int in_adc,
0176 std::string in_s_rbx,
0177 std::string in_s_let) {
0178 int mytopbot;
0179 (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
0180
0181 mydphi_ = in_dph;
0182 mysector_ = in_sec;
0183
0184 myletter_ = in_s_let;
0185
0186
0187 HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spig, in_fed - 700);
0188 heid.setHTR(in_cr, in_htr, mytopbot);
0189
0190 if (in_s_det == "HO") {
0191
0192 HcalDetId hdid(HcalOuter, in_sid * in_et, in_ph, in_dep);
0193 hcalDetID_ = hdid.rawId();
0194 } else {
0195
0196 HcalCalibDetId hdid(in_sid * in_et, in_ph);
0197 hcalDetID_ = hdid.rawId();
0198 }
0199
0200 HcalFrontEndId hrbx(in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc);
0201
0202
0203 hcalEID_ = heid.rawId();
0204 hcalFrontEndID_ = hrbx.rawId();
0205 }
0206
0207 char* HOHXLogicalMapEntry::printLMapLine() {
0208 static char myline[512];
0209
0210 HcalElectronicsId hcaleid(hcalEID_);
0211 HcalGenericDetId hcalgenid(hcalDetID_);
0212 HcalFrontEndId rbxid(hcalFrontEndID_);
0213
0214 int mydcc_sl = 0;
0215 int mydcc = 0;
0216 if ((hcaleid.dccid() % 2) == 1) {
0217 mydcc_sl = 20;
0218 mydcc = 2;
0219 } else {
0220 mydcc_sl = 10;
0221 mydcc = 1;
0222 }
0223
0224 string myfpga = "";
0225 string mydet = "";
0226 int mydepth = 0;
0227 int myside = -2;
0228 int myeta = 0;
0229 int myphi = -1;
0230 if (hcalgenid.isHcalCalibDetId()) {
0231 HcalCalibDetId hcalcompid(hcalDetID_);
0232 mydet = "HOX";
0233 mydepth = 4;
0234 myside = hcalcompid.zside();
0235 myeta = hcalcompid.ieta() * myside;
0236 myphi = hcalcompid.iphi();
0237 } else if (hcalgenid.isHcalDetId()) {
0238 HcalDetId hcalcompid(hcalDetID_);
0239 HcalSubdetector mysubdet = hcalcompid.subdet();
0240 (mysubdet == HcalBarrel)
0241 ? mydet = "HB"
0242 : ((mysubdet == HcalEndcap)
0243 ? mydet = "HE"
0244 : ((mysubdet == HcalOuter) ? mydet = "HO"
0245 : ((mysubdet == HcalForward) ? mydet = "HF" : mydet = "invalid")));
0246 mydepth = hcalcompid.depth();
0247 myside = hcalcompid.zside();
0248 myeta = hcalcompid.ietaAbs();
0249 myphi = hcalcompid.iphi();
0250 }
0251
0252 (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
0253
0254 sprintf(myline,
0255 "%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",
0256 0,
0257 myside,
0258 myeta,
0259 myphi,
0260 mydphi_,
0261 mydepth,
0262 mydet.c_str(),
0263 rbxid.rbx().c_str(),
0264 mysector_,
0265 rbxid.rm(),
0266 rbxid.pixel());
0267 sprintf(myline + strlen(myline),
0268 "%6d %6d %6d %6d %8s %6d %6d %6s",
0269 rbxid.qieCard(),
0270 rbxid.adc(),
0271 rbxid.rmFiber(),
0272 hcaleid.fiberChanId(),
0273 myletter_.c_str(),
0274 hcaleid.readoutVMECrateId(),
0275 hcaleid.htrSlot(),
0276 myfpga.c_str());
0277 sprintf(myline + strlen(myline),
0278 "%8d %7d %6d %6d %6d\n",
0279 hcaleid.fiberIndex(),
0280 mydcc_sl,
0281 hcaleid.spigot(),
0282 mydcc,
0283 hcaleid.dccid() + 700);
0284
0285 return myline;
0286 }
0287
0288
0289
0290 CALIBLogicalMapEntry::CALIBLogicalMapEntry(int in_fi_ch,
0291 int in_htr_fi,
0292 int in_spig,
0293 int in_fed,
0294 int in_cr,
0295 int in_htr,
0296 std::string in_s_fpga,
0297 std::string in_s_det,
0298 int in_et,
0299 int in_ph,
0300 int in_ch_ty,
0301 int in_sid,
0302 int in_dph,
0303 std::string in_s_rbx,
0304 int in_wed,
0305 int in_rm_fi,
0306 std::string in_s_subdet) {
0307 int mytopbot;
0308 (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
0309
0310 myside_ = in_sid;
0311 mydphi_ = in_dph;
0312 mywedge_ = in_wed;
0313
0314 mycalibsubdet_ = in_s_subdet;
0315
0316
0317 HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spig, in_fed - 700);
0318 heid.setHTR(in_cr, in_htr, mytopbot);
0319
0320
0321 HcalSubdetector mysubdet = HcalEmpty;
0322 if (in_s_det == "HB")
0323 mysubdet = HcalBarrel;
0324 else if (in_s_det == "HE")
0325 mysubdet = HcalEndcap;
0326 else if (in_s_det == "HO")
0327 mysubdet = HcalOuter;
0328 else if (in_s_det == "HF")
0329 mysubdet = HcalForward;
0330
0331 HcalCalibDetId hcalibdid(mysubdet, in_et, in_ph, in_ch_ty);
0332
0333 int in_rm, in_pix, in_qie, in_adc;
0334
0335 if (in_s_det == "HF")
0336 in_rm = 4;
0337 else
0338 in_rm = 5;
0339
0340 in_pix = 0;
0341 in_qie = 1;
0342 in_adc = in_fi_ch + (3 * (in_rm_fi - 1));
0343
0344 HcalFrontEndId hrbx(in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc);
0345
0346
0347 hcalEID_ = heid.rawId();
0348 hcalCalibDetID_ = hcalibdid.rawId();
0349 hcalFrontEndID_ = hrbx.rawId();
0350 }
0351
0352 char* CALIBLogicalMapEntry::printLMapLine() {
0353 static char myline[512];
0354
0355 HcalElectronicsId hcaleid(hcalEID_);
0356 HcalCalibDetId hcalcalibid(hcalCalibDetID_);
0357 HcalGenericDetId hcalgenid(hcalCalibDetID_);
0358 HcalFrontEndId rbxid(hcalFrontEndID_);
0359
0360 int mydcc_sl = 0;
0361 int mydcc = 0;
0362 if ((hcaleid.dccid() % 2) == 1) {
0363 mydcc_sl = 20;
0364 mydcc = 2;
0365 } else {
0366 mydcc_sl = 10;
0367 mydcc = 1;
0368 }
0369
0370 string myfpga = "";
0371 string mydet = "";
0372 HcalSubdetector mysubdet = hcalcalibid.hcalSubdet();
0373 (mysubdet == HcalBarrel)
0374 ? mydet = "HB"
0375 : ((mysubdet == HcalEndcap)
0376 ? mydet = "HE"
0377 : ((mysubdet == HcalOuter) ? mydet = "HO"
0378 : ((mysubdet == HcalForward) ? mydet = "HF" : mydet = "invalid")));
0379 (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
0380
0381 sprintf(myline,
0382 "%1d %6d %6d %6d %6d %6s %7s",
0383 0,
0384 myside_,
0385 hcalcalibid.ieta(),
0386 hcalcalibid.iphi(),
0387 mydphi_,
0388 mydet.c_str(),
0389 rbxid.rbx().c_str());
0390 sprintf(myline + strlen(myline),
0391 "%8d %6d %6d %6d %6d %4d %5s",
0392 mywedge_,
0393 rbxid.rm(),
0394 rbxid.rmFiber(),
0395 hcaleid.fiberChanId(),
0396 hcaleid.readoutVMECrateId(),
0397 hcaleid.htrSlot(),
0398 myfpga.c_str());
0399 sprintf(myline + strlen(myline),
0400 "%8d %7d %6d %4d %6d %8d %9s\n",
0401 hcaleid.fiberIndex(),
0402 mydcc_sl,
0403 hcaleid.spigot(),
0404 mydcc,
0405 hcaleid.dccid() + 700,
0406 hcalcalibid.cboxChannel(),
0407 mycalibsubdet_.c_str());
0408
0409 return myline;
0410 }
0411
0412
0413
0414 ZDCLogicalMapEntry::ZDCLogicalMapEntry(int in_fi_ch,
0415 int in_htr_fi,
0416 int in_spigot,
0417 int in_fed,
0418 int in_cr,
0419 int in_htr,
0420 std::string in_s_fpga,
0421 std::string in_s_det,
0422 int in_sid,
0423 int in_dep,
0424 int in_x,
0425 int in_y,
0426 int in_dx,
0427 int in_det_ch,
0428 int in_cab,
0429 int in_rm,
0430 int in_qie,
0431 int in_adc,
0432 int in_rm_fi) {
0433 int mytopbot;
0434 (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
0435
0436 myx_ = in_x;
0437 myy_ = in_y;
0438 mydx_ = in_dx;
0439 mycable_ = in_cab;
0440 myrm_ = in_rm;
0441 myqie_ = in_qie;
0442 myadc_ = in_adc;
0443 myrm_fi_ = in_rm_fi;
0444
0445
0446 HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spigot, in_fed - 700);
0447 heid.setHTR(in_cr, in_htr, mytopbot);
0448
0449
0450 bool myzdccheck;
0451 HcalZDCDetId::Section myzdcsec;
0452 if (in_s_det == "ZDC_EM")
0453 myzdcsec = HcalZDCDetId::EM;
0454 else if (in_s_det == "ZDC_HAD")
0455 myzdcsec = HcalZDCDetId::HAD;
0456 else if (in_s_det == "ZDC_LUM")
0457 myzdcsec = HcalZDCDetId::LUM;
0458 else if (in_s_det == "ZDC_RPD")
0459 myzdcsec = HcalZDCDetId::RPD;
0460 else
0461 myzdcsec = HcalZDCDetId::Unknown;
0462
0463 (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
0464 HcalZDCDetId hzdcdid(myzdcsec, myzdccheck, in_det_ch);
0465
0466
0467 hcalEID_ = heid.rawId();
0468 hcalZDCDetID_ = hzdcdid.rawId();
0469 }
0470
0471 char* ZDCLogicalMapEntry::printLMapLine() {
0472 static char myline[512];
0473
0474 HcalElectronicsId hcaleid(hcalEID_);
0475 HcalZDCDetId hcalzdcid(hcalZDCDetID_);
0476 HcalGenericDetId hcalgenid(hcalZDCDetID_);
0477
0478 int mydcc_sl = -1;
0479 int mydcc = -1;
0480 if ((hcaleid.dccid() % 2) == 1) {
0481 mydcc_sl = 20;
0482 mydcc = 2;
0483 } else {
0484 mydcc_sl = 10;
0485 mydcc = 1;
0486 }
0487
0488 string myfpga = "";
0489 string mydet = "ZDC_";
0490 HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
0491
0492 if (myzdcsec == 0)
0493 mydet += "Unknown";
0494 else if (myzdcsec == 1)
0495 mydet += "EM";
0496 else if (myzdcsec == 2)
0497 mydet += "HAD";
0498 else if (myzdcsec == 3)
0499 mydet += "LUM";
0500 else
0501 mydet += "RPD";
0502
0503 (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
0504
0505 sprintf(myline,
0506 "%1d %5d %2d %2d %3d %6d %7s %7d",
0507 0,
0508 hcalzdcid.zside(),
0509 myx_,
0510 myy_,
0511 mydx_,
0512 hcalzdcid.depth(),
0513 mydet.c_str(),
0514 hcalzdcid.channel());
0515 sprintf(myline + strlen(myline),
0516 "%7d %3d %4d %4d %6d %6d %6d",
0517 mycable_,
0518 myrm_,
0519 myqie_,
0520 myadc_,
0521 myrm_fi_,
0522 hcaleid.fiberChanId(),
0523 hcaleid.readoutVMECrateId());
0524 sprintf(myline + strlen(myline),
0525 "%5d %5s %7d %7d %6d %4d %6d\n",
0526 hcaleid.htrSlot(),
0527 myfpga.c_str(),
0528 hcaleid.fiberIndex(),
0529 mydcc_sl,
0530 hcaleid.spigot(),
0531 mydcc,
0532 hcaleid.dccid() + 700);
0533
0534 return myline;
0535 }
0536
0537
0538
0539 HTLogicalMapEntry::HTLogicalMapEntry(int in_et,
0540 int in_ph,
0541 int in_sid,
0542 int in_dph,
0543 int in_dep,
0544 std::string in_s_chDet,
0545 int in_wed,
0546 int in_cr,
0547 int in_htr,
0548 int in_tb,
0549 int in_spig,
0550 int in_slb,
0551 std::string in_s_slb,
0552 std::string in_s_slb2,
0553 int in_ndat,
0554 std::string in_s_slnam,
0555 int in_rctcra,
0556 int in_rctcar,
0557 int in_rctcon,
0558 std::string in_s_rctnam,
0559 int in_fed) {
0560 myside_ = in_sid;
0561 mydphi_ = in_dph;
0562 mydepth_ = in_dep;
0563 mywedge_ = in_wed;
0564 myrctcra_ = in_rctcra;
0565 myrctcar_ = in_rctcar;
0566 myrctcon_ = in_rctcon;
0567
0568
0569 mydet_ = in_s_chDet;
0570 myslbin_ = in_s_slb;
0571 myslbin2_ = in_s_slb2;
0572 myslnam_ = in_s_slnam;
0573 myrctnam_ = in_s_rctnam;
0574
0575
0576 int top = 1;
0577 in_tb == 1 ? top = 0 : top = 1;
0578
0579 HcalElectronicsId hteid(in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top);
0580
0581
0582
0583 HcalTrigTowerDetId htrigdid(in_et, in_ph);
0584
0585
0586 hcalTrigEID_ = hteid.rawId();
0587 hcalTrigDetID_ = htrigdid.rawId();
0588 }
0589
0590 char* HTLogicalMapEntry::printLMapLine() {
0591 static char myline[512];
0592 HcalElectronicsId hcaltrigeid(hcalTrigEID_);
0593 HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
0594 HcalGenericDetId hcalgenid(hcalTrigDetID_);
0595
0596 int mydcc_sl = 0;
0597 int mydcc = 0;
0598 if ((hcaltrigeid.dccid() % 2) == 1) {
0599 mydcc_sl = 20;
0600 mydcc = 2;
0601 } else {
0602 mydcc_sl = 10;
0603 mydcc = 1;
0604 }
0605
0606 string myfpga = "";
0607 (hcaltrigeid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
0608
0609 sprintf(myline,
0610 "%1d %5d %4d %4d %5d %6d %4s %7d %6d ",
0611 0,
0612 myside_,
0613 hcaltrigid.ieta(),
0614 hcaltrigid.iphi(),
0615 mydphi_,
0616 mydepth_,
0617 mydet_.c_str(),
0618 mywedge_,
0619 hcaltrigeid.readoutVMECrateId());
0620 sprintf(myline + strlen(myline),
0621 "%4d %5s %7d %6d %4d %4d %6s %7s %5d ",
0622 hcaltrigeid.htrSlot(),
0623 myfpga.c_str(),
0624 mydcc_sl,
0625 hcaltrigeid.spigot(),
0626 mydcc,
0627 hcaltrigeid.slbSiteNumber(),
0628 myslbin_.c_str(),
0629 myslbin2_.c_str(),
0630 hcaltrigeid.slbChannelIndex());
0631 sprintf(myline + strlen(myline),
0632 "%13s %7d %7d %7d %17s %6d\n",
0633 myslnam_.c_str(),
0634 myrctcra_,
0635 myrctcar_,
0636 myrctcon_,
0637 myrctnam_.c_str(),
0638 hcaltrigeid.dccid() + 700);
0639
0640 return myline;
0641 }