File indexing completed on 2024-04-06 12:14:39
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() : theTopology(new ZdcTopology), extTopology(theTopology) {
0011 init();
0012 }
0013
0014 ZdcHardcodeGeometryLoader::ZdcHardcodeGeometryLoader(const ZdcTopology& ht) : theTopology(nullptr), extTopology(&ht) {
0015 init();
0016 }
0017
0018 void ZdcHardcodeGeometryLoader::init() {}
0019
0020 ZdcHardcodeGeometryLoader::ReturnType ZdcHardcodeGeometryLoader::load(DetId::Detector , int subdet) {
0021 ReturnType hg(new ZdcGeometry(extTopology));
0022 if (subdet == HcalZDCDetId::SubdetectorId) {
0023 fill(HcalZDCDetId::EM, hg);
0024 fill(HcalZDCDetId::LUM, hg);
0025 fill(HcalZDCDetId::HAD, hg);
0026 if (m_zdcAddRPD)
0027 fill(
0028 HcalZDCDetId::RPD,
0029 hg);
0030 }
0031 return hg;
0032 }
0033
0034 ZdcHardcodeGeometryLoader::ReturnType ZdcHardcodeGeometryLoader::load() {
0035 ReturnType hg(new ZdcGeometry(extTopology));
0036 fill(HcalZDCDetId::EM, hg);
0037 fill(HcalZDCDetId::LUM, hg);
0038 fill(HcalZDCDetId::HAD, hg);
0039 if (m_zdcAddRPD)
0040 fill(HcalZDCDetId::RPD, hg);
0041 return hg;
0042 }
0043
0044 void ZdcHardcodeGeometryLoader::fill(HcalZDCDetId::Section section, ReturnType geom) {
0045
0046 std::vector<HcalZDCDetId> zdcIds;
0047 HcalZDCDetId id;
0048 int firstCell = extTopology->firstCell(section);
0049 int lastCell = extTopology->lastCell(section);
0050 for (int ichannel = firstCell; ichannel <= lastCell; ++ichannel) {
0051 id = HcalZDCDetId(section, true, ichannel);
0052 if (extTopology->valid(id))
0053 zdcIds.emplace_back(id);
0054 id = HcalZDCDetId(section, false, ichannel);
0055 if (extTopology->valid(id))
0056 zdcIds.emplace_back(id);
0057 }
0058 if (geom->cornersMgr() == nullptr)
0059 geom->allocateCorners(HcalZDCDetId::kSizeForDenseIndexing);
0060 if (geom->parMgr() == nullptr)
0061 geom->allocatePar(ZdcGeometry::k_NumberOfParametersPerShape * ZdcGeometry::k_NumberOfShapes,
0062 ZdcGeometry::k_NumberOfParametersPerShape);
0063
0064 edm::LogVerbatim("ZdcGeometry") << "Number of ZDC DetIds made: " << section << " " << zdcIds.size();
0065
0066
0067
0068 for (std::vector<HcalZDCDetId>::const_iterator zdcIdItr = zdcIds.begin(); zdcIdItr != zdcIds.end(); ++zdcIdItr) {
0069 makeCell(*zdcIdItr, geom);
0070 }
0071 }
0072
0073 void ZdcHardcodeGeometryLoader::makeCell(const HcalZDCDetId& detId, ReturnType geom) const {
0074 double zside(detId.zside());
0075
0076 const HcalZDCDetId::Section section(detId.section());
0077
0078 const int channel(detId.channel());
0079
0080 edm::LogVerbatim("ZdcGeometry") << "ZDCGeometry::Cell: " << detId << " Section " << section << " channel " << channel;
0081
0082
0083
0084 static const double x0(0);
0085 static const double y0(0);
0086 static const double z0(14000);
0087
0088 static const double angEM(0);
0089 static const double angLUM(0);
0090 static const double angRPD(0);
0091 static const double angHAD(atan(1.));
0092
0093
0094
0095 static const double dxHAD(4.8);
0096 static const double dxEM(dxHAD / 5.);
0097 static const double dxLUM(4.8);
0098 static const double dxRPD(4.8);
0099
0100 static const double dhEM(6.25);
0101 static const double dhLUM(6.25);
0102 static const double dhHAD(6.25);
0103 static const double dhRPD(6.25);
0104
0105 static const double dzEM(33. * 0.15);
0106 static const double dzLUM(23.5);
0107 static const double dzHAD(0.82 * 6. / cos(angHAD));
0108 static const double dzRPD(23.5);
0109
0110
0111
0112
0113 static const double xOffEM(-4. * dxEM);
0114 static const double xOffLUM(0);
0115 static const double xOffHAD(0);
0116 static const double xOffRPD(0);
0117
0118 static const double yOffEM(0);
0119 static const double yOffLUM(0);
0120 static const double yOffHAD(0);
0121 static const double yOffRPD(0);
0122
0123 static const double zOffEM(-49.85 - 0.15);
0124 static const double zOffLUM(-39.555);
0125 static const double zOffHAD(-29.00);
0126 static const double zOffRPD(-39.555);
0127
0128
0129
0130 double dx, dh, dz, x, y, z, an;
0131
0132 if (section == HcalZDCDetId::EM) {
0133 dx = dxEM;
0134 dh = dhEM;
0135 dz = dzEM;
0136 an = angEM;
0137 x = zside * (x0 + xOffEM + (channel - 1.0) * dxEM * 2.);
0138 y = y0 + yOffEM;
0139 z = zside * (z0 + zOffEM);
0140 } else if (section == HcalZDCDetId::LUM) {
0141 dx = dxLUM;
0142 dh = dhLUM;
0143 dz = dzLUM;
0144 an = angLUM;
0145 x = zside * (x0 + xOffLUM);
0146 y = y0 + yOffLUM;
0147 z = zside * (z0 + zOffLUM + (channel - 1.0) * dzLUM * 2.);
0148 } else if (section == HcalZDCDetId::RPD) {
0149 dx = dxRPD;
0150 dh = dhRPD;
0151 dz = dzRPD;
0152 an = angRPD;
0153 x = zside * (x0 + xOffRPD);
0154 y = y0 + yOffRPD;
0155 z = zside * (z0 + zOffRPD + (channel - 1.0) * dzRPD * 2.);
0156 } else {
0157 assert(section == HcalZDCDetId::HAD);
0158 dx = dxHAD;
0159 dh = dhHAD;
0160 dz = dzHAD;
0161 an = angHAD;
0162 x = zside * (x0 + xOffHAD);
0163 y = y0 + yOffHAD;
0164 z = zside * (z0 + zOffHAD + (channel - 1.0) * dzHAD * 2.);
0165 }
0166
0167 const GlobalPoint fc(x, y, z);
0168
0169 const double dy(dh * cos(an));
0170
0171 std::vector<CCGFloat> zz;
0172 zz.reserve(ZdcGeometry::k_NumberOfParametersPerShape);
0173 zz.emplace_back(an);
0174 zz.emplace_back(dx);
0175 zz.emplace_back(dy);
0176 zz.emplace_back(dz);
0177
0178 geom->newCell(fc, fc, fc, CaloCellGeometry::getParmPtr(zz, geom->parMgr(), geom->parVecVec()), detId);
0179 }