CMS 3D CMS Logo

Public Member Functions

EcalEndcapNumberingScheme Class Reference

#include <EcalEndcapNumberingScheme.h>

Inheritance diagram for EcalEndcapNumberingScheme:
EcalNumberingScheme CaloNumberingScheme

List of all members.

Public Member Functions

 EcalEndcapNumberingScheme ()
virtual uint32_t getUnitID (const EcalBaseNumber &baseNumber) const
 ~EcalEndcapNumberingScheme ()

Detailed Description

Definition at line 10 of file EcalEndcapNumberingScheme.h.


Constructor & Destructor Documentation

EcalEndcapNumberingScheme::EcalEndcapNumberingScheme ( )

Definition at line 11 of file EcalEndcapNumberingScheme.cc.

                                                     : 
  EcalNumberingScheme() {
  edm::LogInfo("EcalGeom") << "Creating EcalEndcapNumberingScheme";
}
EcalEndcapNumberingScheme::~EcalEndcapNumberingScheme ( )

Definition at line 16 of file EcalEndcapNumberingScheme.cc.

                                                      {
  edm::LogInfo("EcalGeom") << "Deleting EcalEndcapNumberingScheme";
}

Member Function Documentation

uint32_t EcalEndcapNumberingScheme::getUnitID ( const EcalBaseNumber baseNumber) const [virtual]

Implements EcalNumberingScheme.

Definition at line 19 of file EcalEndcapNumberingScheme.cc.

References DetId::Ecal, EcalBaseNumber::getCopyNumber(), EcalBaseNumber::getLevelName(), EcalBaseNumber::getLevels(), ExpressReco_HICollisions_FallBack::id, DetId::rawId(), EEDetId::SCCRYSTALMODE, EEDetId::Subdet, and EEDetId::validDetId().

                                                                                    {


   const uint32_t nLevels ( baseNumber.getLevels() ) ;

   //LogDebug("EcalGeom") << "ECalEndcapNumberingScheme geometry levels = " << nLevels;
  
   if( 7 > nLevels )
   {
      
      edm::LogWarning("EcalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                  << "Not enough levels found in EcalBaseNumber ( "
                                  <<  nLevels 
                                  << ") Returning 0" ;
      return 0;
   }

   if ( nLevels <= 10 ) 
   {
    
  
  // Static geometry


  if (baseNumber.getLevels()<1) {
    edm::LogWarning("EcalGeom") << "EalEndcaplNumberingScheme::getUnitID: No "
                                << "level found in EcalBaseNumber Returning 0";
    return 0;
  }

  int PVid = baseNumber.getCopyNumber(0);
  int MVid = 1;
  if (baseNumber.getLevels() > 1) 
    MVid = baseNumber.getCopyNumber(1);
  else 
    edm::LogWarning("EcalGeom") << "ECalEndcapNumberingScheme::getUnitID: Null"
                                << " pointer to alveole ! Use default id=1";

  int zside   = baseNumber.getCopyNumber("EREG");
  zside=2*(1-zside)+1;
  int module_number  = MVid;
  int crystal_number  = PVid;

  uint32_t intindex = EEDetId(module_number,crystal_number,zside,EEDetId::SCCRYSTALMODE).rawId();
  
//LogDebug("EcalGeom") << "EcalEndcapNumberingScheme: zside = "  << zside 
//                     << " super crystal = " << module_number << " crystal = "
//                     << crystal_number << " packed index = 0x" << std::hex 
//                     << intindex << std::dec;


  return intindex;
   }
   else
   {
      // algorithmic geometry

      const int ic  ( baseNumber.getCopyNumber(0)%100 ) ; // crystal #, 0-44
      const int icx ( ic/10 ) ;
      const int icy ( ic%5 ) ;
      const int is  ( baseNumber.getCopyNumber(2)%100 ) ; // supercrystal #, 0-99
      const int isx ( is/10 ) ;
      const int isy ( is%10 ) ;

      const int iq  ( 3 - 2*baseNumber.getCopyNumber(3) ) ; // quadrant #, -1, +1
      const int id  ( 3 - 2*baseNumber.getCopyNumber(5) ) ; // dee      #, -1, +1

      const int iz  ( 3 - 2*baseNumber.getCopyNumber(7) ) ; // z: -1, +1

      const int ix  ( 50 + id*iz*( 5*isx + icx + 1 ) - ( id*iz - 1 )/2 ) ; // x: 1-100
      const int iy  ( 50 + id*iq*( 5*isy + icy + 1 ) - ( id*iq - 1 )/2 ) ; // y: 1-100

      const uint32_t idet ( DetId( DetId::Ecal, EEDetId::Subdet ) | ( ( ( 0<iz ? 0x4000 : 0 ) ) + ( ix<<7 ) + iy ) ) ;

      //*************************** ERROR CHECKING **********************************

      if( 0 > icx ||
          4 < icx ||
          0 > icy ||
          4 < icy    )
      {
         edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                     << "****************** Bad crystal number = " << ic 
                                     << ", Volume Name = " << baseNumber.getLevelName(0)              ;
         return 0 ;
      }

      if( 0 > isx ||
          9 < isx ||
          0 > isy ||
          9 < isy    )
      {
         edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                     << "****************** Bad supercrystal number = " << is 
                                     << ", Volume Name = " << baseNumber.getLevelName(3)              ;
         return 0 ;
      }

      if( 1  != iq &&
          -1 != iq    )
      {
         edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                     << "****************** Bad quadrant number = " << iq 
                                     << ", Volume Name = " << baseNumber.getLevelName(4)              ;
         return 0 ;
      }

      if( 1  != id &&
          -1 != id    )
      {
         edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                     << "****************** Bad dee number = " << id
                                     << ", Volume Name = " << baseNumber.getLevelName(6)              ;
         return 0 ;
      }
      
      if( -1 != iz &&
           1 != iz    )
      {
         edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                     << "****************** Bad z-end number = " << iz
                                     << ", Volume Name = " << baseNumber.getLevelName(8)              ;
         return 0 ;
      }

      if( !EEDetId::validDetId( ix, iy, iz ) )
      {
         edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                     << "****************** Bad DetId numbers = " 
                                     << ix << ", " << iy << ", " << iz               ;
         return 0 ;
      }

      //*************************************************************************************
/*
      edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
                                  <<std::dec<< ix << ", " << iy << ", " <<iq << ", " << id << ", " << iz << ", " << std::hex << idet              ;

      edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::EEDetId: "
                                  << EEDetId(idet)              ;
*/
      return idet ;
   }
}