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