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