CMS 3D CMS Logo

HcalDDDGeometryLoader.cc
Go to the documentation of this file.
8 
9 #include <string>
10 
12 
13 //#define EDM_ML_DEBUG
14 
17 }
18 
20 
22  DetId::Detector det,
23  int subdet) {
24  HcalSubdetector hsub = static_cast<HcalSubdetector>(subdet);
25 
27 
28  if (geom->cornersMgr() == nullptr) {
31  geom->allocateCorners(count);
32  }
33 
34  // if( geom->cornersMgr() == 0 ) geom->allocateCorners( 2592 ) ;
35 
36  if (geom->parMgr() == nullptr)
37  geom->allocatePar(500, 3);
38 
39  fill(hsub, geom);
40  //fast insertion of valid ids requires sort at end
41  geom->sortValidIds();
42  return geom;
43 }
44 
47 
48  if (geom->cornersMgr() == nullptr) {
51  geom->allocateCorners(count);
52  }
53  if (geom->parMgr() == nullptr)
54  geom->allocatePar(500, 3);
55 
60  //fast insertion of valid ids requires sort at end
61  geom->sortValidIds();
62  return geom;
63 }
64 
66  // start by making the new HcalDetIds
67  std::vector<HcalCellType> hcalCells = hcalConstants_->HcalCellTypes(subdet);
68  geom->insertCell(hcalCells);
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometryLoader::fill gets " << hcalCells.size() << " cells for subdetector "
71  << subdet;
72 #endif
73  // Make the new HcalDetIds and the cells
74 
75  std::vector<HcalDetId> hcalIds;
76  for (auto& hcalCell : hcalCells) {
77  int etaRing = hcalCell.etaBin();
78  int iside = hcalCell.zside();
79  int depthBin = hcalCell.depthSegment();
80  double dphi = hcalCell.phiBinWidth();
81  std::vector<std::pair<int, double> > phis = hcalCell.phis();
82 #ifdef EDM_ML_DEBUG
83  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometryLoader: Subdet " << subdet << " side " << iside << " eta "
84  << etaRing << " depth " << depthBin << " with " << phis.size() << "modules:";
85  size_t i(0);
86 #endif
87  geom->increaseReserve(phis.size());
88  for (auto& phi : phis) {
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometryLoader::fill Cell " << i << " eta " << iside * etaRing << " phi "
91  << phi.first << "(" << phi.second / CLHEP::deg << ", " << dphi / CLHEP::deg
92  << ") depth " << depthBin;
93  i++;
94 #endif
95  HcalDetId id(subdet, iside * etaRing, phi.first, depthBin);
96  hcalIds.emplace_back(id);
97  makeCell(id, hcalCell, phi.second, dphi, geom);
98  }
99  }
100 
101  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet << " is " << hcalIds.size();
102 }
103 
105  const HcalDetId& detId, const HcalCellType& hcalCell, double phi, double dphi, HcalDDDGeometry* geom) const {
106  // the two eta boundaries of the cell
107  double eta1 = hcalCell.etaMin();
108  double eta2 = hcalCell.etaMax();
109  HcalSubdetector subdet = detId.subdet();
110  double eta = 0.5 * (eta1 + eta2) * detId.zside();
111  double deta = (eta2 - eta1);
112  double theta = 2.0 * atan(exp(-eta));
113 
114  // barrel vs forward
115  bool rzType = hcalCell.depthType();
116  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
117 
118  double z, r, thickness;
119 #ifdef EDM_ML_DEBUG
120  double r0, r1, r2;
121 #endif
122  if (rzType) {
123  r = hcalCell.depthMin();
124  if (isBarrel) {
125  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
126  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
127 #ifdef EDM_ML_DEBUG
128  r1 = r;
129  r2 = hcalCell.depthMax();
130  r0 = 0.5 * (r1 + r2);
131 #endif
132  } else {
133  z = r * sinh(eta2);
134  thickness = 2. * hcalCell.halfSize();
135  r = z / sinh(std::abs(eta));
136 #ifdef EDM_ML_DEBUG
137  r0 = z / sinh(std::abs(eta));
138  r1 = z / sinh(std::abs(eta) + 0.5 * deta);
139  r2 = z / sinh(std::abs(eta) - 0.5 * deta);
140 #endif
141  }
142 #ifdef EDM_ML_DEBUG
143  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet << " eta = " << eta
144  << " theta = " << theta << " r = " << r << " thickness = " << thickness << " r0-r2 ("
145  << r0 << ":" << r1 << ":" << r2 << ")";
146 #endif
147  } else {
148  z = hcalCell.depthMin();
149  thickness = hcalCell.depthMax() - z;
150  if (isBH_)
151  z += (0.5 * thickness);
152  z *= detId.zside(); // get the sign right.
153  r = z * tan(theta);
155 #ifdef EDM_ML_DEBUG
156  r0 = z / sinh(std::abs(eta));
157  r1 = z / sinh(std::abs(eta) + 0.5 * deta);
158  r2 = z / sinh(std::abs(eta) - 0.5 * deta);
159  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometryLoader::makeCell SubDet " << subdet << " eta = " << eta
160  << " theta = " << theta << " z = " << z << " r = " << r << " thickness = " << thickness
161  << " r0-r2 (" << r0 << ":" << r1 << ":" << r2 << ")";
162 #endif
163  }
164 
165  double x = r * cos(phi);
166  double y = r * sin(phi);
167  GlobalPoint point(x, y, z);
168 
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometryLoader::makeCell for " << detId << " Point " << point
171  << " deta = " << deta << " dphi = " << dphi << " thickness = " << thickness
172  << " isBarrel = " << isBarrel << " " << rzType;
173 #endif
174 
175  std::vector<CCGFloat> hp;
176  hp.reserve(3);
177 
178  if (subdet == HcalForward) {
179  hp.emplace_back(deta / 2.);
180  hp.emplace_back(dphi / 2.);
181  hp.emplace_back(thickness / 2.);
182  } else {
183  const double sign(isBarrel ? 1 : -1);
184  hp.emplace_back(deta / 2.);
185  hp.emplace_back(dphi / 2.);
186  hp.emplace_back(sign * thickness / 2.);
187  }
188  geom->newCellFast(point, point, point, CaloCellGeometry::getParmPtr(hp, geom->parMgr(), geom->parVecVec()), detId);
189 }
Log< level::Info, true > LogVerbatim
void makeCell(const HcalDetId &, const HcalCellType &, double, double, HcalDDDGeometry *geom) const
double halfSize() const
Definition: HcalCellType.h:91
double etaMin() const
lower cell edge. Always positive
Definition: HcalCellType.h:78
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
CaloCellGeometry::CCGFloat CCGFloat
double etaMax() const
cell edge, always positive & greater than etaMin
Definition: HcalCellType.h:81
void fill(HcalSubdetector, HcalDDDGeometry *)
double depthMin() const
Definition: HcalCellType.h:88
HcalDDDGeometryLoader()=delete
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
ReturnType load(const HcalTopology &topo, DetId::Detector, int)
std::vector< HcalCellType > HcalCellTypes(HcalSubdetector) const
const HcalDDDRecConstants * hcalConstants_
Log< level::Info, false > LogInfo
bool depthType() const
Definition: HcalCellType.h:90
unsigned int numberOfCells(HcalSubdetector) const
Detector
Definition: DetId.h:24
double depthMax() const
Definition: HcalCellType.h:89
Geom::Theta< T > theta() const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5