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 7 of file EffectiveAreas.h.

Constructor & Destructor Documentation

◆ EffectiveAreas()

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_, dtResolutionTest_cfi::inputFile, mps_splice::line, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and trackerHitRTTI::undef.

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

Member Function Documentation

◆ checkConsistency()

void EffectiveAreas::checkConsistency ( void  ) const

Definition at line 67 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, Exception, filename_, L1TowerCalibrationProducer_cfi::iEta, L1TMuonDQMOffline_cfi::nEtaBins, and parallelization::uint.

Referenced by EffectiveAreas().

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

◆ getEffectiveArea()

const float EffectiveAreas::getEffectiveArea ( float  eta) const

Definition at line 44 of file EffectiveAreas.cc.

References funct::abs(), absEtaMax_, absEtaMin_, effectiveAreaValues_, PVValHelper::eta, L1TowerCalibrationProducer_cfi::iEta, L1TMuonDQMOffline_cfi::nEtaBins, and parallelization::uint.

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

44  {
45  float effArea = 0;
46  uint nEtaBins = absEtaMin_.size();
47  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
49  effArea = effectiveAreaValues_[iEta];
50  break;
51  }
52  }
53 
54  return effArea;
55 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > absEtaMin_

◆ printEffectiveAreas()

void EffectiveAreas::printEffectiveAreas ( ) const

Definition at line 57 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, filename_, L1TowerCalibrationProducer_cfi::iEta, L1TMuonDQMOffline_cfi::nEtaBins, and parallelization::uint.

57  {
58  printf("EffectiveAreas: source file %s\n", filename_.c_str());
59  printf(" eta_min eta_max effective area\n");
60  uint nEtaBins = absEtaMin_.size();
61  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
62  printf(" %8.4f %8.4f %8.5f\n", absEtaMin_[iEta], absEtaMax_[iEta], effectiveAreaValues_[iEta]);
63  }
64 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
const std::string filename_

Member Data Documentation

◆ absEtaMax_

std::vector<float> EffectiveAreas::absEtaMax_
private

◆ absEtaMin_

std::vector<float> EffectiveAreas::absEtaMin_
private

◆ effectiveAreaValues_

std::vector<float> EffectiveAreas::effectiveAreaValues_
private

◆ filename_

const std::string EffectiveAreas::filename_
private

Definition at line 21 of file EffectiveAreas.h.

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