CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
 ~EffectiveAreas ()
 

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_, HLT_25ns14e33_v1_cff::etaMax, HLT_25ns14e33_v1_cff::etaMin, edm::hlt::Exception, filename_, analyzePatCleaning_cfg::inputFile, geometryCSVtoXML::line, contentValuesCheck::ss, 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
tuple filename
Definition: lut2db_cfg.py:20
const std::string filename_
EffectiveAreas::~EffectiveAreas ( )

Definition at line 46 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, and effectiveAreaValues_.

46  {
47 
48  absEtaMin_.clear();
49  absEtaMax_.clear();
50  effectiveAreaValues_.clear();
51 
52 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_

Member Function Documentation

void EffectiveAreas::checkConsistency ( void  ) const

Definition at line 84 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, edm::hlt::Exception, and filename_.

Referenced by EffectiveAreas().

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

Definition at line 55 of file EffectiveAreas.cc.

References funct::abs(), absEtaMax_, absEtaMin_, and effectiveAreaValues_.

Referenced by GsfEleEffAreaPFIsoCut::operator()(), PhoAnyPFIsoWithEACut::operator()(), PhoAnyPFIsoWithEAAndExpoScalingEBCut::operator()(), PhoAnyPFIsoWithEAAndExpoScalingEBCut::value(), GsfEleEffAreaPFIsoCut::value(), and PhoAnyPFIsoWithEACut::value().

55  {
56 
57  float effArea = 0;
58  uint nEtaBins = absEtaMin_.size();
59  for(uint iEta = 0; iEta<nEtaBins; iEta++){
60  if( std::abs(eta) >= absEtaMin_[iEta]
61  && std::abs(eta) < absEtaMax_[iEta] ){
62  effArea = effectiveAreaValues_[iEta];
63  break;
64  }
65  }
66 
67  return effArea;
68 }
T eta() const
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > absEtaMin_
void EffectiveAreas::printEffectiveAreas ( ) const

Definition at line 70 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, and filename_.

70  {
71 
72  printf("EffectiveAreas: source file %s\n", filename_.c_str());
73  printf(" eta_min eta_max effective area\n");
74  uint nEtaBins = absEtaMin_.size();
75  for(uint iEta = 0; iEta<nEtaBins; iEta++){
76  printf(" %8.4f %8.4f %8.5f\n",
77  absEtaMin_[iEta], absEtaMax_[iEta],
78  effectiveAreaValues_[iEta]);
79  }
80 
81 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
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 24 of file EffectiveAreas.h.

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