CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Geometry/ForwardGeometry/src/CastorHardcodeGeometryLoader.cc

Go to the documentation of this file.
00001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00002 #include "Geometry/ForwardGeometry/interface/CastorHardcodeGeometryLoader.h"
00003 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
00004 #include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
00005 #include "Geometry/ForwardGeometry/src/CastorGeometryData.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include <algorithm>
00008 
00009 CastorHardcodeGeometryLoader::CastorHardcodeGeometryLoader() :
00010    theTopology ( new CastorTopology ) ,
00011    extTopology ( theTopology )
00012 {
00013    init();
00014 }
00015 
00016 CastorHardcodeGeometryLoader::CastorHardcodeGeometryLoader( const CastorTopology& ht ) : 
00017    theTopology( 0 ) , 
00018    extTopology ( &ht )
00019 {
00020    init();
00021 }
00022 
00023 void CastorHardcodeGeometryLoader::init() 
00024 {
00025    theEMSectiondX = 2.*dXEMPlate;
00026    theEMSectiondY = 2.*dYEMPlate;
00027    theEMSectiondZ = 101.0;
00028    theHADSectiondX = 2.*dXHADPlate; 
00029    theHADSectiondY = 2.*dYHADPlate;
00030    theHADSectiondZ = 1212.;
00031 }
00032 
00033 std::auto_ptr<CaloSubdetectorGeometry> 
00034 CastorHardcodeGeometryLoader::load( DetId::Detector det, 
00035                                     int             subdet)
00036 {
00037    std::auto_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry( extTopology ));
00038    if( subdet == HcalCastorDetId::SubdetectorId )
00039    {
00040       fill( HcalCastorDetId::EM,  hg.get() ) ;
00041       fill( HcalCastorDetId::HAD, hg.get() ) ;
00042    }
00043    return hg;
00044 }
00045 
00046 std::auto_ptr<CaloSubdetectorGeometry> 
00047 CastorHardcodeGeometryLoader::load() 
00048 {
00049    std::auto_ptr<CaloSubdetectorGeometry> hg
00050       ( new CastorGeometry( extTopology ) ) ;
00051    fill( HcalCastorDetId::EM,  hg.get() ) ;
00052    fill( HcalCastorDetId::HAD, hg.get() ) ;
00053    return hg;
00054 }
00055 
00056 void 
00057 CastorHardcodeGeometryLoader::fill( HcalCastorDetId::Section section , 
00058                                     CaloSubdetectorGeometry* geom      ) 
00059 {
00060    if( geom->cornersMgr() == 0 ) geom->allocateCorners(
00061       HcalCastorDetId::kSizeForDenseIndexing ) ;
00062    if( geom->parMgr()     == 0 ) geom->allocatePar( 
00063       CastorGeometry::k_NumberOfShapes*
00064       CastorGeometry::k_NumberOfParametersPerShape,
00065       CastorGeometry::k_NumberOfParametersPerShape ) ;
00066 
00067    // start by making the new HcalDetIds
00068    std::vector<HcalCastorDetId> castorIds ;
00069 
00070    const int firstCell ( extTopology->firstCell( section ) ) ;
00071    const int lastCell  ( extTopology->lastCell(  section ) );
00072 
00073    for( int imodule ( firstCell ) ; imodule <= lastCell ; ++imodule ) 
00074    {
00075       for( int isector ( 1 ) ;
00076            isector <= HcalCastorDetId::kNumberSectorsPerEnd ; ++isector ) 
00077       {
00078          const HcalCastorDetId id ( section, false, isector, imodule ) ;
00079          if( extTopology->valid( id ) )  castorIds.push_back( id ) ;
00080       }
00081    }
00082 //   edm::LogInfo("CastorHardcodeGeometry") 
00083 //      << "Number of Castor DetIds made: " << section 
00084 //      << " " << castorIds.size();
00085  
00086    // for each new HcalCastorDetId, make a CaloCellGeometry
00087 
00088    for( std::vector<HcalCastorDetId>::const_iterator 
00089            castorIdItr ( castorIds.begin() ) ;
00090         castorIdItr != castorIds.end() ; ++castorIdItr )
00091    {
00092       geom->addCell( *castorIdItr, makeCell( *castorIdItr, geom ) ) ;
00093    }
00094 }
00095 
00096 CaloCellGeometry*
00097 CastorHardcodeGeometryLoader::makeCell( const HcalCastorDetId&   detId , 
00098                                         CaloSubdetectorGeometry* geom   ) const 
00099 {
00100    const double                   zside   ( 1.0*detId.zside()  ) ;
00101    const HcalCastorDetId::Section section ( detId.section()    ) ;
00102    const int                      module  ( detId.module()     ) ;
00103    const int                      isect   ( detId.sector()     ) ;
00104    const double                   sector  ( 1.0*isect          ) ;
00105 
00106 // length units are cm
00107 
00108 
00109    const double sign ( 0 == isect%2 ? -1 : 1 ) ;
00110 
00111 //********* HERE ARE HARDWIRED GEOMETRY NUMBERS ACTUALLY USED *****
00112 
00113    static const double an     ( atan( 1.)); //angle of cant w.r.t. beam
00114    static const double can    ( cos( an ));
00115    static const double san    ( sin( an ));
00116    static const double dxlEM  ( 1.55/2. ) ; //halflength of side near beam
00117    static const double dxhEM  ( 5.73/2. ) ; //halflength of side away from beam
00118    static const double dhEM   ( 14.26/2. ); //halflength of 2nd longest side
00119    static const double dR     ( 0.1 + 2.*dhEM*san*dxlEM/( dxhEM-dxlEM ) ) ;
00120    static const double dhHAD  ( 19.88/2. ); //halflength of 2nd longest side 
00121 
00122    static const double dxhHAD ( dxhEM*( 2.*dhHAD*san + dR )/
00123                                 ( 2.*dhEM*san + dR ) ) ; //halflength of side away from beam
00124    static const double zm     ( 1439.0  ) ;  //z of start of EM
00125    static const double dzEM   ( 5.45/2 ) ;   // halflength in z of EM
00126    static const double dzHAD  ( 10.075/2 ) ; // halflength in z of HAD
00127 
00128 //*****************************************************************
00129 
00130    const double dxl ( sign*dxlEM ) ; // same for EM and HAD
00131 
00132    const double dxh ( sign*( section == HcalCastorDetId::EM ?
00133                              dxhEM : dxhHAD ) ) ;
00134    const double dh  ( section == HcalCastorDetId::EM ?
00135                       dhEM : dhHAD ) ;
00136    const double dz  ( section == HcalCastorDetId::EM ?
00137                       dzEM : dzHAD ) ;
00138 
00139    const double delz  ( dh*can ) ;
00140    const double dy  ( dh*san ) ;
00141    const double dx  ( ( dxl + dxh )/2. ) ;
00142    const double leg ( dR + dy ) ;
00143    const double len ( sqrt( leg*leg + dx*dx ) ) ;
00144 
00145    static const double dphi 
00146       ( 2.*M_PI/(1.0*HcalCastorDetId::kNumberSectorsPerEnd ) ) ;
00147 
00148    const double fphi ( atan( dx/( dR + dy ) ) ) ;
00149 
00150    const double phi  ( 0==isect%2 ? (sector-1.)*dphi - fphi :
00151                        sector*dphi - fphi ) ;
00152 
00153    const double sphi ( sin( phi ) ) ;
00154    const double cphi ( cos( phi ) ) ;
00155 
00156    const double xc ( len*cphi ) ;
00157    const double yc ( len*sphi ) ; 
00158    const double zc ( zside*( zm + delz + 
00159                              ( module<3 ? ( 1.*module - 1.0 )*2.*dzEM :
00160                                4.*dzEM +  ( 1.*(module-2) - 1 )*2.*dzHAD ) ) ) ;
00161 
00162    const GlobalPoint fc ( xc, yc, zc ) ;
00163 
00164    std::vector<double> zz ;
00165    zz.reserve( CastorGeometry::k_NumberOfParametersPerShape ) ;
00166    zz.push_back( dxl ) ;
00167    zz.push_back( dxh ) ;
00168    zz.push_back( dh ) ;
00169    zz.push_back( dz ) ;
00170    zz.push_back( an ) ;
00171    zz.push_back( dR ) ;
00172 
00173    return new calogeom::IdealCastorTrapezoid( 
00174       fc, 
00175       geom->cornersMgr(),
00176       CaloCellGeometry::getParmPtr( zz, 
00177                                     geom->parMgr(), 
00178                                     geom->parVecVec() ) );
00179 }
00180 
00181