CMS 3D CMS Logo

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

#include <KKCorrectionFactors.h>

Public Member Functions

float getScale (float genEnergy, float genEta, float simEnergy) const
 
 KKCorrectionFactors (const edm::ParameterSet &pset)
 
 ~KKCorrectionFactors ()
 

Private Attributes

TH3F * h3_
 
bool interpolate3D_
 

Detailed Description

Definition at line 25 of file KKCorrectionFactors.h.

Constructor & Destructor Documentation

◆ KKCorrectionFactors()

KKCorrectionFactors::KKCorrectionFactors ( const edm::ParameterSet pset)

Definition at line 3 of file KKCorrectionFactors.cc.

3  {
4  interpolate3D_ = pset.exists("interpolate3D") && pset.getUntrackedParameter<bool>("interpolate3D");
5 
6  // Get the filename and histogram name
7  std::string fileName = pset.getUntrackedParameter<std::string>("fileName");
8  std::string histogramName = pset.getUntrackedParameter<std::string>("histogramName");
9 
10  // Read histo
11  edm::FileInPath myDataFile(fileName);
12  TFile* myFile = TFile::Open(myDataFile.fullPath().c_str());
13 
14  gROOT->cd(); // create histogram in memory
15  auto obj = myFile->Get(histogramName.c_str());
16 
17  // Check if histogram exists in file
18  if (!obj) {
19  throw cms::Exception("FileReadError")
20  << "Histogram \"" << histogramName << "\" not found in file \"" << fileName << "\".\n";
21  }
22  h3_ = new TH3F(*((TH3F*)obj));
23 
24  delete myFile;
25 }

References Exception, MillePedeFileConverter_cfg::fileName, h3_, ECALResponse_cfi::histogramName, interpolate3D_, getGTfromDQMFile::obj, muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~KKCorrectionFactors()

KKCorrectionFactors::~KKCorrectionFactors ( )
inline

Definition at line 31 of file KKCorrectionFactors.h.

31 { delete h3_; };

References h3_.

Member Function Documentation

◆ getScale()

float KKCorrectionFactors::getScale ( float  genEnergy,
float  genEta,
float  simEnergy 
) const

Definition at line 27 of file KKCorrectionFactors.cc.

27  {
28  float r = simE / genE;
29  float scale = 1.;
30 
31  if (interpolate3D_
32  // TH3::Interpolate can only interpolate inside the bondaries of the histogram
33  && genE > h3_->GetXaxis()->GetXmin() && genE < h3_->GetXaxis()->GetXmax() &&
34  genEta > h3_->GetYaxis()->GetXmin() && genEta < h3_->GetYaxis()->GetXmax() && r < h3_->GetZaxis()->GetXmax() &&
35  r > h3_->GetZaxis()->GetXmax()) {
36  scale = h3_->Interpolate(genE, genEta, r);
37 
38  } else { // interpolation in r is mandatory
39 
40  int binE = h3_->GetXaxis()->FindFixBin(genE);
41  int binEta = h3_->GetYaxis()->FindFixBin(genEta);
42 
43  // find the two bins which are closest to the actual value
44  auto binWidthR = h3_->GetZaxis()->GetBinWidth(0);
45  int binRup = h3_->GetZaxis()->FindFixBin(r + binWidthR / 2.);
46  int binRdn = h3_->GetZaxis()->FindFixBin(r - binWidthR / 2.);
47 
48  auto scaleUp = h3_->GetBinContent(binE, binEta, binRup);
49  auto scaleDn = h3_->GetBinContent(binE, binEta, binRdn);
50 
51  // make a linear extrapolation between neighbour bins if they are not zero
52  auto Rdn = h3_->GetZaxis()->GetBinCenter(binRdn);
53  scale = scaleDn + (scaleUp - scaleDn) * (r - Rdn) / binWidthR;
54  }
55  return scale;
56 }

References h3_, interpolate3D_, alignCSCRings::r, and L1EGammaCrystalsEmulatorProducer_cfi::scale.

Member Data Documentation

◆ h3_

TH3F* KKCorrectionFactors::h3_
private

Definition at line 37 of file KKCorrectionFactors.h.

Referenced by getScale(), KKCorrectionFactors(), and ~KKCorrectionFactors().

◆ interpolate3D_

bool KKCorrectionFactors::interpolate3D_
private

Definition at line 38 of file KKCorrectionFactors.h.

Referenced by getScale(), and KKCorrectionFactors().

L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
ECALResponse_cfi.histogramName
histogramName
Definition: ECALResponse_cfi.py:6
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
KKCorrectionFactors::h3_
TH3F * h3_
Definition: KKCorrectionFactors.h:37
edm::FileInPath
Definition: FileInPath.h:61
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
Exception
Definition: hltDiff.cc:245
KKCorrectionFactors::interpolate3D_
bool interpolate3D_
Definition: KKCorrectionFactors.h:38
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27