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.push_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.push_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  int phi, int zside,
258  int depth, 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(double& etaR, double& x, double& y,
303  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 double HcalDDDSimConstants::getLayer0Wt(const int det, const int phi,
329  const int zside) const {
330 
331  double wt = ldmap_.getLayer0Wt(det, phi, zside);
332  if (wt < 0) wt = (det == 2) ? hpar->Layer0Wt[1] : hpar->Layer0Wt[0];
333  return wt;
334 }
335 
336 int HcalDDDSimConstants::getLayerFront(const int det, const int eta,
337  const int phi, const int zside,
338  const int depth) const {
339 
340  int layer = ldmap_.getLayerFront(det, eta, phi, zside, depth);
341  if (layer < 0) {
342  if (det == 1 || det == 2) {
343  layer = 1;
344  for (int l=0; l<getLayerMax(eta,depth); ++l) {
345  if ((int)(layerGroup(eta-1,l)) == depth+1) {
346  layer = l+1; break;
347  }
348  }
349  } else {
350  layer = (eta > hpar->noff[2]) ? maxLayerHB_+1 : maxLayer_;
351  }
352  }
353  return layer;
354 }
355 
356 int HcalDDDSimConstants::getLayerBack(const int det, const int eta,
357  const int phi, const int zside,
358  const int depth) const {
359 
360  int layer = ldmap_.getLayerBack(det, eta, phi, zside, depth);
361  if (layer < 0) {
362  if (det == 1 || det ==2) {
363  layer = depths[depth-1][eta-1];
364  } else {
365  layer = maxLayer_;
366  }
367  }
368  return layer;
369 }
370 
371 int HcalDDDSimConstants::getLayerMax(const int eta, const int depth) const {
372 
373  int layermx = ((eta < hpar->etaMin[1]) && depth-1 < maxDepth[0]) ? maxLayerHB_+1 : (int)layerGroupSize(eta-1);
374  return layermx;
375 }
376 
377 int HcalDDDSimConstants::getMaxDepth(const int det, const int eta,
378  const int phi, const int zside,
379  const bool partialDetOnly) const {
380 
381  int dmax(-1);
382  if (partialDetOnly) {
383  if (ldmap_.isValid(det,phi,zside)) {
384  dmax = ldmap_.getDepths(eta).second;
385  }
386  } else if (det == 1 || det == 2) {
387  if (ldmap_.isValid(det,phi,zside))
388  dmax = ldmap_.getDepths(eta).second;
389  else if (det == 2)
390  dmax = layerGroup(eta-1,maxLayer_);
391  else if (eta == hpar->etaMax[0])
392  dmax = getDepthEta16(det,phi,zside);
393  else
394  dmax = layerGroup(eta-1,maxLayerHB_);
395  } else if (det == 3) { // HF
396  dmax = maxHFDepth(zside*eta,phi);
397  } else if (det == 4) { // HO
398  dmax = maxDepth[3];
399  } else {
400  dmax = -1;
401  }
402  return dmax;
403 }
404 
405 int HcalDDDSimConstants::getMinDepth(const int det, const int eta,
406  const int phi, const int zside,
407  const bool partialDetOnly) const {
408 
409  int lmin(-1);
410  if (partialDetOnly) {
411  if (ldmap_.isValid(det,phi,zside)) {
412  lmin = ldmap_.getDepths(eta).first;
413  }
414  } else if (det == 3) { // HF
415  lmin = 1;
416  } else if (det == 4) { // HO
417  lmin = maxDepth[3];
418  } else {
419  if (ldmap_.isValid(det,phi,zside)) {
420  lmin = ldmap_.getDepths(eta).first;
421  } else if (layerGroupSize(eta-1) > 0) {
422  lmin = (int)(layerGroup(eta-1, 0));
423  unsigned int type = (det == 1) ? 0 : 1;
424  if (type == 1 && eta == hpar->etaMin[1])
425  lmin = getDepthEta16(det, phi, zside);
426  } else {
427  lmin = 1;
428  }
429  }
430  return lmin;
431 }
432 
433 std::pair<int,int> HcalDDDSimConstants::getModHalfHBHE(const int type) const {
434 
435  if (type == 0) {
436  return std::pair<int,int>(nmodHB,nzHB);
437  } else {
438  return std::pair<int,int>(nmodHE,nzHE);
439  }
440 }
441 
442 std::pair<double,double> HcalDDDSimConstants::getPhiCons(const int det,
443  const int ieta) const {
444 
445  double fioff(0), fibin(0);
446  if (det == static_cast<int>(HcalForward)) { // Forward HCal
447  fioff = hpar->phioff[2];
448  fibin = hpar->phitable[ieta-hpar->etaMin[2]];
449  if (unitPhi(fibin) > 2) { // HF double-phi
450  fioff = hpar->phioff[4];
451  }
452  } else { // Barrel or Endcap
453  if (det == static_cast<int>(HcalEndcap)) {
454  fioff = hpar->phioff[1];
455  } else {
456  fioff = hpar->phioff[0];
457  }
458  fibin = hpar->phibin[ieta-1];
459  }
460  return std::pair<double,double>(fioff,fibin);
461 }
462 
463 std::vector<std::pair<int,double> >
464 HcalDDDSimConstants::getPhis(const int subdet, const int ieta) const {
465 
466  std::vector<std::pair<int,double> > phis;
467  int ietaAbs = (ieta > 0) ? ieta : -ieta;
468  std::pair<double,double> ficons = getPhiCons(subdet, ietaAbs);
469  int nphi = int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
470  int units = unitPhi(subdet, ietaAbs);
471  for (int ifi = 0; ifi < nphi; ++ifi) {
472  double phi =-ficons.first + (ifi+0.5)*ficons.second;
473  int iphi = phiNumber(ifi+1,units);
474  phis.push_back(std::pair<int,double>(iphi,phi));
475  }
476 #ifdef EDM_ML_DEBUG
477  std::cout << "getPhis: subdet|ieta|iphi " << subdet << "|" << ieta
478  << " with " << phis.size() << " phi bins" << std::endl;
479  for (unsigned int k=0; k<phis.size(); ++k)
480  std::cout << "[" << k << "] iphi " << phis[k].first << " phi "
481  << phis[k].second/CLHEP::deg << std::endl;
482 #endif
483  return phis;
484 }
485 
486 std::vector<HcalCellType> HcalDDDSimConstants::HcalCellTypes() const{
487 
488  std::vector<HcalCellType> cellTypes = HcalCellTypes(HcalBarrel);
489 #ifdef EDM_ML_DEBUG
490  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << cellTypes.size()
491  << " cells of type HCal Barrel\n";
492  for (unsigned int i=0; i<cellTypes.size(); i++)
493  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << cellTypes[i] << "\n";
494 #endif
495 
496  std::vector<HcalCellType> hoCells = HcalCellTypes(HcalOuter);
497 #ifdef EDM_ML_DEBUG
498  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << hoCells.size()
499  << " cells of type HCal Outer\n";
500  for (unsigned int i=0; i<hoCells.size(); i++)
501  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << hoCells[i] << "\n";
502 #endif
503  cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
504 
505  std::vector<HcalCellType> heCells = HcalCellTypes(HcalEndcap);
506 #ifdef EDM_ML_DEBUG
507  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << heCells.size()
508  << " cells of type HCal Endcap\n";
509  for (unsigned int i=0; i<heCells.size(); i++)
510  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << heCells[i] << "\n";
511 #endif
512  cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
513 
514  std::vector<HcalCellType> hfCells = HcalCellTypes(HcalForward);
515 #ifdef EDM_ML_DEBUG
516  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << hfCells.size()
517  << " cells of type HCal Forward\n";
518  for (unsigned int i=0; i<hfCells.size(); i++)
519  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << hfCells[i] << "\n";
520 #endif
521  cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
522 
523  return cellTypes;
524 }
525 
526 std::vector<HcalCellType> HcalDDDSimConstants::HcalCellTypes(const HcalSubdetector subdet, const int ieta, const int depthl) const {
527 
528  std::vector<HcalCellType> cellTypes;
529  if (subdet == HcalForward) {
530  if (dzVcal < 0) return cellTypes;
531  }
532 
533  int dmin, dmax, indx, nz;
534  double hsize = 0;
535  switch(subdet) {
536  case HcalEndcap:
537  dmin = 1; dmax = maxLayer_+1; indx = 1; nz = nzHE;
538  break;
539  case HcalForward:
540  dmin = 1; dmax = (idHF2QIE.size() > 0) ? 2 : maxDepth[2]; indx = 2; nz = 2;
541  break;
542  case HcalOuter:
543  dmin = 4; dmax = 4; indx = 0; nz = nzHB;
544  break;
545  default:
546  dmin = 1; dmax = maxLayerHB_+1; indx = 0; nz = nzHB;
547  break;
548  }
549  if (depthl > 0) dmin = dmax = depthl;
550  int ietamin = (ieta>0) ? ieta : hpar->etaMin[indx];
551  int ietamax = (ieta>0) ? ieta : hpar->etaMax[indx];
552  int phi = (indx == 2) ? 3 : 1;
553 
554  // Get the Cells
555  int subdet0 = static_cast<int>(subdet);
556  for (int depth=dmin; depth<=dmax; depth++) {
557  int shift = getShift(subdet, depth);
558  double gain = getGain (subdet, depth);
559  if (subdet == HcalForward) {
560  if (depth%2 == 1) hsize = dzVcal;
561  else hsize = dzVcal-0.5*dlShort;
562  }
563  for (int eta=ietamin; eta<=ietamax; eta++) {
564  for (int iz=0; iz<nz; ++iz) {
565  int zside = -2*iz + 1;
566  HcalCellType::HcalCell temp1 = cell(subdet0,zside,depth,eta,phi);
567  if (temp1.ok) {
568  std::vector<std::pair<int,double> > phis = getPhis(subdet0,eta);
569  HcalCellType temp2(subdet, eta, zside, depth, temp1,
570  shift, gain, hsize);
571  double dphi, fioff;
572  std::vector<int> phiMiss2;
573  if ((subdet == HcalBarrel) || (subdet == HcalOuter)) {
574  fioff = hpar->phioff[0];
575  dphi = hpar->phibin[eta-1];
576  if (subdet == HcalOuter) {
577  if (eta == hpar->noff[4]) {
578  int kk = (iz == 0) ? 7 : (7+hpar->noff[5]);
579  for (int miss=0; miss<hpar->noff[5+iz]; miss++) {
580  phiMiss2.push_back(hpar->noff[kk]);
581  kk++;
582  }
583  }
584  }
585  } else if (subdet == HcalEndcap) {
586  fioff = hpar->phioff[1];
587  dphi = hpar->phibin[eta-1];
588  } else {
589  fioff = hpar->phioff[2];
590  dphi = hpar->phitable[eta-hpar->etaMin[2]];
591  if (unitPhi(dphi) > 2) fioff = hpar->phioff[4];
592  }
593  int unit = unitPhi(dphi);
594  temp2.setPhi(phis,phiMiss2,fioff,dphi,unit);
595  cellTypes.push_back(temp2);
596  // For HF look at extra cells
597  if ((subdet == HcalForward) && (idHF2QIE.size() > 0)) {
598  HcalCellType temp3(subdet, eta, zside+2, depth, temp1,
599  shift, gain, hsize);
600  std::vector<int> phiMiss3;
601  for (unsigned int k=0; k<phis.size(); ++k) {
602  bool ok(false);
603  for (unsigned int l=0; l<idHF2QIE.size(); ++l) {
604  if ((eta*zside == idHF2QIE[l].ieta()) &&
605  (phis[k].first == idHF2QIE[l].iphi())) {
606  ok = true;
607  break;
608  }
609  }
610  if (!ok) phiMiss3.push_back(phis[k].first);
611  }
612  dphi = hpar->phitable[eta-hpar->etaMin[2]];
613  unit = unitPhi(dphi);
614  fioff = (unit > 2) ? hpar->phioff[4] : hpar->phioff[2];
615  temp3.setPhi(phis,phiMiss2,fioff,dphi,unit);
616  cellTypes.push_back(temp3);
617  }
618  }
619  }
620  }
621  }
622  return cellTypes;
623 }
624 
625 int HcalDDDSimConstants::maxHFDepth(const int eta, const int iphi) const {
626  int mxdepth = maxDepth[2];
627  if (idHF2QIE.size() > 0) {
628  bool ok(false);
629  for (unsigned int k=0; k<idHF2QIE.size(); ++k) {
630  if ((eta == idHF2QIE[k].ieta()) && (iphi == idHF2QIE[k].iphi())) {
631  ok = true; break;
632  }
633  }
634  if (!ok) mxdepth = 2;
635  }
636  return mxdepth;
637 }
638 
639 unsigned int HcalDDDSimConstants::numberOfCells(const HcalSubdetector subdet) const{
640 
641  unsigned int num = 0;
642  std::vector<HcalCellType> cellTypes = HcalCellTypes(subdet);
643  for (unsigned int i=0; i<cellTypes.size(); i++) {
644  num += (unsigned int)(cellTypes[i].nPhiBins());
645  }
646 #ifdef EDM_ML_DEBUG
647  std::cout << "HcalDDDSimConstants:numberOfCells "
648  << cellTypes.size() << " " << num
649  << " for subdetector " << subdet << std::endl;
650 #endif
651  return num;
652 }
653 
654 int HcalDDDSimConstants::phiNumber(const int phi, const int units) const {
655 
656  int iphi_skip = phi;
657  if (units==2) iphi_skip = (phi-1)*2+1;
658  else if (units==4) iphi_skip = (phi-1)*4-1;
659  if (iphi_skip < 0) iphi_skip += 72;
660  return iphi_skip;
661 }
662 
664 
665  std::vector<int> phis;
666  int detsp = ldmap_.validDet(phis);
667  int kphi = (detsp > 0) ? phis[0] : 1;
668  int zside = (kphi > 0) ? 1 : -1;
669  int iphi = (kphi > 0) ? kphi : -kphi;
670  std::cout << "Tile Information for HB from " << hpar->etaMin[0] << " to " << hpar->etaMax[0] << "\n\n";
671  for (int eta=hpar->etaMin[0]; eta<= hpar->etaMax[0]; eta++) {
672  int dmax = getMaxDepth(1,eta,iphi,-zside,false);
673  for (int depth=1; depth<=dmax; depth++)
674  printTileHB(eta, iphi, -zside, depth);
675  if (detsp == 1) {
676  int dmax = getMaxDepth(1,eta,iphi,zside,false);
677  for (int depth=1; depth<=dmax; depth++)
678  printTileHB(eta, iphi, zside, depth);
679  }
680  }
681 
682  std::cout << "\nTile Information for HE from " << hpar->etaMin[1] << " to " << hpar->etaMax[1] << "\n\n";
683  for (int eta=hpar->etaMin[1]; eta<= hpar->etaMax[1]; eta++) {
684  int dmin = (eta == hpar->etaMin[1]) ? getDepthEta16(2,iphi,-zside) : 1;
685  int dmax = getMaxDepth(2,eta,iphi,-zside,false);
686  for (int depth=dmin; depth<=dmax; depth++)
687  printTileHE(eta, iphi, -zside, depth);
688  if (detsp == 2) {
689  int dmax = getMaxDepth(2,eta,iphi,zside,false);
690  for (int depth=1; depth<=dmax; depth++)
691  printTileHE(eta, iphi, zside, depth);
692  }
693  }
694 }
695 
696 int HcalDDDSimConstants::unitPhi(const int det, const int etaR) const {
697 
698  double dphi = (det == static_cast<int>(HcalForward)) ? hpar->phitable[etaR-hpar->etaMin[2]] : hpar->phibin[etaR-1];
699  return unitPhi(dphi);
700 }
701 
702 int HcalDDDSimConstants::unitPhi(const double dphi) const {
703 
704  const double fiveDegInRad = 2*M_PI/72;
705  int units = int(dphi/fiveDegInRad+0.5);
706  if (units < 1) units = 1;
707  return units;
708 }
709 
711 
712  nEta = hpar->etaTable.size();
713  nR = hpar->rTable.size();
714  nPhiF = nR - 1;
715  isBH_ = false;
716 
717 #ifdef EDM_ML_DEBUG
718  for (int i=0; i<nEta-1; ++i) {
719  std::cout << "HcalDDDSimConstants:Read LayerGroup" << i << ":";
720  for (unsigned int k=0; k<layerGroupSize( i ); k++)
721  std::cout << " [" << k << "] = " << layerGroup( i, k );
722  std::cout << std::endl;
723  }
724 #endif
725 
726  // Geometry parameters for HF
727  dlShort = hpar->gparHF[0];
728  zVcal = hpar->gparHF[4];
729  dzVcal = hpar->dzVcal;
730 #ifdef EDM_ML_DEBUG
731  std::cout << "HcalDDDSimConstants: dlShort " << dlShort << " zVcal " << zVcal
732  << " and dzVcal " << dzVcal << std::endl;
733 #endif
734 
735  //Transform some of the parameters
737  maxDepth[0] = maxDepth[1] = 0;
738  for (int i=0; i<nEta-1; ++i) {
739  unsigned int imx = layerGroupSize( i );
740  int laymax = (imx > 0) ? layerGroup( i, imx-1 ) : 0;
741  if (i < hpar->etaMax[0]) {
742  int laymax0 = (imx > 16) ? layerGroup(i, 16) : laymax;
743  if (i+1 == hpar->etaMax[0] && laymax0 > 2) laymax0 = 2;
744  if (maxDepth[0] < laymax0) maxDepth[0] = laymax0;
745  }
746  if (i >= hpar->etaMin[1]-1 && i < hpar->etaMax[1]) {
747  if (maxDepth[1] < laymax) maxDepth[1] = laymax;
748  }
749  }
750 #ifdef EDM_ML_DEBUG
751  for (int i=0; i<4; ++i)
752  std::cout << "Detector Type [" << i << "] iEta " << hpar->etaMin[i] << ":"
753  << hpar->etaMax[i] << " MaxDepth " << maxDepth[i] << std::endl;
754 #endif
755 
756  int maxdepth = (maxDepth[1]>maxDepth[0]) ? maxDepth[1] : maxDepth[0];
757  for (int i=0; i<maxdepth; ++i) {
758  for (int k=0; k<nEta-1; ++k) {
759  int layermx = getLayerMax(k+1,i+1);
760  int ll = layermx;
761  for (int l=layermx-1; l >= 0; --l) {
762  if ((int)layerGroup( k, l ) == i+1) {
763  ll = l+1; break;
764  }
765  }
766  depths[i].push_back(ll);
767  }
768 
769 #ifdef EDM_ML_DEBUG
770  std::cout << "Depth " << i << " with " << depths[i].size() << " etas:";
771  for (int k=0; k<nEta-1; ++k) std::cout << " " << depths[i][k];
772  std::cout << std::endl;
773 #endif
774  }
775 
776  nzHB = hpar->modHB[1];
777  nmodHB = hpar->modHB[0];
778  nzHE = hpar->modHE[1];
779  nmodHE = hpar->modHE[0];
780 #ifdef EDM_ML_DEBUG
781  std::cout << "HcalDDDSimConstants:: " << nzHB << ":" << nmodHB
782  << " barrel and " << nzHE << ":" << nmodHE
783  << " endcap half-sectors" << std::endl;
784 #endif
785 
786  if (hpar->rHB.size() > maxLayerHB_+1 && hpar->zHO.size() > 4) {
787  rminHO = hpar->rHO[0];
788  for (int k=0; k<4; ++k) etaHO[k] = hpar->rHO[k+1];
789  } else {
790  rminHO =-1.0;
791  etaHO[0] = hpar->etaTable[4];
792  etaHO[1] = hpar->etaTable[4];
793  etaHO[2] = hpar->etaTable[10];
794  etaHO[3] = hpar->etaTable[10];
795  }
796 #ifdef EDM_ML_DEBUG
797  std::cout << "HO Eta boundaries " << etaHO[0] << " " << etaHO[1]
798  << " " << etaHO[2] << " " << etaHO[3] << std::endl;
799  std::cout << "HO Parameters " << rminHO << " " << hpar->zHO.size();
800  for (int i=0; i<4; ++i) std::cout << " eta[" << i << "] = " << etaHO[i];
801  for (unsigned int i=0; i<hpar->zHO.size(); ++i)
802  std::cout << " zHO[" << i << "] = " << hpar->zHO[i];
803  std::cout << std::endl;
804 #endif
805 
806  int noffsize = 7 + hpar->noff[5] + hpar->noff[6];
807  int noffl(noffsize+5);
808  if ((int)(hpar->noff.size()) > (noffsize+3)) {
809  depthEta16[0] = hpar->noff[noffsize];
810  depthEta16[1] = hpar->noff[noffsize+1];
811  depthEta29[0] = hpar->noff[noffsize+2];
812  depthEta29[1] = hpar->noff[noffsize+3];
813  if ((int)(hpar->noff.size()) > (noffsize+4)) {
814  noffl += (2*hpar->noff[noffsize+4]);
815  if ((int)(hpar->noff.size()) > noffl) isBH_ = (hpar->noff[noffl] > 0);
816  }
817  } else {
818  depthEta16[0] = 2;
819  depthEta16[1] = 3;
820  depthEta29[0] = 2;
821  depthEta29[1] = 1;
822  }
823 #ifdef EDM_ML_DEBUG
824  std::cout << "isBH_ " << hpar->noff.size() << ":" << noffsize << ":"
825  << noffl << ":" << isBH_ << std::endl;
826  std::cout << "Depth index at ieta = 16 for HB (max) " << depthEta16[0]
827  << " HE (min) " << depthEta16[1] << "; max depth for itea = 29 : ("
828  << depthEta29[0] << ":" << depthEta29[1] << ")" << std::endl;
829 #endif
830 
831  if ((int)(hpar->noff.size()) > (noffsize+4)) {
832  int npair = hpar->noff[noffsize+4];
833  int kk = noffsize+4;
834  for (int k=0; k<npair; ++k) {
835  idHF2QIE.push_back(HcalDetId(HcalForward,hpar->noff[kk+1],hpar->noff[kk+2],1));
836  kk += 2;
837  }
838  }
839 #ifdef EDM_ML_DEBUG
840  std::cout << idHF2QIE.size() << " detector channels having 2 QIE cards:"
841  << std::endl;
842  for (unsigned int k=0; k<idHF2QIE.size(); ++k)
843  std::cout << " [" << k << "] " << idHF2QIE[k] << std::endl;
844 #endif
845 
846  depthMaxSp_ = std::pair<int,int>(0,0);
847  int noffk(noffsize+5);
848  if ((int)(hpar->noff.size()) > (noffsize+5)) {
849  noffk += (2*hpar->noff[noffsize+4]);
850  if ((int)(hpar->noff.size()) > noffk+5) {
851  int dtype = hpar->noff[noffk+1];
852  int nphi = hpar->noff[noffk+2];
853  int ndeps = hpar->noff[noffk+3];
854  int ndp16 = hpar->noff[noffk+4];
855  int ndp29 = hpar->noff[noffk+5];
856  double wt = 0.1*(hpar->noff[noffk+6]);
857  if (dtype == 1 || dtype == 2) {
858  if ((int)(hpar->noff.size()) >= (noffk+7+nphi+3*ndeps)) {
859  std::vector<int> ifi, iet, ily, idp;
860  for (int i=0; i<nphi; ++i) ifi.push_back(hpar->noff[noffk+7+i]);
861  for (int i=0; i<ndeps;++i) {
862  iet.push_back(hpar->noff[noffk+7+nphi+3*i]);
863  ily.push_back(hpar->noff[noffk+7+nphi+3*i+1]);
864  idp.push_back(hpar->noff[noffk+7+nphi+3*i+2]);
865  }
866 #ifdef EDM_ML_DEBUG
867  std::cout << "Initialize HcalLayerDepthMap for Detector " << dtype
868  << " etaMax " << hpar->etaMax[dtype] << " with " << nphi
869  << " sectors";
870  for (int i=0; i<nphi; ++i) std::cout << ":" << ifi[i];
871  std::cout << " and " << ndeps << " depth sections" << std::endl;
872  for (int i=0; i<ndeps;++i)
873  std::cout << " [" << i << "] " << iet[i] << " " << ily[i] << " "
874  << idp[i] << std::endl;
875  std::cout << "Maximum depth for last HE Eta tower " << depthEta29[0]
876  << ":" << ndp16 << ":" << ndp29 << " L0 Wt "
877  << hpar->Layer0Wt[dtype-1] << ":" << wt << std::endl;
878 #endif
879  ldmap_.initialize(dtype,hpar->etaMax[dtype-1],ndp16,ndp29,wt,ifi,iet,
880  ily,idp);
881  int zside = (ifi[0]>0) ? 1 : -1;
882  int iphi = (ifi[0]>0) ? ifi[0] : -ifi[0];
883  depthMaxSp_ = std::pair<int,int>(dtype,ldmap_.getDepthMax(dtype,iphi,zside));
884  }
885  }
886  }
887  }
888  if (depthMaxSp_.first == 0) {
889  depthMaxSp_ = depthMaxDf_ = std::pair<int,int>(2,maxDepth[1]);
890  } else if (depthMaxSp_.first == 1) {
891  depthMaxDf_ = std::pair<int,int>(1,maxDepth[0]);
892  if (depthMaxSp_.second > maxDepth[0]) maxDepth[0] = depthMaxSp_.second;
893  } else {
894  depthMaxDf_ = std::pair<int,int>(2,maxDepth[1]);
895  if (depthMaxSp_.second > maxDepth[1]) maxDepth[1] = depthMaxSp_.second;
896  }
897 #ifdef EDM_ML_DEBUG
898  std::cout << "Detector type and maximum depth for all RBX "
899  << depthMaxDf_.first << ":" << depthMaxDf_.second
900  << " and for special RBX " << depthMaxSp_.first << ":"
901  << depthMaxSp_.second << std::endl;
902 #endif
903 }
904 
905 double HcalDDDSimConstants::deltaEta(const int det, const int etaR,
906  const int depth) const {
907 
908  double tmp = 0;
909  if (det == static_cast<int>(HcalForward)) {
910  int ir = nR + hpar->etaMin[2] - etaR - 1;
911  if (ir > 0 && ir < nR) {
912  double z = zVcal;
913  if (depth%2 != 1) z += dlShort;
914  tmp = 0.5*(getEta(hpar->rTable[ir-1],z)-getEta(hpar->rTable[ir],z));
915  }
916  } else {
917  if (etaR > 0 && etaR < nEta) {
918  if (etaR == hpar->noff[1]-1 && depth > depthEta29[0]) {
919  tmp = 0.5*(hpar->etaTable[etaR+1]-hpar->etaTable[etaR-1]);
920  } else if (det == static_cast<int>(HcalOuter)) {
921  if (etaR == hpar->noff[2]) {
922  tmp = 0.5*(etaHO[0]-hpar->etaTable[etaR-1]);
923  } else if (etaR == hpar->noff[2]+1) {
924  tmp = 0.5*(hpar->etaTable[etaR]-etaHO[1]);
925  } else if (etaR == hpar->noff[3]) {
926  tmp = 0.5*(etaHO[2]-hpar->etaTable[etaR-1]);
927  } else if (etaR == hpar->noff[3]+1) {
928  tmp = 0.5*(hpar->etaTable[etaR]-etaHO[3]);
929  } else {
930  tmp = 0.5*(hpar->etaTable[etaR]-hpar->etaTable[etaR-1]);
931  }
932  } else {
933  tmp = 0.5*(hpar->etaTable[etaR]-hpar->etaTable[etaR-1]);
934  }
935  }
936  }
937 #ifdef EDM_ML_DEBUG
938  std::cout << "HcalDDDSimConstants::deltaEta " << etaR << " "
939  << depth << " ==> " << tmp << std::endl;
940 #endif
941  return tmp;
942 }
943 
944 double HcalDDDSimConstants::getEta(const int det, const int etaR,
945  const int zside, const int depth) const {
946 
947  double tmp = 0;
948  if (det == static_cast<int>(HcalForward)) {
949  int ir = nR + hpar->etaMin[2] - etaR - 1;
950  if (ir > 0 && ir < nR) {
951  double z = zVcal;
952  if (depth%2 != 1) z += dlShort;
953  tmp = 0.5*(getEta(hpar->rTable[ir-1],z)+getEta(hpar->rTable[ir],z));
954  }
955  } else {
956  if (etaR > 0 && etaR < nEta) {
957  if (etaR == hpar->noff[1]-1 && depth > depthEta29[0]) {
958  tmp = 0.5*(hpar->etaTable[etaR+1]+hpar->etaTable[etaR-1]);
959  } else if (det == static_cast<int>(HcalOuter)) {
960  if (etaR == hpar->noff[2]) {
961  tmp = 0.5*(etaHO[0]+hpar->etaTable[etaR-1]);
962  } else if (etaR == hpar->noff[2]+1) {
963  tmp = 0.5*(hpar->etaTable[etaR]+etaHO[1]);
964  } else if (etaR == hpar->noff[3]) {
965  tmp = 0.5*(etaHO[2]+hpar->etaTable[etaR-1]);
966  } else if (etaR == hpar->noff[3]+1) {
967  tmp = 0.5*(hpar->etaTable[etaR]+etaHO[3]);
968  } else {
969  tmp = 0.5*(hpar->etaTable[etaR]+hpar->etaTable[etaR-1]);
970  }
971  } else {
972  tmp = 0.5*(hpar->etaTable[etaR]+hpar->etaTable[etaR-1]);
973  }
974  }
975  }
976  if (zside == 0) tmp = -tmp;
977 #ifdef EDM_ML_DEBUG
978  std::cout << "HcalDDDSimConstants::getEta " << etaR << " "
979  << zside << " " << depth << " ==> " << tmp << "\n";
980 #endif
981  return tmp;
982 }
983 
984 double HcalDDDSimConstants::getEta(const double r, const double z) const {
985 
986  double tmp = 0;
987  if (z != 0) tmp = -log(tan(0.5*atan(r/z)));
988 #ifdef EDM_ML_DEBUG
989  std::cout << "HcalDDDSimConstants::getEta " << r << " " << z
990  << " ==> " << tmp << std::endl;
991 #endif
992  return tmp;
993 }
994 
996  const int depth) const {
997 
998  int shift;
999  switch(subdet) {
1000  case HcalEndcap:
1001  shift = hpar->HEShift[0];
1002  break;
1003  case HcalForward:
1004  shift = hpar->HFShift[(depth-1)%2];
1005  break;
1006  case HcalOuter:
1007  shift = hpar->HBShift[3];
1008  break;
1009  default:
1010  shift = hpar->HBShift[0];
1011  break;
1012  }
1013  return shift;
1014 }
1015 
1017  const int depth) const {
1018 
1019  double gain;
1020  switch(subdet) {
1021  case HcalEndcap:
1022  gain = hpar->HEGains[0];
1023  break;
1024  case HcalForward:
1025  gain = hpar->HFGains[(depth-1)%2];
1026  break;
1027  case HcalOuter:
1028  gain = hpar->HBGains[3];
1029  break;
1030  default:
1031  gain = hpar->HBGains[0];
1032  break;
1033  }
1034  return gain;
1035 }
1036 
1037 void HcalDDDSimConstants::printTileHB(const int eta, const int phi,
1038  const int zside, const int depth) const {
1039  std::cout << "HcalDDDSimConstants::printTileHB for eta " << eta << " and depth " << depth << "\n";
1040 
1041  double etaL = hpar->etaTable.at(eta-1);
1042  double thetaL = 2.*atan(exp(-etaL));
1043  double etaH = hpar->etaTable.at(eta);
1044  double thetaH = 2.*atan(exp(-etaH));
1045  int layL = getLayerFront(1,eta,phi,zside,depth);
1046  int layH = getLayerBack(1,eta,phi,zside,depth);
1047  std::cout << "\ntileHB:: eta|depth " << zside*eta << "|" << depth << " theta " << thetaH/CLHEP::deg << ":" << thetaL/CLHEP::deg << " Layer " << layL << ":" << layH-1 << "\n";
1048  for (int lay=layL; lay<layH; ++lay) {
1049  std::vector<double> area(2,0);
1050  int kk=0;
1051  for (unsigned int k=0; k<hpar->layHB.size(); ++k) {
1052  if (lay == hpar->layHB[k]) {
1053  double zmin = hpar->rhoxHB[k]*std::cos(thetaL)/std::sin(thetaL);
1054  double zmax = hpar->rhoxHB[k]*std::cos(thetaH)/std::sin(thetaH);
1055  double dz = (std::min(zmax,hpar->dxHB[k]) - zmin);
1056  if (dz > 0) {
1057  area[kk] = dz*hpar->dyHB[k];
1058  kk++;
1059  }
1060  }
1061  }
1062  if (area[0] > 0) std::cout << std::setw(2) << lay << " Area " << std::setw(8) << area[0] << " " << std::setw(8) << area[1] << "\n";
1063  }
1064 }
1065 
1066 void HcalDDDSimConstants::printTileHE(const int eta, const int phi,
1067  const int zside, const int depth) const {
1068 
1069  double etaL = hpar->etaTable[eta-1];
1070  double thetaL = 2.*atan(exp(-etaL));
1071  double etaH = hpar->etaTable[eta];
1072  double thetaH = 2.*atan(exp(-etaH));
1073  int layL = getLayerFront(2,eta,phi,zside,depth);
1074  int layH = getLayerBack(2,eta,phi,zside,depth);
1075  double phib = hpar->phibin[eta-1];
1076  int nphi = 2;
1077  if (phib > 6*CLHEP::deg) nphi = 1;
1078  std::cout << "\ntileHE:: Eta/depth " << zside*eta << "|" << depth << " theta " << thetaH/CLHEP::deg << ":" << thetaL/CLHEP::deg << " Layer " << layL << ":" << layH-1 << " phi " << nphi << "\n";
1079  for (int lay=layL; lay<layH; ++lay) {
1080  std::vector<double> area(4,0);
1081  int kk=0;
1082  for (unsigned int k=0; k<hpar->layHE.size(); ++k) {
1083  if (lay == hpar->layHE[k]) {
1084  double rmin = hpar->zxHE[k]*std::tan(thetaH);
1085  double rmax = hpar->zxHE[k]*std::tan(thetaL);
1086  if ((lay != 0 || eta == 18) &&
1087  (lay != 1 || (eta == 18 && hpar->rhoxHE[k]-hpar->dyHE[k] > 1000) ||
1088  (eta != 18 && hpar->rhoxHE[k]-hpar->dyHE[k] < 1000)) &&
1089  rmin+30 < hpar->rhoxHE[k]+hpar->dyHE[k] &&
1090  rmax > hpar->rhoxHE[k]-hpar->dyHE[k]) {
1091  rmin = std::max(rmin,hpar->rhoxHE[k]-hpar->dyHE[k]);
1092  rmax = std::min(rmax,hpar->rhoxHE[k]+hpar->dyHE[k]);
1093  double dx1 = rmin*std::tan(phib);
1094  double dx2 = rmax*std::tan(phib);
1095  double ar1=0, ar2=0;
1096  if (nphi == 1) {
1097  ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*hpar->dx1HE[k]);
1098  } else {
1099  ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*hpar->dx1HE[k]);
1100  ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*tan(10.*CLHEP::deg)-4*hpar->dx1HE[k])-ar1;
1101  }
1102  area[kk] = ar1;
1103  area[kk+2] = ar2;
1104  kk++;
1105  }
1106  }
1107  }
1108  if (area[0] > 0 && area[1] > 0) {
1109  int lay0 = lay-1;
1110  if (eta == 18) lay0++;
1111  if (nphi == 1) {
1112  std::cout << std::setw(2) << lay0 << " Area " << std::setw(8) << area[0] << " " << std::setw(8) << area[1] << "\n";
1113  } else {
1114  std::cout << std::setw(2) << lay0 << " Area " << std::setw(8) << area[0] << " " << std::setw(8) << area[1] << ":" << std::setw(8) << area[2] << " " << std::setw(8) << area[3] << "\n";
1115  }
1116  }
1117  }
1118 }
1119 
1120 unsigned int HcalDDDSimConstants::layerGroupSize(const int eta) const {
1121  unsigned int k = 0;
1122  for (auto const & it : hpar->layerGroupEtaSim) {
1123  if (it.layer == (unsigned int)(eta + 1)) {
1124  return it.layerGroup.size();
1125  }
1126  if (it.layer > (unsigned int)(eta + 1)) break;
1127  k = it.layerGroup.size();
1128  }
1129  return k;
1130 }
1131 
1132 unsigned int HcalDDDSimConstants::layerGroup(const int eta,
1133  const int i) const {
1134  unsigned int k = 0;
1135  for (auto const & it : hpar->layerGroupEtaSim) {
1136  if (it.layer == (unsigned int)(eta + 1)) {
1137  return it.layerGroup.at(i);
1138  }
1139  if (it.layer > (unsigned int)(eta + 1)) break;
1140  k = it.layerGroup.at(i);
1141  }
1142  return k;
1143 }
1144 
1145 unsigned int HcalDDDSimConstants::layerGroup(const int det, const int eta,
1146  const int phi, const int zside,
1147  const int lay) const {
1148 
1149  int depth0 = findDepth(det,eta,phi,zside,lay);
1150  unsigned int depth = (depth0 > 0) ? (unsigned int)(depth0) : layerGroup(eta-1,lay);
1151  return depth;
1152 }
type
Definition: HCALResponse.h:21
std::vector< double > zHO
void setPhi(std::vector< std::pair< int, double >> &phis, std::vector< int > &iphiMiss, double foff, double dphi, int unit)
Definition: HcalCellType.cc:87
int findDepth(const int det, const int eta, const int phi, const int zside, const int lay) const
std::vector< double > etaTable
int maxHFDepth(const int ieta, const int iphi) const
std::vector< int > layHE
std::pair< int, int > getEtaDepth(const int det, int etaR, int phi, int zside, int depth, int lay)
int getLayerBack(const int det, const int eta, const int phi, const int zside, const int depth) 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
std::pair< double, double > getPhiCons(const int det, const int ieta) const
double getGain(const HcalSubdetector subdet, const int depth) const
std::vector< double > rhoxHB
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int maxLayer_
std::vector< double > HBGains
bool isValid(const int det, const int phi, const int zside) const
Geom::Theta< T > theta() const
std::vector< int > HEShift
int getMaxDepth(const int type) const
std::vector< std::pair< double, double > > getConstHBHE(const int type) const
HcalDDDSimConstants(const HcalParameters *hp)
int getShift(const HcalSubdetector subdet, const int depth) const
void printTileHE(const int eta, const int phi, const int zside, const int depth) const
unsigned int numberOfCells(HcalSubdetector) 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 getDepthEta29M(const int i, const bool planOne) const
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
double deltaEta(const int det, const int eta, const int depth) const
std::vector< double > zxHE
std::vector< std::pair< int, double > > getPhis(const int subdet, const int ieta) const
int validDet(std::vector< int > &phis) const
std::vector< double > zHE
double getEtaHO(double &etaR, double &x, double &y, double &z) const
std::vector< LayerItem > layerGroupEtaSim
std::pair< int, double > getDetEta(const double eta, const int depth)
std::vector< double > dyHE
std::vector< double > dx1HE
std::vector< double > rHO
int getDepthEta29(const int phi, int zside, int i) const
void printTileHB(const int eta, const int phi, const int zside, const int depth) const
std::pair< int, int > depthMaxDf_
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
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
std::vector< HcalCellType > HcalCellTypes() const
std::vector< int > modHE
std::vector< HcalDetId > idHF2QIE
T min(T a, T b)
Definition: MathUtil.h:58
std::pair< int, int > getModHalfHBHE(const int type) const
std::vector< int > HFShift
int getMinDepth(const int det, const int eta, const int phi, const int zside, bool partialOnly) const
int getDepthEta16(const int det, const int phi, const int zside) const
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 findLayer(int layer, const std::vector< HcalParameters::LayerItem > &layerGroup) const
unsigned int layerGroup(const int eta, const int i) const
#define M_PI
int k[5][pyjets_maxn]
double getLayer0Wt(const int det, const int phi, const int zside) const
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::vector< double > gparHF
unsigned int layerGroupSize(const int eta) const
int getEta(const int det, const int lay, const double hetaR)
std::vector< double > Layer0Wt
std::vector< double > dxHB
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int getLayerFront(const int det, const int eta, const int phi, const int zside, const int depth) const
std::vector< double > rTable
std::vector< double > phitable
int phiNumber(const int phi, const int unit) const
int getDepthEta16M(const int det) const
TString units(TString variable, Char_t axis)
std::vector< double > phibin
int unitPhi(const int det, const int etaR) const
std::vector< double > drHB
HcalCellType::HcalCell cell(const int det, const int zside, const int depth, const int etaR, const int iphi) const
std::vector< double > HFGains
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
std::vector< int > layHB
static const int maxLayerHB_
int getDepthMax(const int subdet, const int iphi, const int zside) const
int getLayerMax(const int eta, const int depth) const
std::vector< int > etaMin
HcalLayerDepthMap ldmap_