ATLAS Offline Software
Public Member Functions | Protected Attributes | List of all members
MCP::CalibContainer Class Reference

#include <CalibContainer.h>

Collaboration diagram for MCP::CalibContainer:

Public Member Functions

 CalibContainer (const std::string &fileName, const std::string &histName)
 
double getCalibConstant (const TrackCalibObj &trk) const
 

Protected Attributes

std::unique_ptr< const TH1 > m_calibConstantHist
 
double m_maxX {-1}
 
double m_minX {-1}
 
double m_maxY {-1}
 
double m_minY {-1}
 

Detailed Description

Definition at line 19 of file CalibContainer.h.

Constructor & Destructor Documentation

◆ CalibContainer()

MCP::CalibContainer::CalibContainer ( const std::string &  fileName,
const std::string &  histName 
)

Definition at line 18 of file CalibContainer.cxx.

19  {
20 
21  if (inFileName.empty()) throw std::invalid_argument("fileName arguments must be non empty");
22  if (histName.empty()) throw std::invalid_argument("histName arguments must be non empty");
23 
25 
26  std::unique_ptr<TFile> fmc{TFile::Open(fileName.c_str(), "READ")};
27  if (!fmc || !fmc->IsOpen())
28  {
29  throw std::invalid_argument("Cannot open file " + fileName);
30  }
31 
32  TH2* hist = nullptr;
33  fmc->GetObject(histName.c_str(), hist);
34  if (!hist)
35  {
36  throw std::invalid_argument("Cannot find hist ("+histName+") in file " + fileName);
37  }
38  hist->SetDirectory(nullptr);
40 
41  // Store to check later if the input ranges are within the range of the hist
42  // subtract epsilon so that it doesn't go into the overflow bin at the highest edge
43  m_maxX = m_calibConstantHist->GetXaxis()->GetXmax() - std::numeric_limits<double>::epsilon();
44  m_minX = m_calibConstantHist->GetXaxis()->GetXmin() + std::numeric_limits<double>::epsilon();
45  m_maxY = m_calibConstantHist->GetYaxis()->GetXmax() - std::numeric_limits<double>::epsilon();
46  m_minY = m_calibConstantHist->GetYaxis()->GetXmin() + std::numeric_limits<double>::epsilon();
47 
48  }

Member Function Documentation

◆ getCalibConstant()

double MCP::CalibContainer::getCalibConstant ( const TrackCalibObj trk) const

Definition at line 50 of file CalibContainer.cxx.

51  {
52  // If outside the range, use the last bin in either direction
53  const int binEta = m_calibConstantHist->GetXaxis()->FindFixBin(std::max(std::min(trk.eta,m_maxX),m_minX));
54  const int binPhi = m_calibConstantHist->GetYaxis()->FindFixBin(std::max(std::min(trk.phi,m_maxY),m_minY));
55 
56  int gbin = m_calibConstantHist->GetBin(binEta, binPhi);
57 
58  return m_calibConstantHist->GetBinContent(gbin);
59  }

Member Data Documentation

◆ m_calibConstantHist

std::unique_ptr<const TH1> MCP::CalibContainer::m_calibConstantHist
protected

Definition at line 28 of file CalibContainer.h.

◆ m_maxX

double MCP::CalibContainer::m_maxX {-1}
protected

Definition at line 29 of file CalibContainer.h.

◆ m_maxY

double MCP::CalibContainer::m_maxY {-1}
protected

Definition at line 31 of file CalibContainer.h.

◆ m_minX

double MCP::CalibContainer::m_minX {-1}
protected

Definition at line 30 of file CalibContainer.h.

◆ m_minY

double MCP::CalibContainer::m_minY {-1}
protected

Definition at line 32 of file CalibContainer.h.


The documentation for this class was generated from the following files:
max
#define max(a, b)
Definition: cfImp.cxx:41
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
plotmaker.hist
hist
Definition: plotmaker.py:148
Trk::binEta
@ binEta
Definition: BinningType.h:54
MCP::CalibContainer::m_minX
double m_minX
Definition: CalibContainer.h:30
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
IDTPMcnv.inFileName
inFileName
Definition: IDTPMcnv.py:16
min
#define min(a, b)
Definition: cfImp.cxx:40
MCP::CalibContainer::m_maxY
double m_maxY
Definition: CalibContainer.h:31
MCP::CalibContainer::m_minY
double m_minY
Definition: CalibContainer.h:32
MCP::CalibContainer::m_maxX
double m_maxX
Definition: CalibContainer.h:29
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
Trk::binPhi
@ binPhi
Definition: BinningType.h:51
MCP::CalibContainer::m_calibConstantHist
std::unique_ptr< const TH1 > m_calibConstantHist
Definition: CalibContainer.h:28