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 bool quadraticEAflag=false)
 
const float getEffectiveArea (float eta) const
 
const float getLinearEA (float eta) const
 
const float getQuadraticEA (float eta) const
 
void printEffectiveAreas () const
 

Private Attributes

std::vector< float > absEtaMax_
 
std::vector< float > absEtaMin_
 
std::vector< float > effectiveAreaValues_
 
const std::string filename_
 
std::vector< float > linearEffectiveAreaValues_
 
const bool quadraticEAflag_
 
std::vector< float > quadraticEffectiveAreaValues_
 

Detailed Description

Definition at line 7 of file EffectiveAreas.h.

Constructor & Destructor Documentation

◆ EffectiveAreas()

EffectiveAreas::EffectiveAreas ( const std::string &  filename,
const bool  quadraticEAflag = false 
)

Definition at line 9 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, checkConsistency(), effectiveAreaValues_, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, Exception, filename_, makeListRunsInFiles::inputFile, mps_splice::line, linearEffectiveAreaValues_, quadraticEAflag_, quadraticEffectiveAreaValues_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and trackerHitRTTI::undef.

10  : filename_(filename), quadraticEAflag_(quadraticEAflag) {
11  // Open the file with the effective area constants
12  std::ifstream inputFile;
13  inputFile.open(filename_.c_str());
14  if (!inputFile.is_open())
15  throw cms::Exception("EffectiveAreas config failure") << "failed to open the file " << filename_ << std::endl;
16 
17  // Read file line by line
19  const float undef = -999;
20 
21  if (!quadraticEAflag_) {
22  while (getline(inputFile, line)) {
23  if (line[0] == '#')
24  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  }
42 
43  else {
44  while (getline(inputFile, line)) {
45  if (line[0] == '#')
46  continue; // skip the comments lines
47 
48  float etaMin = undef, etaMax = undef;
49  float linEffArea = undef, quadEffArea = undef;
50 
51  std::stringstream ss(line);
52 
53  ss >> etaMin >> etaMax >> linEffArea >> quadEffArea;
54 
55  // In case if the format is messed up, there are letters
56  // instead of numbers, or not exactly three numbers in the line,
57  // it is likely that one or more of these vars never changed
58  // the original "undef" value:
59  if (etaMin == undef || etaMax == undef || linEffArea == undef || quadEffArea == undef)
60  throw cms::Exception("EffectiveAreas config failure")
61  << "wrong file format, file name " << filename_ << std::endl;
62 
63  absEtaMin_.push_back(etaMin);
64  absEtaMax_.push_back(etaMax);
65  linearEffectiveAreaValues_.push_back(linEffArea);
66  quadraticEffectiveAreaValues_.push_back(quadEffArea);
67  }
68  }
69 
70  // Extra consistency checks are in the function below.
71  // If any of them fail, an exception is thrown.
73 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
const bool quadraticEAflag_
std::vector< float > linearEffectiveAreaValues_
void checkConsistency() const
std::vector< float > quadraticEffectiveAreaValues_
const std::string filename_

Member Function Documentation

◆ checkConsistency()

void EffectiveAreas::checkConsistency ( void  ) const

Definition at line 145 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, Exception, filename_, l1tTowerCalibrationProducer_cfi::iEta, linearEffectiveAreaValues_, L1TMuonDQMOffline_cfi::nEtaBins, quadraticEAflag_, quadraticEffectiveAreaValues_, and parallelization::uint.

Referenced by EffectiveAreas().

145  {
146  // There should be at least one eta range with one constant
147 
148  if (!quadraticEAflag_) {
149  if (effectiveAreaValues_.empty())
150  throw cms::Exception("EffectiveAreas config failure")
151  << "found no effective area constants in the file " << filename_ << std::endl;
152 
153  uint nEtaBins = absEtaMin_.size();
154 
155  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
156  // The low limit should be lower than the upper limit
157  if (!(absEtaMin_[iEta] < absEtaMax_[iEta]))
158  throw cms::Exception("EffectiveAreas config failure")
159  << "eta ranges improperly defined (min>max) in the file" << filename_ << std::endl;
160 
161  // The low limit of the next range should be (near) equal to the
162  // upper limit of the previous range
163  if (iEta != nEtaBins - 1) // don't do the check for the last bin
164  if (!(absEtaMin_[iEta + 1] - absEtaMax_[iEta] < 0.0001))
165  throw cms::Exception("EffectiveAreas config failure")
166  << "eta ranges improperly defined (disjointed) in the file " << filename_ << std::endl;
167 
168  // The effective area should be non-negative number,
169  // and should be less than the whole calorimeter area
170  // eta range -2.5 to 2.5, phi 0 to 2pi => Amax = 5*2*pi ~= 31.4
171  if (!(effectiveAreaValues_[iEta] >= 0 && effectiveAreaValues_[iEta] < 31.4))
172  throw cms::Exception("EffectiveAreas config failure")
173  << "effective area values are too large or negative in the file" << filename_ << std::endl;
174  }
175  }
176 
177  else {
179  throw cms::Exception("EffectiveAreas config failure")
180  << "found no effective area constants (linear and/or quadratic) in the file " << filename_ << std::endl;
181 
182  uint nEtaBins = absEtaMin_.size();
183 
184  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
185  // The low limit should be lower than the upper limit
186  if (!(absEtaMin_[iEta] < absEtaMax_[iEta]))
187  throw cms::Exception("EffectiveAreas config failure")
188  << "eta ranges improperly defined (min>max) in the file" << filename_ << std::endl;
189 
190  // The low limit of the next range should be (near) equal to the
191  // upper limit of the previous range
192  if (iEta != nEtaBins - 1) // don't do the check for the last bin
193  if (!(absEtaMin_[iEta + 1] - absEtaMax_[iEta] < 0.0001))
194  throw cms::Exception("EffectiveAreas config failure")
195  << "eta ranges improperly defined (disjointed) in the file " << filename_ << std::endl;
196 
197  // The linear effective area should be non-negative number,
198  // and should be less than the whole calorimeter area
199  // eta range -2.5 to 2.5, phi 0 to 2pi => Amax = 5*2*pi ~= 31.4
201  throw cms::Exception("EffectiveAreas config failure")
202  << "effective area values are too large or negative in the file" << filename_ << std::endl;
203  }
204  }
205 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
const bool quadraticEAflag_
std::vector< float > linearEffectiveAreaValues_
std::vector< float > quadraticEffectiveAreaValues_
const std::string filename_

◆ getEffectiveArea()

const float EffectiveAreas::getEffectiveArea ( float  eta) const

Definition at line 76 of file EffectiveAreas.cc.

References funct::abs(), absEtaMax_, absEtaMin_, effectiveAreaValues_, PVValHelper::eta, l1tTowerCalibrationProducer_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().

76  {
77  float effArea = 0;
78  uint nEtaBins = absEtaMin_.size();
79  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
81  effArea = effectiveAreaValues_[iEta];
82  break;
83  }
84  }
85 
86  return effArea;
87 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > absEtaMin_

