ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CP::HistHandler_TH3 Class Reference

#include <HistHandler.h>

Inheritance diagram for CP::HistHandler_TH3:
Collaboration diagram for CP::HistHandler_TH3:

Public Member Functions

 HistHandler_TH3 (TH1 *hist)
 The HistHandler TH3 handles 3D histograms, since TH3 inhertis from TH1,a TH1* object is parsed avoiding the dynamic cast. More...
 
 HistHandler_TH3 (const HistHandler_TH3 &other)
 
virtual HistHandler_TH3operator= (const HistHandler_TH3 &other)
 
virtual ~HistHandler_TH3 ()
 
int nBins () const override
 Return the total number of bins in the histogram -> (GetNbins() +2)**n. More...
 
int nOverFlowBins () const override
 Return the number of overflow bins. More...
 
bool isOverFlowBin (int b) const override
 States whether a bin is overflow or not. More...
 
std::string GetBinName (unsigned int bin) const override
 Translates the bin number into the borders and return them as name. More...
 
CorrectionCode FindBin (const xAOD::Muon &muon, int &bin) const override
 Function that changes from Implementation to implementation. More...
 
double GetBinContent (int bin) const
 
void SetBinContent (int bin, float val)
 
double GetBinError (int bin) const
 
TH1GetHist () const
 
void SetBinError (int bin, float val)
 

Protected Member Functions

void Copy (const HistHandler &other)
 

Private Attributes

std::unique_ptr< AxisHandlerm_x_handler
 
std::unique_ptr< AxisHandlerm_y_handler
 
std::unique_ptr< AxisHandlerm_z_handler
 
std::unique_ptr< TH1m_H
 

Detailed Description

Definition at line 133 of file HistHandler.h.

Constructor & Destructor Documentation

◆ HistHandler_TH3() [1/2]

CP::HistHandler_TH3::HistHandler_TH3 ( TH1 hist)

The HistHandler TH3 handles 3D histograms, since TH3 inhertis from TH1,a TH1* object is parsed avoiding the dynamic cast.

Via the GetDimension() method of the TH1 the class ensures that the histogram has actual dimension 3. No specific TH3 method is required in all use-caes of the class.

Definition at line 263 of file HistHandler.cxx.

263  :
264  HistHandler(h),
265  m_x_handler(GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(h->GetXaxis())),
266  m_y_handler(GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(h->GetYaxis())),
267  m_z_handler(GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(h->GetZaxis())) {
268 
269  }

◆ HistHandler_TH3() [2/2]

CP::HistHandler_TH3::HistHandler_TH3 ( const HistHandler_TH3 other)

Definition at line 270 of file HistHandler.cxx.

270  :
272  m_x_handler(other.GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(other.GetHist()->GetXaxis())),
273  m_y_handler(other.GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(other.GetHist()->GetYaxis())),
274  m_z_handler(other.GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(other.GetHist()->GetZaxis())) {
275 
276  }

◆ ~HistHandler_TH3()

CP::HistHandler_TH3::~HistHandler_TH3 ( )
virtual

Definition at line 277 of file HistHandler.cxx.

277  {
278  }

Member Function Documentation

◆ Copy()

void HistHandler::Copy ( const HistHandler other)
protectedinherited

Definition at line 126 of file HistHandler.cxx.

126  {
127  if (this == &other) {
128  return;
129  }
130  if (other.m_H) {
131  m_H = clone(other.GetHist());
132  }
133  }

◆ FindBin()

CorrectionCode CP::HistHandler_TH3::FindBin ( const xAOD::Muon muon,
int &  bin 
) const
overridevirtual

Function that changes from Implementation to implementation.

Implements CP::HistHandler.

Definition at line 302 of file HistHandler.cxx.

