CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EffectiveAreas Class Reference

#include <EffectiveAreas.h>

Public Member Functions

void checkConsistency () const
 
 EffectiveAreas (const std::string &filename)
 
const float getEffectiveArea (float eta) const
 
void printEffectiveAreas () const
 

Private Attributes

std::vector< float > absEtaMax_
 
std::vector< float > absEtaMin_
 
std::vector< float > effectiveAreaValues_
 
const std::string filename_
 

Detailed Description

Definition at line 8 of file EffectiveAreas.h.

Constructor & Destructor Documentation

EffectiveAreas::EffectiveAreas ( const std::string &  filename)

Definition at line 9 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, checkConsistency(), effectiveAreaValues_, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, Exception, filename_, analyzePatCleaning_cfg::inputFile, mps_splice::line, AlCaHLTBitMon_QueryRunRegistry::string, and trackerHitRTTI::undef.

9  :
11 {
12 
13  // Open the file with the effective area constants
14  std::ifstream inputFile;
15  inputFile.open(filename_.c_str());
16  if( !inputFile.is_open() )
17  throw cms::Exception("EffectiveAreas config failure")
18  << "failed to open the file " << filename_ << std::endl;
19 
20  // Read file line by line
22  const float undef = -999;
23  while( getline(inputFile, line) ){
24  if(line[0]=='#') continue; // skip the comments lines
25  float etaMin = undef, etaMax = undef, effArea = undef;
26  std::stringstream ss(line);
27  ss >> etaMin >> etaMax >> effArea;
28  // In case if the format is messed up, there are letters
29  // instead of numbers, or not exactly three numbers in the line,
30  // it is likely that one or more of these vars never changed
31  // the original "undef" value:
32  if( etaMin==undef || etaMax==undef || effArea==undef )
33  throw cms::Exception("EffectiveAreas config failure")
34  << "wrong file format, file name " << filename_ << std::endl;
35 
36  absEtaMin_ .push_back( etaMin );
37  absEtaMax_ .push_back( etaMax );
38  effectiveAreaValues_.push_back( effArea );
39  }
40 
41  // Extra consistency checks are in the function below.
42  // If any of them fail, an exception is thrown.
44 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
void checkConsistency() const
const std::string filename_

Member Function Documentation

void EffectiveAreas::checkConsistency ( void  ) const

Definition at line 76 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, Exception, filename_, fftjetcommon_cfi::nEtaBins, and parallelization::uint().

Referenced by EffectiveAreas().

76  {
77 
78  // There should be at least one eta range with one constant
79  if( effectiveAreaValues_.empty() )
80  throw cms::Exception("EffectiveAreas config failure")
81  << "found no effective area constans in the file "
82  << filename_ << std::endl;
83 
84  uint nEtaBins = absEtaMin_.size();
85  for(uint iEta = 0; iEta<nEtaBins; iEta++){
86 
87  // The low limit should be lower than the upper limit
88  if( !( absEtaMin_[iEta] < absEtaMax_[iEta] ) )
89  throw cms::Exception("EffectiveAreas config failure")
90  << "eta ranges improperly defined (min>max) in the file"
91  << filename_ << std::endl;
92 
93  // The low limit of the next range should be (near) equal to the
94  // upper limit of the previous range
95  if( iEta != nEtaBins-1 ) // don't do the check for the last bin
96  if( !( absEtaMin_[iEta+1] - absEtaMax_[iEta] < 0.0001 ) )
97  throw cms::Exception("EffectiveAreas config failure")
98  << "eta ranges improperly defined (disjointed) in the file "
99  << filename_ << std::endl;
100 
101  // The effective area should be non-negative number,
102  // and should be less than the whole calorimeter area
103  // eta range -2.5 to 2.5, phi 0 to 2pi => Amax = 5*2*pi ~= 31.4
104  if( !( effectiveAreaValues_[iEta] >= 0
105  && effectiveAreaValues_[iEta] < 31.4 ) )
106  throw cms::Exception("EffectiveAreas config failure")
107  << "effective area values are too large or negative in the file"
108  << filename_ << std::endl;
109  }
110 
111 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
def uint(string)
const std::string filename_
const float EffectiveAreas::getEffectiveArea ( float  eta) const

Definition at line 47 of file EffectiveAreas.cc.

References funct::abs(), absEtaMax_, absEtaMin_, effectiveAreaValues_, fftjetcommon_cfi::nEtaBins, and parallelization::uint().

Referenced by ElectronIdentifier::isolation(), GsfEleEffAreaPFIsoCut::operator()(), PhoAnyPFIsoWithEAAndExpoScalingEBCut::operator()(), PhoAnyPFIsoWithEAAndQuadScalingCut::operator()(), PhoAnyPFIsoWithEAAndExpoScalingCut::operator()(), PhoAnyPFIsoWithEACut::operator()(), PhoGenericRhoPtScaledCut::operator()(), GsfEleCalPFClusterIsoCut::operator()(), PhoAnyPFIsoWithEAAndExpoScalingCut::value(), GsfEleEffAreaPFIsoCut::value(), GsfEleRelPFIsoScaledCut::value(), PhoAnyPFIsoWithEACut::value(), PhoAnyPFIsoWithEAAndQuadScalingCut::value(), PhoAnyPFIsoWithEAAndExpoScalingEBCut::value(), and GsfEleCalPFClusterIsoCut::value().

47  {
48 
49  float effArea = 0;
50  uint nEtaBins = absEtaMin_.size();
51  for(uint iEta = 0; iEta<nEtaBins; iEta++){
52  if( std::abs(eta) >= absEtaMin_[iEta]
53  && std::abs(eta) < absEtaMax_[iEta] ){
54  effArea = effectiveAreaValues_[iEta];
55  break;
56  }
57  }
58 
59  return effArea;
60 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > absEtaMin_
def uint(string)
void EffectiveAreas::printEffectiveAreas ( ) const

Definition at line 62 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, filename_, fftjetcommon_cfi::nEtaBins, and parallelization::uint().

62  {
63 
64  printf("EffectiveAreas: source file %s\n", filename_.c_str());
65  printf(" eta_min eta_max effective area\n");
66  uint nEtaBins = absEtaMin_.size();
67  for(uint iEta = 0; iEta<nEtaBins; iEta++){
68  printf(" %8.4f %8.4f %8.5f\n",
69  absEtaMin_[iEta], absEtaMax_[iEta],
70  effectiveAreaValues_[iEta]);
71  }
72 
73 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
def uint(string)
const std::string filename_

Member Data Documentation

std::vector<float> EffectiveAreas::absEtaMax_
private
std::vector<float> EffectiveAreas::absEtaMin_
private
std::vector<float> EffectiveAreas::effectiveAreaValues_
private
const std::string EffectiveAreas::filename_
private

Definition at line 23 of file EffectiveAreas.h.

Referenced by checkConsistency(), EffectiveAreas(), and printEffectiveAreas().