CMS 3D CMS Logo

HCALProperties.cc
Go to the documentation of this file.
2 
3 //This class header
5 #include <cmath>
6 #include <iostream>
8 
10  edm::ParameterSet fastDetHCAL = fastDet.getParameter<edm::ParameterSet>("HadronicCalorimeterProperties");
11  hOPi = fastDetHCAL.getParameter<double>("HCAL_PiOverE");
12  spotFrac = fastDetHCAL.getParameter<double>("HCAL_Sampling");
13  HCALAeff_ = fastDetHCAL.getParameter<double>("HCALAeff");
14  HCALZeff_ = fastDetHCAL.getParameter<double>("HCALZeff");
15  HCALrho_ = fastDetHCAL.getParameter<double>("HCALrho");
16  HCALradiationLengthIncm_ = fastDetHCAL.getParameter<double>("HCALradiationLengthIncm");
17  HCALradLenIngcm2_ = fastDetHCAL.getParameter<double>("HCALradLenIngcm2");
18  HCALmoliereRadius_ = fastDetHCAL.getParameter<double>("HCALmoliereRadius");
19  HCALcriticalEnergy_ = fastDetHCAL.getParameter<double>("HCALcriticalEnergy");
20  HCALinteractionLength_ = fastDetHCAL.getParameter<double>("HCALinteractionLength");
21  etatow_ = fastDetHCAL.getParameter<std::vector<double>>("HCALetatow");
22  hcalDepthLam_ = fastDetHCAL.getParameter<std::vector<double>>("HCALDepthLam");
23 
24  // in principle this splitting into 42 bins may change with future detectors, but let's add a protection to make sure that differences are not typos in the configuration file:
25  if (etatow_.size() != 42)
26  std::cout << " HCALProperties::eta2ieta - WARNING: here we expect 42 entries instead of " << etatow_.size()
27  << "; is the change intentional?" << std::endl;
28  // splitting of 28-th tower is taken into account (2.65-2.853-3.0)
29  if (hcalDepthLam_.size() != etatow_.size() - 1)
30  std::cout << " HCALProperties::eta2ieta - WARNING: the sizes of HCALetatow and HCALDepthLam should differ by 1 "
31  "unit! HCALDepthLam has size "
32  << hcalDepthLam_.size() << " and HCALetatow has size " << etatow_.size() << std::endl;
33 }
34 
35 double HCALProperties::getHcalDepth(double eta) const {
36  int ieta = eta2ieta(eta);
37 
38  /*
39  std::cout << " HCALProperties::getHcalDepth for eta = " << eta
40  << " returns lam.thickness = " << hcalDepthLam_[ieta] << std::endl;
41  */
42 
43  return hcalDepthLam_[ieta];
44 }
45 
46 int HCALProperties::eta2ieta(double eta) const {
47  // binary search in the array of towers eta edges
48  int size = etatow_.size();
49 
50  double x = fabs(eta);
51  int curr = size / 2;
52  int step = size / 4;
53  int iter;
54  int prevdir = 0;
55  int actudir = 0;
56 
57  for (iter = 0; iter < size; iter++) {
58  if (curr >= size || curr < 1)
59  std::cout << " HCALProperties::eta2ieta - wrong current index = " << curr << " !!!" << std::endl;
60 
61  if ((x <= etatow_[curr]) && (x > etatow_[curr - 1]))
62  break;
63  prevdir = actudir;
64  if (x > etatow_[curr]) {
65  actudir = 1;
66  } else {
67  actudir = -1;
68  }
69  if (prevdir * actudir < 0) {
70  if (step > 1)
71  step /= 2;
72  }
73  curr += actudir * step;
74  if (curr > size)
75  curr = size;
76  else {
77  if (curr < 1) {
78  curr = 1;
79  }
80  }
81 
82  /*
83  std::cout << " HCALProperties::eta2ieta end of iter." << iter
84  << " curr, etatow_[curr-1], etatow_[curr] = "
85  << curr << " " << etatow_[curr-1] << " " << etatow_[curr] << std::endl;
86  */
87  }
88 
89  /*
90  std::cout << " HCALProperties::eta2ieta for input x = " << x
91  << " found index = " << curr-1
92  << std::endl;
93  */
94 
95  return curr - 1;
96 }
std::vector< double > etatow_
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double HCALradiationLengthIncm_
int eta2ieta(double eta) const
HCALProperties(const edm::ParameterSet &fastDet)
double HCALradLenIngcm2_
double HCALcriticalEnergy_
double HCALinteractionLength_
double getHcalDepth(double) const
step
Definition: StallMonitor.cc:98
double HCALmoliereRadius_
std::vector< double > hcalDepthLam_