test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
25 
27 #ifdef EDM_ML_DEBUG
28  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants::destructed!!!\n";
29 #endif
30 }
31 
33  int depth, int etaR,
34  int iphi) const {
35 
36  double etaMn = hpar->etaMin[0];
37  double etaMx = hpar->etaMax[0];
38  if (idet==static_cast<int>(HcalEndcap)) {
39  etaMn = hpar->etaMin[1]; etaMx = hpar->etaMax[1];
40  } else if (idet==static_cast<int>(HcalForward)) {
41  etaMn = hpar->etaMin[2]; etaMx = hpar->etaMax[2];
42  }
43  double eta = 0, deta = 0, phi = 0, dphi = 0, rz = 0, drz = 0;
44  bool ok = false, flagrz = true;
45  if ((idet==static_cast<int>(HcalBarrel)||idet==static_cast<int>(HcalEndcap)||
46  idet==static_cast<int>(HcalOuter)||idet==static_cast<int>(HcalForward))
47  && etaR >=etaMn && etaR <= etaMx && depth > 0) ok = true;
48  if (idet == static_cast<int>(HcalEndcap) && depth>(int)(hpar->zHE.size()))ok=false;
49  else if (idet == static_cast<int>(HcalBarrel) && depth > 17) ok=false;
50  else if (idet == static_cast<int>(HcalOuter) && depth != 4) ok=false;
51  else if (idet == static_cast<int>(HcalForward) && depth > maxDepth[2]) ok=false;
52  if (ok) {
53  eta = getEta(idet, etaR, zside, depth);
54  deta = deltaEta(idet, etaR, depth);
55  double fibin, fioff;
56  if (idet == static_cast<int>(HcalBarrel)||
57  idet == static_cast<int>(HcalOuter)) {
58  fioff = hpar->phioff[0];
59  fibin = hpar->phibin[etaR-1];
60  } else if (idet == static_cast<int>(HcalEndcap)) {
61  fioff = hpar->phioff[1];
62  fibin = hpar->phibin[etaR-1];
63  } else {
64  fioff = hpar->phioff[2];
65  fibin = hpar->phitable[etaR-hpar->etaMin[2]];
66  if (unitPhi(fibin) > 2) fioff = hpar->phioff[4];
67  }
68  phi = fioff + (iphi - 0.5)*fibin;
69  dphi = 0.5*fibin;
70  if (idet == static_cast<int>(HcalForward)) {
71  int ir = nR + hpar->etaMin[2] - etaR - 1;
72  if (ir > 0 && ir < nR) {
73  rz = 0.5*(hpar->rTable[ir]+hpar->rTable[ir-1]);
74  drz = 0.5*(hpar->rTable[ir]-hpar->rTable[ir-1]);
75  } else {
76  ok = false;
77 #ifdef EDM_ML_DEBUG
78  edm::LogInfo("HCalGeom") << "HcalDDDSimConstants: wrong eta " << etaR
79  << " (" << ir << "/" << nR << ") Detector "
80  << idet << std::endl;
81 #endif
82  }
83  } else if (etaR <= nEta) {
84  int laymin(depth), laymax(depth);
85  if (idet == static_cast<int>(HcalOuter)) {
86  laymin = (etaR > hpar->noff[2]) ? ((int)(hpar->zHE.size())) : ((int)(hpar->zHE.size()))-1;
87  laymax = ((int)(hpar->zHE.size()));
88  }
89  double d1=0, d2=0;
90  if (idet == static_cast<int>(HcalEndcap)) {
91  flagrz = false;
92  d1 = hpar->zHE[laymin-1] - hpar->dzHE[laymin-1];
93  d2 = hpar->zHE[laymax-1] + hpar->dzHE[laymax-1];
94  } else {
95  d1 = hpar->rHB[laymin-1] - hpar->drHB[laymin-1];
96  d2 = hpar->rHB[laymax-1] + hpar->drHB[laymax-1];
97  }
98  rz = 0.5*(d2+d1);
99  drz = 0.5*(d2-d1);
100  } else {
101  ok = false;
102  edm::LogWarning("HCalGeom") << "HcalDDDSimConstants: wrong depth "
103  << depth << " or etaR " << etaR
104  << " for detector " << idet;
105  }
106  } else {
107  ok = false;
108  edm::LogWarning("HCalGeom") << "HcalDDDSimConstants: wrong depth " << depth
109  << " det " << idet;
110  }
111  HcalCellType::HcalCell tmp(ok,eta,deta,phi,dphi,rz,drz,flagrz);
112 
113 #ifdef EDM_ML_DEBUG
114  std::cout << "HcalDDDSimConstants: det/side/depth/etaR/phi "
115  << idet << "/" << zside << "/" << depth << "/"
116  << etaR << "/" << iphi << " Cell Flag " << tmp.ok
117  << " " << tmp.eta << " " << tmp.deta << " phi "
118  << tmp.phi << " " << tmp.dphi << " r(z) " << tmp.rz
119  << " " << tmp.drz << " " << tmp.flagrz << std::endl;
120 #endif
121  return tmp;
122 }
123 
124 std::vector<std::pair<double,double> > HcalDDDSimConstants::getConstHBHE(const int type) const {
125 
126  std::vector<std::pair<double,double> > gcons;
127  if (type == 0) {
128  for (unsigned int i=0; i<hpar->rHB.size(); ++i) {
129  gcons.push_back(std::pair<double,double>(hpar->rHB[i],hpar->drHB[i]));
130  }
131  } else {
132  for (unsigned int i=0; i<hpar->zHE.size(); ++i) {
133  gcons.push_back(std::pair<double,double>(hpar->zHE[i],hpar->dzHE[i]));
134  }
135  }
136  return gcons;
137 }
138 
139 
140 std::pair<int,double> HcalDDDSimConstants::getDetEta(double eta, int depth) {
141 
142  int hsubdet(0), ieta(0);
143  double etaR(0);
144  double heta = fabs(eta);
145  for (int i = 0; i < nEta; i++)
146  if (heta > hpar->etaTable[i]) ieta = i + 1;
147  if (heta <= hpar->etaRange[1]) {
148  if ((ieta <= hpar->etaMin[1] && depth==3) || ieta > hpar->etaMax[0]) {
149  hsubdet = static_cast<int>(HcalEndcap);
150  } else {
151  hsubdet = static_cast<int>(HcalBarrel);
152  }
153  etaR = eta;
154  } else {
155  hsubdet = static_cast<int>(HcalForward);
156  double theta = 2.*atan(exp(-heta));
157  double hR = zVcal*tan(theta);
158  etaR = (eta >= 0. ? hR : -hR);
159  }
160  return std::pair<int,double>(hsubdet,etaR);
161 }
162 
163 int HcalDDDSimConstants::getEta(int det, int lay, double hetaR) {
164 
165  int ieta(0);
166  if (det == static_cast<int>(HcalForward)) { // Forward HCal
167  ieta = hpar->etaMax[2];
168  for (int i = nR-1; i > 0; i--)
169  if (hetaR < hpar->rTable[i]) ieta = hpar->etaMin[2] + nR - i - 1;
170  } else { // Barrel or Endcap
171  ieta = 1;
172  for (int i = 0; i < nEta-1; i++)
173  if (hetaR > hpar->etaTable[i]) ieta = i + 1;
174  if (det == static_cast<int>(HcalBarrel)) {
175  if (ieta > hpar->etaMax[0]) ieta = hpar->etaMax[0];
176  if (lay == 18) {
177  if (hetaR > etaHO[1] && ieta == hpar->noff[2]) ieta++;
178  }
179  } else if (det == static_cast<int>(HcalEndcap)) {
180  if (ieta <= hpar->etaMin[1]) ieta = hpar->etaMin[1];
181  }
182  }
183  return ieta;
184 }
185 
186 std::pair<int,int> HcalDDDSimConstants::getEtaDepth(int det, int etaR, int phi,
187  int depth, int lay) {
188 
189  //Modify the depth index
190  if (det == static_cast<int>(HcalForward)) { // Forward HCal
191  } else if (det == static_cast<int>(HcalOuter)) {
192  depth = 4;
193  } else {
194  if (lay >= 0) {
195  depth= layerGroup( etaR-1, lay-1 );
196  if (etaR == hpar->noff[0] && lay > 1) {
197  int kphi = phi + int((hpar->phioff[3]+0.1)/hpar->phibin[etaR-1]);
198  kphi = (kphi-1)%4 + 1;
199  if (kphi == 2 || kphi == 3) depth = layerGroup( etaR-1, lay-2 );
200  }
201  } else if (det == static_cast<int>(HcalBarrel)) {
202  if (depth>maxDepth[0]) depth = maxDepth[0];
203  }
204  if (etaR >= hpar->noff[1] && depth > depthEta29[0]) {
205  etaR -= depthEta29[1];
206  } else if (etaR == hpar->etaMin[1]) {
207  if (det == static_cast<int>(HcalBarrel)) {
208  if (depth > depthEta16[0]) depth = depthEta16[0];
209  } else {
210  if (depth < depthEta16[1]) depth = depthEta16[1];
211  }
212  }
213  }
214  if ((det == static_cast<int>(HcalEndcap)) && (etaR == 17) && (lay == 1))
215  etaR = 18;
216  return std::pair<int,int>(etaR,depth);
217 }
218 
219 double HcalDDDSimConstants::getEtaHO(double& etaR, double& x, double& y,
220  double& z) const {
221 
222  if (hpar->zHO.size() > 4) {
223  double eta = fabs(etaR);
224  double r = std::sqrt(x*x+y*y);
225  if (r > rminHO) {
226  double zz = fabs(z);
227  if (zz > hpar->zHO[3]) {
228  if (eta <= hpar->etaTable[10]) eta = hpar->etaTable[10]+0.001;
229  } else if (zz > hpar->zHO[1]) {
230  if (eta <= hpar->etaTable[4]) eta = hpar->etaTable[4]+0.001;
231  }
232  }
233  eta = (z >= 0. ? eta : -eta);
234 #ifdef EDM_ML_DEBUG
235  std::cout << "R " << r << " Z " << z << " eta " << etaR
236  << ":" << eta << std::endl;
237  if (eta != etaR) edm::LogInfo ("HCalGeom") << "**** Check *****";
238 #endif
239  return eta;
240  } else {
241  return etaR;
242  }
243 }
244 
245 unsigned int HcalDDDSimConstants::findLayer(int layer, const std::vector<HcalParameters::LayerItem>& layerGroup) const {
246 
247  unsigned int id = layerGroup.size();
248  for (unsigned int i = 0; i < layerGroup.size(); i++) {
249  if (layer == (int)(layerGroup[i].layer)) {
250  id = i;
251  break;
252  }
253  }
254  return id;
255 }
256 
257 std::pair<int,int> HcalDDDSimConstants::getModHalfHBHE(const int type) const {
258 
259  if (type == 0) {
260  return std::pair<int,int>(nmodHB,nzHB);
261  } else {
262  return std::pair<int,int>(nmodHE,nzHE);
263  }
264 }
265 
266 std::pair<double,double> HcalDDDSimConstants::getPhiCons(int det, int ieta) {
267 
268  double fioff(0), fibin(0);
269  if (det == static_cast<int>(HcalForward)) { // Forward HCal
270  fioff = hpar->phioff[2];
271  fibin = hpar->phitable[ieta-hpar->etaMin[2]];
272  if (unitPhi(fibin) > 2) { // HF double-phi
273  fioff = hpar->phioff[4];
274  }
275  } else { // Barrel or Endcap
276  if (det == static_cast<int>(HcalBarrel)) {
277  fioff = hpar->phioff[0];
278  } else {
279  fioff = hpar->phioff[1];
280  }
281  fibin = hpar->phibin[ieta-1];
282  }
283  return std::pair<double,double>(fioff,fibin);
284 }
285 
286 std::vector<HcalCellType> HcalDDDSimConstants::HcalCellTypes() const{
287 
288  std::vector<HcalCellType> cellTypes = HcalCellTypes(HcalBarrel);
289 #ifdef EDM_ML_DEBUG
290  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << cellTypes.size()
291  << " cells of type HCal Barrel\n";
292  for (unsigned int i=0; i<cellTypes.size(); i++)
293  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << cellTypes[i] << "\n";
294 #endif
295 
296  std::vector<HcalCellType> hoCells = HcalCellTypes(HcalOuter);
297 #ifdef EDM_ML_DEBUG
298  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << hoCells.size()
299  << " cells of type HCal Outer\n";
300  for (unsigned int i=0; i<hoCells.size(); i++)
301  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << hoCells[i] << "\n";
302 #endif
303  cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
304 
305  std::vector<HcalCellType> heCells = HcalCellTypes(HcalEndcap);
306 #ifdef EDM_ML_DEBUG
307  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << heCells.size()
308  << " cells of type HCal Endcap\n";
309  for (unsigned int i=0; i<heCells.size(); i++)
310  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << heCells[i] << "\n";
311 #endif
312  cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
313 
314  std::vector<HcalCellType> hfCells = HcalCellTypes(HcalForward);
315 #ifdef EDM_ML_DEBUG
316  edm::LogInfo ("HCalGeom") << "HcalDDDSimConstants: " << hfCells.size()
317  << " cells of type HCal Forward\n";
318  for (unsigned int i=0; i<hfCells.size(); i++)
319  edm::LogInfo ("HCalGeom") << "Cell " << i << " " << hfCells[i] << "\n";
320 #endif
321  cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
322 
323  return cellTypes;
324 }
325 
326 std::vector<HcalCellType> HcalDDDSimConstants::HcalCellTypes(HcalSubdetector subdet,
327  int ieta, int depthl) const {
328 
329  std::vector<HcalCellType> cellTypes;
330  if (subdet == HcalForward) {
331  if (dzVcal < 0) return cellTypes;
332  }
333 
334  int dmin, dmax, indx, nz, nmod;
335  double hsize = 0;
336  switch(subdet) {
337  case HcalEndcap:
338  dmin = 1; dmax = 19; indx = 1; nz = nzHE; nmod = nmodHE;
339  break;
340  case HcalForward:
341  dmin = 1; dmax = maxDepth[2]; indx = 2; nz = 2; nmod = 18;
342  break;
343  case HcalOuter:
344  dmin = 4; dmax = 4; indx = 0; nz = nzHB; nmod = nmodHB;
345  break;
346  default:
347  dmin = 1; dmax = 17; indx = 0; nz = nzHB; nmod = nmodHB;
348  break;
349  }
350  if (depthl > 0) dmin = dmax = depthl;
351  int ietamin = (ieta>0) ? ieta : hpar->etaMin[indx];
352  int ietamax = (ieta>0) ? ieta : hpar->etaMax[indx];
353  int phi = 1, zside = 1;
354 
355  // Get the Cells
356  int subdet0 = static_cast<int>(subdet);
357  for (int depth=dmin; depth<=dmax; depth++) {
358  int shift = getShift(subdet, depth);
359  double gain = getGain (subdet, depth);
360  if (subdet == HcalForward) {
361  if (depth%2 == 1) hsize = dzVcal;
362  else hsize = dzVcal-0.5*dlShort;
363  }
364  for (int eta=ietamin; eta<= ietamax; eta++) {
365  HcalCellType::HcalCell temp1 = cell(subdet0,zside,depth,eta,phi);
366  if (temp1.ok) {
367  int units = unitPhi (subdet0, eta);
368  HcalCellType temp2(subdet, eta, phi, depth, temp1,
369  shift, gain, nz, nmod, hsize, units);
370  if (subdet == HcalOuter) {
371  if (eta == hpar->noff[4]) {
372  std::vector<int> missPlus, missMinus;
373  int kk = 7;
374  for (int miss=0; miss<hpar->noff[5]; miss++) {
375  missPlus.push_back(hpar->noff[kk]);
376  kk++;
377  }
378  for (int miss=0; miss<hpar->noff[6]; miss++) {
379  missMinus.push_back(hpar->noff[kk]);
380  kk++;
381  }
382  temp2.setMissingPhi(missPlus, missMinus);
383  }
384  } else if (subdet == HcalForward) {
385  if (idHF2QIE.size() > 0 && depth > 2) {
386  int phiInc = 4/temp2.nPhiModule();
387  int iphi = 1;
388  if (temp2.unitPhi() == 4) iphi = 3;
389  std::vector<int> missPlus, missMinus;
390  for (int k=0; k<temp2.nPhiBins(); ++k) {
391  bool okp(true), okn(true);
392  for (unsigned int l=0; l<idHF2QIE.size(); ++l) {
393  if ((eta == idHF2QIE[l].ietaAbs()) &&
394  (iphi == idHF2QIE[l].iphi())) {
395  if (idHF2QIE[l].zside() == 1) okp = false;
396  else okn = false;
397  }
398  }
399  if (okp) missPlus.push_back(iphi);
400  if (okn) missMinus.push_back(iphi);
401  iphi += phiInc;
402  }
403  temp2.setMissingPhi(missPlus, missMinus);
404  }
405  }
406  cellTypes.push_back(temp2);
407  }
408  }
409  }
410  return cellTypes;
411 }
412 
413 int HcalDDDSimConstants::maxHFDepth(int eta, int iphi) const {
414  int mxdepth = maxDepth[2];
415  if (idHF2QIE.size() > 0) {
416  bool ok(false);
417  for (unsigned int k=0; k<idHF2QIE.size(); ++k) {
418  if ((eta == idHF2QIE[k].ieta()) && (iphi == idHF2QIE[k].iphi())) {
419  ok = true; break;
420  }
421  }
422  if (!ok) mxdepth = 2;
423  }
424  return mxdepth;
425 }
426 
428 
429  unsigned int num = 0;
430  std::vector<HcalCellType> cellTypes = HcalCellTypes(subdet);
431  for (unsigned int i=0; i<cellTypes.size(); i++) {
432  int ncur = (cellTypes[i].nHalves() > 1) ? 2*cellTypes[i].nPhiBins() :
433  cellTypes[i].nPhiBins();
434  num += (unsigned int)(ncur);
435  num -= (unsigned int)(cellTypes[i].nPhiMissingBins());
436  }
437 #ifdef EDM_ML_DEBUG
438  std::cout << "HcalDDDSimConstants:numberOfCells "
439  << cellTypes.size() << " " << num
440  << " for subdetector " << subdet << std::endl;
441 #endif
442  return num;
443 }
444 
446 
447  int iphi_skip = phi;
448  if (units==2) iphi_skip = (phi-1)*2+1;
449  else if (units==4) iphi_skip = (phi-1)*4-1;
450  if (iphi_skip < 0) iphi_skip += 72;
451  return iphi_skip;
452 }
453 
455 
456  std::cout << "Tile Information for HB from " << hpar->etaMin[0] << " to " << hpar->etaMax[0] << "\n\n";
457  for (int eta=hpar->etaMin[0]; eta<= hpar->etaMax[0]; eta++) {
458  int dmax = 1;
459  if (depths[0][eta-1] < 17) dmax = 2;
460  if (maxDepth[0] > 2) {
461  if (eta == hpar->etaMin[1]) dmax = depthEta16[0];
462  else dmax = maxDepth[0];
463  }
464  for (int depth=1; depth<=dmax; depth++)
466  }
467 
468  std::cout << "\nTile Information for HE from " << hpar->etaMin[1] << " to " << hpar->etaMax[1] << "\n\n";
469  for (int eta=hpar->etaMin[1]; eta<= hpar->etaMax[1]; eta++) {
470  int dmin=1, dmax=3;
471  if (eta == hpar->etaMin[1]) {
472  dmax = dmin = depthEta16[1];
473  } else if (depths[0][eta-1] > 18) {
474  dmax = 1;
475  } else if (depths[1][eta-1] > 18) {
476  dmax = 2;
477  }
478  for (int depth=dmin; depth<=dmax; depth++)
480  }
481 }
482 
483 int HcalDDDSimConstants::unitPhi(int det, int etaR) const {
484 
485  double dphi = (det == static_cast<int>(HcalForward)) ? hpar->phitable[etaR-hpar->etaMin[2]] : hpar->phibin[etaR-1];
486  return unitPhi(dphi);
487 }
488 
489 int HcalDDDSimConstants::unitPhi(double dphi) const {
490 
491  const double fiveDegInRad = 2*M_PI/72;
492  int units = int(dphi/fiveDegInRad+0.5);
493  if (units < 1) units = 1;
494  return units;
495 }
496 
498 
499  nEta = hpar->etaTable.size();
500  nR = hpar->rTable.size();
501  nPhiF = nR - 1;
502  isBH_ = false;
503 
504 #ifdef EDM_ML_DEBUG
505  for (int i=0; i<nEta-1; ++i) {
506  std::cout << "HcalDDDSimConstants:Read LayerGroup" << i << ":";
507  for (unsigned int k=0; k<layerGroupSize( i ); k++)
508  std::cout << " [" << k << "] = " << layerGroup( i, k );
509  std::cout << std::endl;
510  }
511 #endif
512 
513  // Geometry parameters for HF
514  dlShort = hpar->gparHF[0];
515  zVcal = hpar->gparHF[4];
516  dzVcal = hpar->dzVcal;
517 #ifdef EDM_ML_DEBUG
518  std::cout << "HcalDDDSimConstants: dlShort " << dlShort << " zVcal " << zVcal
519  << " and dzVcal " << dzVcal << std::endl;
520 #endif
521 
522  //Transform some of the parameters
524  maxDepth[0] = maxDepth[1] = 0;
525  for (int i=0; i<nEta-1; ++i) {
526  unsigned int imx = layerGroupSize( i );
527  int laymax = (imx > 0) ? layerGroup( i, imx-1 ) : 0;
528  if (i < hpar->etaMax[0]) {
529  int laymax0 = (imx > 16) ? layerGroup( i, 16 ) : laymax;
530  if (i+1 == hpar->etaMax[0] && laymax0 > 2) laymax0 = 2;
531  if (maxDepth[0] < laymax0) maxDepth[0] = laymax0;
532  }
533  if (i >= hpar->etaMin[1]-1 && i < hpar->etaMax[1]) {
534  if (maxDepth[1] < laymax) maxDepth[1] = laymax;
535  }
536  }
537 #ifdef EDM_ML_DEBUG
538  for (int i=0; i<4; ++i)
539  std::cout << "Detector Type [" << i << "] iEta " << hpar->etaMin[i] << ":"
540  << hpar->etaMax[i] << " MaxDepth " << maxDepth[i] << std::endl;
541 #endif
542 
543  int maxdepth = (maxDepth[1]>maxDepth[0]) ? maxDepth[1] : maxDepth[0];
544  for (int i=0; i<maxdepth; ++i) {
545  for (int k=0; k<nEta-1; ++k) {
546  int layermx = ((k+1 < hpar->etaMin[1]) && i < maxDepth[0]) ? 17 : (int)layerGroupSize( k );
547  int ll = layermx;
548  for (int l=layermx-1; l >= 0; --l) {
549  if ((int)layerGroup( k, l ) == i+1) {
550  ll = l+1; break;
551  }
552  }
553  depths[i].push_back(ll);
554  }
555 
556 #ifdef EDM_ML_DEBUG
557  std::cout << "Depth " << i << " with " << depths[i].size() << " etas:";
558  for (int k=0; k<nEta-1; ++k) std::cout << " " << depths[i][k];
559  std::cout << std::endl;
560 #endif
561  }
562 
563  nzHB = hpar->modHB[0];
564  nmodHB = hpar->modHB[1];
565  nzHE = hpar->modHE[0];
566  nmodHE = hpar->modHE[1];
567 #ifdef EDM_ML_DEBUG
568  std::cout << "HcalDDDSimConstants:: " << nzHB << ":" << nmodHB
569  << " barrel and " << nzHE << ":" << nmodHE
570  << " endcap half-sectors" << std::endl;
571 #endif
572 
573  if (hpar->rHB.size() > 17 && hpar->zHO.size() > 4) {
574  rminHO = hpar->rHO[0];
575  for (int k=0; k<4; ++k) etaHO[k] = hpar->rHO[k+1];
576  } else {
577  rminHO =-1.0;
578  etaHO[0] = hpar->etaTable[4];
579  etaHO[1] = hpar->etaTable[4];
580  etaHO[2] = hpar->etaTable[10];
581  etaHO[3] = hpar->etaTable[10];
582  }
583 #ifdef EDM_ML_DEBUG
584  std::cout << "HO Eta boundaries " << etaHO[0] << " " << etaHO[1]
585  << " " << etaHO[2] << " " << etaHO[3] << std::endl;
586  std::cout << "HO Parameters " << rminHO << " " << hpar->zHO.size();
587  for (int i=0; i<4; ++i) std::cout << " eta[" << i << "] = " << etaHO[i];
588  for (unsigned int i=0; i<hpar->zHO.size(); ++i)
589  std::cout << " zHO[" << i << "] = " << hpar->zHO[i];
590  std::cout << std::endl;
591 #endif
592 
593  int noffsize = 7 + hpar->noff[5] + hpar->noff[6];
594  int noffl(noffsize+5);
595  if ((int)(hpar->noff.size()) > (noffsize+3)) {
596  depthEta16[0] = hpar->noff[noffsize];
597  depthEta16[1] = hpar->noff[noffsize+1];
598  depthEta29[0] = hpar->noff[noffsize+2];
599  depthEta29[1] = hpar->noff[noffsize+3];
600  if ((int)(hpar->noff.size()) > (noffsize+4)) {
601  noffl += (2*hpar->noff[noffsize+4]);
602  if ((int)(hpar->noff.size()) > noffl) isBH_ = (hpar->noff[noffl] > 0);
603  }
604  } else {
605  depthEta16[0] = 2;
606  depthEta16[1] = 3;
607  depthEta29[0] = 2;
608  depthEta29[1] = 1;
609  }
610 #ifdef EDM_ML_DEBUG
611  std::cout << "isBH_ " << hpar->noff.size() << ":" << noffsize << ":"
612  << noffl << ":" << isBH_ << std::endl;
613  std::cout << "Depth index at ieta = 16 for HB (max) " << depthEta16[0]
614  << " HE (min) " << depthEta16[1] << "; max depth for itea = 29 : ("
615  << depthEta29[0] << ":" << depthEta29[1] << ")" << std::endl;
616 #endif
617 
618  if ((int)(hpar->noff.size()) > (noffsize+4)) {
619  int npair = hpar->noff[noffsize+4];
620  int kk = noffsize+4;
621  for (int k=0; k<npair; ++k) {
622  idHF2QIE.push_back(HcalDetId(HcalForward,hpar->noff[kk+1],hpar->noff[kk+2],1));
623  kk += 2;
624  }
625  }
626 #ifdef EDM_ML_DEBUG
627  std::cout << idHF2QIE.size() << " detector channels having 2 QIE cards:"
628  << std::endl;
629  for (unsigned int k=0; k<idHF2QIE.size(); ++k)
630  std::cout << " [" << k << "] " << idHF2QIE[k] << std::endl;
631 #endif
632 }
633 
634 double HcalDDDSimConstants::deltaEta(int det, int etaR, int depth) const {
635 
636  double tmp = 0;
637  if (det == static_cast<int>(HcalForward)) {
638  int ir = nR + hpar->etaMin[2] - etaR - 1;
639  if (ir > 0 && ir < nR) {
640  double z = zVcal;
641  if (depth%2 != 1) z += dlShort;
642  tmp = 0.5*(getEta(hpar->rTable[ir-1],z)-getEta(hpar->rTable[ir],z));
643  }
644  } else {
645  if (etaR > 0 && etaR < nEta) {
646  if (etaR == hpar->noff[1]-1 && depth > 2) {
647  tmp = 0.5*(hpar->etaTable[etaR+1]-hpar->etaTable[etaR-1]);
648  } else if (det == static_cast<int>(HcalOuter)) {
649  if (etaR == hpar->noff[2]) {
650  tmp = 0.5*(etaHO[0]-hpar->etaTable[etaR-1]);
651  } else if (etaR == hpar->noff[2]+1) {
652  tmp = 0.5*(hpar->etaTable[etaR]-etaHO[1]);
653  } else if (etaR == hpar->noff[3]) {
654  tmp = 0.5*(etaHO[2]-hpar->etaTable[etaR-1]);
655  } else if (etaR == hpar->noff[3]+1) {
656  tmp = 0.5*(hpar->etaTable[etaR]-etaHO[3]);
657  } else {
658  tmp = 0.5*(hpar->etaTable[etaR]-hpar->etaTable[etaR-1]);
659  }
660  } else {
661  tmp = 0.5*(hpar->etaTable[etaR]-hpar->etaTable[etaR-1]);
662  }
663  }
664  }
665 #ifdef EDM_ML_DEBUG
666  std::cout << "HcalDDDSimConstants::deltaEta " << etaR << " "
667  << depth << " ==> " << tmp << std::endl;
668 #endif
669  return tmp;
670 }
671 
672 double HcalDDDSimConstants::getEta(int det, int etaR, int zside,
673  int depth) const {
674 
675  double tmp = 0;
676  if (det == static_cast<int>(HcalForward)) {
677  int ir = nR + hpar->etaMin[2] - etaR - 1;
678  if (ir > 0 && ir < nR) {
679  double z = zVcal;
680  if (depth%2 != 1) z += dlShort;
681  tmp = 0.5*(getEta(hpar->rTable[ir-1],z)+getEta(hpar->rTable[ir],z));
682  }
683  } else {
684  if (etaR > 0 && etaR < nEta) {
685  if (etaR == hpar->noff[1]-1 && depth > 2) {
686  tmp = 0.5*(hpar->etaTable[etaR+1]+hpar->etaTable[etaR-1]);
687  } else if (det == static_cast<int>(HcalOuter)) {
688  if (etaR == hpar->noff[2]) {
689  tmp = 0.5*(etaHO[0]+hpar->etaTable[etaR-1]);
690  } else if (etaR == hpar->noff[2]+1) {
691  tmp = 0.5*(hpar->etaTable[etaR]+etaHO[1]);
692  } else if (etaR == hpar->noff[3]) {
693  tmp = 0.5*(etaHO[2]+hpar->etaTable[etaR-1]);
694  } else if (etaR == hpar->noff[3]+1) {
695  tmp = 0.5*(hpar->etaTable[etaR]+etaHO[3]);
696  } else {
697  tmp = 0.5*(hpar->etaTable[etaR]+hpar->etaTable[etaR-1]);
698  }
699  } else {
700  tmp = 0.5*(hpar->etaTable[etaR]+hpar->etaTable[etaR-1]);
701  }
702  }
703  }
704  if (zside == 0) tmp = -tmp;
705 #ifdef EDM_ML_DEBUG
706  std::cout << "HcalDDDSimConstants::getEta " << etaR << " "
707  << zside << " " << depth << " ==> " << tmp << "\n";
708 #endif
709  return tmp;
710 }
711 
712 double HcalDDDSimConstants::getEta(double r, double z) const {
713 
714  double tmp = 0;
715  if (z != 0) tmp = -log(tan(0.5*atan(r/z)));
716 #ifdef EDM_ML_DEBUG
717  std::cout << "HcalDDDSimConstants::getEta " << r << " " << z
718  << " ==> " << tmp << std::endl;
719 #endif
720  return tmp;
721 }
722 
724 
725  int shift;
726  switch(subdet) {
727  case HcalEndcap:
728  shift = hpar->HEShift[0];
729  break;
730  case HcalForward:
731  shift = hpar->HFShift[(depth-1)%2];
732  break;
733  case HcalOuter:
734  shift = hpar->HBShift[3];
735  break;
736  default:
737  shift = hpar->HBShift[0];
738  break;
739  }
740  return shift;
741 }
742 
744 
745  double gain;
746  switch(subdet) {
747  case HcalEndcap:
748  gain = hpar->HEGains[0];
749  break;
750  case HcalForward:
751  gain = hpar->HFGains[(depth-1)%2];
752  break;
753  case HcalOuter:
754  gain = hpar->HBGains[3];
755  break;
756  default:
757  gain = hpar->HBGains[0];
758  break;
759  }
760  return gain;
761 }
762 
764  std::cout << "HcalDDDSimConstants::printTileHB for eta " << eta << " and depth " << depth << "\n";
765 
766  double etaL = hpar->etaTable.at(eta-1);
767  double thetaL = 2.*atan(exp(-etaL));
768  double etaH = hpar->etaTable.at(eta);
769  double thetaH = 2.*atan(exp(-etaH));
770  int layL=0, layH=0;
771  if (depth == 1) {
772  layH = depths[0][eta-1];
773  } else {
774  layL = depths[0][eta-1];
775  layH = depths[1][eta-1];
776  }
777  std::cout << "\ntileHB:: eta|depth " << eta << "|" << depth << " theta " << thetaH/CLHEP::deg << ":" << thetaL/CLHEP::deg << " Layer " << layL << ":" << layH-1 << "\n";
778  for (int lay=layL; lay<layH; ++lay) {
779  std::vector<double> area(2,0);
780  int kk=0;
781  for (unsigned int k=0; k<hpar->layHB.size(); ++k) {
782  if (lay == hpar->layHB[k]) {
783  double zmin = hpar->rhoxHB[k]*std::cos(thetaL)/std::sin(thetaL);
784  double zmax = hpar->rhoxHB[k]*std::cos(thetaH)/std::sin(thetaH);
785  double dz = (std::min(zmax,hpar->dxHB[k]) - zmin);
786  if (dz > 0) {
787  area[kk] = dz*hpar->dyHB[k];
788  kk++;
789  }
790  }
791  }
792  if (area[0] > 0) std::cout << std::setw(2) << lay << " Area " << std::setw(8) << area[0] << " " << std::setw(8) << area[1] << "\n";
793  }
794 }
795 
797 
798  double etaL = hpar->etaTable[eta-1];
799  double thetaL = 2.*atan(exp(-etaL));
800  double etaH = hpar->etaTable[eta];
801  double thetaH = 2.*atan(exp(-etaH));
802  int layL=0, layH=0;
803  if (eta == 16) {
804  layH = depths[2][eta-1];
805  } else if (depth == 1) {
806  layH = depths[0][eta-1];
807  } else if (depth == 2) {
808  layL = depths[0][eta-1];
809  layH = depths[1][eta-1];
810  } else {
811  layL = depths[1][eta-1];
812  layH = depths[2][eta-1];
813  }
814  double phib = hpar->phibin[eta-1];
815  int nphi = 2;
816  if (phib > 6*CLHEP::deg) nphi = 1;
817  std::cout << "\ntileHE:: Eta/depth " << eta << "|" << depth << " theta " << thetaH/CLHEP::deg << ":" << thetaL/CLHEP::deg << " Layer " << layL << ":" << layH-1 << " phi " << nphi << "\n";
818  for (int lay=layL; lay<layH; ++lay) {
819  std::vector<double> area(4,0);
820  int kk=0;
821  for (unsigned int k=0; k<hpar->layHE.size(); ++k) {
822  if (lay == hpar->layHE[k]) {
823  double rmin = hpar->zxHE[k]*std::tan(thetaH);
824  double rmax = hpar->zxHE[k]*std::tan(thetaL);
825  if ((lay != 0 || eta == 18) &&
826  (lay != 1 || (eta == 18 && hpar->rhoxHE[k]-hpar->dyHE[k] > 1000) ||
827  (eta != 18 && hpar->rhoxHE[k]-hpar->dyHE[k] < 1000)) &&
828  rmin+30 < hpar->rhoxHE[k]+hpar->dyHE[k] &&
829  rmax > hpar->rhoxHE[k]-hpar->dyHE[k]) {
830  rmin = std::max(rmin,hpar->rhoxHE[k]-hpar->dyHE[k]);
831  rmax = std::min(rmax,hpar->rhoxHE[k]+hpar->dyHE[k]);
832  double dx1 = rmin*std::tan(phib);
833  double dx2 = rmax*std::tan(phib);
834  double ar1=0, ar2=0;
835  if (nphi == 1) {
836  ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*hpar->dx1HE[k]);
837  } else {
838  ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*hpar->dx1HE[k]);
839  ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*tan(10.*CLHEP::deg)-4*hpar->dx1HE[k])-ar1;
840  }
841  area[kk] = ar1;
842  area[kk+2] = ar2;
843  kk++;
844  }
845  }
846  }
847  if (area[0] > 0 && area[1] > 0) {
848  int lay0 = lay-1;
849  if (eta == 18) lay0++;
850  if (nphi == 1) {
851  std::cout << std::setw(2) << lay0 << " Area " << std::setw(8) << area[0] << " " << std::setw(8) << area[1] << "\n";
852  } else {
853  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";
854  }
855  }
856  }
857 }
858 
859 unsigned int HcalDDDSimConstants::layerGroupSize(unsigned int eta) const {
860  unsigned int k = 0;
861  for( auto const & it : hpar->layerGroupEtaSim ) {
862  if( it.layer == eta + 1 ) {
863  return it.layerGroup.size();
864  }
865  if( it.layer > eta + 1 ) break;
866  k = it.layerGroup.size();
867  }
868  return k;
869 }
870 
871 unsigned int HcalDDDSimConstants::layerGroup(unsigned int eta,
872  unsigned int i) const {
873  unsigned int k = 0;
874  for( auto const & it : hpar->layerGroupEtaSim ) {
875  if( it.layer == eta + 1 ) {
876  return it.layerGroup.at( i );
877  }
878  if( it.layer > eta + 1 ) break;
879  k = it.layerGroup.at( i );
880  }
881  return k;
882 }
std::pair< int, int > getEtaDepth(int det, int etaR, int phi, int depth, int lay)
type
Definition: HCALResponse.h:21
std::vector< double > zHO
int i
Definition: DBlmapReader.cc:9
std::vector< double > etaTable
void setMissingPhi(std::vector< int > &, std::vector< int > &)
Definition: HcalCellType.cc:81
int unitPhi(int det, int etaR) const
void printTileHB(int eta, int depth) const
std::vector< int > layHE
std::vector< int > maxDepth
std::vector< double > rHB
int getEta(int det, int lay, double hetaR)
std::vector< double > rhoxHB
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< double > HBGains
Geom::Theta< T > theta() const
std::vector< int > HEShift
int zside(DetId const &)
std::vector< std::pair< double, double > > getConstHBHE(const int type) const
HcalDDDSimConstants(const HcalParameters *hp)
unsigned int numberOfCells(HcalSubdetector) const
float float float z
std::vector< int > etaMax
std::vector< int > depths[nDepthMax]
std::vector< int > modHB
std::vector< double > rhoxHE
std::vector< double > zxHE
T x() const
Cartesian x coordinate.
std::vector< double > zHE
double getEtaHO(double &etaR, double &x, double &y, double &z) const
std::vector< LayerItem > layerGroupEtaSim
void printTileHE(int eta, int depth) const
std::vector< double > dyHE
std::vector< double > dx1HE
std::vector< double > rHO
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
int getShift(HcalSubdetector subdet, int depth) const
double getGain(HcalSubdetector subdet, int depth) const
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
unsigned int findLayer(int layer, const std::vector< HcalParameters::LayerItem > &layerGroup) const
#define M_PI
std::vector< double > HEGains
std::pair< int, double > getDetEta(double eta, int depth)
std::vector< double > dyHB
std::vector< double > phioff
std::pair< double, double > getPhiCons(int det, int ieta)
std::vector< double > gparHF
double deltaEta(int det, int eta, int depth) const
Geom::Phi< T > phi() const
std::vector< double > dxHB
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)
int nPhiModule() const
Definition: HcalCellType.h:52
std::vector< double > phibin
HcalCellType::HcalCell cell(int det, int zside, int depth, int etaR, int iphi) const
int phiNumber(int phi, int unit) const
std::vector< double > drHB
std::vector< double > HFGains
static unsigned int const shift
std::vector< int > noff
tuple cout
Definition: gather_cfg.py:145
std::vector< int > HBShift
int nPhiBins() const
the number of these cells in a ring
Definition: HcalCellType.h:51
const HcalParameters * hpar
std::vector< int > maxDepth
int unitPhi() const
Definition: HcalCellType.h:59
std::vector< int > layHB
unsigned int layerGroup(unsigned int eta, unsigned int i) const
std::vector< int > etaMin
int maxHFDepth(int ieta, int iphi) const
unsigned int layerGroupSize(unsigned int eta) const