CMS 3D CMS Logo

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