302  {
303  if (!GetHist()) return CorrectionCode::Error;
304  float parx = 0;
305  float pary = 0;
306  float parz = 0;
307  if (m_x_handler->GetBinningParameter(muon, parx) == CorrectionCode::Error ||
308  m_y_handler->GetBinningParameter(muon, pary) == CorrectionCode::Error ||
309  m_z_handler->GetBinningParameter(muon, parz) == CorrectionCode::Error) return CorrectionCode::Error;
310  else {
311  int binx = GetHist()->GetXaxis()->FindBin(parx);
312  int biny = GetHist()->GetYaxis()->FindBin(pary);
313  int binz = GetHist()->GetZaxis()->FindBin(parz);
314  if (binx < 1 || binx > GetHist()->GetNbinsX() || biny < 1 || biny > GetHist()->GetNbinsY() || binz < 1 || binz > GetHist()->GetNbinsZ()) {
316  }
317  bin = GetHist()->GetBin(binx, biny, binz);
318  }
319  return CorrectionCode::Ok;
320  }

◆ GetBinContent()

double CP::HistHandler::GetBinContent ( int  bin) const
inlineinherited

Definition at line 46 of file HistHandler.h.

46  {
47  if (!m_H) return DBL_MAX;
48  return m_H->GetBinContent(bin);
49  }

◆ GetBinError()

double CP::HistHandler::GetBinError ( int  bin) const
inlineinherited

Definition at line 53 of file HistHandler.h.

53  {
54  if (!m_H) return DBL_MAX;
55  return m_H->GetBinError(bin);
56  }

◆ GetBinName()

std::string CP::HistHandler_TH3::GetBinName ( unsigned int  bin) const
overridevirtual

Translates the bin number into the borders and return them as name.

Implements CP::HistHandler.

Definition at line 322 of file HistHandler.cxx.

322  {
323  int x(0), y(0), z(0);
324  GetHist()->GetBinXYZ(bin, x, y, z);
325  TAxis* xAx = GetHist()->GetXaxis();
326  TAxis* yAx = GetHist()->GetYaxis();
327  TAxis* zAx = GetHist()->GetZaxis();
328  return Form("%s_%.2f_to_%.2f_times_%s_%.2f_to_%.2f_times_%s_%.2f_to_%.2f",
329  //xAxis
330  xAx->GetTitle(), xAx->GetBinLowEdge(x), xAx->GetBinUpEdge(x),
331  //yAxis
332  yAx->GetTitle(), yAx->GetBinLowEdge(y), yAx->GetBinUpEdge(y),
333  //zAxis
334  zAx->GetTitle(), zAx->GetBinLowEdge(z), zAx->GetBinUpEdge(z));
335  }

◆ GetHist()

TH1* CP::HistHandler::GetHist ( ) const
inlineinherited

Definition at line 58 of file HistHandler.h.

58  {
59  return m_H.get();
60  }

◆ isOverFlowBin()

bool CP::HistHandler_TH3::isOverFlowBin ( int  b) const
overridevirtual

States whether a bin is overflow or not.

Implements CP::HistHandler.

Definition at line 295 of file HistHandler.cxx.

295  {
296  int x(-1),y(-1), z(-1);
297  GetHist()->GetBinXYZ(b,x,y,z);
298  return x == 0 || x == GetHist()->GetXaxis()->GetNbins() + 1 ||
299  y == 0 || y == GetHist()->GetYaxis()->GetNbins() + 1 ||
300  z == 0 || z == GetHist()->GetZaxis()->GetNbins() + 1;
301  }

◆ nBins()

int CP::HistHandler_TH3::nBins ( ) const
overridevirtual

Return the total number of bins in the histogram -> (GetNbins() +2)**n.

Implements CP::HistHandler.

Definition at line 289 of file HistHandler.cxx.

289  {
290  return (GetHist()->GetNbinsX() + 2) * (GetHist()->GetNbinsY() + 2) * (GetHist()->GetNbinsZ() + 2);
291  }

◆ nOverFlowBins()

