CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Geometry/HcalTowerAlgo/src/CaloTowerHardcodeGeometryLoader.cc

Go to the documentation of this file.
00001 #include "Geometry/HcalTowerAlgo/interface/CaloTowerHardcodeGeometryLoader.h"
00002 #include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h"
00003 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00005 #include "Geometry/CaloGeometry/interface/IdealObliquePrism.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00009 
00010 std::auto_ptr<CaloSubdetectorGeometry> CaloTowerHardcodeGeometryLoader::load(const HcalTopology *limits) {
00011     m_limits = limits;
00012     
00013   CaloTowerGeometry* geom=new CaloTowerGeometry();
00014 
00015   if( 0 == geom->cornersMgr() ) geom->allocateCorners ( 
00016      CaloTowerGeometry::k_NumberOfCellsForCorners ) ;
00017   if( 0 == geom->parMgr() ) geom->allocatePar (
00018      CaloTowerGeometry::k_NumberOfParametersPerShape*CaloTowerGeometry::k_NumberOfShapes,
00019      CaloTowerGeometry::k_NumberOfParametersPerShape ) ;
00020 
00021   int nnn=0;
00022   // simple loop
00023   for (int ieta=-m_limits->lastHFRing(); ieta<=m_limits->lastHFRing(); ieta++) {
00024     if (ieta==0) continue; // skip not existing eta=0 ring
00025     for (int iphi=1; iphi<=72; iphi++) {
00026       if (abs(ieta)>=m_limits->firstHFQuadPhiRing() && ((iphi-1)%4)==0) continue;
00027       if (abs(ieta)>=m_limits->firstHEDoublePhiRing() && ((iphi-1)%2)!=0) continue;
00028       ++nnn;
00029     }
00030   }
00031   if( geom->cornersMgr() == 0 ) geom->allocateCorners( nnn ) ; 
00032   if( geom->parMgr()     == 0 ) geom->allocatePar( 41, 3 ) ;
00033 
00034   int n=0;
00035   // simple loop
00036   for (int ieta=-m_limits->lastHFRing(); ieta<=m_limits->lastHFRing(); ieta++) {
00037     if (ieta==0) continue; // skip not existing eta=0 ring
00038     for (int iphi=1; iphi<=72; iphi++) {
00039       if (abs(ieta)>=m_limits->firstHFQuadPhiRing() && ((iphi-1)%4)==0) continue;
00040       if (abs(ieta)>=m_limits->firstHEDoublePhiRing() && ((iphi-1)%2)!=0) continue;
00041       makeCell(ieta,iphi, geom);
00042       n++;
00043     }
00044   }
00045   edm::LogInfo("Geometry") << "CaloTowersHardcodeGeometry made " << n << " towers.";
00046   return std::auto_ptr<CaloSubdetectorGeometry>(geom); 
00047 }
00048 
00049 void
00050 CaloTowerHardcodeGeometryLoader::makeCell( int ieta,
00051                                            int iphi,
00052                                            CaloSubdetectorGeometry* geom ) const {
00053   const double EBradius = 143.0; // cm
00054   const double HOradius = 406.0+1.0;
00055   const double EEz = 320.0; // rough (cm)
00056   const double HEz = 568.0; // back (cm)
00057   const double HFz = 1100.0;
00058   const double HFthick = 165;
00059   // Tower 17 is the last EB tower
00060 
00061   int etaRing=abs(ieta);
00062   int sign=(ieta>0)?(1):(-1);
00063   double eta1, eta2;
00064   if (etaRing>m_limits->lastHERing()) {
00065     eta1 = theHFEtaBounds[etaRing-m_limits->firstHFRing()];
00066     eta2 = theHFEtaBounds[etaRing-m_limits->firstHFRing()+1];
00067   } else {
00068     eta1 = theHBHEEtaBounds[etaRing-1];
00069     eta2 = theHBHEEtaBounds[etaRing];
00070   }
00071   double eta = 0.5*(eta1+eta2);
00072   double deta = (eta2-eta1);  
00073 
00074   // in radians
00075   double dphi_nominal = 2.0*M_PI / m_limits->nPhiBins(1); // always the same
00076   double dphi_half = M_PI / m_limits->nPhiBins(etaRing); // half-width
00077   
00078   double phi_low = dphi_nominal*(iphi-1); // low-edge boundaries are constant...
00079   double phi = phi_low+dphi_half;
00080 
00081   double x,y,z,thickness;
00082   bool alongZ=true;
00083   if (etaRing>m_limits->lastHERing()) { // forward
00084     z=HFz;
00085     double r=z/sinh(eta);
00086     x=r * cos(phi);
00087     y=r * sin(phi);
00088     thickness=HFthick/tanh(eta);
00089   } else if (etaRing>17) { // EE-containing
00090     z=EEz;
00091     double r=z/sinh(eta);
00092     x=r * cos(phi);
00093     y=r * sin(phi);
00094     thickness=(HEz-EEz)/tanh(eta);
00095   } else { // EB-containing
00096     x=EBradius * cos(phi);
00097     y=EBradius * sin(phi);
00098     alongZ=false;
00099     z=EBradius * sinh(eta);
00100     thickness=(HOradius-EBradius) * cosh(eta);
00101   }
00102 
00103   z*=sign;
00104   GlobalPoint point(x,y,z);
00105 
00106   const double mysign ( !alongZ ? 1 : -1 ) ;
00107   std::vector<CCGFloat> hh ;
00108   hh.reserve(5) ;
00109   hh.push_back( deta/2 ) ;
00110   hh.push_back( dphi_half ) ;
00111   hh.push_back( mysign*thickness/2. ) ;
00112 
00113   hh.push_back( fabs( eta ) ) ;
00114   hh.push_back( fabs( z ) ) ;
00115 
00116   geom->newCell( point, point, point,
00117                  CaloCellGeometry::getParmPtr( hh, 
00118                                                geom->parMgr(), 
00119                                                geom->parVecVec() ),
00120                  CaloTowerDetId( ieta, iphi ) ) ;
00121 }