Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:12

0001 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0002 #include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
0003 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0004 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
0005 
0006 #include <string>
0007 #include <cstring>
0008 #include <iostream>
0009 #include <fstream>
0010 #include <sstream>
0011 #include <cstdio>
0012 #include <ctime>
0013 #include <memory>
0014 
0015 using namespace std;
0016 
0017 HcalLogicalMap::HcalLogicalMap(const HcalTopology* topo,
0018                                std::vector<HBHEHFLogicalMapEntry>& HBHEHFEntries,
0019                                std::vector<HOHXLogicalMapEntry>& HOHXEntries,
0020                                std::vector<CALIBLogicalMapEntry>& CALIBEntries,
0021                                std::vector<ZDCLogicalMapEntry>& ZDCEntries,
0022                                std::vector<HTLogicalMapEntry>& HTEntries,
0023                                std::vector<uint32_t>& LinearIndex2Entry,
0024                                std::vector<uint32_t>& HbHash2Entry,
0025                                std::vector<uint32_t>& HeHash2Entry,
0026                                std::vector<uint32_t>& HfHash2Entry,
0027                                std::vector<uint32_t>& HtHash2Entry,
0028                                std::vector<uint32_t>& HoHash2Entry,
0029                                std::vector<uint32_t>& HxCalibHash2Entry,
0030                                std::vector<uint32_t>& ZdcHash2Entry)
0031     : topo_(topo)
0032 
0033 {
0034   HBHEHFEntries_.resize(HBHEHFEntries.size());
0035   HOHXEntries_.resize(HOHXEntries.size());
0036   CALIBEntries_.resize(CALIBEntries.size());
0037   ZDCEntries_.resize(ZDCEntries.size());
0038   HTEntries_.resize(HTEntries.size());
0039 
0040   LinearIndex2Entry_.resize(LinearIndex2Entry.size());
0041   HbHash2Entry_.resize(HbHash2Entry.size());
0042   HeHash2Entry_.resize(HeHash2Entry.size());
0043   HfHash2Entry_.resize(HfHash2Entry.size());
0044   HtHash2Entry_.resize(HtHash2Entry.size());
0045   HoHash2Entry_.resize(HoHash2Entry.size());
0046   HxCalibHash2Entry_.resize(HxCalibHash2Entry.size());
0047   ZdcHash2Entry_.resize(ZdcHash2Entry.size());
0048 
0049   copy(HBHEHFEntries.begin(), HBHEHFEntries.end(), HBHEHFEntries_.begin());
0050   copy(HOHXEntries.begin(), HOHXEntries.end(), HOHXEntries_.begin());
0051   copy(CALIBEntries.begin(), CALIBEntries.end(), CALIBEntries_.begin());
0052   copy(ZDCEntries.begin(), ZDCEntries.end(), ZDCEntries_.begin());
0053   copy(HTEntries.begin(), HTEntries.end(), HTEntries_.begin());
0054   copy(LinearIndex2Entry.begin(), LinearIndex2Entry.end(), LinearIndex2Entry_.begin());
0055   copy(HbHash2Entry.begin(), HbHash2Entry.end(), HbHash2Entry_.begin());
0056   copy(HeHash2Entry.begin(), HeHash2Entry.end(), HeHash2Entry_.begin());
0057   copy(HfHash2Entry.begin(), HfHash2Entry.end(), HfHash2Entry_.begin());
0058   copy(HtHash2Entry.begin(), HtHash2Entry.end(), HtHash2Entry_.begin());
0059   copy(HoHash2Entry.begin(), HoHash2Entry.end(), HoHash2Entry_.begin());
0060   copy(HxCalibHash2Entry.begin(), HxCalibHash2Entry.end(), HxCalibHash2Entry_.begin());
0061   copy(ZdcHash2Entry.begin(), ZdcHash2Entry.end(), ZdcHash2Entry_.begin());
0062 }
0063 
0064 HcalLogicalMap::~HcalLogicalMap() {}
0065 
0066 uint32_t HcalLogicalMap::makeEntryNumber(bool isvalid, int vectorid, int entry) {
0067   uint32_t answer = 0;
0068   answer |= isvalid;
0069   answer |= (vectorid & 0x3) << 1;
0070   answer |= entry << 3;
0071   return answer;
0072 }
0073 
0074 void HcalLogicalMap::printMap(unsigned int mapIOV) {
0075   using namespace std;
0076 
0077   static FILE* HBEFmap;
0078   static FILE* HOXmap;
0079   static FILE* CALIBmap;
0080   static FILE* ZDCmap;
0081   static FILE* HTmap;
0082 
0083   char tempbuff[30];
0084 
0085   stringstream mystream;
0086   string HBEFmapstr, HOXmapstr, CALIBmapstr, ZDCmapstr, HTmapstr;
0087   string date;
0088   string IOVlabel;
0089 
0090   time_t myTime;
0091   time(&myTime);
0092 
0093   strftime(tempbuff, 128, "%d.%b.%Y", localtime(&myTime));
0094   mystream << tempbuff;
0095   date = mystream.str();
0096 
0097   mystream.str("");
0098   if (mapIOV == 1)
0099     IOVlabel = "A";
0100   else if (mapIOV == 2)
0101     IOVlabel = "B";
0102   else if (mapIOV == 3)
0103     IOVlabel = "C";
0104   else if (mapIOV == 4)
0105     IOVlabel = "D";
0106   else
0107     IOVlabel = "E";
0108 
0109   HBEFmapstr = "./HCALmapHBEF_" + IOVlabel + ".txt";
0110   HOXmapstr = "./HCALmapHO_" + IOVlabel + ".txt";
0111   CALIBmapstr = "./HCALmapCALIB_" + IOVlabel + ".txt";
0112   ZDCmapstr = "./ZDCmap_" + IOVlabel + ".txt";
0113   HTmapstr = "./HCALmapHT_" + IOVlabel + ".txt";
0114 
0115   //  HBEFmapstr  = "./HCALmapHBEF_"+date+".txt";
0116   //  HOXmapstr   = "./HCALmapHO_"+date+"_"+IOVlabel+".txt";
0117   //  CALIBmapstr = "./HCALmapCALIB_"+date+".txt";
0118   //  ZDCmapstr   = "./ZDCmap_"+date+".txt";
0119   //  HTmapstr    = "./HCALmapHT_"+date+".txt";
0120 
0121   HBEFmap = fopen(HBEFmapstr.c_str(), "w");
0122   HOXmap = fopen(HOXmapstr.c_str(), "w");
0123   CALIBmap = fopen(CALIBmapstr.c_str(), "w");
0124   ZDCmap = fopen(ZDCmapstr.c_str(), "w");
0125   HTmap = fopen(HTmapstr.c_str(), "w");
0126   /**********************/
0127 
0128   if (HBEFmap) {
0129     fprintf(HBEFmap, "## file created %s ##\n", date.c_str());
0130     printHBEFMap(HBEFmap);
0131   } else
0132     cout << HBEFmapstr << " not found!" << endl;
0133 
0134   if (HOXmap) {
0135     fprintf(HOXmap, "## file created %s ##\n", date.c_str());
0136     printHOXMap(HOXmap);
0137   } else
0138     cout << HOXmapstr << " not found!" << endl;
0139 
0140   if (CALIBmap) {
0141     fprintf(CALIBmap, "## file created %s ##\n", date.c_str());
0142     printCalibMap(CALIBmap);
0143   } else
0144     cout << CALIBmapstr << " not found!" << endl;
0145 
0146   if (ZDCmap) {
0147     fprintf(ZDCmap, "## file created %s ##\n", date.c_str());
0148     printZDCMap(ZDCmap);
0149   } else
0150     cout << ZDCmapstr << " not found!" << endl;
0151 
0152   if (HTmap) {
0153     fprintf(HTmap, "## file created %s ##\n", date.c_str());
0154     printHTMap(HTmap);
0155   } else
0156     cout << HTmapstr << " not found!" << endl;
0157 }
0158 
0159 /**************/
0160 std::unique_ptr<HcalElectronicsMap> HcalLogicalMap::generateHcalElectronicsMap() {
0161   HcalElectronicsMapAddons::Helper theemapHelper;
0162 
0163   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it != HBHEHFEntries_.end(); ++it) {
0164     theemapHelper.mapEId2chId(it->getHcalElectronicsId(), it->getDetId());
0165   }
0166   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it != HOHXEntries_.end(); ++it) {
0167     theemapHelper.mapEId2chId(it->getHcalElectronicsId(), it->getDetId());
0168   }
0169   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it != CALIBEntries_.end(); ++it) {
0170     theemapHelper.mapEId2chId(it->getHcalElectronicsId(), it->getDetId());
0171   }
0172   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it != ZDCEntries_.end(); ++it) {
0173     theemapHelper.mapEId2chId(it->getHcalElectronicsId(), it->getDetId());
0174   }
0175   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it != HTEntries_.end(); ++it) {
0176     theemapHelper.mapEId2tId(it->getHcalTrigElectronicsId(), it->getDetId());
0177   }
0178   return std::make_unique<HcalElectronicsMap>(theemapHelper);
0179 }
0180 /**************/
0181 
0182 void HcalLogicalMap::printHBEFMap(FILE* hbefmapfile) {
0183   int titlecounter = 0;
0184 
0185   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it != HBHEHFEntries_.end(); ++it) {
0186     titlecounter = titlecounter % 21;
0187     if (titlecounter == 0) {
0188       fprintf(hbefmapfile, "#   side    eta    phi   dphi  depth    det     rbx  wedge     rm  pixel   qie    adc");
0189       fprintf(hbefmapfile, "  rm_fi  fi_ch  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc    slb  slbin  slbin2");
0190       fprintf(hbefmapfile, "           slnam    rctcra rctcar rctcon               rctnam     fedid\n");
0191     }
0192     titlecounter++;
0193     fprintf(hbefmapfile, "%s", it->printLMapLine());
0194   }
0195 }
0196 
0197 void HcalLogicalMap::printHOXMap(FILE* hoxmapfile) {
0198   int titlecounter = 0;
0199 
0200   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it != HOHXEntries_.end(); ++it) {
0201     titlecounter = titlecounter % 21;
0202     if (titlecounter == 0) {
0203       fprintf(hoxmapfile, "#   side    eta    phi   dphi  depth    det     rbx  sector    rm  pixel   qie    adc");
0204       fprintf(hoxmapfile, "  rm_fi  fi_ch let_code  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc  fedid\n");
0205     }
0206     titlecounter++;
0207     fprintf(hoxmapfile, "%s", it->printLMapLine());
0208   }
0209 }
0210 
0211 void HcalLogicalMap::printCalibMap(FILE* calibmapfile) {
0212   int titlecounter = 0;
0213 
0214   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it != CALIBEntries_.end(); ++it) {
0215     titlecounter = titlecounter % 21;
0216     if (titlecounter == 0) {
0217       fprintf(calibmapfile, "#   side    eta    phi   dphi    det     rbx  sector  rm  rm_fi ");
0218       fprintf(calibmapfile, " fi_ch  crate  htr  fpga  htr_fi  dcc_sl  spigo  dcc  fedid  ch_type      name\n");
0219     }
0220     titlecounter++;
0221     fprintf(calibmapfile, "%s", it->printLMapLine());
0222   }
0223 }
0224 
0225 void HcalLogicalMap::printZDCMap(FILE* zdcmapfile) {
0226   int titlecounter = 0;
0227 
0228   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it != ZDCEntries_.end(); ++it) {
0229     titlecounter = titlecounter % 21;
0230     if (titlecounter == 0) {
0231       fprintf(zdcmapfile, "#  side  x  y  dx  depth     det  det_ch  cable  rm  qie ");
0232       fprintf(zdcmapfile, " adc  rm_fi  fi_ch  crate  htr  fpga  htr_fi  dcc_sl  spigo  dcc  fedid\n");
0233     }
0234     titlecounter++;
0235     fprintf(zdcmapfile, "%s", it->printLMapLine());
0236   }
0237 }
0238 
0239 void HcalLogicalMap::printHTMap(FILE* htmapfile) {
0240   int titlecounter = 0;
0241 
0242   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it != HTEntries_.end(); ++it) {
0243     titlecounter = titlecounter % 21;
0244     if (titlecounter == 0) {
0245       fprintf(htmapfile, "#  side  eta  phi  dphi  depth  det   wedge  crate");
0246       fprintf(htmapfile, "  htr  fpga  dcc_sl  spigo  dcc  slb  slbin  slbin2  nDat    ");
0247       fprintf(htmapfile, "     slnam  rctcra  rctcar  rctcon            rctnam  fedid\n");
0248     }
0249     titlecounter++;
0250     fprintf(htmapfile, "%s", it->printLMapLine());
0251   }
0252 }
0253 
0254 const DetId HcalLogicalMap::getDetId(const HcalElectronicsId& eid) {
0255   const uint32_t entry = LinearIndex2Entry_.at(eid.linearIndex());
0256   if (!(entry & 0x1))
0257     return DetId(0);
0258   if (((entry >> 1) & 0x3) == 0)
0259     return HBHEHFEntries_.at(entry >> 3).getDetId();
0260   if (((entry >> 1) & 0x3) == 1)
0261     return HOHXEntries_.at(entry >> 3).getDetId();
0262   if (((entry >> 1) & 0x3) == 2)
0263     return CALIBEntries_.at(entry >> 3).getDetId();
0264   if (((entry >> 1) & 0x3) == 3)
0265     return ZDCEntries_.at(entry >> 3).getDetId();
0266   return DetId(0);
0267 }
0268 
0269 const HcalFrontEndId HcalLogicalMap::getHcalFrontEndId(const DetId& did) {
0270   const HcalGenericDetId hgdi(did);
0271 
0272   const HcalGenericDetId::HcalGenericSubdetector hgsd = hgdi.genericSubdet();
0273   if (hgsd == HcalGenericDetId::HcalGenBarrel) {
0274     const int hashedId = topo_->detId2denseIdHB(did);
0275     const uint32_t entry = HbHash2Entry_.at(hashedId) - 1;
0276     return HBHEHFEntries_.at(entry).getHcalFrontEndId();
0277   } else if (hgsd == HcalGenericDetId::HcalGenEndcap) {
0278     const int hashedId = topo_->detId2denseIdHE(did);
0279     const uint32_t entry = HeHash2Entry_.at(hashedId) - 1;
0280     return HBHEHFEntries_.at(entry).getHcalFrontEndId();
0281   } else if (hgsd == HcalGenericDetId::HcalGenForward) {
0282     const int hashedId = topo_->detId2denseIdHF(did);
0283     const uint32_t entry = HfHash2Entry_.at(hashedId) - 1;
0284     return HBHEHFEntries_.at(entry).getHcalFrontEndId();
0285   } else if (hgsd == HcalGenericDetId::HcalGenOuter) {
0286     const int hashedId = topo_->detId2denseIdHO(did);
0287     const uint32_t entry = HoHash2Entry_.at(hashedId) - 1;
0288     return HOHXEntries_.at(entry).getHcalFrontEndId();
0289   } else if (hgsd == HcalGenericDetId::HcalGenCalibration) {
0290     HcalCalibDetId hcid(did);
0291     if (hcid.calibFlavor() == HcalCalibDetId::HOCrosstalk) {
0292       const int hashedId = topo_->detId2denseIdCALIB(did);
0293       const uint32_t entry = HxCalibHash2Entry_.at(hashedId) - 1;
0294       return HOHXEntries_.at(entry).getHcalFrontEndId();
0295     } else if (hcid.calibFlavor() == HcalCalibDetId::CalibrationBox) {
0296       const int hashedId = topo_->detId2denseIdCALIB(did);
0297       const uint32_t entry = HxCalibHash2Entry_.at(hashedId) - 1;
0298       return CALIBEntries_.at(entry).getHcalFrontEndId();
0299     }
0300   }
0301   return HcalFrontEndId(0);
0302 }
0303 
0304 void HcalLogicalMap::checkIdFunctions() {
0305   int HBHEHF_EID_pass = 0;
0306   int HBHEHF_EID_fail = 0;
0307   int HOHX_EID_pass = 0;
0308   int HOHX_EID_fail = 0;
0309   int CALIB_EID_pass = 0;
0310   int CALIB_EID_fail = 0;
0311   int ZDC_EID_pass = 0;
0312   int ZDC_EID_fail = 0;
0313 
0314   int HBHEHF_FEID_pass = 0;
0315   int HBHEHF_FEID_fail = 0;
0316   int HOHX_FEID_pass = 0;
0317   int HOHX_FEID_fail = 0;
0318   int CALIB_FEID_pass = 0;
0319   int CALIB_FEID_fail = 0;
0320 
0321   cout << "\nRunning the id function checker..." << endl;
0322 
0323   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it != HBHEHFEntries_.end(); ++it) {
0324     const HcalElectronicsId heid = it->getHcalElectronicsId();
0325     const DetId did0 = it->getDetId();
0326     const DetId did1 = getDetId(heid);
0327     if (did0 == did1)
0328       HBHEHF_EID_pass++;
0329     else
0330       HBHEHF_EID_fail++;
0331 
0332     const HcalFrontEndId hfeid0 = it->getHcalFrontEndId();
0333     const HcalFrontEndId hfeid1 = getHcalFrontEndId(did0);
0334     if (hfeid0 == hfeid1)
0335       HBHEHF_FEID_pass++;
0336     else
0337       HBHEHF_FEID_fail++;
0338   }
0339   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it != HOHXEntries_.end(); ++it) {
0340     const HcalElectronicsId heid = it->getHcalElectronicsId();
0341     const DetId did0 = it->getDetId();
0342     const DetId did1 = getDetId(heid);
0343     if (did0 == did1)
0344       HOHX_EID_pass++;
0345     else
0346       HOHX_EID_fail++;
0347 
0348     const HcalFrontEndId hfeid0 = it->getHcalFrontEndId();
0349     const HcalFrontEndId hfeid1 = getHcalFrontEndId(did0);
0350     if (hfeid0 == hfeid1)
0351       HOHX_FEID_pass++;
0352     else
0353       HOHX_FEID_fail++;
0354   }
0355   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it != CALIBEntries_.end(); ++it) {
0356     const HcalElectronicsId heid = it->getHcalElectronicsId();
0357     const DetId did0 = it->getDetId();
0358     const DetId did1 = getDetId(heid);
0359     if (did0 == did1)
0360       CALIB_EID_pass++;
0361     else
0362       CALIB_EID_fail++;
0363 
0364     const HcalFrontEndId hfeid0 = it->getHcalFrontEndId();
0365     const HcalFrontEndId hfeid1 = getHcalFrontEndId(did0);
0366     if (hfeid0 == hfeid1)
0367       CALIB_FEID_pass++;
0368     else
0369       CALIB_FEID_fail++;
0370   }
0371   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it != ZDCEntries_.end(); ++it) {
0372     const HcalElectronicsId heid = it->getHcalElectronicsId();
0373     const DetId did0 = it->getDetId();
0374     const DetId did1 = getDetId(heid);
0375     if (did0 == did1)
0376       ZDC_EID_pass++;
0377     else
0378       ZDC_EID_fail++;
0379   }
0380 
0381   cout << "Checking detIds from electronics ids..." << endl;
0382   cout << "HBHEHF EID (pass,fail) = (" << HBHEHF_EID_pass << "," << HBHEHF_EID_fail << ")" << endl;
0383   cout << "HOHX EID (pass,fail) = (" << HOHX_EID_pass << "," << HOHX_EID_fail << ")" << endl;
0384   cout << "CALIB EID (pass,fail) = (" << CALIB_EID_pass << "," << CALIB_EID_fail << ")" << endl;
0385   cout << "ZDC EID (pass,fail) = (" << ZDC_EID_pass << "," << ZDC_EID_fail << ")" << endl;
0386   cout << endl;
0387   cout << "Checking frontEndIds from electronics ids..." << endl;
0388   cout << "HBHEHF FEID (pass,fail) = (" << HBHEHF_FEID_pass << "," << HBHEHF_FEID_fail << ")" << endl;
0389   cout << "HOHX FEID (pass,fail) = (" << HOHX_FEID_pass << "," << HOHX_FEID_fail << ")" << endl;
0390   cout << "CALIB FEID (pass,fail) = (" << CALIB_FEID_pass << "," << CALIB_FEID_fail << ")" << endl;
0391 }
0392 
0393 void HcalLogicalMap::checkHashIds() {
0394   std::vector<int> HB_Hashes_;       // index 0
0395   std::vector<int> HE_Hashes_;       // index 1
0396   std::vector<int> HF_Hashes_;       // index 2
0397   std::vector<int> HO_Hashes_;       // index 3
0398   std::vector<int> CALIBHX_Hashes_;  // index 4
0399   std::vector<int> ZDC_Hashes_;      // index 5
0400   std::vector<int> HT_Hashes_;       // index 6
0401 
0402   int numfails[7] = {0, 0, 0, 0, 0, 0, 0};
0403   int numpass[7] = {0, 0, 0, 0, 0, 0, 0};
0404   int numnotdense[7] = {0, 0, 0, 0, 0, 0, 0};
0405 
0406   cout << "\nRunning the hash checker for detIds..." << endl;
0407   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it != HBHEHFEntries_.end(); ++it) {
0408     if (it->getDetId().subdetId() == HcalBarrel) {
0409       HB_Hashes_.push_back(topo_->detId2denseIdHB(it->getDetId()));
0410     } else if (it->getDetId().subdetId() == HcalEndcap) {
0411       HE_Hashes_.push_back(topo_->detId2denseIdHE(it->getDetId()));
0412     } else if (it->getDetId().subdetId() == HcalForward) {
0413       HF_Hashes_.push_back(topo_->detId2denseIdHF(it->getDetId()));
0414     }
0415   }
0416   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it != HOHXEntries_.end(); ++it) {
0417     if (HcalGenericDetId(it->getDetId().rawId()).isHcalCalibDetId()) {
0418       CALIBHX_Hashes_.push_back(topo_->detId2denseIdCALIB(it->getDetId()));
0419     } else {
0420       HO_Hashes_.push_back(topo_->detId2denseIdHO(it->getDetId()));
0421     }
0422   }
0423   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it != CALIBEntries_.end(); ++it) {
0424     CALIBHX_Hashes_.push_back(topo_->detId2denseIdCALIB(it->getDetId()));
0425   }
0426   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it != ZDCEntries_.end(); ++it) {
0427     ZDC_Hashes_.push_back(HcalZDCDetId(it->getDetId()).denseIndex());
0428   }
0429   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it != HTEntries_.end(); ++it) {
0430     HT_Hashes_.push_back(topo_->detId2denseIdHT(it->getDetId()));
0431   }
0432 
0433   sort(HB_Hashes_.begin(), HB_Hashes_.end());
0434   sort(HE_Hashes_.begin(), HE_Hashes_.end());
0435   sort(HF_Hashes_.begin(), HF_Hashes_.end());
0436   sort(HO_Hashes_.begin(), HO_Hashes_.end());
0437   sort(CALIBHX_Hashes_.begin(), CALIBHX_Hashes_.end());
0438   sort(ZDC_Hashes_.begin(), ZDC_Hashes_.end());
0439   sort(HT_Hashes_.begin(), HT_Hashes_.end());
0440 
0441   for (unsigned int i = 0; i < HB_Hashes_.size() - 1; i++) {
0442     int diff = HB_Hashes_.at(i + 1) - HB_Hashes_.at(i);
0443     if (diff == 0)
0444       numfails[0]++;
0445     else if (diff > 1)
0446       numnotdense[0]++;
0447     else
0448       numpass[0]++;
0449   }
0450   for (unsigned int i = 0; i < HE_Hashes_.size() - 1; i++) {
0451     int diff = HE_Hashes_.at(i + 1) - HE_Hashes_.at(i);
0452     if (diff == 0)
0453       numfails[1]++;
0454     else if (diff > 1)
0455       numnotdense[1]++;
0456     else
0457       numpass[1]++;
0458   }
0459   for (unsigned int i = 0; i < HF_Hashes_.size() - 1; i++) {
0460     int diff = HF_Hashes_.at(i + 1) - HF_Hashes_.at(i);
0461     if (diff == 0)
0462       numfails[2]++;
0463     else if (diff > 1)
0464       numnotdense[2]++;
0465     else
0466       numpass[2]++;
0467   }
0468   for (unsigned int i = 0; i < HO_Hashes_.size() - 1; i++) {
0469     int diff = HO_Hashes_.at(i + 1) - HO_Hashes_.at(i);
0470     if (diff == 0)
0471       numfails[3]++;
0472     else if (diff > 1)
0473       numnotdense[3]++;
0474     else
0475       numpass[3]++;
0476   }
0477   for (unsigned int i = 0; i < CALIBHX_Hashes_.size() - 1; i++) {
0478     int diff = CALIBHX_Hashes_.at(i + 1) - CALIBHX_Hashes_.at(i);
0479     if (diff == 0)
0480       numfails[4]++;
0481     else if (diff > 1)
0482       numnotdense[4]++;
0483     else
0484       numpass[4]++;
0485   }
0486   for (unsigned int i = 0; i < ZDC_Hashes_.size() - 1; i++) {
0487     int diff = ZDC_Hashes_.at(i + 1) - ZDC_Hashes_.at(i);
0488     if (diff == 0)
0489       numfails[5]++;
0490     else if (diff > 1)
0491       numnotdense[5]++;
0492     else
0493       numpass[5]++;
0494   }
0495   for (unsigned int i = 0; i < HT_Hashes_.size() - 1; i++) {
0496     int diff = HT_Hashes_.at(i + 1) - HT_Hashes_.at(i);
0497     if (diff == 0)
0498       numfails[6]++;
0499     else if (diff > 1)
0500       numnotdense[6]++;
0501     else
0502       numpass[6]++;
0503   }
0504   cout << "HB HashIds (pass, collisions, non-dense) = (" << numpass[0] << "," << numfails[0] << "," << numnotdense[0]
0505        << ")" << endl;
0506   cout << "HE HashIds (pass, collisions, non-dense) = (" << numpass[1] << "," << numfails[1] << "," << numnotdense[1]
0507        << ")" << endl;
0508   cout << "HF HashIds (pass, collisions, non-dense) = (" << numpass[2] << "," << numfails[2] << "," << numnotdense[2]
0509        << ")" << endl;
0510   cout << "HO HashIds (pass, collisions, non-dense) = (" << numpass[3] << "," << numfails[3] << "," << numnotdense[3]
0511        << ")" << endl;
0512   cout << "CALIB/HX HashIds (pass, collisions, non-dense) = (" << numpass[4] << "," << numfails[4] << ","
0513        << numnotdense[4] << ")" << endl;
0514   cout << "ZDC HashIds (pass, collisions, non-dense) = (" << numpass[5] << "," << numfails[5] << "," << numnotdense[5]
0515        << ")" << endl;
0516   cout << "HT HashIds (pass, collisions, non-dense) = (" << numpass[6] << "," << numfails[6] << "," << numnotdense[6]
0517        << ")" << endl;
0518 }
0519 
0520 void HcalLogicalMap::checkElectronicsHashIds() {
0521   std::vector<int> Electronics_Hashes_;
0522 
0523   int numfails = 0;
0524   int numpass = 0;
0525   int numnotdense = 0;
0526 
0527   cout << "\nRunning the hash checker for electronics Ids..." << endl;
0528   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it != HBHEHFEntries_.end(); ++it) {
0529     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
0530   }
0531   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it != ZDCEntries_.end(); ++it) {
0532     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
0533   }
0534   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it != CALIBEntries_.end(); ++it) {
0535     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
0536   }
0537   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it != HOHXEntries_.end(); ++it) {
0538     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
0539   }
0540   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it != HTEntries_.end(); ++it) {
0541     Electronics_Hashes_.push_back((it->getHcalTrigElectronicsId()).linearIndex());
0542   }
0543 
0544   sort(Electronics_Hashes_.begin(), Electronics_Hashes_.end());
0545 
0546   for (unsigned int i = 0; i < Electronics_Hashes_.size() - 1; i++) {
0547     int diff = Electronics_Hashes_.at(i + 1) - Electronics_Hashes_.at(i);
0548     if (diff == 0)
0549       numfails++;
0550     else if (diff > 1)
0551       numnotdense++;
0552     else
0553       numpass++;
0554   }
0555   cout << "Electronics Id linearIndex (pass, collisions, nondense) = (" << numpass << "," << numfails << ","
0556        << numnotdense << ")" << endl;
0557 }