CMS 3D CMS Logo

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