CMS 3D CMS Logo

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