Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-18 05:06:58

0001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0002 #include "Geometry/ForwardGeometry/interface/ZdcHardcodeGeometryLoader.h"
0003 #include "Geometry/ForwardGeometry/interface/IdealZDCTrapezoid.h"
0004 #include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <algorithm>
0007 
0008 typedef CaloCellGeometry::CCGFloat CCGFloat;
0009 
0010 ZdcHardcodeGeometryLoader::ZdcHardcodeGeometryLoader(const ZdcTopology& ht) : extTopology(&ht) { init(); }
0011 
0012 void ZdcHardcodeGeometryLoader::init() {}
0013 
0014 ZdcHardcodeGeometryLoader::ReturnType ZdcHardcodeGeometryLoader::load(DetId::Detector /*det*/, int subdet) {
0015   ReturnType hg(new ZdcGeometry(extTopology));
0016   if (subdet == HcalZDCDetId::SubdetectorId) {
0017     fill(HcalZDCDetId::EM, hg);
0018     fill(HcalZDCDetId::LUM, hg);
0019     fill(HcalZDCDetId::HAD, hg);
0020     if (m_zdcAddRPD)
0021       fill(
0022           HcalZDCDetId::RPD,
0023           hg);  // line will be needed in next version of code, but is commented out for now in order to ensure run1 compatability.
0024   }
0025   return hg;
0026 }
0027 
0028 ZdcHardcodeGeometryLoader::ReturnType ZdcHardcodeGeometryLoader::load() {
0029   ReturnType hg(new ZdcGeometry(extTopology));
0030   fill(HcalZDCDetId::EM, hg);
0031   fill(HcalZDCDetId::LUM, hg);
0032   fill(HcalZDCDetId::HAD, hg);
0033   if (m_zdcAddRPD)
0034     fill(HcalZDCDetId::RPD, hg);
0035   return hg;
0036 }
0037 
0038 void ZdcHardcodeGeometryLoader::fill(HcalZDCDetId::Section section, ReturnType geom) {
0039   // start by making the new HcalDetIds
0040   std::vector<HcalZDCDetId> zdcIds;
0041   HcalZDCDetId id;
0042   int firstCell = extTopology->firstCell(section);
0043   int lastCell = extTopology->lastCell(section);
0044   for (int ichannel = firstCell; ichannel <= lastCell; ++ichannel) {
0045     id = HcalZDCDetId(section, true, ichannel);
0046     if (extTopology->valid(id))
0047       zdcIds.emplace_back(id);
0048     id = HcalZDCDetId(section, false, ichannel);
0049     if (extTopology->valid(id))
0050       zdcIds.emplace_back(id);
0051   }
0052   if (geom->cornersMgr() == nullptr)
0053     geom->allocateCorners(extTopology->kSizeForDenseIndexing());
0054   if (geom->parMgr() == nullptr)
0055     geom->allocatePar(ZdcGeometry::k_NumberOfParametersPerShape * ZdcGeometry::k_NumberOfShapes,
0056                       ZdcGeometry::k_NumberOfParametersPerShape);
0057 
0058   edm::LogVerbatim("ZdcGeometry") << "Number of ZDC DetIds made: " << section << " " << zdcIds.size();
0059 
0060   // for each new HcalZdcDetId, make a CaloCellGeometry
0061 
0062   for (std::vector<HcalZDCDetId>::const_iterator zdcIdItr = zdcIds.begin(); zdcIdItr != zdcIds.end(); ++zdcIdItr) {
0063     makeCell(*zdcIdItr, geom);
0064   }
0065 }
0066 
0067 void ZdcHardcodeGeometryLoader::makeCell(const HcalZDCDetId& detId, ReturnType geom) const {
0068   double zside(detId.zside());
0069 
0070   const HcalZDCDetId::Section section(detId.section());
0071 
0072   const int channel(detId.channel());
0073 
0074   edm::LogVerbatim("ZdcGeometry") << "ZDCGeometry::Cell: " << detId << " Section " << section << " channel " << channel;
0075   //********* Here are all the hardcoded numbers you need to know, in **cm**
0076   //********* Most are from the zdc.xml and zdclum.xml files ******
0077 
0078   static const double x0(0);  // these 3 are for the "mother" volume
0079   static const double y0(0);
0080   static const double z0(14000);
0081 
0082   static const double angEM(0);  // the angles of front face wrt vertical
0083   static const double angLUM(0);
0084   static const double angRPD(0);
0085   static const double angHAD(atan(1.));  // this is 45 deg
0086 
0087   // these dimensions are **half**-sizes
0088 
0089   static const double dxHAD(4.8);
0090   static const double dxEM(dxHAD / 5.);
0091   static const double dxLUM(4.8);  // to be updated when known
0092   static const double dxRPD(4.8);  // to be updated when known
0093 
0094   static const double dhEM(6.25);
0095   static const double dhLUM(6.25);  // to be updated when known
0096   static const double dhHAD(6.25);
0097   static const double dhRPD(6.25);  // to be updated when known
0098 
0099   static const double dzEM(33. * 0.15);
0100   static const double dzLUM(23.5);  // to be updated when known
0101   static const double dzHAD(0.82 * 6. / cos(angHAD));
0102   static const double dzRPD(23.5);  // to be updated when known
0103 
0104   // these are not half-dimensions, they are offsets from nominal
0105   // for the center-of-front-face points
0106 
0107   static const double xOffEM(-4. * dxEM);
0108   static const double xOffLUM(0);
0109   static const double xOffHAD(0);
0110   static const double xOffRPD(0);
0111 
0112   static const double yOffEM(0);
0113   static const double yOffLUM(0);
0114   static const double yOffHAD(0);
0115   static const double yOffRPD(0);
0116 
0117   static const double zOffEM(-49.85 - 0.15);
0118   static const double zOffLUM(-39.555);
0119   static const double zOffHAD(-29.00);
0120   static const double zOffRPD(-39.555);
0121 
0122   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0123 
0124   double dx, dh, dz, x, y, z, an;
0125 
0126   if (section == HcalZDCDetId::EM) {
0127     dx = dxEM;
0128     dh = dhEM;
0129     dz = dzEM;
0130     an = angEM;
0131     x = zside * (x0 + xOffEM + (channel - 1.0) * dxEM * 2.);
0132     y = y0 + yOffEM;
0133     z = zside * (z0 + zOffEM);
0134   } else if (section == HcalZDCDetId::LUM) {
0135     dx = dxLUM;
0136     dh = dhLUM;
0137     dz = dzLUM;
0138     an = angLUM;
0139     x = zside * (x0 + xOffLUM);
0140     y = y0 + yOffLUM;
0141     z = zside * (z0 + zOffLUM + (channel - 1.0) * dzLUM * 2.);
0142   } else if (section == HcalZDCDetId::RPD) {
0143     dx = dxRPD;
0144     dh = dhRPD;
0145     dz = dzRPD;
0146     an = angRPD;
0147     x = zside * (x0 + xOffRPD);
0148     y = y0 + yOffRPD;
0149     z = zside * (z0 + zOffRPD + (channel - 1.0) * dzRPD * 2.);
0150   } else {
0151     assert(section == HcalZDCDetId::HAD);
0152     dx = dxHAD;
0153     dh = dhHAD;
0154     dz = dzHAD;
0155     an = angHAD;
0156     x = zside * (x0 + xOffHAD);
0157     y = y0 + yOffHAD;
0158     z = zside * (z0 + zOffHAD + (channel - 1.0) * dzHAD * 2.);
0159   }
0160 
0161   const GlobalPoint fc(x, y, z);
0162 
0163   const double dy(dh * cos(an));
0164 
0165   std::vector<CCGFloat> zz;
0166   zz.reserve(ZdcGeometry::k_NumberOfParametersPerShape);
0167   zz.emplace_back(an);
0168   zz.emplace_back(dx);
0169   zz.emplace_back(dy);
0170   zz.emplace_back(dz);
0171 
0172   geom->newCell(fc, fc, fc, CaloCellGeometry::getParmPtr(zz, geom->parMgr(), geom->parVecVec()), detId);
0173 }