int CP::HistHandler_TH3::nOverFlowBins ( ) const
overridevirtual

Return the number of overflow bins.

Implements CP::HistHandler.

Definition at line 292 of file HistHandler.cxx.

292  {return 2*(GetHist()->GetNbinsX()*GetHist()->GetNbinsY() +
293  GetHist()->GetNbinsX()*GetHist()->GetNbinsZ() +
294  GetHist()->GetNbinsY()*GetHist()->GetNbinsZ()) + 8; }

◆ operator=()

HistHandler_TH3 & CP::HistHandler_TH3::operator= ( const HistHandler_TH3 other)
virtual

Definition at line 279 of file HistHandler.cxx.

279  {
280  if (this == &other) {
281  return *this;
282  }
283  Copy(other);
284  m_x_handler = std::unique_ptr<AxisHandler>(other.GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(other.GetHist()->GetXaxis()));
285  m_y_handler = std::unique_ptr<AxisHandler>(other.GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(other.GetHist()->GetYaxis()));
286  m_z_handler = std::unique_ptr<AxisHandler>(other.GetHist() == nullptr ? 0 : AxisHandlerProvider::GetAxisHandler(other.GetHist()->GetZaxis()));
287  return *this;
288  }

◆ SetBinContent()

void HistHandler::SetBinContent ( int  bin,
float  val 
)
inherited

Definition at line 140 of file HistHandler.cxx.

140  {
141  if (m_H) {
142  m_H->SetBinContent(bin, val);
143  }
144  }

◆ SetBinError()

void HistHandler::SetBinError ( int  bin,
float  val 
)
inherited

Definition at line 145 of file HistHandler.cxx.

145  {
146  if (m_H) {
147  m_H->SetBinError(bin, val);
148  }
149  }

Member Data Documentation

◆ m_H

std::unique_ptr<TH1> CP::HistHandler::m_H
privateinherited

Definition at line 81 of file HistHandler.h.

◆ m_x_handler

std::unique_ptr<AxisHandler> CP::HistHandler_TH3::m_x_handler
private

Definition at line 156 of file HistHandler.h.

◆ m_y_handler

std::unique_ptr<AxisHandler> CP::HistHandler_TH3::m_y_handler
private

Definition at line 157 of file HistHandler.h.

◆ m_z_handler

std::unique_ptr<AxisHandler> CP::HistHandler_TH3::m_z_handler
private

Definition at line 158 of file HistHandler.h.


The documentation for this class was generated from the following files:
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
CP::HistHandler::Copy
void Copy(const HistHandler &other)
Definition: HistHandler.cxx:126
bin
Definition: BinsDiffFromStripMedian.h:43
x
#define x
CP::HistHandler_TH3::m_y_handler
std::unique_ptr< AxisHandler > m_y_handler
Definition: HistHandler.h:157
CP::HistHandler::HistHandler
HistHandler(TH1 *Hist)
Definition: HistHandler.cxx:122
CP::clone
std::unique_ptr< TH1 > clone(TH1 *H)
Clones a TH1 and handles the ownership then to a unique_ptr.
Definition: PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/UtilFunctions.cxx:43
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
CP::HistHandler::GetHist
TH1 * GetHist() const
Definition: HistHandler.h:58
CP::HistHandler_TH3::m_z_handler
std::unique_ptr< AxisHandler > m_z_handler
Definition: HistHandler.h:158
z
#define z
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
y
#define y
h
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
CP::AxisHandlerProvider::GetAxisHandler
static std::unique_ptr< AxisHandler > GetAxisHandler(const TAxis *axis)
Definition: HistHandler.cxx:20
CP::HistHandler_TH3::m_x_handler
std::unique_ptr< AxisHandler > m_x_handler
Definition: HistHandler.h:156
CP::HistHandler::m_H
std::unique_ptr< TH1 > m_H
Definition: HistHandler.h:81