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 std::auto_ptr<CaloSubdetectorGeometry> CaloTowerHardcodeGeometryLoader::load() {
00009 CaloTowerGeometry* geom=new CaloTowerGeometry();
00010
00011 int nnn=0;
00012
00013 for (int ieta=-limits.lastHFRing(); ieta<=limits.lastHFRing(); ieta++) {
00014 if (ieta==0) continue;
00015 for (int iphi=1; iphi<=72; iphi++) {
00016 if (abs(ieta)>=limits.firstHFQuadPhiRing() && ((iphi-1)%4)==0) continue;
00017 if (abs(ieta)>=limits.firstHEDoublePhiRing() && ((iphi-1)%2)!=0) continue;
00018 ++nnn;
00019 }
00020 }
00021 if( geom->cornersMgr() == 0 ) geom->allocateCorners( nnn ) ;
00022 if( geom->parMgr() == 0 ) geom->allocatePar( 41, 3 ) ;
00023
00024 int n=0;
00025
00026 for (int ieta=-limits.lastHFRing(); ieta<=limits.lastHFRing(); ieta++) {
00027 if (ieta==0) continue;
00028 for (int iphi=1; iphi<=72; iphi++) {
00029 if (abs(ieta)>=limits.firstHFQuadPhiRing() && ((iphi-1)%4)==0) continue;
00030 if (abs(ieta)>=limits.firstHEDoublePhiRing() && ((iphi-1)%2)!=0) continue;
00031 geom->addCell(CaloTowerDetId(ieta,iphi),makeCell(ieta,iphi, geom));
00032 n++;
00033 }
00034 }
00035 edm::LogInfo("Geometry") << "CaloTowersHardcodeGeometry made " << n << " towers.";
00036 return std::auto_ptr<CaloSubdetectorGeometry>(geom);
00037 }
00038
00039 const CaloCellGeometry* CaloTowerHardcodeGeometryLoader::makeCell(int ieta, int iphi,
00040 CaloSubdetectorGeometry* geom) const {
00041 const double EBradius = 143.0;
00042 const double HOradius = 406.0+1.0;
00043 const double EEz = 320.0;
00044 const double HEz = 568.0;
00045 const double HFz = 1100.0;
00046 const double HFthick = 165;
00047
00048
00049 int etaRing=abs(ieta);
00050 int sign=(ieta>0)?(1):(-1);
00051 double eta1, eta2;
00052 if (etaRing>limits.lastHERing()) {
00053 eta1 = theHFEtaBounds[etaRing-limits.firstHFRing()];
00054 eta2 = theHFEtaBounds[etaRing-limits.firstHFRing()+1];
00055 } else {
00056 eta1 = theHBHEEtaBounds[etaRing-1];
00057 eta2 = theHBHEEtaBounds[etaRing];
00058 }
00059 double eta = 0.5*(eta1+eta2);
00060 double deta = (eta2-eta1);
00061
00062
00063 double dphi_nominal = 2.0*M_PI / limits.nPhiBins(1);
00064 double dphi_half = M_PI / limits.nPhiBins(etaRing);
00065
00066 double phi_low = dphi_nominal*(iphi-1);
00067 double phi = phi_low+dphi_half;
00068
00069 double x,y,z,thickness;
00070 bool alongZ=true;
00071 if (etaRing>limits.lastHERing()) {
00072 z=HFz;
00073 double r=z/sinh(eta);
00074 x=r * cos(phi);
00075 y=r * sin(phi);
00076 thickness=HFthick/tanh(eta);
00077 } else if (etaRing>17) {
00078 z=EEz;
00079 double r=z/sinh(eta);
00080 x=r * cos(phi);
00081 y=r * sin(phi);
00082 thickness=(HEz-EEz)/tanh(eta);
00083 } else {
00084 x=EBradius * cos(phi);
00085 y=EBradius * sin(phi);
00086 alongZ=false;
00087 z=EBradius * sinh(eta);
00088 thickness=(HOradius-EBradius) * cosh(eta);
00089 }
00090
00091 z*=sign;
00092 GlobalPoint point(x,y,z);
00093
00094 const double mysign ( !alongZ ? 1 : -1 ) ;
00095 std::vector<float> hh ;
00096 hh.reserve(3) ;
00097 hh.push_back( deta/2 ) ;
00098 hh.push_back( dphi_half ) ;
00099 hh.push_back( mysign*thickness/2. ) ;
00100 return new calogeom::IdealObliquePrism(
00101 point,
00102 geom->cornersMgr(),
00103 CaloCellGeometry::getParmPtr( hh,
00104 geom->parMgr(),
00105 geom->parVecVec() ) );
00106 }