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 
56  fill(HcalBarrel, geom);
57  fill(HcalEndcap, geom);
58  fill(HcalForward, geom);
59  fill(HcalOuter, geom);
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  std::cout << "HcalDDDGeometryLoader::fill gets " << hcalCells.size() << " cells for subdetector " << subdet
71  << std::endl;
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  std::cout << "HcalDDDGeometryLoader: Subdet " << subdet << " side " << iside << " eta " << etaRing << " depth "
84  << depthBin << " with " << phis.size() << "modules:" << std::endl;
85 #endif
86  geom->increaseReserve(phis.size());
87  for (auto& phi : phis) {
88 #ifdef EDM_ML_DEBUG
89  std::cout << "HcalDDDGeometryLoader::fill Cell " << i << " eta " << iside * etaRing << " phi " << phis[k].first
90  << "(" << phis[k].second / CLHEP::deg << ", " << dphi / CLHEP::deg << ") depth " << depthBin
91  << std::endl;
92 #endif
93  HcalDetId id(subdet, iside * etaRing, phi.first, depthBin);
94  hcalIds.emplace_back(id);
95  makeCell(id, hcalCell, phi.second, dphi, geom);
96  }
97  }
98 
99  edm::LogInfo("HCalGeom") << "Number of HCAL DetIds made for " << subdet << " is " << hcalIds.size();
100 }
101 
103  const HcalDetId& detId, const HcalCellType& hcalCell, double phi, double dphi, HcalDDDGeometry* geom) const {
104  // the two eta boundaries of the cell
105  double eta1 = hcalCell.etaMin();
106  double eta2 = hcalCell.etaMax();
107  HcalSubdetector subdet = detId.subdet();
108  double eta = 0.5 * (eta1 + eta2) * detId.zside();
109  double deta = (eta2 - eta1);
110  double theta = 2.0 * atan(exp(-eta));
111 
112  // barrel vs forward
113  bool rzType = hcalCell.depthType();
114  bool isBarrel = (subdet == HcalBarrel || subdet == HcalOuter);
115 
116  double z, r, thickness;
117 #ifdef EDM_ML_DEBUG
118  double r0, r1, r2;
119 #endif
120  if (rzType) {
121  r = hcalCell.depthMin();
122  if (isBarrel) {
123  z = r * sinh(eta); // sinh(eta) == 1/tan(theta)
124  thickness = (hcalCell.depthMax() - r) * cosh(eta); // cosh(eta) == 1/sin(theta)
125 #ifdef EDM_ML_DEBUG
126  r1 = r;
127  r2 = hcalCell.depthMax();
128  r0 = 0.5 * (r1 + r2);
129 #endif
130  } else {
131  z = r * sinh(eta2);
132  thickness = 2. * hcalCell.halfSize();
133  r = z / sinh(std::abs(eta));
134 #ifdef EDM_ML_DEBUG
135  r0 = z / sinh(std::abs(eta));
136  r1 = z / sinh(std::abs(eta) + 0.5 * deta);
137  r2 = z / sinh(std::abs(eta) - 0.5 * deta);
138 #endif
139  }
140 #ifdef EDM_ML_DEBUG
141  std::cout << "HcalDDDGeometryLoader::makeCell SubDet " << subdet << " eta = " << eta << " theta = " << theta
142  << " r = " << r << " thickness = " << thickness << " r0-r2 (" << r0 << ":" << r1 << ":" << r2 << ")"
143  << std::endl;
144 #endif
145  } else {
146  z = hcalCell.depthMin();
147  thickness = hcalCell.depthMax() - z;
148  if (isBH_)
149  z += (0.5 * thickness);
150  z *= detId.zside(); // get the sign right.
151  r = z * tan(theta);
152  thickness /= std::abs(cos(theta));
153 #ifdef EDM_ML_DEBUG
154  r0 = z / sinh(std::abs(eta));
155  r1 = z / sinh(std::abs(eta) + 0.5 * deta);
156  r2 = z / sinh(std::abs(eta) - 0.5 * deta);
157  std::cout << "HcalDDDGeometryLoader::makeCell SubDet " << subdet << " eta = " << eta << " theta = " << theta
158  << " z = " << z << " r = " << r << " thickness = " << thickness << " r0-r2 (" << r0 << ":" << r1 << ":"
159  << r2 << ")" << std::endl;
160 #endif
161  }
162 
163  double x = r * cos(phi);
164  double y = r * sin(phi);
165  GlobalPoint point(x, y, z);
166 
167 #ifdef EDM_ML_DEBUG
168  std::cout << "HcalDDDGeometryLoader::makeCell for " << detId << " Point " << point << " deta = " << deta
169  << " dphi = " << dphi << " thickness = " << thickness << " isBarrel = " << isBarrel << " " << rzType
170  << std::endl;
171 #endif
172 
173  std::vector<CCGFloat> hp;
174  hp.reserve(3);
175 
176  if (subdet == HcalForward) {
177  hp.emplace_back(deta / 2.);
178  hp.emplace_back(dphi / 2.);
179  hp.emplace_back(thickness / 2.);
180  } else {
181  const double sign(isBarrel ? 1 : -1);
182  hp.emplace_back(deta / 2.);
183  hp.emplace_back(dphi / 2.);
184  hp.emplace_back(sign * thickness / 2.);
185  }
186  geom->newCellFast(point, point, point, CaloCellGeometry::getParmPtr(hp, geom->parMgr(), geom->parVecVec()), detId);
187 }
double depthMax() const
Definition: HcalCellType.h:89
double depthMin() const
Definition: HcalCellType.h:88
bool depthType() const
Definition: HcalCellType.h:90
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
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
Geom::Theta< T > theta() const
CaloCellGeometry::CCGFloat CCGFloat
void allocatePar(ParVec::size_type n, unsigned int m)
void fill(HcalSubdetector, HcalDDDGeometry *)
HcalDDDGeometryLoader()=delete
void newCellFast(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
double halfSize() const
Definition: HcalCellType.h:91
unsigned int numberOfCells(HcalSubdetector) const
int insertCell(std::vector< HcalCellType > const &)
void increaseReserve(unsigned int extra)
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
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_
void makeCell(const HcalDetId &, const HcalCellType &, double, double, HcalDDDGeometry *geom) const
double etaMax() const
cell edge, always positive & greater than etaMin
Definition: HcalCellType.h:81
CaloCellGeometry::CornersMgr * cornersMgr()
Detector
Definition: DetId.h:24
double etaMin() const
lower cell edge. Always positive
Definition: HcalCellType.h:78
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
*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