◆ getLinearEA()

const float EffectiveAreas::getLinearEA ( float  eta) const

Definition at line 90 of file EffectiveAreas.cc.

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

Referenced by PhoGenericQuadraticRhoPtScaledCut::operator()().

90  {
91  float linEffArea = 0;
92  uint nEtaBins = absEtaMin_.size();
93 
94  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
96  linEffArea = linearEffectiveAreaValues_[iEta];
97  break;
98  }
99  }
100 
101  return linEffArea;
102 }
std::vector< float > absEtaMax_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > absEtaMin_
std::vector< float > linearEffectiveAreaValues_

◆ getQuadraticEA()

const float EffectiveAreas::getQuadraticEA ( float  eta) const

Definition at line 105 of file EffectiveAreas.cc.

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

Referenced by PhoGenericQuadraticRhoPtScaledCut::operator()().

105  {
106  float quadEffArea = 0;
107  uint nEtaBins = absEtaMin_.size();
108 
109  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
111  quadEffArea = quadraticEffectiveAreaValues_[iEta];
112  break;
113  }
114  }
115 
116  return quadEffArea;
117 }
std::vector< float > absEtaMax_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > absEtaMin_
std::vector< float > quadraticEffectiveAreaValues_

◆ printEffectiveAreas()

void EffectiveAreas::printEffectiveAreas ( ) const

Definition at line 119 of file EffectiveAreas.cc.

References absEtaMax_, absEtaMin_, effectiveAreaValues_, filename_, l1tTowerCalibrationProducer_cfi::iEta, linearEffectiveAreaValues_, L1TMuonDQMOffline_cfi::nEtaBins, quadraticEAflag_, quadraticEffectiveAreaValues_, and parallelization::uint.

119  {
120  printf("EffectiveAreas: source file %s\n", filename_.c_str());
121 
122  if (!quadraticEAflag_) {
123  printf(" eta_min eta_max effective area\n");
124  uint nEtaBins = absEtaMin_.size();
125 
126  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
127  printf(" %8.4f %8.4f %8.5f\n", absEtaMin_[iEta], absEtaMax_[iEta], effectiveAreaValues_[iEta]);
128  }
129  }
130 
131  else {
132  printf(" eta_min eta_max EA linear term EA quadratic term\n");
133  uint nEtaBins = absEtaMin_.size();
134  for (uint iEta = 0; iEta < nEtaBins; iEta++) {
135  printf(" %8.4f %8.4f %8.5f %8.5f\n",
136  absEtaMin_[iEta],
137  absEtaMax_[iEta],
140  }
141  }
142 }
std::vector< float > absEtaMax_
std::vector< float > effectiveAreaValues_
std::vector< float > absEtaMin_
const bool quadraticEAflag_
std::vector< float > linearEffectiveAreaValues_
std::vector< float > quadraticEffectiveAreaValues_
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 23 of file EffectiveAreas.h.

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

◆ linearEffectiveAreaValues_

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

◆ quadraticEAflag_

const bool EffectiveAreas::quadraticEAflag_
private

Definition at line 29 of file EffectiveAreas.h.

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

◆ quadraticEffectiveAreaValues_

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