Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-16 01:19:30

0001 #include "DQM/HcalCommon/interface/HashFunctions.h"
0002 #include "DQM/HcalCommon/interface/Utilities.h"
0003 
0004 namespace hcaldqm {
0005   using namespace constants;
0006   namespace hashfunctions {
0007     /**
0008  *  HcalDetId
0009  */
0010     uint32_t hash_Subdet(HcalDetId const &did) { return utilities::hash(HcalDetId(did.subdet(), 1, 1, 1)); }
0011 
0012     uint32_t hash_Subdetiphi(HcalDetId const &did) {
0013       return utilities::hash(HcalDetId(did.subdet(), 1, did.iphi(), 1));
0014     }
0015 
0016     uint32_t hash_Subdetieta(HcalDetId const &did) {
0017       return utilities::hash(HcalDetId(did.subdet(), did.ieta(), 1, 1));
0018     }
0019 
0020     uint32_t hash_Subdetdepth(HcalDetId const &did) {
0021       return utilities::hash(HcalDetId(did.subdet(), 1, 1, did.depth()));
0022     }
0023 
0024     uint32_t hash_SubdetPM(HcalDetId const &did) {
0025       return utilities::hash(HcalDetId(did.subdet(), did.ieta() > 0 ? 1 : -1, 1, 1));
0026     }
0027 
0028     uint32_t hash_SubdetPMiphi(HcalDetId const &did) {
0029       return utilities::hash(HcalDetId(did.subdet(), did.ieta() > 0 ? 1 : -1, did.iphi(), 1));
0030     }
0031 
0032     uint32_t hash_iphi(HcalDetId const &did) { return utilities::hash(HcalDetId(HcalBarrel, 1, did.iphi(), 1)); }
0033 
0034     uint32_t hash_ieta(HcalDetId const &did) { return utilities::hash(HcalDetId(HcalBarrel, did.ieta(), 1, 1)); }
0035 
0036     uint32_t hash_depth(HcalDetId const &did) {
0037       if (did.subdet() == HcalOuter)
0038         return 9;  // key of map, can be any uint32_t valure that is not a raw hcal detid
0039       else
0040         return utilities::hash(HcalDetId(HcalBarrel, 1, 1, did.depth()));
0041     }
0042 
0043     uint32_t hash_HFPMiphi(HcalDetId const &did) {
0044       return utilities::hash(HcalDetId(HcalForward, did.ieta() > 0 ? 1 : -1, did.iphi(), 1));
0045     }
0046 
0047     uint32_t hash_HBHEPartition(HcalDetId const &did) {
0048       int iphi = did.iphi();
0049       uint32_t hash = 0;
0050       if (iphi >= 3 && iphi <= 26)
0051         hash = utilities::hash(HcalDetId(HcalBarrel, 1, 3, 1));
0052       else if (iphi >= 27 && iphi <= 50)
0053         hash = utilities::hash(HcalDetId(HcalBarrel, 1, 27, 1));
0054       else
0055         hash = utilities::hash(HcalDetId(HcalBarrel, 1, 1, 1));
0056 
0057       return hash;
0058     }
0059 
0060     uint32_t hash_DChannel(HcalDetId const &did) { return utilities::hash(did); }
0061 
0062     std::string name_Subdet(HcalDetId const &did) { return constants::SUBDET_NAME[did.subdet() - 1]; }
0063 
0064     uint32_t hash_Subdet(std::string const &name) {
0065       for (int i = 0; i < constants::SUBDET_NUM; i++)
0066         if (constants::SUBDET_NAME[i] == name)
0067           return (HcalDetId((HcalSubdetector)(i + 1), 1, 1, 1).rawId());
0068 
0069       return HcalDetId().rawId();
0070     }
0071 
0072     std::string name_SubdetPM(HcalDetId const &did) {
0073       char name[10];
0074       sprintf(name, "%s%s", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta() > 0 ? "P" : "M");
0075       return std::string(name);
0076     }
0077 
0078     uint32_t hash_SubdetPM(std::string const &name) {
0079       for (int i = 0; i < constants::SUBDET_NUM * 2; i++)
0080         if (constants::SUBDETPM_NAME[i] == name)
0081           return HcalDetId((HcalSubdetector)(i / 2 + 1), i % 2 == 0 ? -1 : 1, 1, 1).rawId();
0082 
0083       return HcalDetId().rawId();
0084     }
0085 
0086     std::string name_Subdetiphi(HcalDetId const &did) {
0087       char name[10];
0088       sprintf(name, "%siphi%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.iphi());
0089       return std::string(name);
0090     }
0091 
0092     uint32_t hash_Subdetiphi(std::string const &name) {
0093       std::string sub = name.substr(0, 2);
0094       int iphi = std::stoi(name.substr(6, name.length() - 6), nullptr);
0095       for (int i = 0; i < constants::SUBDET_NUM; i++)
0096         if (constants::SUBDET_NAME[i] == sub)
0097           return HcalDetId((HcalSubdetector)(i + 1), 1, iphi, 1).rawId();
0098 
0099       //    default
0100       return HcalDetId().rawId();
0101     }
0102 
0103     std::string name_Subdetieta(HcalDetId const &did) {
0104       char name[20];
0105       sprintf(name, "%sieta%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta());
0106       return std::string(name);
0107     }
0108 
0109     uint32_t hash_Subdetieta(std::string const &name) {
0110       std::string sub = name.substr(0, 2);
0111       int ieta = std::stoi(name.substr(6, name.length() - 6), nullptr);
0112       for (int i = 0; i < constants::SUBDET_NUM; i++)
0113         if (constants::SUBDET_NAME[i] == sub)
0114           return HcalDetId((HcalSubdetector)(i + 1), ieta, 1, 1).rawId();
0115 
0116       //    default
0117       return HcalDetId().rawId();
0118     }
0119 
0120     std::string name_Subdetdepth(HcalDetId const &did) {
0121       char name[20];
0122       sprintf(name, "%sdepth%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.depth());
0123       return std::string(name);
0124     }
0125 
0126     uint32_t hash_Subdetdepth(std::string const &name) {
0127       std::string sub = name.substr(0, 2);
0128       int depth = std::stoi(name.substr(7, name.length() - 7), nullptr);
0129       for (int i = 0; i < constants::SUBDET_NUM; i++)
0130         if (constants::SUBDET_NAME[i] == sub)
0131           return HcalDetId((HcalSubdetector)(i + 1), 1, 1, depth).rawId();
0132 
0133       return HcalDetId().rawId();
0134     }
0135 
0136     std::string name_SubdetPMiphi(HcalDetId const &did) {
0137       char name[20];
0138       sprintf(
0139           name, "%s%siphi%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta() > 0 ? "P" : "M", did.iphi());
0140       return std::string(name);
0141     }
0142 
0143     uint32_t hash_SubdetPMiphi(std::string const &name) {
0144       std::string sub = name.substr(0, 3);
0145       int iphi = std::stoi(name.substr(7, name.length() - 7), nullptr);
0146       for (int i = 0; i < constants::SUBDET_NUM * 2; i++)
0147         if (constants::SUBDETPM_NAME[i] == sub)
0148           return HcalDetId((HcalSubdetector)(i / 2 + 1), i % 2 == 0 ? -1 : 1, iphi, 1).rawId();
0149 
0150       return HcalDetId().rawId();
0151     }
0152 
0153     std::string name_iphi(HcalDetId const &did) {
0154       char name[10];
0155       sprintf(name, "iphi%d", did.iphi());
0156       return std::string(name);
0157     }
0158 
0159     uint32_t hash_iphi(std::string const &name) {
0160       int iphi = std::stoi(name.substr(4, name.length() - 4), nullptr);
0161       return HcalDetId(HcalBarrel, 1, iphi, 1).rawId();
0162     }
0163 
0164     std::string name_ieta(HcalDetId const &did) {
0165       char name[10];
0166       sprintf(name, "ieta%d", did.ieta());
0167       return std::string(name);
0168     }
0169 
0170     uint32_t hash_ieta(std::string const &name) {
0171       int ieta = std::stoi(name.substr(4, name.length() - 4), nullptr);
0172       return HcalDetId(HcalBarrel, ieta, 1, 1).rawId();
0173     }
0174 
0175     std::string name_depth(HcalDetId const &did) {
0176       char name[10];
0177       if (did.subdet() == HcalOuter)
0178         sprintf(name, "depthHO");
0179       else
0180         sprintf(name, "depth%d", did.depth());
0181       return std::string(name);
0182     }
0183 
0184     uint32_t hash_depth(std::string const &name) {
0185       int depth = std::stoi(name.substr(5, name.length() - 5), nullptr);
0186       if (name.find("HO") != std::string::npos)
0187         return 9;  // must match the value in method hash_depth(& digi)
0188       else
0189         return HcalDetId(HcalBarrel, 1, 1, depth).rawId();
0190     }
0191 
0192     std::string name_HFPMiphi(HcalDetId const &did) {
0193       char name[12];
0194       snprintf(name, sizeof(name), "HF%ciphi%d", did.ieta() > 0 ? 'P' : 'M', did.iphi());
0195       return std::string(name);
0196     }
0197 
0198     uint32_t hash_HFPMiphi(std::string const &name) {
0199       int iphi = std::stoi(name.substr(7, name.length() - 7), nullptr);
0200       int ieta = name[2] == 'P' ? 1 : -1;
0201       return HcalDetId(HcalForward, ieta, iphi, 1).rawId();
0202     }
0203 
0204     std::string name_HBHEPartition(HcalDetId const &did) {
0205       char c;
0206       if (did.iphi() >= 3 && did.iphi() <= 26)
0207         c = 'a';
0208       else if (did.iphi() >= 27 && did.iphi() <= 50)
0209         c = 'b';
0210       else
0211         c = 'c';
0212       char name[10];
0213       sprintf(name, "HBHE%c", c);
0214       return std::string(name);
0215     }
0216 
0217     uint32_t hash_HBHEPartition(std::string const &name) {
0218       if (name[4] == 'a')
0219         return HcalDetId(HcalBarrel, 1, 5, 1).rawId();
0220       else if (name[4] == 'b')
0221         return HcalDetId(HcalBarrel, 1, 29, 1).rawId();
0222       else
0223         return HcalDetId(HcalBarrel, 1, 55, 1).rawId();
0224 
0225       return HcalDetId().rawId();
0226     }
0227 
0228     std::string name_DChannel(HcalDetId const &did) {
0229       char name[40];
0230       sprintf(
0231           name, "%s-%d-%d-%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta(), did.iphi(), did.depth());
0232       return std::string(name);
0233     }
0234 
0235     //  TODO: Make it work here
0236     //  Not neccessary right now!
0237     uint32_t hash_DChannel(std::string const &name) { return HcalDetId(HcalBarrel, 1, 1, 1).rawId(); }
0238 
0239     /**
0240  *  by ElectronicsId
0241  */
0242     uint32_t hash_FED(HcalElectronicsId const &eid) {
0243       if (eid.isVMEid())
0244         return utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, eid.dccid()));
0245       else {
0246         //  HO and HO are dual-FED
0247         bool isHF = eid.crateId() == 22 || eid.crateId() == 29 || eid.crateId() == 32;
0248         bool isHO = eid.crateId() == 23 || eid.crateId() == 27 || eid.crateId() == 26 || eid.crateId() == 38;
0249         //  for HF, slot number is either
0250         int slotToUse = 1;
0251         if (isHF || isHO)
0252           slotToUse = eid.slot() > 6 ? SLOT_uTCA_MIN + 6 : SLOT_uTCA_MIN;
0253         else
0254           slotToUse = eid.slot() > 8 ? SLOT_uTCA_MIN + 8 : (eid.slot() > 4 ? SLOT_uTCA_MIN + 4 : SLOT_uTCA_MIN);
0255         return utilities::hash(HcalElectronicsId(eid.crateId(), slotToUse, FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0256       }
0257     }
0258 
0259     uint32_t hash_FEDSpigot(HcalElectronicsId const &eid) {
0260       //    note that hashing of uTCA is done by FED-Slot...
0261       return eid.isVMEid()
0262                  ? utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), eid.dccid()))
0263                  : utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0264     }
0265 
0266     uint32_t hash_FEDSlot(HcalElectronicsId const &eid) {
0267       //    note that hashing of VME is done with
0268       return eid.isVMEid()
0269                  ? utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), eid.dccid()))
0270                  : utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0271     }
0272 
0273     uint32_t hash_Crate(HcalElectronicsId const &eid) {
0274       //    note hashing of VME is done with dccId
0275       //    note 2: there are two dccids per crate, <even> and <even+1>. We don't
0276       // care about this, so use the even one.
0277       return eid.isVMEid()
0278                  ? utilities::hash(HcalElectronicsId(
0279                        FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, (eid.dccid() % 2 == 0 ? eid.dccid() : eid.dccid() - 1)))
0280                  : utilities::hash(
0281                        HcalElectronicsId(eid.crateId(), SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0282     }
0283 
0284     uint32_t hash_CrateSpigot(HcalElectronicsId const &eid) {
0285       //    note hashing of VME is done with dccid and
0286       //    uTCA with Slots
0287       return eid.isVMEid()
0288                  ? utilities::hash(HcalElectronicsId(
0289                        FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), (eid.dccid() % 2 == 0 ? eid.dccid() : eid.dccid() - 1)))
0290                  : utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0291     }
0292 
0293     uint32_t hash_CrateSlot(HcalElectronicsId const &eid) {
0294       return eid.isVMEid()
0295                  ? utilities::hash(HcalElectronicsId(
0296                        FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), (eid.dccid() % 2 == 0 ? eid.dccid() : eid.dccid() - 1)))
0297                  : utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0298     }
0299 
0300     uint32_t hash_Fiber(HcalElectronicsId const &) { return 0; }
0301 
0302     uint32_t hash_FiberFiberCh(HcalElectronicsId const &) { return 0; }
0303 
0304     uint32_t hash_FiberCh(HcalElectronicsId const &eid) { return 0; }
0305 
0306     uint32_t hash_Electronics(HcalElectronicsId const &eid) {
0307       return eid.isVMEid() ? utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN))
0308                            : utilities::hash(
0309                                  HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false));
0310       /*            NOTE: as an update - should separate Trigger Eid and Det
0311    Eid *            return eid.isVMEid() ? eid.isTriggerChainId()?
0312                                           utilities::hash(HcalElectronicsId(SLBCH_MIN,
0313                                                   SLB_MIN, SPIGOT_MIN,
0314    CRATE_VME_MIN, CRATE_VME_MIN, SLOT_VME_MIN1, 0)):
0315                                           utilities::hash(HcalElectronicsId(FIBERCH_MIN,
0316                                                   FIBER_VME_MIN, SPIGOT_MIN,
0317    CRATE_VME_MIN))
0318                                   :
0319                                   eid.isTriggerChainId()?
0320                                   utilities::hash(HcalElectronicsId(CRATE_uTCA_MIN,
0321                                           SLOT_uTCA_MIN, TPFIBER_MIN,
0322    TPFIBERCH_MIN, true)): utilities::hash(HcalElectronicsId(CRATE_uTCA_MIN,
0323                                           SLOT_uTCA_MIN, FIBER_uTCA_MIN1,
0324    FIBERCH_MIN, false));
0325                                           */
0326     }
0327 
0328     uint32_t hash_EChannel(HcalElectronicsId const &eid) {
0329       return eid.isVMEid()
0330                  ? utilities::hash(HcalElectronicsId(eid.fiberChanId(), eid.fiberIndex(), eid.spigot(), eid.dccid()))
0331                  : utilities::hash(
0332                        HcalElectronicsId(eid.crateId(), eid.slot(), eid.fiberIndex(), eid.fiberChanId(), false));
0333     }
0334 
0335     std::string name_FED(HcalElectronicsId const &eid) {
0336       char name[10];
0337       sprintf(name, "FED%d", eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()));
0338       return std::string(name);
0339     }
0340 
0341     uint32_t hash_FED(std::string const &name) {
0342       int fed = std::stoi(name.substr(3, name.length() - 3), nullptr);
0343       if (fed >= constants::FED_uTCA_MIN) {
0344         std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
0345         return HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
0346       } else
0347         return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, fed - FED_VME_MIN).rawId();
0348 
0349       return HcalElectronicsId().rawId();
0350     }
0351 
0352     std::string name_FEDSpigot(HcalElectronicsId const &eid) {
0353       char name[20];
0354       sprintf(name,
0355               "FED%dS%d",
0356               eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()),
0357               eid.isVMEid() ? eid.spigot() : eid.slot());
0358       return std::string(name);
0359     }
0360 
0361     uint32_t hash_FEDSpigot(std::string const &name) {
0362       int pos = name.find('S');
0363       int fed = std::stoi(name.substr(3, pos - 3), nullptr);
0364       int s = std::stoi(name.substr(pos + 1, name.length() - pos - 1), nullptr);
0365       if (fed >= FED_uTCA_MIN) {
0366         std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
0367         return HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
0368       } else
0369         return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, s, fed - FED_VME_MIN).rawId();
0370 
0371       return HcalElectronicsId().rawId();
0372     }
0373 
0374     std::string name_FEDSlot(HcalElectronicsId const &eid) {
0375       char name[20];
0376       sprintf(name,
0377               "FED%dS%d",
0378               eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()),
0379               eid.isVMEid() ? eid.spigot() : eid.slot());
0380       return std::string(name);
0381     }
0382 
0383     uint32_t hash_FEDSlot(std::string const &name) {
0384       int pos = name.find('S');
0385       int fed = std::stoi(name.substr(3, pos - 3), nullptr);
0386       int s = std::stoi(name.substr(pos + 1, name.length() - pos - 1), nullptr);
0387       if (fed >= FED_uTCA_MIN) {
0388         std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
0389         return HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
0390       } else
0391         return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, s, fed - FED_VME_MIN).rawId();
0392 
0393       return HcalElectronicsId().rawId();
0394     }
0395 
0396     std::string name_Crate(HcalElectronicsId const &eid) {
0397       char name[16];
0398       sprintf(name, "Crate%d", eid.crateId());
0399 
0400       // Note: previous, different hashes were returned for the two dccids in a VME
0401       // crate. These now count as one crate.
0402       // if (eid.isVMEid()) {
0403       //    sprintf(name, "Crate%d_VME_DCC%d", eid.crateId(), eid.dccid());
0404       //} else {
0405       //    sprintf(name, "Crate%d", eid.crateId());
0406       //}
0407       return std::string(name);
0408     }
0409 
0410     //  TODO: implement - not used at this point
0411     uint32_t hash_Crate(std::string const &) { return HcalElectronicsId().rawId(); }
0412 
0413     std::string name_CrateSpigot(HcalElectronicsId const &eid) {
0414       char name[20];
0415       sprintf(name, "Crate%dS%d", eid.crateId(), eid.isVMEid() ? eid.spigot() : eid.slot());
0416       return std::string(name);
0417     }
0418 
0419     //  TODO: implement - not used at this point
0420     uint32_t hash_CrateSpigot(std::string const &) { return HcalElectronicsId().rawId(); }
0421 
0422     std::string name_CrateSlot(HcalElectronicsId const &eid) {
0423       char name[20];
0424       sprintf(name, "Crate%dS%d", eid.crateId(), eid.isVMEid() ? eid.spigot() : eid.slot());
0425       return std::string(name);
0426     }
0427 
0428     //  TODO: implement - not used at this point
0429     uint32_t hash_CrateSlot(std::string const &) { return HcalElectronicsId().rawId(); }
0430 
0431     std::string name_Fiber(HcalElectronicsId const &) { return "None"; }
0432 
0433     //  TODO: implement - not used at this point
0434     uint32_t hash_Fiber(std::string const &) { return HcalElectronicsId().rawId(); }
0435 
0436     std::string name_FiberFiberCh(HcalElectronicsId const &) { return "None"; }
0437 
0438     //  TODO: implement - not used at this point
0439     uint32_t hash_FiberFiberCh(std::string const &) { return HcalElectronicsId().rawId(); }
0440 
0441     std::string name_FiberCh(HcalElectronicsId const &) { return "None"; }
0442 
0443     //  TODO: implement - not used at this point
0444     uint32_t hash_FiberCh(std::string const &) { return HcalElectronicsId().rawId(); }
0445 
0446     std::string name_Electronics(HcalElectronicsId const &eid) {
0447       return eid.isVMEid() ? std::string("VME") : std::string("uTCA");
0448     }
0449 
0450     uint32_t hash_Electronics(std::string const &name) {
0451       if (name == "VME")
0452         return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN).rawId();
0453       else
0454         return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
0455 
0456       return HcalElectronicsId().rawId();
0457     }
0458 
0459     std::string name_EChannel(HcalElectronicsId const &eid) {
0460       char name[20];
0461       if (eid.isVMEid())
0462         sprintf(name, "%d-%d-%d-%d", eid.dccid(), eid.spigot(), eid.fiberIndex(), eid.fiberChanId());
0463       else
0464         sprintf(name, "%d-%d-%d-%d", eid.crateId(), eid.slot(), eid.fiberIndex(), eid.fiberChanId());
0465       return std::string(name);
0466     }
0467 
0468     //  TODO: implement - not used at this point
0469     uint32_t hash_EChannel(std::string const &) { return HcalElectronicsId().rawId(); }
0470 
0471     /**
0472  *  by TrigTowerDetId
0473  */
0474     uint32_t hash_TTSubdet(HcalTrigTowerDetId const &tid) {
0475       return utilities::hash(HcalTrigTowerDetId(tid.ietaAbs() >= 29 ? 29 : 1, 1));
0476     }
0477 
0478     uint32_t hash_TTSubdetPM(HcalTrigTowerDetId const &tid) {
0479       return utilities::hash(
0480           HcalTrigTowerDetId(tid.ietaAbs() < 29 ? (tid.ieta() < 0 ? -1 : 1) : (tid.ieta() < 0 ? -29 : 29), 1));
0481     }
0482 
0483     uint32_t hash_TTSubdetPMiphi(HcalTrigTowerDetId const &tid) {
0484       return utilities::hash(
0485           HcalTrigTowerDetId(tid.ietaAbs() < 29 ? (tid.ieta() < 0 ? 0 : 1) : (tid.ieta() < 0 ? 2 : 3), tid.iphi()));
0486     }
0487 
0488     uint32_t hash_TTSubdetieta(HcalTrigTowerDetId const &tid) { return 0; }
0489 
0490     uint32_t hash_TTdepth(HcalTrigTowerDetId const &tid) {
0491       return utilities::hash(HcalTrigTowerDetId(1, 1, tid.depth()));
0492     }
0493 
0494     uint32_t hash_TChannel(HcalTrigTowerDetId const &tid) {
0495       return utilities::hash(HcalTrigTowerDetId(tid.ieta(), tid.iphi(), tid.depth()));
0496     }
0497 
0498     std::string name_TTSubdet(HcalTrigTowerDetId const &tid) {
0499       return constants::TPSUBDET_NAME[tid.ietaAbs() < 29 ? 0 : 1];
0500     }
0501 
0502     uint32_t hash_TTSubdet(std::string const &name) {
0503       if (name == "HBHE")
0504         return HcalTrigTowerDetId(1, 1).rawId();
0505       else
0506         return HcalTrigTowerDetId(29, 1).rawId();
0507 
0508       return HcalTrigTowerDetId().rawId();
0509     }
0510 
0511     std::string name_TTSubdetPM(HcalTrigTowerDetId const &tid) {
0512       return constants::TPSUBDETPM_NAME[tid.ietaAbs() < 29 ? (tid.ieta() < 0 ? 0 : 1) : (tid.ieta() < 0 ? 2 : 3)];
0513     }
0514 
0515     uint32_t hash_TTSubdetPM(std::string const &name) {
0516       if (name == "HBHEM")
0517         return HcalTrigTowerDetId(-1, 1).rawId();
0518       else if (name == "HBHEP")
0519         return HcalTrigTowerDetId(1, 1).rawId();
0520       else if (name == "HFM")
0521         return HcalTrigTowerDetId(-29, 1).rawId();
0522       else
0523         return HcalTrigTowerDetId(29, 1).rawId();
0524 
0525       return HcalTrigTowerDetId().rawId();
0526     }
0527 
0528     std::string name_TTSubdetPMiphi(HcalTrigTowerDetId const &tid) {
0529       char name[10];
0530       sprintf(name, "%siphi%d", name_TTSubdetPM(tid).c_str(), tid.iphi());
0531       return std::string(name);
0532     }
0533 
0534     uint32_t hash_TTSubdetPMiphi(std::string const &name) {
0535       int pos = name.find("iphi");
0536       std::string sub = name.substr(0, pos);
0537       int iphi = std::stoi(name.substr(pos + 4, name.length() - pos - 4), nullptr);
0538       if (name == "HBHEM")
0539         return HcalTrigTowerDetId(-1, iphi).rawId();
0540       else if (name == "HBHEP")
0541         return HcalTrigTowerDetId(1, iphi).rawId();
0542       else if (name == "HFM")
0543         return HcalTrigTowerDetId(-29, iphi).rawId();
0544       else
0545         return HcalTrigTowerDetId(29, iphi).rawId();
0546 
0547       return HcalTrigTowerDetId().rawId();
0548     }
0549 
0550     std::string name_TTSubdetieta(HcalTrigTowerDetId const &tid) { return "None"; }
0551 
0552     //  TODO: implement - not used right now
0553     uint32_t hash_TTSubdetieta(std::string const &) { return HcalTrigTowerDetId().rawId(); }
0554 
0555     std::string name_TTdepth(HcalTrigTowerDetId const &tid) {
0556       char name[10];
0557       sprintf(name, "depth%d", tid.depth());
0558       return std::string(name);
0559     }
0560 
0561     uint32_t hash_TTdepth(std::string const &name) {
0562       int depth = std::stoi(name.substr(5, name.length() - 5), nullptr);
0563       return HcalTrigTowerDetId(1, 1, depth);
0564     }
0565 
0566     std::string name_TChannel(HcalTrigTowerDetId const &tid) {
0567       std::ostringstream stream;
0568       stream << tid;
0569       return std::string(stream.str());
0570     }
0571 
0572     //  TODO: implement - not used right now
0573     uint32_t hash_TChannel(std::string const &) { return HcalTrigTowerDetId().rawId(); }
0574 
0575     /**
0576  *      by Mixed Id
0577  */
0578     uint32_t hash_TTSubdetFW(HcalTrigTowerDetId const &tid, HcalElectronicsId const &eid) {
0579       if (tid.ietaAbs() < 29) {
0580         if (eid.slot() % 3 == 1)
0581           return utilities::hash(HcalTrigTowerDetId(1, 1));
0582         else if (eid.slot() % 3 == 2)
0583           return utilities::hash(HcalTrigTowerDetId(17, 1));
0584         else if (eid.slot() % 3 == 0)
0585           return utilities::hash(HcalTrigTowerDetId(19, 1));
0586       } else
0587         return utilities::hash(HcalTrigTowerDetId(29, 1));
0588 
0589       return HcalTrigTowerDetId().rawId();
0590     }
0591 
0592     std::string name_TTSubdetFW(HcalTrigTowerDetId const &tid, HcalElectronicsId const &eid) {
0593       int idx = -1;
0594       if (tid.ietaAbs() < 29) {
0595         if (eid.slot() % 3 == 1)
0596           idx = 0;
0597         else if (eid.slot() % 3 == 2)
0598           idx = 1;
0599         else if (eid.slot() % 3 == 0)
0600           idx = 2;
0601       } else
0602         idx = 3;
0603       return constants::TPSUBDETFW_NAME[idx];
0604     }
0605 
0606     uint32_t hash_TTSubdetFW(std::string const &name) {
0607       if (name == "HB")
0608         return HcalTrigTowerDetId(1, 1).rawId();
0609       else if (name == "HBHE")
0610         return HcalTrigTowerDetId(17, 1).rawId();
0611       else if (name == "HE")
0612         return HcalTrigTowerDetId(19, 1).rawId();
0613       else
0614         return HcalTrigTowerDetId(29, 1).rawId();
0615 
0616       return HcalTrigTowerDetId().rawId();
0617     }
0618 
0619   }  // namespace hashfunctions
0620 }  // namespace hcaldqm