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::EffectiveAreas ( const std::string &  filename)

Definition at line 9 of file EffectiveAreas.cc.

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 }

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.

Member Function Documentation

◆ checkConsistency()

void EffectiveAreas::checkConsistency ( void  ) const

Definition at line 67 of file EffectiveAreas.cc.

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 }

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

Referenced by EffectiveAreas().

◆ getEffectiveArea()

const float EffectiveAreas::getEffectiveArea ( float  eta) const

◆ printEffectiveAreas()

void EffectiveAreas::printEffectiveAreas ( ) const

Definition at line 57 of file EffectiveAreas.cc.

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 }

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

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

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

ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
trackerHitRTTI::undef
Definition: trackerHitRTTI.h:9
parallelization.uint
uint
Definition: parallelization.py:124
EffectiveAreas::absEtaMax_
std::vector< float > absEtaMax_
Definition: EffectiveAreas.h:24
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
PVValHelper::eta
Definition: PVValidationHelpers.h:69
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EffectiveAreas::effectiveAreaValues_
std::vector< float > effectiveAreaValues_
Definition: EffectiveAreas.h:25
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
EffectiveAreas::absEtaMin_
std::vector< float > absEtaMin_
Definition: EffectiveAreas.h:23
L1TMuonDQMOffline_cfi.nEtaBins
nEtaBins
Definition: L1TMuonDQMOffline_cfi.py:21
Exception
Definition: hltDiff.cc:246
EffectiveAreas::checkConsistency
void checkConsistency() const
Definition: EffectiveAreas.cc:67
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
EffectiveAreas::filename_
const std::string filename_
Definition: EffectiveAreas.h:22
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
mps_splice.line
line
Definition: mps_splice.py:76