CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondFormats/HcalObjects/src/HcalLogicalMap.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00002 #include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
00003 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00004 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00005 
00006 #include <string>
00007 #include <cstring>
00008 #include <iostream>
00009 #include <fstream>
00010 #include <sstream>
00011 #include <stdio.h>
00012 #include <time.h>
00013 
00014 using namespace std;
00015 
00016 HcalLogicalMap::HcalLogicalMap(const HcalTopology* topo,std::vector<HBHEHFLogicalMapEntry>& HBHEHFEntries,
00017                                std::vector<HOHXLogicalMapEntry>& HOHXEntries,
00018                                std::vector<CALIBLogicalMapEntry>& CALIBEntries,
00019                                std::vector<ZDCLogicalMapEntry>& ZDCEntries,
00020                                std::vector<HTLogicalMapEntry>& HTEntries,
00021                                std::vector<uint32_t>& LinearIndex2Entry,
00022                                std::vector<uint32_t>& HbHash2Entry,
00023                                std::vector<uint32_t>& HeHash2Entry,
00024                                std::vector<uint32_t>& HfHash2Entry,
00025                                std::vector<uint32_t>& HtHash2Entry,
00026                                std::vector<uint32_t>& HoHash2Entry,
00027                                std::vector<uint32_t>& HxCalibHash2Entry,
00028                                std::vector<uint32_t>& ZdcHash2Entry) : topo_(topo)
00029 
00030 {
00031   HBHEHFEntries_.resize(HBHEHFEntries.size());
00032   HOHXEntries_.resize(HOHXEntries.size());
00033   CALIBEntries_.resize(CALIBEntries.size());
00034   ZDCEntries_.resize(ZDCEntries.size());
00035   HTEntries_.resize(HTEntries.size());
00036 
00037   LinearIndex2Entry_.resize(LinearIndex2Entry.size());
00038   HbHash2Entry_.resize(HbHash2Entry.size());
00039   HeHash2Entry_.resize(HeHash2Entry.size());
00040   HfHash2Entry_.resize(HfHash2Entry.size());
00041   HtHash2Entry_.resize(HtHash2Entry.size());
00042   HoHash2Entry_.resize(HoHash2Entry.size());
00043   HxCalibHash2Entry_.resize(HxCalibHash2Entry.size());
00044   ZdcHash2Entry_.resize(ZdcHash2Entry.size());
00045   
00046   copy(HBHEHFEntries.begin(),HBHEHFEntries.end(),HBHEHFEntries_.begin());
00047   copy(HOHXEntries.begin(),HOHXEntries.end(),HOHXEntries_.begin());
00048   copy(CALIBEntries.begin(),CALIBEntries.end(),CALIBEntries_.begin());
00049   copy(ZDCEntries.begin(),ZDCEntries.end(),ZDCEntries_.begin());
00050   copy(HTEntries.begin(),HTEntries.end(),HTEntries_.begin());
00051   copy(LinearIndex2Entry.begin(),LinearIndex2Entry.end(),LinearIndex2Entry_.begin());
00052   copy(HbHash2Entry.begin(),HbHash2Entry.end(),HbHash2Entry_.begin());
00053   copy(HeHash2Entry.begin(),HeHash2Entry.end(),HeHash2Entry_.begin());
00054   copy(HfHash2Entry.begin(),HfHash2Entry.end(),HfHash2Entry_.begin());
00055   copy(HtHash2Entry.begin(),HtHash2Entry.end(),HtHash2Entry_.begin());
00056   copy(HoHash2Entry.begin(),HoHash2Entry.end(),HoHash2Entry_.begin());
00057   copy(HxCalibHash2Entry.begin(),HxCalibHash2Entry.end(),HxCalibHash2Entry_.begin());
00058   copy(ZdcHash2Entry.begin(),ZdcHash2Entry.end(),ZdcHash2Entry_.begin());
00059 }
00060 
00061 HcalLogicalMap::~HcalLogicalMap()
00062 {
00063 }
00064 
00065 uint32_t HcalLogicalMap::makeEntryNumber(bool isvalid, int vectorid, int entry)
00066 {
00067   uint32_t answer=0;
00068   answer|=isvalid;
00069   answer|=(vectorid&0x3)<<1;
00070   answer|=entry<<3;
00071   return answer;
00072 }
00073 
00074 void HcalLogicalMap::printMap( unsigned int mapIOV ){  
00075   using namespace std;
00076 
00077   static FILE* HBEFmap; 
00078   static FILE* HOXmap;
00079   static FILE* CALIBmap; 
00080   static FILE* ZDCmap; 
00081   static FILE* HTmap;  
00082   
00083   char tempbuff[30];
00084 
00085   stringstream mystream;
00086   string HBEFmapstr, HOXmapstr, CALIBmapstr, ZDCmapstr, HTmapstr;
00087   string date;
00088   string IOVlabel;
00089   
00090   time_t myTime;
00091   time(&myTime);
00092   
00093   strftime(tempbuff,128,"%d.%b.%Y",localtime(&myTime) );
00094   mystream<<tempbuff;
00095   date= mystream.str();
00096 
00097   mystream.str("");
00098   if      (mapIOV==1) IOVlabel = "A";
00099   else if (mapIOV==2) IOVlabel = "B";
00100   else if (mapIOV==3) IOVlabel = "C";
00101   else                IOVlabel = "D";
00102 
00103   HBEFmapstr  = "./HCALmapHBEF_"+IOVlabel+".txt";
00104   HOXmapstr   = "./HCALmapHO_"+IOVlabel+".txt";
00105   CALIBmapstr = "./HCALmapCALIB_"+IOVlabel+".txt";
00106   ZDCmapstr   = "./ZDCmap_"+IOVlabel+".txt";
00107   HTmapstr    = "./HCALmapHT_"+IOVlabel+".txt";
00108 
00109 //  HBEFmapstr  = "./HCALmapHBEF_"+date+".txt";
00110 //  HOXmapstr   = "./HCALmapHO_"+date+"_"+IOVlabel+".txt";
00111 //  CALIBmapstr = "./HCALmapCALIB_"+date+".txt";
00112 //  ZDCmapstr   = "./ZDCmap_"+date+".txt";
00113 //  HTmapstr    = "./HCALmapHT_"+date+".txt";
00114   
00115   HBEFmap     = fopen(HBEFmapstr.c_str(),"w");
00116   HOXmap      = fopen(HOXmapstr.c_str(),"w");
00117   CALIBmap    = fopen(CALIBmapstr.c_str(),"w");
00118   ZDCmap      = fopen(ZDCmapstr.c_str(),"w");
00119   HTmap       = fopen(HTmapstr.c_str(),"w");
00120   /**********************/
00121 
00122   if(HBEFmap) {
00123     fprintf(HBEFmap,"## file created %s ##\n",date.c_str());
00124     printHBEFMap(HBEFmap);
00125   }
00126   else cout <<HBEFmapstr<<" not found!"<<endl;
00127 
00128   if(HOXmap) {
00129     fprintf(HOXmap,"## file created %s ##\n",date.c_str());
00130     printHOXMap(HOXmap);
00131   }
00132   else cout <<HOXmapstr<<" not found!"<<endl;
00133 
00134   if(CALIBmap) {
00135     fprintf(CALIBmap,"## file created %s ##\n",date.c_str());
00136     printCalibMap(CALIBmap);
00137   }
00138   else cout <<CALIBmapstr<<" not found!"<<endl;
00139 
00140   if(ZDCmap) {
00141     fprintf(ZDCmap,"## file created %s ##\n",date.c_str());
00142     printZDCMap(ZDCmap);
00143   }
00144   else cout <<ZDCmapstr<<" not found!"<<endl;
00145 
00146   if(HTmap) {
00147     fprintf(HTmap,"## file created %s ##\n",date.c_str());
00148     printHTMap(HTmap);
00149   }
00150   else cout <<HTmapstr<<" not found!"<<endl;
00151 
00152 }
00153 
00154 /**************/
00155 HcalElectronicsMap HcalLogicalMap::generateHcalElectronicsMap()
00156 {
00157   HcalElectronicsMap* theemap = new HcalElectronicsMap();
00158   
00159   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it!=HBHEHFEntries_.end(); ++it) {
00160     theemap->mapEId2chId( it->getHcalElectronicsId(), it->getDetId() );}
00161   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it!=HOHXEntries_.end(); ++it) {
00162     theemap->mapEId2chId( it->getHcalElectronicsId(), it->getDetId() );}
00163   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it!=CALIBEntries_.end(); ++it) {
00164     theemap->mapEId2chId( it->getHcalElectronicsId(), it->getDetId() );}
00165   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it!=ZDCEntries_.end(); ++it) {
00166     theemap->mapEId2chId( it->getHcalElectronicsId(), it->getDetId() );}
00167   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it!=HTEntries_.end(); ++it) {
00168     theemap->mapEId2tId( it->getHcalTrigElectronicsId(), it->getDetId() );}
00169   theemap->sort();
00170   return *theemap;
00171 }
00172 /**************/
00173 
00174 void HcalLogicalMap::printHBEFMap(FILE* hbefmapfile){
00175   int titlecounter = 0;
00176 
00177   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it!=HBHEHFEntries_.end(); ++it) {
00178     titlecounter = titlecounter % 21;
00179     if (titlecounter == 0){
00180       fprintf(hbefmapfile,"#   side    eta    phi   dphi  depth    det     rbx  wedge     rm  pixel   qie    adc");
00181       fprintf(hbefmapfile,"  rm_fi  fi_ch  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc    slb  slbin  slbin2");
00182       fprintf(hbefmapfile,"           slnam    rctcra rctcar rctcon               rctnam     fedid\n");
00183     }
00184     titlecounter++;
00185     fprintf(hbefmapfile,"%s",it->printLMapLine());
00186   }
00187 }
00188 
00189 void HcalLogicalMap::printHOXMap(FILE* hoxmapfile){
00190 
00191   int titlecounter = 0;
00192 
00193   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it!=HOHXEntries_.end(); ++it) {
00194     titlecounter = titlecounter % 21;
00195     if (titlecounter == 0){
00196       fprintf(hoxmapfile,"#   side    eta    phi   dphi  depth    det     rbx  sector    rm  pixel   qie    adc");
00197       fprintf(hoxmapfile,"  rm_fi  fi_ch let_code  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc  fedid\n");
00198     }
00199     titlecounter++;
00200     fprintf(hoxmapfile,"%s",it->printLMapLine());
00201   }    
00202 }
00203 
00204 void HcalLogicalMap::printCalibMap(FILE* calibmapfile){
00205 
00206   int titlecounter = 0;
00207 
00208   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it!=CALIBEntries_.end(); ++it) {
00209     titlecounter = titlecounter % 21;
00210     if (titlecounter == 0){       
00211       fprintf(calibmapfile,"#   side    eta    phi   dphi    det     rbx  sector  rm  rm_fi ");
00212       fprintf(calibmapfile," fi_ch  crate  htr  fpga  htr_fi  dcc_sl  spigo  dcc  fedid  ch_type      name\n");
00213     }
00214     titlecounter++;
00215     fprintf(calibmapfile,"%s",it->printLMapLine());
00216   }
00217 }
00218 
00219 void HcalLogicalMap::printZDCMap(FILE* zdcmapfile){
00220 
00221   int titlecounter = 0;
00222 
00223   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it!=ZDCEntries_.end(); ++it) {
00224     titlecounter = titlecounter % 21;
00225     if (titlecounter == 0){
00226       fprintf(zdcmapfile,"#  side  x  y  dx  depth     det  det_ch  cable  rm  qie ");
00227       fprintf(zdcmapfile," adc  rm_fi  fi_ch  crate  htr  fpga  htr_fi  dcc_sl  spigo  dcc  fedid\n");
00228     }
00229     titlecounter++;
00230     fprintf(zdcmapfile,"%s",it->printLMapLine());
00231   }
00232 }
00233 
00234 void HcalLogicalMap::printHTMap(FILE* htmapfile){
00235 
00236   int titlecounter = 0;
00237 
00238   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it!=HTEntries_.end(); ++it) {
00239     titlecounter = titlecounter % 21;
00240       if (titlecounter == 0){
00241         fprintf(htmapfile,"#  side  eta  phi  dphi  depth  det   wedge  crate");
00242         fprintf(htmapfile,"  htr  fpga  dcc_sl  spigo  dcc  slb  slbin  slbin2  nDat    ");
00243         fprintf(htmapfile,"     slnam  rctcra  rctcar  rctcon            rctnam  fedid\n");
00244       }
00245     titlecounter++;
00246     fprintf(htmapfile,"%s",it->printLMapLine());
00247   }
00248 }
00249 
00250 
00251 const DetId HcalLogicalMap::getDetId(const HcalElectronicsId& eid)
00252 {
00253   const uint32_t entry=LinearIndex2Entry_.at(eid.linearIndex());
00254   if ( !(entry&0x1) ) return DetId(0);
00255   if ( ((entry>>1)&0x3)==0) return HBHEHFEntries_.at(entry>>3).getDetId();
00256   if ( ((entry>>1)&0x3)==1) return HOHXEntries_.at(entry>>3).getDetId();
00257   if ( ((entry>>1)&0x3)==2) return CALIBEntries_.at(entry>>3).getDetId();
00258   if ( ((entry>>1)&0x3)==3) return ZDCEntries_.at(entry>>3).getDetId();
00259   return DetId(0);
00260 }
00261 
00262 const HcalFrontEndId HcalLogicalMap::getHcalFrontEndId(const DetId& did)
00263 {
00264   const HcalGenericDetId hgdi(did);
00265   
00266   const HcalGenericDetId::HcalGenericSubdetector hgsd=hgdi.genericSubdet();
00267   if (hgsd==HcalGenericDetId::HcalGenBarrel) {
00268     const int hashedId=topo_->detId2denseIdHB(did);
00269     const uint32_t entry=HbHash2Entry_.at(hashedId)-1;
00270     return HBHEHFEntries_.at(entry).getHcalFrontEndId();
00271   }
00272   else if (hgsd==HcalGenericDetId::HcalGenEndcap) {
00273     const int hashedId=topo_->detId2denseIdHE(did);
00274     const uint32_t entry=HeHash2Entry_.at(hashedId)-1;
00275     return HBHEHFEntries_.at(entry).getHcalFrontEndId();
00276   }
00277   else if (hgsd==HcalGenericDetId::HcalGenForward) {
00278     const int hashedId=topo_->detId2denseIdHF(did);
00279     const uint32_t entry=HfHash2Entry_.at(hashedId)-1;
00280     return HBHEHFEntries_.at(entry).getHcalFrontEndId();
00281   }
00282   else if (hgsd==HcalGenericDetId::HcalGenOuter) {
00283     const int hashedId=topo_->detId2denseIdHO(did);
00284     const uint32_t entry=HoHash2Entry_.at(hashedId)-1;
00285     return HOHXEntries_.at(entry).getHcalFrontEndId();
00286   }
00287   else if (hgsd==HcalGenericDetId::HcalGenCalibration) {
00288     HcalCalibDetId hcid(did);
00289     if (hcid.calibFlavor()==HcalCalibDetId::HOCrosstalk) {
00290       const int hashedId=topo_->detId2denseIdCALIB(did);
00291       const uint32_t entry=HxCalibHash2Entry_.at(hashedId)-1;
00292       return HOHXEntries_.at(entry).getHcalFrontEndId();
00293     }
00294     else if (hcid.calibFlavor()==HcalCalibDetId::CalibrationBox) {
00295       const int hashedId=topo_->detId2denseIdCALIB(did);
00296       const uint32_t entry=HxCalibHash2Entry_.at(hashedId)-1;
00297       return CALIBEntries_.at(entry).getHcalFrontEndId();
00298     }
00299   }
00300   return HcalFrontEndId(0);
00301 }
00302 
00303 void HcalLogicalMap::checkIdFunctions() {
00304   int HBHEHF_EID_pass=0;
00305   int HBHEHF_EID_fail=0;
00306   int HOHX_EID_pass=0;
00307   int HOHX_EID_fail=0;
00308   int CALIB_EID_pass=0;
00309   int CALIB_EID_fail=0;
00310   int ZDC_EID_pass=0;
00311   int ZDC_EID_fail=0;
00312 
00313   int HBHEHF_FEID_pass=0;
00314   int HBHEHF_FEID_fail=0;
00315   int HOHX_FEID_pass=0;
00316   int HOHX_FEID_fail=0;
00317   int CALIB_FEID_pass=0;
00318   int CALIB_FEID_fail=0;
00319 
00320   cout << "\nRunning the id function checker..." << endl;
00321 
00322   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it!=HBHEHFEntries_.end(); ++it) {
00323     const HcalElectronicsId heid=it->getHcalElectronicsId();
00324     const DetId did0=it->getDetId();
00325     const DetId did1=getDetId(heid);
00326     if (did0==did1) HBHEHF_EID_pass++;
00327     else HBHEHF_EID_fail++;
00328 
00329     const HcalFrontEndId hfeid0=it->getHcalFrontEndId();
00330     const HcalFrontEndId hfeid1=getHcalFrontEndId(did0);
00331     if (hfeid0==hfeid1) HBHEHF_FEID_pass++;
00332     else HBHEHF_FEID_fail++;
00333   }
00334   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it!=HOHXEntries_.end(); ++it) {
00335     const HcalElectronicsId heid=it->getHcalElectronicsId();
00336     const DetId did0=it->getDetId();
00337     const DetId did1=getDetId(heid);
00338     if (did0==did1) HOHX_EID_pass++;
00339     else HOHX_EID_fail++;
00340 
00341     const HcalFrontEndId hfeid0=it->getHcalFrontEndId();
00342     const HcalFrontEndId hfeid1=getHcalFrontEndId(did0);
00343     if (hfeid0==hfeid1) HOHX_FEID_pass++;
00344     else HOHX_FEID_fail++;
00345   }
00346   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it!=CALIBEntries_.end(); ++it) {
00347     const HcalElectronicsId heid=it->getHcalElectronicsId();
00348     const DetId did0=it->getDetId();
00349     const DetId did1=getDetId(heid);
00350     if (did0==did1) CALIB_EID_pass++;
00351     else CALIB_EID_fail++;
00352 
00353     const HcalFrontEndId hfeid0=it->getHcalFrontEndId();
00354     const HcalFrontEndId hfeid1=getHcalFrontEndId(did0);
00355     if (hfeid0==hfeid1) CALIB_FEID_pass++;
00356     else CALIB_FEID_fail++;
00357   }
00358   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it!=ZDCEntries_.end(); ++it) {
00359     const HcalElectronicsId heid=it->getHcalElectronicsId();
00360     const DetId did0=it->getDetId();
00361     const DetId did1=getDetId(heid);
00362     if (did0==did1) ZDC_EID_pass++;
00363     else ZDC_EID_fail++;
00364   }
00365   
00366   cout << "Checking detIds from electronics ids..." << endl;
00367   cout << "HBHEHF EID (pass,fail) = (" << HBHEHF_EID_pass << "," << HBHEHF_EID_fail << ")" << endl;
00368   cout << "HOHX EID (pass,fail) = (" << HOHX_EID_pass << "," << HOHX_EID_fail << ")" << endl;
00369   cout << "CALIB EID (pass,fail) = (" << CALIB_EID_pass << "," << CALIB_EID_fail << ")" << endl;
00370   cout << "ZDC EID (pass,fail) = (" << ZDC_EID_pass << "," << ZDC_EID_fail << ")" << endl;
00371   cout << endl;
00372   cout << "Checking frontEndIds from electronics ids..." << endl;
00373   cout << "HBHEHF FEID (pass,fail) = (" << HBHEHF_FEID_pass << "," << HBHEHF_FEID_fail << ")" << endl;
00374   cout << "HOHX FEID (pass,fail) = (" << HOHX_FEID_pass << "," << HOHX_FEID_fail << ")" << endl;
00375   cout << "CALIB FEID (pass,fail) = (" << CALIB_FEID_pass << "," << CALIB_FEID_fail << ")" << endl;
00376 }
00377 
00378 
00379 void HcalLogicalMap::checkHashIds() {
00380   std::vector<int> HB_Hashes_;     // index 0
00381   std::vector<int> HE_Hashes_;     // index 1
00382   std::vector<int> HF_Hashes_;     // index 2
00383   std::vector<int> HO_Hashes_;     // index 3
00384   std::vector<int> CALIBHX_Hashes_;// index 4
00385   std::vector<int> ZDC_Hashes_;    // index 5
00386   std::vector<int> HT_Hashes_;     // index 6
00387 
00388   int numfails[7]    = {0,0,0,0,0,0,0};
00389   int numpass[7]     = {0,0,0,0,0,0,0};
00390   int numnotdense[7] = {0,0,0,0,0,0,0};
00391 
00392   cout << "\nRunning the hash checker for detIds..." << endl;
00393   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it!=HBHEHFEntries_.end(); ++it) {
00394     if (it->getDetId().subdetId()==HcalBarrel) {
00395       HB_Hashes_.push_back(topo_->detId2denseIdHB(it->getDetId()));
00396     }
00397     else if (it->getDetId().subdetId()==HcalEndcap) {
00398       HE_Hashes_.push_back(topo_->detId2denseIdHE(it->getDetId()));
00399     }
00400     else if (it->getDetId().subdetId()==HcalForward) {
00401       HF_Hashes_.push_back(topo_->detId2denseIdHF(it->getDetId()));
00402     }
00403   }
00404   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it!=HOHXEntries_.end(); ++it) {
00405     if (HcalGenericDetId(it->getDetId().rawId()).isHcalCalibDetId() ) {
00406       CALIBHX_Hashes_.push_back(topo_->detId2denseIdCALIB(it->getDetId()));
00407     }
00408     else {
00409       HO_Hashes_.push_back(topo_->detId2denseIdHO(it->getDetId()));
00410     }
00411   }
00412   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it!=CALIBEntries_.end(); ++it) {
00413     CALIBHX_Hashes_.push_back(topo_->detId2denseIdCALIB(it->getDetId()));
00414   }
00415   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it!=ZDCEntries_.end(); ++it) {
00416     ZDC_Hashes_.push_back(HcalZDCDetId(it->getDetId()).denseIndex());
00417   }
00418   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it!=HTEntries_.end(); ++it) {
00419     HT_Hashes_.push_back(topo_->detId2denseIdHT(it->getDetId()));
00420   }
00421 
00422   sort(HB_Hashes_.begin()     , HB_Hashes_.end());
00423   sort(HE_Hashes_.begin()     , HE_Hashes_.end());
00424   sort(HF_Hashes_.begin()     , HF_Hashes_.end());
00425   sort(HO_Hashes_.begin()     , HO_Hashes_.end());
00426   sort(CALIBHX_Hashes_.begin(), CALIBHX_Hashes_.end());
00427   sort(ZDC_Hashes_.begin()    , ZDC_Hashes_.end());
00428   sort(HT_Hashes_.begin()     , HT_Hashes_.end());
00429 
00430   for(unsigned int i = 0; i<HB_Hashes_.size()-1; i++) {
00431     int diff = HB_Hashes_.at(i+1)-HB_Hashes_.at(i);
00432     if (diff==0) numfails[0]++;
00433     else if (diff>1) numnotdense[0]++;
00434     else numpass[0]++;
00435   }
00436   for(unsigned int i = 0; i<HE_Hashes_.size()-1; i++) {
00437     int diff = HE_Hashes_.at(i+1)-HE_Hashes_.at(i);
00438     if (diff==0) numfails[1]++;
00439     else if (diff>1) numnotdense[1]++;
00440     else numpass[1]++;
00441   }
00442   for(unsigned int i = 0; i<HF_Hashes_.size()-1; i++) {
00443     int diff = HF_Hashes_.at(i+1)-HF_Hashes_.at(i);
00444     if (diff==0) numfails[2]++;
00445     else if (diff>1) numnotdense[2]++;
00446     else numpass[2]++;
00447   }
00448   for(unsigned int i = 0; i<HO_Hashes_.size()-1; i++) {
00449     int diff = HO_Hashes_.at(i+1)-HO_Hashes_.at(i);
00450     if (diff==0) numfails[3]++;
00451     else if (diff>1) numnotdense[3]++;
00452     else numpass[3]++;
00453   }
00454   for(unsigned int i = 0; i<CALIBHX_Hashes_.size()-1; i++) {
00455     int diff = CALIBHX_Hashes_.at(i+1)-CALIBHX_Hashes_.at(i);
00456     if (diff==0) numfails[4]++;
00457     else if (diff>1) numnotdense[4]++;
00458     else numpass[4]++;
00459   }
00460   for(unsigned int i = 0; i<ZDC_Hashes_.size()-1; i++) {
00461     int diff = ZDC_Hashes_.at(i+1)-ZDC_Hashes_.at(i);
00462     if (diff==0) numfails[5]++;
00463     else if (diff>1) numnotdense[5]++;
00464     else numpass[5]++;
00465   }
00466   for(unsigned int i = 0; i<HT_Hashes_.size()-1; i++) {
00467     int diff = HT_Hashes_.at(i+1)-HT_Hashes_.at(i);
00468     if (diff==0) numfails[6]++;
00469     else if (diff>1) numnotdense[6]++;
00470     else numpass[6]++;
00471   }
00472   cout << "HB HashIds (pass, collisions, non-dense) = (" << numpass[0] << "," << numfails[0] << "," << numnotdense[0] << ")" << endl;
00473   cout << "HE HashIds (pass, collisions, non-dense) = (" << numpass[1] << "," << numfails[1] << "," << numnotdense[1] << ")" << endl;
00474   cout << "HF HashIds (pass, collisions, non-dense) = (" << numpass[2] << "," << numfails[2] << "," << numnotdense[2] << ")" << endl;
00475   cout << "HO HashIds (pass, collisions, non-dense) = (" << numpass[3] << "," << numfails[3] << "," << numnotdense[3] << ")" << endl;
00476   cout << "CALIB/HX HashIds (pass, collisions, non-dense) = (" << numpass[4] << "," << numfails[4] << "," << numnotdense[4] << ")" << endl;
00477   cout << "ZDC HashIds (pass, collisions, non-dense) = (" << numpass[5] << "," << numfails[5] << "," << numnotdense[5] << ")" << endl;
00478   cout << "HT HashIds (pass, collisions, non-dense) = (" << numpass[6] << "," << numfails[6] << "," << numnotdense[6] << ")" << endl;
00479 }
00480 
00481 void HcalLogicalMap::checkElectronicsHashIds() {
00482   std::vector<int> Electronics_Hashes_;
00483 
00484   int numfails = 0;
00485   int numpass  = 0;
00486   int numnotdense = 0;
00487 
00488   cout << "\nRunning the hash checker for electronics Ids..." << endl;
00489   for (std::vector<HBHEHFLogicalMapEntry>::iterator it = HBHEHFEntries_.begin(); it!=HBHEHFEntries_.end(); ++it) {
00490     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
00491   }
00492   for (std::vector<ZDCLogicalMapEntry>::iterator it = ZDCEntries_.begin(); it!=ZDCEntries_.end(); ++it) {
00493     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
00494   }
00495   for (std::vector<CALIBLogicalMapEntry>::iterator it = CALIBEntries_.begin(); it!=CALIBEntries_.end(); ++it) {
00496     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
00497   }
00498   for (std::vector<HOHXLogicalMapEntry>::iterator it = HOHXEntries_.begin(); it!=HOHXEntries_.end(); ++it) {
00499     Electronics_Hashes_.push_back((it->getHcalElectronicsId()).linearIndex());
00500   }
00501   for (std::vector<HTLogicalMapEntry>::iterator it = HTEntries_.begin(); it!=HTEntries_.end(); ++it) {
00502     Electronics_Hashes_.push_back((it->getHcalTrigElectronicsId()).linearIndex());
00503   }
00504 
00505   sort(Electronics_Hashes_.begin() , Electronics_Hashes_.end());
00506 
00507   for(unsigned int i = 0; i<Electronics_Hashes_.size()-1; i++) {
00508     int diff = Electronics_Hashes_.at(i+1)-Electronics_Hashes_.at(i);
00509     if (diff==0) numfails++;
00510     else if (diff>1) numnotdense++;
00511     else numpass++;
00512   }
00513   cout << "Electronics Id linearIndex (pass, collisions, nondense) = (" << numpass << "," << numfails << "," << numnotdense << ")" << endl;
00514 }
00515