CMS 3D CMS Logo

CastorHardcodeGeometryLoader.cc
Go to the documentation of this file.
7 #include <algorithm>
8 #include <utility>
9 
11 
13  : theTopology(new CastorTopology), extTopology(theTopology) {
14  init();
15 }
16 
18  : theTopology(nullptr), extTopology(&ht) {
19  init();
20 }
21 
25  theEMSectiondZ = 101.0;
28  theHADSectiondZ = 1212.;
29 }
30 
31 std::unique_ptr<CaloSubdetectorGeometry> CastorHardcodeGeometryLoader::load(DetId::Detector /*det*/, int subdet) {
32  std::unique_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry(extTopology));
33  if (subdet == HcalCastorDetId::SubdetectorId) {
34  fill(HcalCastorDetId::EM, hg.get());
35  fill(HcalCastorDetId::HAD, hg.get());
36  }
37  return hg;
38 }
39 
40 std::unique_ptr<CaloSubdetectorGeometry> CastorHardcodeGeometryLoader::load() {
41  std::unique_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry(extTopology));
42  fill(HcalCastorDetId::EM, hg.get());
43  fill(HcalCastorDetId::HAD, hg.get());
44  return hg;
45 }
46 
48  if (geom->cornersMgr() == nullptr)
50  if (geom->parMgr() == nullptr)
53 
54  // start by making the new HcalDetIds
55  std::vector<HcalCastorDetId> castorIds;
56 
57  const int firstCell(extTopology->firstCell(section));
58  const int lastCell(extTopology->lastCell(section));
59 
60  for (int imodule(firstCell); imodule <= lastCell; ++imodule) {
61  for (int isector(1); isector <= HcalCastorDetId::kNumberSectorsPerEnd; ++isector) {
62  const HcalCastorDetId id(section, false, isector, imodule);
63  if (extTopology->valid(id))
64  castorIds.emplace_back(id);
65  }
66  }
67  // edm::LogInfo("CastorHardcodeGeometry")
68  // << "Number of Castor DetIds made: " << section
69  // << " " << castorIds.size();
70 
71  // for each new HcalCastorDetId, make a CaloCellGeometry
72 
73  for (std::vector<HcalCastorDetId>::const_iterator castorIdItr(castorIds.begin()); castorIdItr != castorIds.end();
74  ++castorIdItr) {
75  makeCell(*castorIdItr, geom);
76  }
77 }
78 
80  const double zside(1.0 * detId.zside());
81  const HcalCastorDetId::Section section(detId.section());
82  const int module(detId.module());
83  const int isect(detId.sector());
84  const double sector(1.0 * isect);
85 
86  // length units are cm
87 
88  const double sign(0 == isect % 2 ? -1 : 1);
89 
90  //********* HERE ARE HARDWIRED GEOMETRY NUMBERS ACTUALLY USED *****
91 
92  static const double an(atan(1.)); //angle of cant w.r.t. beam
93  static const double can(cos(an));
94  static const double san(sin(an));
95  static const double dxlEM(1.55 / 2.); //halflength of side near beam
96  static const double dxhEM(5.73 / 2.); //halflength of side away from beam
97  static const double dhEM(14.26 / 2.); //halflength of 2nd longest side
98  static const double dR(0.1 + 2. * dhEM * san * dxlEM / (dxhEM - dxlEM));
99  static const double dhHAD(19.88 / 2.); //halflength of 2nd longest side
100 
101  static const double dxhHAD(dxhEM * (2. * dhHAD * san + dR) /
102  (2. * dhEM * san + dR)); //halflength of side away from beam
103  static const double zm(1439.0); //z of start of EM
104  static const double dzEM(5.45 / 2); // halflength in z of EM
105  static const double dzHAD(10.075 / 2); // halflength in z of HAD
106 
107  //*****************************************************************
108 
109  const double dxl(sign * dxlEM); // same for EM and HAD
110 
111  const double dxh(sign * (section == HcalCastorDetId::EM ? dxhEM : dxhHAD));
112  const double dh(section == HcalCastorDetId::EM ? dhEM : dhHAD);
113  const double dz(section == HcalCastorDetId::EM ? dzEM : dzHAD);
114 
115  const double delz(dh * can);
116  const double dy(dh * san);
117  const double dx((dxl + dxh) / 2.);
118  const double leg(dR + dy);
119  const double len(sqrt(leg * leg + dx * dx));
120 
121  static const double dphi(2. * M_PI / (1.0 * HcalCastorDetId::kNumberSectorsPerEnd));
122 
123  const double fphi(atan(dx / (dR + dy)));
124 
125  const double phi(0 == isect % 2 ? (sector - 1.) * dphi - fphi : sector * dphi - fphi);
126 
127  const double sphi(sin(phi));
128  const double cphi(cos(phi));
129 
130  const double xc(len * cphi);
131  const double yc(len * sphi);
132  const double zc(
133  zside *
134  (zm + delz + (module < 3 ? (1. * module - 1.0) * 2. * dzEM : 4. * dzEM + (1. * (module - 2) - 1) * 2. * dzHAD)));
135 
136  const GlobalPoint fc(xc, yc, zc);
137 
138  std::vector<CCGFloat> zz;
140  zz.emplace_back(dxl);
141  zz.emplace_back(dxh);
142  zz.emplace_back(dh);
143  zz.emplace_back(dz);
144  zz.emplace_back(an);
145  zz.emplace_back(dR);
146 
147  geom->newCell(fc, fc, fc, CaloCellGeometry::getParmPtr(zz, geom->parMgr(), geom->parVecVec()), detId);
148 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
CaloCellGeometry::CCGFloat CCGFloat
int zside(DetId const &)
virtual bool valid(const HcalCastorDetId &id) const
static const double dYHADPlate
void fill(HcalCastorDetId::Section section, CaloSubdetectorGeometry *cg)
void makeCell(const HcalCastorDetId &detId, CaloSubdetectorGeometry *geom) const
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static const double dXHADPlate
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
static const int SubdetectorId
#define M_PI
std::unique_ptr< CaloSubdetectorGeometry > load()
static const double dYEMPlate
Detector
Definition: DetId.h:24
static const double dXEMPlate
dh
Definition: cuy.py:354
int firstCell(HcalCastorDetId::Section section) const
int lastCell(HcalCastorDetId::Section section) const