CMS 3D CMS Logo

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