CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 
00009 
00010 HCALProperties::HCALProperties(const edm::ParameterSet& fastDet) : CalorimeterProperties()
00011 {
00012 
00013     edm::ParameterSet fastDetHCAL= fastDet.getParameter<edm::ParameterSet>("HadronicCalorimeterProperties");
00014   hOPi = fastDetHCAL.getParameter<double>("HCAL_PiOverE");
00015   spotFrac= fastDetHCAL.getParameter<double>("HCAL_Sampling");
00016   HCALAeff_= fastDetHCAL.getParameter<double>("HCALAeff");
00017   HCALZeff_= fastDetHCAL.getParameter<double>("HCALZeff");
00018   HCALrho_= fastDetHCAL.getParameter<double>("HCALrho");
00019   HCALradiationLengthIncm_= fastDetHCAL.getParameter< double>("HCALradiationLengthIncm");
00020   HCALradLenIngcm2_= fastDetHCAL.getParameter<double>("HCALradLenIngcm2");
00021   HCALmoliereRadius_= fastDetHCAL.getParameter<double>("HCALmoliereRadius");
00022   HCALcriticalEnergy_= fastDetHCAL.getParameter<double>("HCALcriticalEnergy");
00023   HCALinteractionLength_= fastDetHCAL.getParameter<double>("HCALinteractionLength");
00024   etatow_=fastDetHCAL.getParameter<std::vector<double>>("HCALetatow");
00025   hcalDepthLam_=fastDetHCAL.getParameter<std::vector<double>>("HCALDepthLam");
00026 
00027   // 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:
00028   if (etatow_.size() != 42) std::cout << " HCALProperties::eta2ieta - WARNING: here we expect 42 entries instead of " << etatow_.size() << "; is the change intentional?" << std::endl;
00029   // splitting of  28-th tower is taken into account (2.65-2.853-3.0)
00030   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;
00031   
00032 
00033 }
00034 
00035 double HCALProperties::getHcalDepth(double eta) const{
00036 
00037   int  ieta = eta2ieta(eta); 
00038 
00039   /* 
00040   std::cout << " HCALProperties::getHcalDepth for eta = " << eta 
00041             << "  returns lam.thickness = " << hcalDepthLam_[ieta] << std::endl;
00042   */
00043 
00044   return  hcalDepthLam_[ieta];
00045 
00046 }
00047 
00048 
00049 
00050 int HCALProperties::eta2ieta(double eta) const {
00051   // binary search in the array of towers eta edges
00052   int size = etatow_.size();
00053 
00054   double x = fabs(eta);
00055   int curr = size / 2;
00056   int step = size / 4;
00057   int iter;
00058   int prevdir = 0; 
00059   int actudir = 0; 
00060 
00061   for (iter = 0; iter < size ; iter++) {
00062 
00063     if( curr >= size || curr < 1 )
00064       std::cout <<  " HCALProperties::eta2ieta - wrong current index = "
00065                 << curr << " !!!" << std::endl;
00066 
00067     if ((x <= etatow_[curr]) && (x > etatow_[curr-1])) break;
00068     prevdir = actudir;
00069     if(x > etatow_[curr]) {actudir =  1;}
00070     else                 {actudir = -1;}
00071     if(prevdir * actudir < 0) { if(step > 1) step /= 2;}
00072     curr += actudir * step;
00073     if(curr > size) curr = size;
00074     else { if(curr < 1) {curr = 1;}}
00075 
00076     /*
00077     std::cout << " HCALProperties::eta2ieta  end of iter." << iter 
00078               << " curr, etatow_[curr-1], etatow_[curr] = "
00079               << curr << " " << etatow_[curr-1] << " " << etatow_[curr] << std::endl;
00080     */
00081     
00082   }
00083 
00084   /*
00085   std::cout << " HCALProperties::eta2ieta  for input x = " << x 
00086             << "  found index = " << curr-1
00087             << std::endl;
00088   */
00089   
00090   return curr-1;
00091 }