Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:38

0001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0002 #include "Geometry/ForwardGeometry/interface/CastorHardcodeGeometryLoader.h"
0003 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
0004 #include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
0005 #include "Geometry/ForwardGeometry/src/CastorGeometryData.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include <algorithm>
0008 #include <utility>
0009 
0010 typedef CaloCellGeometry::CCGFloat CCGFloat;
0011 
0012 CastorHardcodeGeometryLoader::CastorHardcodeGeometryLoader()
0013     : theTopology(new CastorTopology), extTopology(theTopology) {
0014   init();
0015 }
0016 
0017 CastorHardcodeGeometryLoader::CastorHardcodeGeometryLoader(const CastorTopology& ht)
0018     : theTopology(nullptr), extTopology(&ht) {
0019   init();
0020 }
0021 
0022 void CastorHardcodeGeometryLoader::init() {
0023   theEMSectiondX = 2. * dXEMPlate;
0024   theEMSectiondY = 2. * dYEMPlate;
0025   theEMSectiondZ = 101.0;
0026   theHADSectiondX = 2. * dXHADPlate;
0027   theHADSectiondY = 2. * dYHADPlate;
0028   theHADSectiondZ = 1212.;
0029 }
0030 
0031 std::unique_ptr<CaloSubdetectorGeometry> CastorHardcodeGeometryLoader::load(DetId::Detector /*det*/, int subdet) {
0032   std::unique_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry(extTopology));
0033   if (subdet == HcalCastorDetId::SubdetectorId) {
0034     fill(HcalCastorDetId::EM, hg.get());
0035     fill(HcalCastorDetId::HAD, hg.get());
0036   }
0037   return hg;
0038 }
0039 
0040 std::unique_ptr<CaloSubdetectorGeometry> CastorHardcodeGeometryLoader::load() {
0041   std::unique_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry(extTopology));
0042   fill(HcalCastorDetId::EM, hg.get());
0043   fill(HcalCastorDetId::HAD, hg.get());
0044   return hg;
0045 }
0046 
0047 void CastorHardcodeGeometryLoader::fill(HcalCastorDetId::Section section, CaloSubdetectorGeometry* geom) {
0048   if (geom->cornersMgr() == nullptr)
0049     geom->allocateCorners(HcalCastorDetId::kSizeForDenseIndexing);
0050   if (geom->parMgr() == nullptr)
0051     geom->allocatePar(CastorGeometry::k_NumberOfShapes * CastorGeometry::k_NumberOfParametersPerShape,
0052                       CastorGeometry::k_NumberOfParametersPerShape);
0053 
0054   // start by making the new HcalDetIds
0055   std::vector<HcalCastorDetId> castorIds;
0056 
0057   const int firstCell(extTopology->firstCell(section));
0058   const int lastCell(extTopology->lastCell(section));
0059 
0060   for (int imodule(firstCell); imodule <= lastCell; ++imodule) {
0061     for (int isector(1); isector <= HcalCastorDetId::kNumberSectorsPerEnd; ++isector) {
0062       const HcalCastorDetId id(section, false, isector, imodule);
0063       if (extTopology->valid(id))
0064         castorIds.emplace_back(id);
0065     }
0066   }
0067   //   edm::LogInfo("CastorHardcodeGeometry")
0068   //      << "Number of Castor DetIds made: " << section
0069   //      << " " << castorIds.size();
0070 
0071   // for each new HcalCastorDetId, make a CaloCellGeometry
0072 
0073   for (std::vector<HcalCastorDetId>::const_iterator castorIdItr(castorIds.begin()); castorIdItr != castorIds.end();
0074        ++castorIdItr) {
0075     makeCell(*castorIdItr, geom);
0076   }
0077 }
0078 
0079 void CastorHardcodeGeometryLoader::makeCell(const HcalCastorDetId& detId, CaloSubdetectorGeometry* geom) const {
0080   const double zside(1.0 * detId.zside());
0081   const HcalCastorDetId::Section section(detId.section());
0082   const int module(detId.module());
0083   const int isect(detId.sector());
0084   const double sector(1.0 * isect);
0085 
0086   // length units are cm
0087 
0088   const double sign(0 == isect % 2 ? -1 : 1);
0089 
0090   //********* HERE ARE HARDWIRED GEOMETRY NUMBERS ACTUALLY USED *****
0091 
0092   static const double an(atan(1.));  //angle of cant w.r.t. beam
0093   static const double can(cos(an));
0094   static const double san(sin(an));
0095   static const double dxlEM(1.55 / 2.);  //halflength of side near beam
0096   static const double dxhEM(5.73 / 2.);  //halflength of side away from beam
0097   static const double dhEM(14.26 / 2.);  //halflength of 2nd longest side
0098   static const double dR(0.1 + 2. * dhEM * san * dxlEM / (dxhEM - dxlEM));
0099   static const double dhHAD(19.88 / 2.);  //halflength of 2nd longest side
0100 
0101   static const double dxhHAD(dxhEM * (2. * dhHAD * san + dR) /
0102                              (2. * dhEM * san + dR));  //halflength of side away from beam
0103   static const double zm(1439.0);                      //z of start of EM
0104   static const double dzEM(5.45 / 2);                  // halflength in z of EM
0105   static const double dzHAD(10.075 / 2);               // halflength in z of HAD
0106 
0107   //*****************************************************************
0108 
0109   const double dxl(sign * dxlEM);  // same for EM and HAD
0110 
0111   const double dxh(sign * (section == HcalCastorDetId::EM ? dxhEM : dxhHAD));
0112   const double dh(section == HcalCastorDetId::EM ? dhEM : dhHAD);
0113   const double dz(section == HcalCastorDetId::EM ? dzEM : dzHAD);
0114 
0115   const double delz(dh * can);
0116   const double dy(dh * san);
0117   const double dx((dxl + dxh) / 2.);
0118   const double leg(dR + dy);
0119   const double len(sqrt(leg * leg + dx * dx));
0120 
0121   static const double dphi(2. * M_PI / (1.0 * HcalCastorDetId::kNumberSectorsPerEnd));
0122 
0123   const double fphi(atan(dx / (dR + dy)));
0124 
0125   const double phi(0 == isect % 2 ? (sector - 1.) * dphi - fphi : sector * dphi - fphi);
0126 
0127   const double sphi(sin(phi));
0128   const double cphi(cos(phi));
0129 
0130   const double xc(len * cphi);
0131   const double yc(len * sphi);
0132   const double zc(
0133       zside *
0134       (zm + delz + (module < 3 ? (1. * module - 1.0) * 2. * dzEM : 4. * dzEM + (1. * (module - 2) - 1) * 2. * dzHAD)));
0135 
0136   const GlobalPoint fc(xc, yc, zc);
0137 
0138   std::vector<CCGFloat> zz;
0139   zz.reserve(CastorGeometry::k_NumberOfParametersPerShape);
0140   zz.emplace_back(dxl);
0141   zz.emplace_back(dxh);
0142   zz.emplace_back(dh);
0143   zz.emplace_back(dz);
0144   zz.emplace_back(an);
0145   zz.emplace_back(dR);
0146 
0147   geom->newCell(fc, fc, fc, CaloCellGeometry::getParmPtr(zz, geom->parMgr(), geom->parVecVec()), detId);
0148 }