CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/FastSimulation/CalorimeterProperties/src/HCALProperties.cc

Go to the documentation of this file.
00001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00002 
00003 //This class header
00004 #include "FastSimulation/CalorimeterProperties/interface/HCALProperties.h"
00005 #include <cmath>
00006 #include <iostream>
00007 
00008 
00009 HCALProperties::HCALProperties(const edm::ParameterSet& fastDet) : CalorimeterProperties()
00010 {
00011   hOPi = fastDet.getParameter<double>("HCAL_PiOverE");
00012   spotFrac= fastDet.getParameter<double>("HCAL_Sampling");
00013 
00014   // splitting of  28-th tower is taken into account (2.65-2.853-3.0)
00015   double etatow_ [42] = {
00016     0.000, 0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609, 0.696, 0.783, 0.870,    0.957, 1.044, 1.131, 1.218, 1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830,    1.930, 2.043, 2.172, 2.322, 2.500, 2.650, 2.853, 3.000, 3.139, 3.314, 3.489,    3.664, 3.839, 4.013, 4.191, 4.363, 4.538, 4.716, 4.889, 5.191
00017   };
00018 
00019   double hcalDepthLam_ [41] = { 
00020     8.930, 9.001, 9.132, 8.912, 8.104, 8.571, 8.852, 9.230, 9.732, 10.29,          10.95, 11.68, 12.49, 12.57, 12.63,  6.449, 5.806, 8.973, 8.934,  8.823,          8.727, 8.641, 8.565, 8.496, 8.436, 8.383, 8.346, 8.307, 8.298,  8.281,          9.442, 9.437, 9.432, 9.429, 9.432, 9.433, 9.430, 9.437, 9.442,  9.446, 9.435  };
00021 
00022   for (int i = 0; i < 42; i++) { etatow[i] = etatow_[i];}
00023   for (int i = 0; i < 41; i++) { hcalDepthLam[i] = hcalDepthLam_[i];}
00024 
00025 }
00026 
00027 double HCALProperties::getHcalDepth(double eta) const{
00028 
00029   int  ieta = eta2ieta(eta); 
00030 
00031   /* 
00032   std::cout << " HCALProperties::getHcalDepth for eta = " << eta 
00033             << "  returns lam.thickness = " << hcalDepthLam[ieta] << std::endl;
00034   */
00035 
00036   return  hcalDepthLam[ieta];
00037 
00038 }
00039 
00040 
00041 
00042 int HCALProperties::eta2ieta(double eta) const {
00043   // binary search in the array of towers eta edges
00044   int size = 42;
00045 
00046   double x = fabs(eta);
00047   int curr = size / 2;
00048   int step = size / 4;
00049   int iter;
00050   int prevdir = 0; 
00051   int actudir = 0; 
00052 
00053   for (iter = 0; iter < size ; iter++) {
00054 
00055     if( curr >= size || curr < 1 )
00056       std::cout <<  " HCALProperties::eta2ieta - wrong current index = "
00057                 << curr << " !!!" << std::endl;
00058 
00059     if ((x <= etatow[curr]) && (x > etatow[curr-1])) break;
00060     prevdir = actudir;
00061     if(x > etatow[curr]) {actudir =  1;}
00062     else                 {actudir = -1;}
00063     if(prevdir * actudir < 0) { if(step > 1) step /= 2;}
00064     curr += actudir * step;
00065     if(curr > size) curr = size;
00066     else { if(curr < 1) {curr = 1;}}
00067 
00068     /*
00069     std::cout << " HCALProperties::eta2ieta  end of iter." << iter 
00070               << " curr, etatow[curr-1], etatow[curr] = "
00071               << curr << " " << etatow[curr-1] << " " << etatow[curr] << std::endl;
00072     */
00073     
00074   }
00075 
00076   /*
00077   std::cout << " HCALProperties::eta2ieta  for input x = " << x 
00078             << "  found index = " << curr-1
00079             << std::endl;
00080   */
00081   
00082   return curr-1;
00083 }