CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Geometry/ForwardGeometry/src/ZdcHardcodeGeometryLoader.cc

Go to the documentation of this file.
00001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00002 #include "Geometry/ForwardGeometry/interface/ZdcHardcodeGeometryLoader.h"
00003 #include "Geometry/ForwardGeometry/interface/IdealZDCTrapezoid.h"
00004 #include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <algorithm>
00007 
00008 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00009 
00010 ZdcHardcodeGeometryLoader::ZdcHardcodeGeometryLoader() :
00011    theTopology ( new ZdcTopology ) ,
00012    extTopology ( theTopology )
00013 {
00014   init();
00015 }
00016 
00017 ZdcHardcodeGeometryLoader::ZdcHardcodeGeometryLoader(const ZdcTopology& ht) : 
00018    theTopology( 0   ) ,
00019    extTopology( &ht ) 
00020 {
00021   init();
00022 }
00023 
00024 void ZdcHardcodeGeometryLoader::init() 
00025 {
00026 }
00027 
00028 ZdcHardcodeGeometryLoader::ReturnType 
00029 ZdcHardcodeGeometryLoader::load(DetId::Detector /*det*/, int subdet)
00030 {
00031    ReturnType hg(new ZdcGeometry( extTopology ) );
00032    if(subdet == HcalZDCDetId::SubdetectorId)
00033    {
00034       fill(HcalZDCDetId::EM  ,hg );
00035       fill(HcalZDCDetId::LUM ,hg );
00036       fill(HcalZDCDetId::HAD ,hg );
00037    }
00038    return hg;
00039 }
00040 
00041 ZdcHardcodeGeometryLoader::ReturnType 
00042 ZdcHardcodeGeometryLoader::load() 
00043 {
00044    ReturnType hg(new ZdcGeometry( extTopology ) );
00045    fill(HcalZDCDetId::EM  ,hg );
00046    fill(HcalZDCDetId::LUM ,hg );
00047    fill(HcalZDCDetId::HAD ,hg );
00048    return hg;
00049 }
00050 
00051 void ZdcHardcodeGeometryLoader::fill( HcalZDCDetId::Section section, 
00052                                       ReturnType            geom     ) 
00053 {
00054   // start by making the new HcalDetIds
00055   std::vector<HcalZDCDetId> zdcIds;
00056   HcalZDCDetId id;
00057   int firstCell = extTopology->firstCell(section);
00058   int lastCell = extTopology->lastCell(section);
00059   for(int ichannel = firstCell; ichannel <= lastCell; ++ichannel) {
00060     id = HcalZDCDetId(section, true, ichannel);
00061     if(extTopology->valid(id)) zdcIds.push_back(id);
00062     id = HcalZDCDetId(section, false, ichannel);
00063     if(extTopology->valid(id)) zdcIds.push_back(id);
00064    }
00065   if( geom->cornersMgr() == 0 ) geom->allocateCorners( HcalZDCDetId::kSizeForDenseIndexing ) ;
00066   if( geom->parMgr()     == 0 ) geom->allocatePar( 
00067      ZdcGeometry::k_NumberOfParametersPerShape*ZdcGeometry::k_NumberOfShapes,
00068      ZdcGeometry::k_NumberOfParametersPerShape ) ;
00069 
00070   edm::LogInfo("ZdcHardcodeGeometry") << "Number of ZDC DetIds made: " << section << " " << zdcIds.size();
00071  
00072   // for each new HcalZdcDetId, make a CaloCellGeometry
00073 
00074  for(std::vector<HcalZDCDetId>::const_iterator zdcIdItr = zdcIds.begin();
00075      zdcIdItr != zdcIds.end(); ++zdcIdItr)
00076    {
00077       makeCell( *zdcIdItr, geom ) ;
00078    }
00079 }
00080 
00081 void
00082 ZdcHardcodeGeometryLoader::makeCell(const HcalZDCDetId& detId,
00083                                     ReturnType          geom) const 
00084 {
00085    double zside ( detId.zside() ) ;
00086 
00087    const HcalZDCDetId::Section section ( detId.section() ) ;
00088 
00089    const int channel ( detId.channel() ) ;
00090 
00091 //********* Here are all the hardcoded numbers you need to know, in **cm**
00092 //********* Most are from the zdc.xml and zdclum.xml files ******
00093 
00094    static const double x0 ( 0 ) ; // these 3 are for the "mother" volume
00095    static const double y0 ( 0 ) ;
00096    static const double z0 ( 14000 ) ;
00097 
00098    static const double angEM  ( 0 ) ; // the angles of front face wrt vertical
00099    static const double angLUM ( 0 ) ;
00100    static const double angHAD ( atan( 1. ) ) ; // this is 45 deg
00101 
00102    // these dimensions are **half**-sizes
00103 
00104    static const double dxHAD ( 4.8 ) ;
00105    static const double dxEM  ( dxHAD/5. ) ;
00106    static const double dxLUM ( 4.8 ) ; // to be updated when known
00107 
00108    static const double dhEM  ( 6.25 ) ;
00109    static const double dhLUM ( 6.25 ) ; // to be updated when known
00110    static const double dhHAD ( 6.25 ) ;
00111 
00112    static const double dzEM  ( 33.*0.15 ) ;
00113    static const double dzLUM ( 23.5 ) ; // to be updated when known
00114    static const double dzHAD ( 0.82*6./cos(angHAD) ) ;
00115 
00116    // these are not half-dimensions, they are offsets from nominal
00117    // for the center-of-front-face points
00118 
00119    static const double xOffEM  ( -4.*dxEM ) ; 
00120    static const double xOffLUM ( 0 ) ; 
00121    static const double xOffHAD ( 0 ) ; 
00122 
00123    static const double yOffEM  ( 0 ) ; 
00124    static const double yOffLUM ( 0 ) ; 
00125    static const double yOffHAD ( 0 ) ; 
00126 
00127    static const double zOffEM  ( -49.85  - 0.15 ) ; 
00128    static const double zOffLUM ( -39.555        ) ; 
00129    static const double zOffHAD ( -29.00         ) ; 
00130 
00131 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00132 
00133    double dx, dh, dz, x, y, z, an ;
00134 
00135    if( section==HcalZDCDetId::EM )
00136    {
00137       dx = dxEM ;
00138       dh = dhEM ;
00139       dz = dzEM ;
00140       an = angEM ;
00141       x  = zside*( x0 + xOffEM + ( channel - 1.0 )*dxEM*2. ) ;
00142       y  = y0 + yOffEM ;
00143       z  = zside*( z0 + zOffEM ) ;
00144    }
00145    else
00146    {
00147       if( section==HcalZDCDetId::LUM )
00148       {
00149          dx = dxLUM ;
00150          dh = dhLUM ;
00151          dz = dzLUM ;
00152          an = angLUM ;
00153          x  = zside*( x0 + xOffLUM ) ;
00154          y  = y0 + yOffLUM ;
00155          z  = zside*( z0 + zOffLUM + ( channel - 1.0 )*dzLUM*2. ) ;
00156       }
00157       else
00158       {
00159          assert( section==HcalZDCDetId::HAD ) ;
00160          dx = dxHAD ;
00161          dh = dhHAD ;
00162          dz = dzHAD ;
00163          an = angHAD ;
00164          x  = zside*( x0 + xOffHAD ) ;
00165          y  = y0 + yOffHAD ;
00166          z  = zside*( z0 + zOffHAD + ( channel - 1.0 )*dzHAD*2. ) ;
00167       }
00168    }
00169 
00170    const GlobalPoint fc ( x, y, z );
00171 
00172    const double dy ( dh*cos( an ) ) ;
00173 
00174    std::vector<CCGFloat> zz ;
00175    zz.reserve( ZdcGeometry::k_NumberOfParametersPerShape ) ;
00176    zz.push_back( an ) ;
00177    zz.push_back( dx ) ;
00178    zz.push_back( dy ) ;
00179    zz.push_back( dz ) ;
00180 
00181    geom->newCell( fc, fc, fc, 
00182                   CaloCellGeometry::getParmPtr( zz, 
00183                                                 geom->parMgr(), 
00184                                                 geom->parVecVec() ),
00185                   detId ) ;
00186 }
00187 
00188