CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/Geometry/EcalCommonData/src/EcalBarrelNumberingScheme.cc

Go to the documentation of this file.
00001 
00002 // File: EcalBarrelNumberingScheme.cc
00003 // Description: Numbering scheme for barrel electromagnetic calorimeter
00005 #include "Geometry/EcalCommonData/interface/EcalBarrelNumberingScheme.h"
00006 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00007 
00008 #include <iostream>
00009 
00010 EcalBarrelNumberingScheme::EcalBarrelNumberingScheme() : 
00011   EcalNumberingScheme() {
00012   edm::LogInfo("EcalGeom") << "Creating EcalBarrelNumberingScheme";
00013 }
00014 
00015 EcalBarrelNumberingScheme::~EcalBarrelNumberingScheme() {
00016   edm::LogInfo("EcalGeom") << "Deleting EcalBarrelNumberingScheme";
00017 }
00018 
00019 uint32_t EcalBarrelNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
00020 
00021   const uint32_t nLevels ( baseNumber.getLevels() ) ;
00022 
00023 //  LogDebug("EcalGeom") << "ECalBarrelNumberingScheme geometry levels = " << nLevels;
00024   
00025 
00026   if( 12 > nLevels )
00027   {   
00028      edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
00029                                  << "Not enough levels found in EcalBaseNumber ( "
00030                                  <<  nLevels 
00031                                  << ") Returning 0" ;
00032      return 0;
00033   }
00034 
00035   const std::string& cryName ( baseNumber.getLevelName( 0 ) ) ; // name of crystal volume
00036 
00037   const int cryType ( ::atoi( cryName.c_str() + 5 ) ) ;
00038 
00039   const int off ( 12 < nLevels ? 3 : 0 ) ;
00040 
00041   const uint32_t wallCopy ( baseNumber.getCopyNumber( 3 + off ) ) ;
00042   const uint32_t hawCopy  ( baseNumber.getCopyNumber( 4 + off ) ) ;
00043   const uint32_t fawCopy  ( baseNumber.getCopyNumber( 5 + off ) ) ;
00044   const uint32_t supmCopy ( baseNumber.getCopyNumber( 6 + off ) ) ;
00045 
00046 //      LogDebug("EcalGeom") << baseNumber.getLevelName(0) << ", "
00047 //                           << baseNumber.getLevelName(1) << ", "
00048 //                           << baseNumber.getLevelName(2) << ", "
00049 //                           << baseNumber.getLevelName(3) << ", "
00050 //                           << baseNumber.getLevelName(4) << ", "
00051 //                           << baseNumber.getLevelName(5) << ", "
00052 //                           << baseNumber.getLevelName(6) << ", "
00053 //                           << baseNumber.getLevelName(7)         ;
00054 
00055       // error checking
00056 
00057   if( 1  > cryType ||
00058       17 < cryType    )
00059   {
00060      edm::LogWarning("EdalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
00061                                  << "****************** Bad crystal name = " 
00062                                  << cryName 
00063                                  << ", Volume Name = " 
00064                                  << baseNumber.getLevelName(0)              ;
00065      return 0 ;
00066   }
00067 
00068   if( 1 > wallCopy ||
00069       5 < wallCopy    )
00070   {
00071      edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
00072                                  << "****************** Bad wall copy = " 
00073                                  << wallCopy 
00074                                  << ", Volume Name = " 
00075                                  << baseNumber.getLevelName(3)              ;
00076      return 0 ;
00077   }
00078 
00079   if( 1 > hawCopy ||
00080       2 < hawCopy    )
00081   {
00082      edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
00083                                  << "****************** Bad haw copy = " 
00084                                  << hawCopy  
00085                                  << ", Volume Name = " 
00086                                  << baseNumber.getLevelName(4)              ;
00087      return 0 ;
00088   }
00089 
00090   if( 1  > fawCopy ||
00091       10 < fawCopy    )
00092   {
00093      edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
00094                                  << "****************** Bad faw copy = " 
00095                                  << fawCopy  
00096                                  << ", Volume Name = " 
00097                                  << baseNumber.getLevelName(5)              ;
00098      return 0 ;
00099   }
00100 
00101   if( 1  > supmCopy ||
00102       36 < supmCopy    )
00103   {
00104      edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
00105                                  << "****************** Bad supermodule copy = " 
00106                                  << supmCopy 
00107                                  << ", Volume Name = " 
00108                                  << baseNumber.getLevelName(6)              ;
00109      return 0 ;
00110   }
00111 
00112   // all inputs are fine. Go ahead and decode
00113 
00114   const int32_t zsign    ( 18 < supmCopy ? -1 : 1 ) ;
00115 
00116   const int32_t eta      ( 5*( cryType - 1 ) + wallCopy ) ;
00117 
00118   const int32_t phi      ( 18 < supmCopy ?
00119                            20*( supmCopy - 19 ) + 2*( 10 - fawCopy ) + 3 - hawCopy :
00120                            20*( supmCopy -  1 ) + 2*( fawCopy - 1  ) +     hawCopy   ) ;
00121 
00122   const int32_t intindex ( EBDetId( zsign*eta, phi ).rawId() ) ;
00123 
00124 /*
00125   static int count ( 1 ) ;
00126   if( 0==count%1000 )
00127   {
00128      std::cout<<"************************** NLEVELS="<<nLevels
00129               <<", eta="<<eta<<", phi="<<phi<<", zsign="<<zsign<<std::endl;
00130   }
00131   ++count;
00132 */
00133 //      LogDebug("EcalGeom") << "EcalBarrelNumberingScheme: "
00134 //                           << "supmCopy = " << supmCopy
00135 //                           << ", fawCopy = " << fawCopy
00136 //                           << ", hawCopy = " << hawCopy
00137 //                           << ", wallCopy = " << wallCopy
00138 //                           << ", cryType = " << cryType
00139 //                           << "\n           zsign = "  << zsign 
00140 //                           << ", eta = " << eta 
00141 //                           << ", phi = " << phi 
00142 //                           << ", packed index = 0x" << std::hex << intindex << std::dec ;
00143 
00144   return intindex ;  
00145 }