CMS 3D CMS Logo

HcalDDDSimConstants.cc
Go to the documentation of this file.
2 
6 
7 //#define EDM_ML_DEBUG
8 using namespace geant_units::operators;
9 
11 #ifdef EDM_ML_DEBUG
12  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants::HcalDDDSimConstants (const HcalParameters* hp) constructor\n";
13 #endif
14 
15  initialize();
16 #ifdef EDM_ML_DEBUG
17  std::vector<HcalCellType> cellTypes = HcalCellTypes();
18  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants: " << cellTypes.size() << " cells of type HCal (All)\n";
19 #endif
20 }
21 
23 #ifdef EDM_ML_DEBUG
24  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants::destructed!!!\n";
25 #endif
26 }
27 
29  const int& idet, const int& zside, const int& depth, const int& etaR, const int& iphi) const {
30  double etaMn = hpar->etaMin[0];
31  double etaMx = hpar->etaMax[0];
32  if (idet == static_cast<int>(HcalEndcap)) {
33  etaMn = hpar->etaMin[1];
34  etaMx = hpar->etaMax[1];
35  } else if (idet == static_cast<int>(HcalForward)) {
36  etaMn = hpar->etaMin[2];
37  etaMx = hpar->etaMax[2];
38  }
39  double eta = 0, deta = 0, phi = 0, dphi = 0, rz = 0, drz = 0;
40  bool ok = false, flagrz = true;
41  if ((idet == static_cast<int>(HcalBarrel) || idet == static_cast<int>(HcalEndcap) ||
42  idet == static_cast<int>(HcalOuter) || idet == static_cast<int>(HcalForward)) &&
43  etaR >= etaMn && etaR <= etaMx && depth > 0)
44  ok = true;
45  if (idet == static_cast<int>(HcalEndcap) && depth > (int)(hpar->zHE.size()))
46  ok = false;
47  else if (idet == static_cast<int>(HcalBarrel) && depth > maxLayerHB_ + 1)
48  ok = false;
49  else if (idet == static_cast<int>(HcalOuter) && depth != 4)
50  ok = false;
51  else if (idet == static_cast<int>(HcalForward) && depth > maxDepth[2])
52  ok = false;
53  if (ok) {
54  eta = getEta(idet, etaR, zside, depth);
55  deta = deltaEta(idet, etaR, depth);
56  double fibin, fioff;
57  if (idet == static_cast<int>(HcalBarrel) || idet == static_cast<int>(HcalOuter)) {
58  fioff = hpar->phioff[0];
59  fibin = hpar->phibin[etaR - 1];
60  } else if (idet == static_cast<int>(HcalEndcap)) {
61  fioff = hpar->phioff[1];
62  fibin = hpar->phibin[etaR - 1];
63  } else {
64  fioff = hpar->phioff[2];
65  fibin = hpar->phitable[etaR - hpar->etaMin[2]];
66  if (unitPhi(fibin) > 2)
67  fioff = hpar->phioff[4];
68  }
69  phi = -fioff + (iphi - 0.5) * fibin;
70  dphi = 0.5 * fibin;
71  if (idet == static_cast<int>(HcalForward)) {
72  int ir = nR + hpar->etaMin[2] - etaR - 1;
73  if (ir > 0 && ir < nR) {
74  rz = 0.5 * (hpar->rTable[ir] + hpar->rTable[ir - 1]);
75  drz = 0.5 * (hpar->rTable[ir] - hpar->rTable[ir - 1]);
76  } else {
77  ok = false;
78 #ifdef EDM_ML_DEBUG
79  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants: wrong eta " << etaR << " (" << ir << "/" << nR
80  << ") Detector " << idet << std::endl;
81 #endif
82  }
83  } else if (etaR <= nEta) {
84  int laymin(depth), laymax(depth);
85  if (idet == static_cast<int>(HcalOuter)) {
86  laymin = (etaR > hpar->noff[2]) ? ((int)(hpar->zHE.size())) : ((int)(hpar->zHE.size())) - 1;
87  laymax = ((int)(hpar->zHE.size()));
88  }
89  double d1 = 0, d2 = 0;
90  if (idet == static_cast<int>(HcalEndcap)) {
91  flagrz = false;
92  d1 = hpar->zHE[laymin - 1] - hpar->dzHE[laymin - 1];
93  d2 = hpar->zHE[laymax - 1] + hpar->dzHE[laymax - 1];
94  } else {
95  d1 = hpar->rHB[laymin - 1] - hpar->drHB[laymin - 1];
96  d2 = hpar->rHB[laymax - 1] + hpar->drHB[laymax - 1];
97  }
98  rz = 0.5 * (d2 + d1);
99  drz = 0.5 * (d2 - d1);
100  } else {
101  ok = false;
102  edm::LogWarning("HCalGeom") << "HcalDDDSimConstants: wrong depth " << depth << " or etaR " << etaR
103  << " for detector " << idet;
104  }
105  } else {
106  ok = false;
107  edm::LogWarning("HCalGeom") << "HcalDDDSimConstants: wrong depth " << depth << " det " << idet;
108  }
109  HcalCellType::HcalCell tmp(ok, eta, deta, phi, dphi, rz, drz, flagrz);
110 
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants: det/side/depth/etaR/"
113  << "phi " << idet << "/" << zside << "/" << depth << "/" << etaR << "/" << iphi
114  << " Cell Flag " << tmp.ok << " " << tmp.eta << " " << tmp.deta << " phi " << tmp.phi
115  << " " << tmp.dphi << " r(z) " << tmp.rz << " " << tmp.drz << " " << tmp.flagrz;
116 #endif
117  return tmp;
118 }
119 
121  const int& det, const int& eta, const int& phi, const int& zside, const int& lay) const {
122  int depth = (ldmap_.isValid(det, phi, zside)) ? ldmap_.getDepth(det, eta, phi, zside, lay) : -1;
123  return depth;
124 }
125 
126 unsigned int HcalDDDSimConstants::findLayer(const int& layer,
127  const std::vector<HcalParameters::LayerItem>& layerGroup) const {
128  unsigned int id = layerGroup.size();
129  for (unsigned int i = 0; i < layerGroup.size(); i++) {
130  if (layer == (int)(layerGroup[i].layer)) {
131  id = i;
132  break;
133  }
134  }
135  return id;
136 }
137 
138 std::vector<std::pair<double, double> > HcalDDDSimConstants::getConstHBHE(const int& type) const {
139  std::vector<std::pair<double, double> > gcons;
140  if (type == 0) {
141  for (unsigned int i = 0; i < hpar->rHB.size(); ++i) {
142  gcons.emplace_back(std::pair<double, double>(hpar->rHB[i], hpar->drHB[i]));
143  }
144  } else {
145  for (unsigned int i = 0; i < hpar->zHE.size(); ++i) {
146  gcons.emplace_back(std::pair<double, double>(hpar->zHE[i], hpar->dzHE[i]));
147  }
148  }
149  return gcons;
150 }
151 
152 int HcalDDDSimConstants::getDepthEta16(const int& det, const int& phi, const int& zside) const {
153  int depth = ldmap_.getDepth16(det, phi, zside);
154  if (depth < 0)
155  depth = (det == 2) ? depthEta16[1] : depthEta16[0];
156 #ifdef EDM_ML_DEBUG
157  edm::LogVerbatim("HCalGeom") << "getDepthEta16: " << det << ":" << depth;
158 #endif
159  return depth;
160 }
161 
162 int HcalDDDSimConstants::getDepthEta16M(const int& det) const {
163  int depth = (det == 2) ? depthEta16[1] : depthEta16[0];
164  std::vector<int> phis;
165  int detsp = ldmap_.validDet(phis);
166  if (detsp == det) {
167  int zside = (phis[0] > 0) ? 1 : -1;
168  int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
169  int depthsp = ldmap_.getDepth16(det, iphi, zside);
170  if (det == 1 && depthsp > depth)
171  depth = depthsp;
172  if (det == 2 && depthsp < depth)
173  depth = depthsp;
174  }
175  return depth;
176 }
177 
178 int HcalDDDSimConstants::getDepthEta29(const int& phi, const int& zside, const int& i) const {
179  int depth = (i == 0) ? ldmap_.getMaxDepthLastHE(2, phi, zside) : -1;
180  if (depth < 0)
181  depth = (i == 1) ? depthEta29[1] : depthEta29[0];
182  return depth;
183 }
184 
185 int HcalDDDSimConstants::getDepthEta29M(const int& i, const bool& planOne) const {
186  int depth = (i == 1) ? depthEta29[1] : depthEta29[0];
187  if (i == 0 && planOne) {
188  std::vector<int> phis;
189  int detsp = ldmap_.validDet(phis);
190  if (detsp == 2) {
191  int zside = (phis[0] > 0) ? 1 : -1;
192  int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
193  int depthsp = ldmap_.getMaxDepthLastHE(2, iphi, zside);
194  if (depthsp > depth)
195  depth = depthsp;
196  }
197  }
198  return depth;
199 }
200 
201 std::pair<int, double> HcalDDDSimConstants::getDetEta(const double& eta, const int& depth) const {
202  int hsubdet(0), ieta(0);
203  double etaR(0);
204  double heta = fabs(eta);
205  for (int i = 0; i < nEta; i++)
206  if (heta > hpar->etaTable[i])
207  ieta = i + 1;
208  if (heta <= hpar->etaRange[1]) {
209  if (((ieta == hpar->etaMin[1] && depth == depthEta16[1]) || (ieta > hpar->etaMax[0])) &&
210  (ieta <= hpar->etaMax[1])) {
211  hsubdet = static_cast<int>(HcalEndcap);
212  } else {
213  hsubdet = static_cast<int>(HcalBarrel);
214  }
215  etaR = eta;
216  } else {
217  hsubdet = static_cast<int>(HcalForward);
218  double theta = 2. * atan(exp(-heta));
219  double hR = zVcal * tan(theta);
220  etaR = (eta >= 0. ? hR : -hR);
221  }
222  return std::pair<int, double>(hsubdet, etaR);
223 }
224 
225 int HcalDDDSimConstants::getEta(const int& det, const int& lay, const double& hetaR) const {
226  int ieta(0);
227  if (det == static_cast<int>(HcalForward)) { // Forward HCal
228  ieta = hpar->etaMax[2];
229  for (int i = nR - 1; i > 0; i--)
230  if (hetaR < hpar->rTable[i])
231  ieta = hpar->etaMin[2] + nR - i - 1;
232  } else { // Barrel or Endcap
233  ieta = 1;
234  for (int i = 0; i < nEta - 1; i++)
235  if (hetaR > hpar->etaTable[i])
236  ieta = i + 1;
237  if (det == static_cast<int>(HcalBarrel)) {
238  if (ieta > hpar->etaMax[0])
239  ieta = hpar->etaMax[0];
240  if (lay == maxLayer_) {
241  if (hetaR > etaHO[1] && ieta == hpar->noff[2])
242  ieta++;
243  }
244  } else if (det == static_cast<int>(HcalEndcap)) {
245  if (ieta <= hpar->etaMin[1])
246  ieta = hpar->etaMin[1];
247  }
248  }
249  return ieta;
250 }
251 
253  const int& det, int etaR, const int& phi, const int& zside, int depth, const int& lay) const {
254 #ifdef EDM_ML_DEBUG
255  edm::LogVerbatim("HCalGeom") << "HcalDDDEsimConstants:getEtaDepth: I/P " << det << ":" << etaR << ":" << phi << ":"
256  << zside << ":" << depth << ":" << lay;
257 #endif
258  //Modify the depth index
259  if ((det == static_cast<int>(HcalEndcap)) && (etaR == 17) && (lay == 1))
260  etaR = 18;
261  if (det == static_cast<int>(HcalForward)) { // Forward HCal
262  } else if (det == static_cast<int>(HcalOuter)) {
263  depth = 4;
264  } else {
265  if (lay >= 0) {
266  depth = layerGroup(det, etaR, phi, zside, lay - 1);
267  if (etaR == hpar->noff[0] && lay > 1) {
268  int kphi = phi + int((hpar->phioff[3] + 0.1) / hpar->phibin[etaR - 1]);
269  kphi = (kphi - 1) % 4 + 1;
270  if (kphi == 2 || kphi == 3)
271  depth = layerGroup(det, etaR, phi, zside, lay - 2);
272  }
273  } else if (det == static_cast<int>(HcalBarrel)) {
274  if (depth > getMaxDepth(det, etaR, phi, zside, false))
275  depth = getMaxDepth(det, etaR, phi, zside, false);
276  }
277  if (etaR >= hpar->noff[1] && depth > getDepthEta29(phi, zside, 0)) {
278  etaR -= getDepthEta29(phi, zside, 1);
279  } else if (etaR == hpar->etaMin[1]) {
280  if (det == static_cast<int>(HcalBarrel)) {
281  if (depth > getDepthEta16(det, phi, zside))
282  depth = getDepthEta16(det, phi, zside);
283  } else {
284  if (depth < getDepthEta16(det, phi, zside))
285  depth = getDepthEta16(det, phi, zside);
286  }
287  }
288  }
289 #ifdef EDM_ML_DEBUG
290  edm::LogVerbatim("HCalGeom") << "HcalDDDEsimConstants:getEtaDepth: O/P " << etaR << ":" << depth;
291 #endif
292  return std::pair<int, int>(etaR, depth);
293 }
294 
295 double HcalDDDSimConstants::getEtaHO(const double& etaR, const double& x, const double& y, const double& z) const {
296  if (hpar->zHO.size() > 4) {
297  double eta = fabs(etaR);
298  double r = std::sqrt(x * x + y * y);
299  if (r > rminHO) {
300  double zz = fabs(z);
301  if (zz > hpar->zHO[3]) {
302  if (eta <= hpar->etaTable[10])
303  eta = hpar->etaTable[10] + 0.001;
304  } else if (zz > hpar->zHO[1]) {
305  if (eta <= hpar->etaTable[4])
306  eta = hpar->etaTable[4] + 0.001;
307  }
308  }
309  eta = (z >= 0. ? eta : -eta);
310 #ifdef EDM_ML_DEBUG
311  edm::LogVerbatim("HCalGeom") << "R " << r << " Z " << z << " eta " << etaR << ":" << eta;
312  if (eta != etaR)
313  edm::LogInfo("HCalGeom") << "**** Check *****";
314 #endif
315  return eta;
316  } else {
317  return etaR;
318  }
319 }
320 
321 int HcalDDDSimConstants::getFrontLayer(const int& det, const int& eta) const {
322  int lay = 0;
323  if (det == 1) {
324  if (std::abs(eta) == 16)
325  lay = layFHB[1];
326  else
327  lay = layFHB[0];
328  } else {
329  if (std::abs(eta) == 16)
330  lay = layFHE[1];
331  else if (std::abs(eta) == 18)
332  lay = layFHE[2];
333  else
334  lay = layFHE[0];
335  }
336  return lay;
337 }
338 
339 int HcalDDDSimConstants::getLastLayer(const int& det, const int& eta) const {
340  int lay = 0;
341  if (det == 1) {
342  if (std::abs(eta) == 15)
343  lay = layBHB[1];
344  else if (std::abs(eta) == 16)
345  lay = layBHB[2];
346  else
347  lay = layBHB[0];
348  } else {
349  if (std::abs(eta) == 16)
350  lay = layBHE[1];
351  else if (std::abs(eta) == 17)
352  lay = layBHE[2];
353  else if (std::abs(eta) == 18)
354  lay = layBHE[3];
355  else
356  lay = layBHE[0];
357  }
358  return lay;
359 }
360 
361 double HcalDDDSimConstants::getLayer0Wt(const int& det, const int& phi, const int& zside) const {
362  double wt = ldmap_.getLayer0Wt(det, phi, zside);
363  if (wt < 0)
364  wt = (det == 2) ? hpar->Layer0Wt[1] : hpar->Layer0Wt[0];
365  return wt;
366 }
367 
369  const int& det, const int& eta, const int& phi, const int& zside, const int& depth) const {
370  int layer = ldmap_.getLayerFront(det, eta, phi, zside, depth);
371  if (layer < 0) {
372  if (det == 1 || det == 2) {
373  layer = 1;
374  for (int l = 0; l < getLayerMax(eta, depth); ++l) {
375  if ((int)(layerGroup(eta - 1, l)) == depth) {
376  layer = l + 1;
377  break;
378  }
379  }
380  } else {
381  layer = (eta > hpar->noff[2]) ? maxLayerHB_ + 1 : maxLayer_;
382  }
383  }
384  return layer;
385 }
386 
388  const int& det, const int& eta, const int& phi, const int& zside, const int& depth) const {
389  int layer = ldmap_.getLayerBack(det, eta, phi, zside, depth);
390  if (layer < 0) {
391  if (det == 1 || det == 2) {
392  layer = depths[depth - 1][eta - 1];
393  } else {
394  layer = maxLayer_;
395  }
396  }
397  return layer;
398 }
399 
400 int HcalDDDSimConstants::getLayerMax(const int& eta, const int& depth) const {
401  int layermx = ((eta < hpar->etaMin[1]) && depth - 1 < maxDepth[0]) ? maxLayerHB_ + 1 : (int)layerGroupSize(eta - 1);
402  return layermx;
403 }
404 
406  const int& det, const int& eta, const int& phi, const int& zside, const bool& partialDetOnly) const {
407  int dmax(-1);
408  if (partialDetOnly) {
409  if (ldmap_.isValid(det, phi, zside)) {
410  dmax = ldmap_.getDepths(eta).second;
411  }
412  } else if (det == 1 || det == 2) {
413  if (ldmap_.isValid(det, phi, zside))
414  dmax = ldmap_.getDepths(eta).second;
415  else if (det == 2)
416  dmax = (maxDepth[1] > 0) ? layerGroup(eta - 1, maxLayer_) : 0;
417  else if (eta == hpar->etaMax[0])
418  dmax = getDepthEta16(det, phi, zside);
419  else
420  dmax = layerGroup(eta - 1, maxLayerHB_);
421  } else if (det == 3) { // HF
422  dmax = maxHFDepth(zside * eta, phi);
423  } else if (det == 4) { // HO
424  dmax = maxDepth[3];
425  } else {
426  dmax = -1;
427  }
428  return dmax;
429 }
430 
432  const int& det, const int& eta, const int& phi, const int& zside, const bool& partialDetOnly) const {
433  int lmin(-1);
434  if (partialDetOnly) {
435  if (ldmap_.isValid(det, phi, zside)) {
436  lmin = ldmap_.getDepths(eta).first;
437  }
438  } else if (det == 3) { // HF
439  lmin = 1;
440  } else if (det == 4) { // HO
441  lmin = maxDepth[3];
442  } else {
443  if (ldmap_.isValid(det, phi, zside)) {
444  lmin = ldmap_.getDepths(eta).first;
445  } else if (layerGroupSize(eta - 1) > 0) {
446  lmin = (int)(layerGroup(eta - 1, 0));
447  unsigned int type = (det == 1) ? 0 : 1;
448  if (type == 1 && eta == hpar->etaMin[1])
449  lmin = getDepthEta16(det, phi, zside);
450  } else {
451  lmin = 1;
452  }
453  }
454  return lmin;
455 }
456 
457 std::pair<int, int> HcalDDDSimConstants::getModHalfHBHE(const int& type) const {
458  if (type == 0) {
459  return std::pair<int, int>(nmodHB, nzHB);
460  } else {
461  return std::pair<int, int>(nmodHE, nzHE);
462  }
463 }
464 
465 std::pair<double, double> HcalDDDSimConstants::getPhiCons(const int& det, const int& ieta) const {
466  double fioff(0), fibin(0);
467  if (det == static_cast<int>(HcalForward)) { // Forward HCal
468  fioff = hpar->phioff[2];
469  fibin = hpar->phitable[ieta - hpar->etaMin[2]];
470  if (unitPhi(fibin) > 2) { // HF double-phi
471  fioff = hpar->phioff[4];
472  }
473  } else { // Barrel or Endcap
474  if (det == static_cast<int>(HcalEndcap)) {
475  fioff = hpar->phioff[1];
476  } else {
477  fioff = hpar->phioff[0];
478  }
479  fibin = hpar->phibin[ieta - 1];
480  }
481  return std::pair<double, double>(fioff, fibin);
482 }
483 
484 std::vector<std::pair<int, double> > HcalDDDSimConstants::getPhis(const int& subdet, const int& ieta) const {
485  std::vector<std::pair<int, double> > phis;
486  int ietaAbs = (ieta > 0) ? ieta : -ieta;
487  std::pair<double, double> ficons = getPhiCons(subdet, ietaAbs);
488  int nphi = int((2._pi + 0.1 * ficons.second) / ficons.second);
489  int units = unitPhi(subdet, ietaAbs);
490  for (int ifi = 0; ifi < nphi; ++ifi) {
491  double phi = -ficons.first + (ifi + 0.5) * ficons.second;
492  int iphi = phiNumber(ifi + 1, units);
493  phis.emplace_back(std::pair<int, double>(iphi, phi));
494  }
495 #ifdef EDM_ML_DEBUG
496  edm::LogVerbatim("HCalGeom") << "getPhis: subdet|ieta|iphi " << subdet << "|" << ieta << " with " << phis.size()
497  << " phi bins";
498  for (unsigned int k = 0; k < phis.size(); ++k)
499  edm::LogVerbatim("HCalGeom") << "[" << k << "] iphi " << phis[k].first << " phi "
500  << convertRadToDeg(phis[k].second);
501 #endif
502  return phis;
503 }
504 
505 std::vector<HcalCellType> HcalDDDSimConstants::HcalCellTypes() const {
506  std::vector<HcalCellType> cellTypes = HcalCellTypes(HcalBarrel);
507 #ifdef EDM_ML_DEBUG
508  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants: " << cellTypes.size() << " cells of type HCal Barrel\n";
509  for (unsigned int i = 0; i < cellTypes.size(); i++)
510  edm::LogInfo("HCalGeom") << "Cell " << i << " " << cellTypes[i] << "\n";
511 #endif
512 
513  std::vector<HcalCellType> hoCells = HcalCellTypes(HcalOuter);
514 #ifdef EDM_ML_DEBUG
515  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants: " << hoCells.size() << " cells of type HCal Outer\n";
516  for (unsigned int i = 0; i < hoCells.size(); i++)
517  edm::LogInfo("HCalGeom") << "Cell " << i << " " << hoCells[i] << "\n";
518 #endif
519  cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
520 
521  std::vector<HcalCellType> heCells = HcalCellTypes(HcalEndcap);
522 #ifdef EDM_ML_DEBUG
523  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants: " << heCells.size() << " cells of type HCal Endcap\n";
524  for (unsigned int i = 0; i < heCells.size(); i++)
525  edm::LogInfo("HCalGeom") << "Cell " << i << " " << heCells[i] << "\n";
526 #endif
527  cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
528 
529  std::vector<HcalCellType> hfCells = HcalCellTypes(HcalForward);
530 #ifdef EDM_ML_DEBUG
531  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants: " << hfCells.size() << " cells of type HCal Forward\n";
532  for (unsigned int i = 0; i < hfCells.size(); i++)
533  edm::LogInfo("HCalGeom") << "Cell " << i << " " << hfCells[i] << "\n";
534 #endif
535  cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
536 
537  return cellTypes;
538 }
539 
540 std::vector<HcalCellType> HcalDDDSimConstants::HcalCellTypes(const HcalSubdetector& subdet,
541  int ieta,
542  int depthl) const {
543  std::vector<HcalCellType> cellTypes;
544  if (subdet == HcalForward) {
545  if (dzVcal < 0)
546  return cellTypes;
547  }
548 
549  int dmin, dmax, indx, nz;
550  double hsize = 0;
551  switch (subdet) {
552  case HcalEndcap:
553  dmin = 1;
554  dmax = (maxDepth[1] > 0) ? maxLayer_ + 1 : 0;
555  indx = 1;
556  nz = nzHE;
557  break;
558  case HcalForward:
559  dmin = 1;
560  dmax = (!idHF2QIE.empty()) ? 2 : maxDepth[2];
561  indx = 2;
562  nz = 2;
563  break;
564  case HcalOuter:
565  dmin = 4;
566  dmax = 4;
567  indx = 0;
568  nz = nzHB;
569  break;
570  default:
571  dmin = 1;
572  dmax = maxLayerHB_ + 1;
573  indx = 0;
574  nz = nzHB;
575  break;
576  }
577  if (depthl > 0)
578  dmin = dmax = depthl;
579  int ietamin = (ieta > 0) ? ieta : hpar->etaMin[indx];
580  int ietamax = (ieta > 0) ? ieta : hpar->etaMax[indx];
581  int phi = (indx == 2) ? 3 : 1;
582 
583  // Get the Cells
584  int subdet0 = static_cast<int>(subdet);
585  for (int depth = dmin; depth <= dmax; depth++) {
586  int shift = getShift(subdet, depth);
587  double gain = getGain(subdet, depth);
588  if (subdet == HcalForward) {
589  if (depth % 2 == 1)
590  hsize = dzVcal;
591  else
592  hsize = dzVcal - 0.5 * dlShort;
593  }
594  for (int eta = ietamin; eta <= ietamax; eta++) {
595  for (int iz = 0; iz < nz; ++iz) {
596  int zside = -2 * iz + 1;
597  HcalCellType::HcalCell temp1 = cell(subdet0, zside, depth, eta, phi);
598  if (temp1.ok) {
599  std::vector<std::pair<int, double> > phis = getPhis(subdet0, eta);
600  HcalCellType temp2(subdet, eta, zside, depth, temp1, shift, gain, hsize);
601  double dphi, fioff;
602  std::vector<int> phiMiss2;
603  if ((subdet == HcalBarrel) || (subdet == HcalOuter)) {
604  fioff = hpar->phioff[0];
605  dphi = hpar->phibin[eta - 1];
606  if (subdet == HcalOuter) {
607  if (eta == hpar->noff[4]) {
608  int kk = (iz == 0) ? 7 : (7 + hpar->noff[5]);
609  for (int miss = 0; miss < hpar->noff[5 + iz]; miss++) {
610  phiMiss2.emplace_back(hpar->noff[kk]);
611  kk++;
612  }
613  }
614  }
615  } else if (subdet == HcalEndcap) {
616  fioff = hpar->phioff[1];
617  dphi = hpar->phibin[eta - 1];
618  } else {
619  fioff = hpar->phioff[2];
620  dphi = hpar->phitable[eta - hpar->etaMin[2]];
621  if (unitPhi(dphi) > 2)
622  fioff = hpar->phioff[4];
623  }
624  int unit = unitPhi(dphi);
625  temp2.setPhi(phis, phiMiss2, fioff, dphi, unit);
626  cellTypes.emplace_back(temp2);
627  // For HF look at extra cells
628  if ((subdet == HcalForward) && (!idHF2QIE.empty())) {
629  HcalCellType temp3(subdet, eta, zside + 2, depth, temp1, shift, gain, hsize);
630  std::vector<int> phiMiss3;
631  for (auto& phi : phis) {
632  bool ok(false);
633  for (auto l : idHF2QIE) {
634  if ((eta * zside == l.ieta()) && (phi.first == l.iphi())) {
635  ok = true;
636  break;
637  }
638  }
639  if (!ok)
640  phiMiss3.emplace_back(phi.first);
641  }
642  dphi = hpar->phitable[eta - hpar->etaMin[2]];
643  unit = unitPhi(dphi);
644  fioff = (unit > 2) ? hpar->phioff[4] : hpar->phioff[2];
645  temp3.setPhi(phis, phiMiss2, fioff, dphi, unit);
646  cellTypes.emplace_back(temp3);
647  }
648  }
649  }
650  }
651  }
652  return cellTypes;
653 }
654 
655 int HcalDDDSimConstants::maxHFDepth(const int& eta, const int& iphi) const {
656  int mxdepth = maxDepth[2];
657  if (!idHF2QIE.empty()) {
658  bool ok(false);
659  for (auto k : idHF2QIE) {
660  if ((eta == k.ieta()) && (iphi == k.iphi())) {
661  ok = true;
662  break;
663  }
664  }
665  if (!ok)
666  mxdepth = 2;
667  }
668  return mxdepth;
669 }
670 
671 unsigned int HcalDDDSimConstants::numberOfCells(const HcalSubdetector& subdet) const {
672  unsigned int num = 0;
673  std::vector<HcalCellType> cellTypes = HcalCellTypes(subdet);
674  for (auto& cellType : cellTypes) {
675  num += (unsigned int)(cellType.nPhiBins());
676  }
677 #ifdef EDM_ML_DEBUG
678  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants:numberOfCells " << cellTypes.size() << " " << num
679  << " for subdetector " << subdet;
680 #endif
681  return num;
682 }
683 
684 int HcalDDDSimConstants::phiNumber(const int& phi, const int& units) const {
685  int iphi_skip = phi;
686  if (units == 2)
687  iphi_skip = (phi - 1) * 2 + 1;
688  else if (units == 4)
689  iphi_skip = (phi - 1) * 4 - 1;
690  if (iphi_skip < 0)
691  iphi_skip += 72;
692  return iphi_skip;
693 }
694 
696  std::vector<int> phis;
697  int detsp = ldmap_.validDet(phis);
698  int kphi = (detsp > 0) ? phis[0] : 1;
699  int zside = (kphi > 0) ? 1 : -1;
700  int iphi = (kphi > 0) ? kphi : -kphi;
701  edm::LogVerbatim("HCalGeom") << "Tile Information for HB from " << hpar->etaMin[0] << " to " << hpar->etaMax[0]
702  << "\n";
703  for (int eta = hpar->etaMin[0]; eta <= hpar->etaMax[0]; eta++) {
704  int dmax = getMaxDepth(1, eta, iphi, -zside, false);
705  for (int depth = 1; depth <= dmax; depth++)
707  if (detsp == 1) {
708  int dmax = getMaxDepth(1, eta, iphi, zside, false);
709  for (int depth = 1; depth <= dmax; depth++)
711  }
712  }
713 
714  edm::LogVerbatim("HCalGeom") << "\nTile Information for HE from " << hpar->etaMin[1] << " to " << hpar->etaMax[1]
715  << "\n";
716  for (int eta = hpar->etaMin[1]; eta <= hpar->etaMax[1]; eta++) {
717  int dmin = (eta == hpar->etaMin[1]) ? getDepthEta16(2, iphi, -zside) : 1;
718  int dmax = getMaxDepth(2, eta, iphi, -zside, false);
719  for (int depth = dmin; depth <= dmax; depth++)
721  if (detsp == 2) {
722  int dmax = getMaxDepth(2, eta, iphi, zside, false);
723  for (int depth = 1; depth <= dmax; depth++)
725  }
726  }
727 }
728 
729 int HcalDDDSimConstants::unitPhi(const int& det, const int& etaR) const {
730  double dphi =
731  (det == static_cast<int>(HcalForward)) ? hpar->phitable[etaR - hpar->etaMin[2]] : hpar->phibin[etaR - 1];
732  return unitPhi(dphi);
733 }
734 
735 int HcalDDDSimConstants::unitPhi(const double& dphi) const {
736  const double fiveDegInRad = 2 * M_PI / 72;
737  int units = int(dphi / fiveDegInRad + 0.5);
738  if (units < 1)
739  units = 1;
740  return units;
741 }
742 
744  nEta = hpar->etaTable.size();
745  nR = hpar->rTable.size();
746  nPhiF = nR - 1;
747  isBH_ = false;
748 
749 #ifdef EDM_ML_DEBUG
750  for (int i = 0; i < nEta - 1; ++i) {
751  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants:Read LayerGroup" << i << ":";
752  for (unsigned int k = 0; k < layerGroupSize(i); k++)
753  edm::LogVerbatim("HCalGeom") << " [" << k << "] = " << layerGroup(i, k);
754  }
755 #endif
756 
757  // Geometry parameters for HF
758  dlShort = hpar->gparHF[0];
759  zVcal = hpar->gparHF[4];
760  dzVcal = hpar->dzVcal;
761 #ifdef EDM_ML_DEBUG
762  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants: dlShort " << dlShort << " zVcal " << zVcal << " and dzVcal "
763  << dzVcal;
764 #endif
765 
766  //Transform some of the parameters
768  maxDepth[0] = maxDepth[1] = 0;
769  for (int i = 0; i < nEta - 1; ++i) {
770  unsigned int imx = layerGroupSize(i);
771  int laymax = (imx > 0) ? layerGroup(i, imx - 1) : 0;
772  if (i < hpar->etaMax[0]) {
773  int laymax0 = (imx > 16) ? layerGroup(i, 16) : laymax;
774  if (i + 1 == hpar->etaMax[0] && laymax0 > 2)
775  laymax0 = 2;
776  if (maxDepth[0] < laymax0)
777  maxDepth[0] = laymax0;
778  }
779  if (i >= hpar->etaMin[1] - 1 && i < hpar->etaMax[1]) {
780  if (maxDepth[1] < laymax)
781  maxDepth[1] = laymax;
782  }
783  }
784 #ifdef EDM_ML_DEBUG
785  for (int i = 0; i < 4; ++i)
786  edm::LogVerbatim("HCalGeom") << "Detector Type [" << i << "] iEta " << hpar->etaMin[i] << ":" << hpar->etaMax[i]
787  << " MaxDepth " << maxDepth[i];
788 #endif
789 
790  int maxdepth = (maxDepth[1] > maxDepth[0]) ? maxDepth[1] : maxDepth[0];
791  for (int i = 0; i < maxdepth; ++i) {
792  for (int k = 0; k < nEta - 1; ++k) {
793  int layermx = getLayerMax(k + 1, i + 1);
794  int ll = layermx;
795  for (int l = layermx - 1; l >= 0; --l) {
796  if ((int)layerGroup(k, l) == i + 1) {
797  ll = l + 1;
798  break;
799  }
800  }
801  depths[i].emplace_back(ll);
802  }
803 
804 #ifdef EDM_ML_DEBUG
805  edm::LogVerbatim("HCalGeom") << "Depth " << i + 1 << " with " << depths[i].size() << " etas:";
806  for (int k = 0; k < nEta - 1; ++k)
807  edm::LogVerbatim("HCalGeom") << " [" << k << "] " << depths[i][k];
808 #endif
809  }
810 
811  nzHB = hpar->modHB[1];
812  nmodHB = hpar->modHB[0];
813  nzHE = hpar->modHE[1];
814  nmodHE = hpar->modHE[0];
815 #ifdef EDM_ML_DEBUG
816  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants:: " << nzHB << ":" << nmodHB << " barrel and " << nzHE << ":"
817  << nmodHE << " endcap half-sectors";
818 #endif
819 
820  if (hpar->rHB.size() > maxLayerHB_ + 1 && hpar->zHO.size() > 4) {
821  rminHO = hpar->rHO[0];
822  for (int k = 0; k < 4; ++k)
823  etaHO[k] = hpar->rHO[k + 1];
824  } else {
825  rminHO = -1.0;
826  etaHO[0] = hpar->etaTable[4];
827  etaHO[1] = hpar->etaTable[4];
828  etaHO[2] = hpar->etaTable[10];
829  etaHO[3] = hpar->etaTable[10];
830  }
831 #ifdef EDM_ML_DEBUG
832  edm::LogVerbatim("HCalGeom") << "HO Eta boundaries " << etaHO[0] << " " << etaHO[1] << " " << etaHO[2] << " "
833  << etaHO[3];
834  edm::LogVerbatim("HCalGeom") << "HO Parameters " << rminHO << " " << hpar->zHO.size();
835  for (int i = 0; i < 4; ++i)
836  edm::LogVerbatim("HCalGeom") << " eta[" << i << "] = " << etaHO[i];
837  for (unsigned int i = 0; i < hpar->zHO.size(); ++i)
838  edm::LogVerbatim("HCalGeom") << " zHO[" << i << "] = " << hpar->zHO[i];
839 #endif
840 
841  int noffsize = 7 + hpar->noff[5] + hpar->noff[6];
842  int noffl(noffsize + 5);
843  if ((int)(hpar->noff.size()) > (noffsize + 3)) {
844  depthEta16[0] = hpar->noff[noffsize];
845  depthEta16[1] = hpar->noff[noffsize + 1];
846  depthEta29[0] = hpar->noff[noffsize + 2];
847  depthEta29[1] = hpar->noff[noffsize + 3];
848  if ((int)(hpar->noff.size()) > (noffsize + 4)) {
849  noffl += (2 * hpar->noff[noffsize + 4]);
850  if ((int)(hpar->noff.size()) > noffl)
851  isBH_ = (hpar->noff[noffl] > 0);
852  }
853  } else {
854  depthEta16[0] = 2;
855  depthEta16[1] = 3;
856  depthEta29[0] = 2;
857  depthEta29[1] = 1;
858  }
859 #ifdef EDM_ML_DEBUG
860  edm::LogVerbatim("HCalGeom") << "isBH_ " << hpar->noff.size() << ":" << noffsize << ":" << noffl << ":" << isBH_;
861  edm::LogVerbatim("HCalGeom") << "Depth index at ieta = 16 for HB (max) " << depthEta16[0] << " HE (min) "
862  << depthEta16[1] << "; max depth for itea = 29 : (" << depthEta29[0] << ":"
863  << depthEta29[1] << ")";
864 #endif
865 
866  if ((int)(hpar->noff.size()) > (noffsize + 4)) {
867  int npair = hpar->noff[noffsize + 4];
868  int kk = noffsize + 4;
869  for (int k = 0; k < npair; ++k) {
870  idHF2QIE.emplace_back(HcalDetId(HcalForward, hpar->noff[kk + 1], hpar->noff[kk + 2], 1));
871  kk += 2;
872  }
873  }
874 #ifdef EDM_ML_DEBUG
875  edm::LogVerbatim("HCalGeom") << idHF2QIE.size() << " detector channels having 2 QIE cards:";
876  for (unsigned int k = 0; k < idHF2QIE.size(); ++k)
877  edm::LogVerbatim("HCalGeom") << " [" << k << "] " << idHF2QIE[k];
878 #endif
879 
880  layFHB[0] = 0;
881  layFHB[1] = 1;
882  layBHB[0] = 16;
883  layBHB[1] = 15;
884  layBHB[2] = 8;
885  if (maxDepth[1] == 0) {
886  layFHE[0] = layFHE[1] = layFHE[2] = 0;
887  layBHE[0] = layBHE[1] = layBHE[2] = layBHE[3] = 0;
888  } else {
889  layFHE[0] = 1;
890  layFHE[1] = 4;
891  layFHE[2] = 0;
892  layBHE[0] = 18;
893  layBHE[1] = 9;
894  layBHE[2] = 14;
895  layBHE[3] = 16;
896  }
897  depthMaxSp_ = std::pair<int, int>(0, 0);
898  int noffk(noffsize + 5);
899  if ((int)(hpar->noff.size()) > (noffsize + 5)) {
900  noffk += (2 * hpar->noff[noffsize + 4]);
901  if ((int)(hpar->noff.size()) >= noffk + 7) {
902  int dtype = hpar->noff[noffk + 1];
903  int nphi = hpar->noff[noffk + 2];
904  int ndeps = hpar->noff[noffk + 3];
905  int ndp16 = hpar->noff[noffk + 4];
906  int ndp29 = hpar->noff[noffk + 5];
907  double wt = 0.1 * (hpar->noff[noffk + 6]);
908  if ((int)(hpar->noff.size()) >= (noffk + 7 + nphi + 3 * ndeps)) {
909  if (dtype == 1 || dtype == 2) {
910  std::vector<int> ifi, iet, ily, idp;
911  for (int i = 0; i < nphi; ++i)
912  ifi.emplace_back(hpar->noff[noffk + 7 + i]);
913  for (int i = 0; i < ndeps; ++i) {
914  iet.emplace_back(hpar->noff[noffk + 7 + nphi + 3 * i]);
915  ily.emplace_back(hpar->noff[noffk + 7 + nphi + 3 * i + 1]);
916  idp.emplace_back(hpar->noff[noffk + 7 + nphi + 3 * i + 2]);
917  }
918 #ifdef EDM_ML_DEBUG
919  edm::LogVerbatim("HCalGeom") << "Initialize HcalLayerDepthMap for "
920  << "Detector " << dtype << " etaMax " << hpar->etaMax[dtype] << " with " << nphi
921  << " sectors";
922  for (int i = 0; i < nphi; ++i)
923  edm::LogVerbatim("HCalGeom") << " [" << i << "] " << ifi[i];
924  edm::LogVerbatim("HCalGeom") << "And " << ndeps << " depth sections";
925  for (int i = 0; i < ndeps; ++i)
926  edm::LogVerbatim("HCalGeom") << " [" << i << "] " << iet[i] << " " << ily[i] << " " << idp[i];
927  edm::LogVerbatim("HCalGeom") << "Maximum depth for last HE Eta tower " << depthEta29[0] << ":" << ndp16 << ":"
928  << ndp29 << " L0 Wt " << hpar->Layer0Wt[dtype - 1] << ":" << wt;
929 #endif
930  ldmap_.initialize(dtype, hpar->etaMax[dtype - 1], ndp16, ndp29, wt, ifi, iet, ily, idp);
931  int zside = (ifi[0] > 0) ? 1 : -1;
932  int iphi = (ifi[0] > 0) ? ifi[0] : -ifi[0];
933  depthMaxSp_ = std::pair<int, int>(dtype, ldmap_.getDepthMax(dtype, iphi, zside));
934  }
935  }
936  int noffm = (noffk + 7 + nphi + 3 * ndeps);
937  if ((int)(hpar->noff.size()) > noffm) {
938  int ndnext = hpar->noff[noffm];
939  if (ndnext > 4 && (int)(hpar->noff.size()) >= noffm + ndnext) {
940  for (int i = 0; i < 2; ++i)
941  layFHB[i] = hpar->noff[noffm + i + 1];
942  for (int i = 0; i < 3; ++i)
943  layFHE[i] = hpar->noff[noffm + i + 3];
944  }
945  if (ndnext > 11 && (int)(hpar->noff.size()) >= noffm + ndnext) {
946  for (int i = 0; i < 3; ++i)
947  layBHB[i] = hpar->noff[noffm + i + 6];
948  for (int i = 0; i < 4; ++i)
949  layBHE[i] = hpar->noff[noffm + i + 9];
950  }
951  }
952  }
953  }
954 #ifdef EDM_ML_DEBUG
955  edm::LogVerbatim("HCalGeom") << "Front Layer Definition for HB: " << layFHB[0] << ":" << layFHB[1]
956  << " and for HE: " << layFHE[0] << ":" << layFHE[1] << ":" << layFHE[2];
957  edm::LogVerbatim("HCalGeom") << "Last Layer Definition for HB: " << layBHB[0] << ":" << layBHB[1] << ":" << layBHB[2]
958  << " and for HE: " << layBHE[0] << ":" << layBHE[1] << ":" << layBHE[2] << ":"
959  << layBHE[3];
960 #endif
961  if (depthMaxSp_.first == 0) {
962  depthMaxSp_ = depthMaxDf_ = std::pair<int, int>(2, maxDepth[1]);
963  } else if (depthMaxSp_.first == 1) {
964  depthMaxDf_ = std::pair<int, int>(1, maxDepth[0]);
965  if (depthMaxSp_.second > maxDepth[0])
966  maxDepth[0] = depthMaxSp_.second;
967  } else {
968  depthMaxDf_ = std::pair<int, int>(2, maxDepth[1]);
969  if (depthMaxSp_.second > maxDepth[1])
970  maxDepth[1] = depthMaxSp_.second;
971  }
972 #ifdef EDM_ML_DEBUG
973  edm::LogVerbatim("HCalGeom") << "Detector type and maximum depth for all RBX " << depthMaxDf_.first << ":"
974  << depthMaxDf_.second << " and for special RBX " << depthMaxSp_.first << ":"
975  << depthMaxSp_.second;
976 #endif
977 }
978 
979 double HcalDDDSimConstants::deltaEta(const int& det, const int& etaR, const int& depth) const {
980  double tmp = 0;
981  if (det == static_cast<int>(HcalForward)) {
982  int ir = nR + hpar->etaMin[2] - etaR - 1;
983  if (ir > 0 && ir < nR) {
984  double z = zVcal;
985  if (depth % 2 != 1)
986  z += dlShort;
987  tmp = 0.5 * (getEta(hpar->rTable[ir - 1], z) - getEta(hpar->rTable[ir], z));
988  }
989  } else {
990  if (etaR > 0 && etaR < nEta) {
991  if (etaR == hpar->noff[1] - 1 && depth > depthEta29[0]) {
992  tmp = 0.5 * (hpar->etaTable[etaR + 1] - hpar->etaTable[etaR - 1]);
993  } else if (det == static_cast<int>(HcalOuter)) {
994  if (etaR == hpar->noff[2]) {
995  tmp = 0.5 * (etaHO[0] - hpar->etaTable[etaR - 1]);
996  } else if (etaR == hpar->noff[2] + 1) {
997  tmp = 0.5 * (hpar->etaTable[etaR] - etaHO[1]);
998  } else if (etaR == hpar->noff[3]) {
999  tmp = 0.5 * (etaHO[2] - hpar->etaTable[etaR - 1]);
1000  } else if (etaR == hpar->noff[3] + 1) {
1001  tmp = 0.5 * (hpar->etaTable[etaR] - etaHO[3]);
1002  } else {
1003  tmp = 0.5 * (hpar->etaTable[etaR] - hpar->etaTable[etaR - 1]);
1004  }
1005  } else {
1006  tmp = 0.5 * (hpar->etaTable[etaR] - hpar->etaTable[etaR - 1]);
1007  }
1008  }
1009  }
1010 #ifdef EDM_ML_DEBUG
1011  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants::deltaEta " << etaR << " " << depth << " ==> " << tmp;
1012 #endif
1013  return tmp;
1014 }
1015 
1016 double HcalDDDSimConstants::getEta(const int& det, const int& etaR, const int& zside, int depth) const {
1017  double tmp = 0;
1018  if (det == static_cast<int>(HcalForward)) {
1019  int ir = nR + hpar->etaMin[2] - etaR - 1;
1020  if (ir > 0 && ir < nR) {
1021  double z = zVcal;
1022  if (depth % 2 != 1)
1023  z += dlShort;
1024  tmp = 0.5 * (getEta(hpar->rTable[ir - 1], z) + getEta(hpar->rTable[ir], z));
1025  }
1026  } else {
1027  if (etaR > 0 && etaR < nEta) {
1028  if (etaR == hpar->noff[1] - 1 && depth > depthEta29[0]) {
1029  tmp = 0.5 * (hpar->etaTable[etaR + 1] + hpar->etaTable[etaR - 1]);
1030  } else if (det == static_cast<int>(HcalOuter)) {
1031  if (etaR == hpar->noff[2]) {
1032  tmp = 0.5 * (etaHO[0] + hpar->etaTable[etaR - 1]);
1033  } else if (etaR == hpar->noff[2] + 1) {
1034  tmp = 0.5 * (hpar->etaTable[etaR] + etaHO[1]);
1035  } else if (etaR == hpar->noff[3]) {
1036  tmp = 0.5 * (etaHO[2] + hpar->etaTable[etaR - 1]);
1037  } else if (etaR == hpar->noff[3] + 1) {
1038  tmp = 0.5 * (hpar->etaTable[etaR] + etaHO[3]);
1039  } else {
1040  tmp = 0.5 * (hpar->etaTable[etaR] + hpar->etaTable[etaR - 1]);
1041  }
1042  } else {
1043  tmp = 0.5 * (hpar->etaTable[etaR] + hpar->etaTable[etaR - 1]);
1044  }
1045  }
1046  }
1047  if (zside == 0)
1048  tmp = -tmp;
1049 #ifdef EDM_ML_DEBUG
1050  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants::getEta " << etaR << " " << zside << " " << depth << " ==> "
1051  << tmp;
1052 #endif
1053  return tmp;
1054 }
1055 
1056 double HcalDDDSimConstants::getEta(const double& r, const double& z) const {
1057  double tmp = 0;
1058  if (z != 0)
1059  tmp = -log(tan(0.5 * atan(r / z)));
1060 #ifdef EDM_ML_DEBUG
1061  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants::getEta " << r << " " << z << " ==> " << tmp;
1062 #endif
1063  return tmp;
1064 }
1065 
1066 int HcalDDDSimConstants::getShift(const HcalSubdetector& subdet, const int& depth) const {
1067  int shift;
1068  switch (subdet) {
1069  case HcalEndcap:
1070  shift = hpar->HEShift[0];
1071  break;
1072  case HcalForward:
1073  shift = hpar->HFShift[(depth - 1) % 2];
1074  break;
1075  case HcalOuter:
1076  shift = hpar->HBShift[3];
1077  break;
1078  default:
1079  shift = hpar->HBShift[0];
1080  break;
1081  }
1082  return shift;
1083 }
1084 
1085 double HcalDDDSimConstants::getGain(const HcalSubdetector& subdet, const int& depth) const {
1086  double gain;
1087  switch (subdet) {
1088  case HcalEndcap:
1089  gain = hpar->HEGains[0];
1090  break;
1091  case HcalForward:
1092  gain = hpar->HFGains[(depth - 1) % 2];
1093  break;
1094  case HcalOuter:
1095  gain = hpar->HBGains[3];
1096  break;
1097  default:
1098  gain = hpar->HBGains[0];
1099  break;
1100  }
1101  return gain;
1102 }
1103 
1104 void HcalDDDSimConstants::printTileHB(const int& eta, const int& phi, const int& zside, const int& depth) const {
1105  edm::LogVerbatim("HCalGeom") << "HcalDDDSimConstants::printTileHB for eta " << eta << " and depth " << depth;
1106 
1107  double etaL = hpar->etaTable.at(eta - 1);
1108  double thetaL = 2. * atan(exp(-etaL));
1109  double etaH = hpar->etaTable.at(eta);
1110  double thetaH = 2. * atan(exp(-etaH));
1111  int layL = getLayerFront(1, eta, phi, zside, depth);
1112  int layH = getLayerBack(1, eta, phi, zside, depth);
1113  edm::LogVerbatim("HCalGeom") << "\ntileHB:: eta|depth " << zside * eta << "|" << depth << " theta "
1114  << convertRadToDeg(thetaH) << ":" << convertRadToDeg(thetaL) << " Layer " << layL - 1
1115  << ":" << layH - 1;
1116  for (int lay = layL - 1; lay < layH; ++lay) {
1117  std::vector<double> area(2, 0);
1118  int kk(0);
1119  double mean(0);
1120  for (unsigned int k = 0; k < hpar->layHB.size(); ++k) {
1121  if (lay == hpar->layHB[k]) {
1122  double zmin = hpar->rhoxHB[k] * std::cos(thetaL) / std::sin(thetaL);
1123  double zmax = hpar->rhoxHB[k] * std::cos(thetaH) / std::sin(thetaH);
1124  double dz = (std::min(zmax, hpar->dxHB[k]) - zmin);
1125  if (dz > 0) {
1126  area[kk] = dz * hpar->dyHB[k];
1127  mean += area[kk];
1128  kk++;
1129  }
1130  }
1131  }
1132  if (area[0] > 0) {
1133  mean /= (kk * 100);
1134  edm::LogVerbatim("HCalGeom") << std::setw(2) << lay << " Area " << std::setw(8) << area[0] << " " << std::setw(8)
1135  << area[1] << " Mean " << mean;
1136  }
1137  }
1138 }
1139 
1140 void HcalDDDSimConstants::printTileHE(const int& eta, const int& phi, const int& zside, const int& depth) const {
1141  double etaL = hpar->etaTable[eta - 1];
1142  double thetaL = 2. * atan(exp(-etaL));
1143  double etaH = hpar->etaTable[eta];
1144  double thetaH = 2. * atan(exp(-etaH));
1145  int layL = getLayerFront(2, eta, phi, zside, depth);
1146  int layH = getLayerBack(2, eta, phi, zside, depth);
1147  double phib = hpar->phibin[eta - 1];
1148  int nphi = 2;
1149  if (phib > 6._deg)
1150  nphi = 1;
1151  edm::LogVerbatim("HCalGeom") << "\ntileHE:: Eta/depth " << zside * eta << "|" << depth << " theta "
1152  << convertRadToDeg(thetaH) << ":" << convertRadToDeg(thetaL) << " Layer " << layL - 1
1153  << ":" << layH - 1 << " phi " << nphi;
1154  for (int lay = layL - 1; lay < layH; ++lay) {
1155  std::vector<double> area(4, 0);
1156  int kk(0);
1157  double mean(0);
1158  for (unsigned int k = 0; k < hpar->layHE.size(); ++k) {
1159  if (lay == hpar->layHE[k]) {
1160  double rmin = hpar->zxHE[k] * std::tan(thetaH);
1161  double rmax = hpar->zxHE[k] * std::tan(thetaL);
1162  if ((lay != 0 || eta == 18) &&
1163  (lay != 1 || (eta == 18 && hpar->rhoxHE[k] - hpar->dyHE[k] > 1000) ||
1164  (eta != 18 && hpar->rhoxHE[k] - hpar->dyHE[k] < 1000)) &&
1165  rmin + 30 < hpar->rhoxHE[k] + hpar->dyHE[k] && rmax > hpar->rhoxHE[k] - hpar->dyHE[k]) {
1166  rmin = std::max(rmin, hpar->rhoxHE[k] - hpar->dyHE[k]);
1167  rmax = std::min(rmax, hpar->rhoxHE[k] + hpar->dyHE[k]);
1168  double dx1 = rmin * std::tan(phib);
1169  double dx2 = rmax * std::tan(phib);
1170  double ar1 = 0, ar2 = 0;
1171  if (nphi == 1) {
1172  ar1 = 0.5 * (rmax - rmin) * (dx1 + dx2 - 4. * hpar->dx1HE[k]);
1173  mean += ar1;
1174  } else {
1175  ar1 = 0.5 * (rmax - rmin) * (dx1 + dx2 - 2. * hpar->dx1HE[k]);
1176  ar2 = 0.5 * (rmax - rmin) * ((rmax + rmin) * tan(10._deg) - 4 * hpar->dx1HE[k]) - ar1;
1177  mean += (ar1 + ar2);
1178  }
1179  area[kk] = ar1;
1180  area[kk + 2] = ar2;
1181  kk++;
1182  }
1183  }
1184  }
1185  if (area[0] > 0 && area[1] > 0) {
1186  int lay0 = lay - 1;
1187  if (eta == 18)
1188  lay0++;
1189  if (nphi == 1) {
1190  mean /= (kk * 100);
1191  edm::LogVerbatim("HCalGeom") << std::setw(2) << lay0 << " Area " << std::setw(8) << area[0] << " "
1192  << std::setw(8) << area[1] << " Mean " << mean;
1193  } else {
1194  mean /= (kk * 200);
1195  edm::LogVerbatim("HCalGeom") << std::setw(2) << lay0 << " Area " << std::setw(8) << area[0] << " "
1196  << std::setw(8) << area[1] << ":" << std::setw(8) << area[2] << " " << std::setw(8)
1197  << area[3] << " Mean " << mean;
1198  }
1199  }
1200  }
1201 }
1202 
1203 unsigned int HcalDDDSimConstants::layerGroupSize(int eta) const {
1204  unsigned int k = 0;
1205  for (auto const& it : hpar->layerGroupEtaSim) {
1206  if (it.layer == (unsigned int)(eta + 1)) {
1207  return it.layerGroup.size();
1208  }
1209  if (it.layer > (unsigned int)(eta + 1))
1210  break;
1211  k = it.layerGroup.size();
1212  }
1213  return k;
1214 }
1215 
1216 unsigned int HcalDDDSimConstants::layerGroup(int eta, int i) const {
1217  unsigned int k = 0;
1218  for (auto const& it : hpar->layerGroupEtaSim) {
1219  if (it.layer == (unsigned int)(eta + 1)) {
1220  return it.layerGroup.at(i);
1221  }
1222  if (it.layer > (unsigned int)(eta + 1))
1223  break;
1224  k = it.layerGroup.at(i);
1225  }
1226  return k;
1227 }
1228 
1229 unsigned int HcalDDDSimConstants::layerGroup(int det, int eta, int phi, int zside, int lay) const {
1230  int depth0 = findDepth(det, eta, phi, zside, lay);
1231  unsigned int depth = (depth0 > 0) ? (unsigned int)(depth0) : layerGroup(eta - 1, lay);
1232  return depth;
1233 }
double getLayer0Wt(const int subdet, const int iphi, const int zside) const
HcalCellType::HcalCell cell(const int &det, const int &zside, const int &depth, const int &etaR, const int &iphi) const
Log< level::Info, true > LogVerbatim
const int nphi
int getEta(const int &det, const int &lay, const double &hetaR) const
std::vector< double > zHO
std::vector< double > etaTable
int getFrontLayer(const int &det, const int &eta) const
int getDepth(const int subdet, const int ieta, const int iphi, const int zside, const int layer) const
double getEtaHO(const double &etaR, const double &x, const double &y, const double &z) const
unsigned int findLayer(const int &layer, const std::vector< HcalParameters::LayerItem > &layerGroup) const
std::vector< int > layHE
void initialize(const int subdet, const int ietaMax, const int dep16C, const int dep29C, const double wtl0C, std::vector< int > const &iphi, std::vector< int > const &ieta, std::vector< int > const &layer, std::vector< int > const &depth)
std::vector< int > maxDepth
std::vector< double > rHB
bool isValid(const int det, const int phi, const int zside) const
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
int getDepthEta29M(const int &i, const bool &planOne) const
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
std::vector< double > rhoxHB
int maxHFDepth(const int &ieta, const int &iphi) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int maxLayer_
std::vector< double > HBGains
int getLayerFront(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
std::pair< int, int > depthMaxDf_
int getDepthEta29(const int &phi, const int &zside, const int &i) const
std::vector< int > HEShift
double deltaEta(const int &det, const int &eta, const int &depth) const
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
int zside(DetId const &)
std::pair< double, double > getPhiCons(const int &det, const int &ieta) const
HcalDDDSimConstants(const HcalParameters *hp)
double getGain(const HcalSubdetector &subdet, const int &depth) const
float float float z
std::pair< int, double > getDetEta(const double &eta, const int &depth) const
int getDepthEta16M(const int &det) const
unsigned int numberOfCells(const HcalSubdetector &) const
std::vector< int > etaMax
std::vector< int > depths[nDepthMax]
std::vector< int > modHB
int phiNumber(const int &phi, const int &unit) const
std::vector< double > rhoxHE
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
U second(std::pair< T, U > const &p)
std::vector< double > zxHE
std::vector< double > zHE
std::vector< LayerItem > layerGroupEtaSim
unsigned int layerGroupSize(int eta) const
std::vector< double > dyHE
void setPhi(const std::vector< std::pair< int, double >> &phis, const std::vector< int > &iphiMiss, double foff, double dphi, int unit)
std::pair< int, int > getEtaDepth(const int &det, int etaR, const int &phi, const int &zside, int depth, const int &lay) const
int getMaxDepthLastHE(const int subdet, const int iphi, const int zside) const
std::vector< double > dx1HE
std::vector< double > rHO
std::pair< int, int > getDepths(const int eta) const
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< double > dzHE
std::vector< std::pair< double, double > > getConstHBHE(const int &type) const
std::pair< int, int > depthMaxSp_
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
std::vector< HcalCellType > HcalCellTypes() const
std::vector< int > modHE
std::vector< std::pair< int, double > > getPhis(const int &subdet, const int &ieta) const
std::vector< HcalDetId > idHF2QIE
std::vector< int > HFShift
int findDepth(const int &det, const int &eta, const int &phi, const int &zside, const int &lay) const
Basic3DVector unit() const
int unitPhi(const int &det, const int &etaR) const
int getLayerBack(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
int getLayerBack(const int &det, const int &eta, const int &phi, const int &zside, const int &depth) const
#define M_PI
std::vector< double > HEGains
int getLayerFront(const int &det, const int &eta, const int &phi, const int &zside, const int &depth) const
Log< level::Info, false > LogInfo
std::vector< double > dyHB
std::vector< double > phioff
std::vector< double > gparHF
void printTileHE(const int &eta, const int &phi, const int &zside, const int &depth) const
int getMinDepth(const int &det, const int &eta, const int &phi, const int &zside, const bool &partialOnly) const
std::vector< double > Layer0Wt
std::vector< double > dxHB
void printTileHB(const int &eta, const int &phi, const int &zside, const int &depth) const
std::vector< double > rTable
std::vector< double > phitable
std::pair< int, int > getModHalfHBHE(const int &type) const
TString units(TString variable, Char_t axis)
int getDepthMax(const int subdet, const int iphi, const int zside) const
std::vector< double > phibin
std::vector< double > drHB
std::vector< double > HFGains
static unsigned int const shift
float x
std::vector< int > noff
unsigned int layerGroup(int eta, int i) const
std::vector< int > HBShift
int getDepth16(const int subdet, const int iphi, const int zside) const
Log< level::Warning, false > LogWarning
const HcalParameters * hpar
std::vector< int > maxDepth
static constexpr float d1
tmp
align.sh
Definition: createJobs.py:716
std::vector< int > layHB
int getMaxDepth(const int &type) const
int getLastLayer(const int &det, const int &eta) const
int getLayerMax(const int &eta, const int &depth) const
Geom::Theta< T > theta() const
static const int maxLayerHB_
int validDet(std::vector< int > &phis) const
int getDepthEta16(const int &det, const int &phi, const int &zside) const
std::vector< int > etaMin
int getShift(const HcalSubdetector &subdet, const int &depth) const
HcalLayerDepthMap ldmap_