Crombie Tools
Corrector Class Reference

Can be created using the CrombieTools.SkimmingTools.Corrector module. More...

#include <Corrector.h>

+ Inheritance diagram for Corrector:

Public Types

enum  HistReader { eValue = 0, eZeroCenteredUnc, eUnityCenteredUnc }
 Used to set the way to read the correction histogram. More...
 
- Public Types inherited from Debug
enum  DebugLevel { eQuiet = 0, eError, eInfo, eDebug }
 Different possible debug levels. More...
 

Public Member Functions

 Corrector (TString name="correction")
 Constructor setting the name of a branch it would like to write to. More...
 
virtual ~Corrector ()
 
void AddInExpression (TString expres)
 Add an expression to read from the histogram. More...
 
Bool_t CompareFileName (TString fileName)
 Compares the file name to the Regex and returns true if corrections will be applied. More...
 
virtual CorrectorCopy ()
 Copy this Corrector for parallelization. More...
 
Float_t Evaluate ()
 Evaluate the TTree pointer fInTree at its current entry. More...
 
std::pair< bool, Float_t > EvaluateWithFlag ()
 Evaluate the TTree pointer fInTree at its current entry and return a status bit corresponding to cut. More...
 
virtual std::vector< TString > GetFormulas ()
 Gets the list of formulas that this corrector is using. More...
 
TString GetName () const
 Get the name of the branch that this Corrector would like to write to. More...
 
void SetBinning (UInt_t num, Double_t min, Double_t max)
 Set the binning when the histograms do not store the correct x values. More...
 
void SetCorrectionFile (TString fileName)
 Set the file containing the correction histogram by name. More...
 
void SetCorrectionHist (TString histName)
 Set the correction histogram name within the correction file. More...
 
void SetCorrectionHist (TString hist1, TString hist2)
 Set two histograms to divide in order to obtain the correction histogram. More...
 
void SetHistReader (HistReader reader)
 Set the type of histogram reader. More...
 
void SetInCut (TString cut)
 Set a cut for the corrector. More...
 
virtual void SetInTree (TTree *tree)
 Set the pointer to the TTree this Corrector is reading. More...
 
void SetMatchFileName (TString regexpr)
 Set a RegEx for the Corrector to check against the filename. If no match, corrections are not applied. More...
 
- Public Member Functions inherited from Debug
 Debug ()
 
virtual ~Debug ()
 
DebugLevel GetDebugLevel ()
 Gets the verbosity for a class. More...
 
template<typename T , typename... V>
void Message (DebugLevel level, T message, V... more)
 Sends a message if the verbosity level is appropriate. More...
 
void Message (DebugLevel level)
 
void SetDebugLevel (DebugLevel level)
 Sets the verbosity for a class. More...
 

Public Attributes

bool Merge = true
 Flag determining whether or not to merge into the CorrectorApplicator branch. More...
 

Protected Member Functions

virtual Float_t DoEval ()
 Function that actually does the evaluation of the correction factor. More...
 
Double_t GetFormulaResult (Int_t index, Bool_t use_mins=true)
 Evaluate one of the formulae. If use_lims, then don't give a result that would go off the relevant axis. More...
 
Int_t GetNumDims ()
 Get the number of dimensions that the formulas hold. More...
 
void InitializeTree ()
 Function to initialize TTreeFormula on the tree. More...
 
- Protected Member Functions inherited from Debug
void DisplayFunc (const char *func)
 Sends the name of the function during debuggin. More...
 

Protected Attributes

TTreeFormula * fCutFormula = NULL
 Formula for cut. More...
 
TString fInCut = "1"
 Corrector cut. More...
 
TTree * fInTree = NULL
 Pointer to tree being read. More...
 
Bool_t fIsCopy = false
 Track if instance is a copy. More...
 
Bool_t fMatchedFileName
 A flag telling this corrector if the file has been matched. More...
 
TString fName
 Name of branch to write to. More...
 

Private Member Functions

void SetMinMax ()
 Set the mininum and maximum values for each histogram axis. More...
 

Private Attributes

Double_t bin_max = 0
 
Double_t bin_min = 0
 
UInt_t bin_num = 0
 Used if the binning of the histograms is off. More...
 
TFile * fCorrectionFile = NULL
 Name of file containing correction histogram. More...
 
TH1 * fCorrectionHist = NULL
 Name of correction histogram. More...
 
std::vector< TTreeFormula * > fFormulas
 Formulae of fInExpressions. More...
 
HistReader fHistReader = eValue
 The method to reading histograms. More...
 
std::vector< TString > fInExpressions
 Expressions to read from tree. More...
 
TString fMatchFileName = ""
 
std::vector< Double_t > fMaxs
 Maximum possible values of each axis. More...
 
std::vector< Double_t > fMins
 Minimum possible values of each axis. More...
 
Int_t fNumDims = 0
 Number of dimensions in the correction histogram. More...
 

Detailed Description

Can be created using the CrombieTools.SkimmingTools.Corrector module.

A Corrector reads from a tree and histogram and returns a correction factor. The CorrectorApplicator facilitates this application by providing the trees and writes the result to a branch.

Definition at line 32 of file Corrector.h.

Member Enumeration Documentation

§ HistReader

Used to set the way to read the correction histogram.

Note that the uncertainty is added in quadrature, so the unity-centered uncertainty can safely be used for both up and down histograms.

Enumerator
eValue 

Simply returns the value of the histogram.

eZeroCenteredUnc 

The fractional uncertainty is just the value of the histogram.

eUnityCenteredUnc 

For when reading an uncertainty from a histogram where the perfect precision would be at unity.

Definition at line 80 of file Corrector.h.

Constructor & Destructor Documentation

§ Corrector()

Corrector::Corrector ( TString  name = "correction")

Constructor setting the name of a branch it would like to write to.

Referenced by Copy().

§ ~Corrector()

Corrector::~Corrector ( )
virtual

Definition at line 23 of file Corrector.cc.

References fCorrectionFile, fCutFormula, fFormulas, and fIsCopy.

Member Function Documentation

§ AddInExpression()

void Corrector::AddInExpression ( TString  expres)
inline

Add an expression to read from the histogram.

In most normal uses (reading from a TH1) this function needs to only be called once. If reading from a 2D histogram, call it twice. This gets the bin contents in the order that the expressions were added. Up to 3D histograms is supported.

Definition at line 66 of file Corrector.h.

References fInExpressions, and fNumDims.

Referenced by TMVACorrector::ReadVarConfig().

§ CompareFileName()

Bool_t Corrector::CompareFileName ( TString  fileName)

Compares the file name to the Regex and returns true if corrections will be applied.

Definition at line 185 of file Corrector.cc.

References fMatchedFileName, and fMatchFileName.

§ Copy()

Corrector * Corrector::Copy ( )
virtual

Copy this Corrector for parallelization.

Reimplemented in TwoScaleFactorCorrector, TMVACorrector, and FormulaCorrector.

Definition at line 211 of file Corrector.cc.

References Corrector(), fIsCopy, and CrombieTools.SkimmingTools.Corrector::newCorrector.

§ DoEval()

Float_t Corrector::DoEval ( )
protectedvirtual

Function that actually does the evaluation of the correction factor.

Reimplemented in TwoScaleFactorCorrector, FormulaCorrector, and TMVACorrector.

Definition at line 98 of file Corrector.cc.

References bin_max, bin_min, bin_num, fCorrectionHist, fNumDims, and GetFormulaResult().

Referenced by EvaluateWithFlag().

§ Evaluate()

Float_t Corrector::Evaluate ( )

Evaluate the TTree pointer fInTree at its current entry.

Returns
value of correction histogram using the expressions added through AddInExpression(), unless the event does not pass the cut set by SetInCut(). In that case, a default value is returned (depending on if it's a scale factor or an uncertainty).

Definition at line 154 of file Corrector.cc.

References EvaluateWithFlag().

§ EvaluateWithFlag()

std::pair< bool, Float_t > Corrector::EvaluateWithFlag ( )

Evaluate the TTree pointer fInTree at its current entry and return a status bit corresponding to cut.

Returns
value of correction histogram using the expressions added through AddInExpression(), unless the event does not pass the cut set by SetInCut(). In that case, a default value is returned (depending on if it's a scale factor or an uncertainty). First part of the pair is a bool determining whether or not that cut was passed

Definition at line 128 of file Corrector.cc.

References DoEval(), eUnityCenteredUnc, eZeroCenteredUnc, fCutFormula, fHistReader, fInTree, and fMatchedFileName.

Referenced by Evaluate().

§ GetFormulaResult()

Double_t Corrector::GetFormulaResult ( Int_t  index,
Bool_t  use_mins = true 
)
protected

Evaluate one of the formulae. If use_lims, then don't give a result that would go off the relevant axis.

Definition at line 80 of file Corrector.cc.

References bin_max, bin_min, bin_num, fFormulas, fMaxs, and fMins.

Referenced by TMVACorrector::DoEval(), and DoEval().

§ GetFormulas()

std::vector< TString > Corrector::GetFormulas ( )
virtual

Gets the list of formulas that this corrector is using.

Reimplemented in TwoScaleFactorCorrector, and FormulaCorrector.

Definition at line 219 of file Corrector.cc.

References fInCut, and fInExpressions.

Referenced by FormulaCorrector::GetFormulas(), and SetInTree().

§ GetName()

TString Corrector::GetName ( ) const
inline

Get the name of the branch that this Corrector would like to write to.

Definition at line 58 of file Corrector.h.

References fName.

§ GetNumDims()

Int_t Corrector::GetNumDims ( )
inlineprotected

Get the number of dimensions that the formulas hold.

Definition at line 112 of file Corrector.h.

References fNumDims.

Referenced by TMVACorrector::Copy(), and TMVACorrector::DoEval().

§ InitializeTree()

void Corrector::InitializeTree ( )
protected

Function to initialize TTreeFormula on the tree.

Definition at line 162 of file Corrector.cc.

References fCutFormula, fFormulas, fInCut, fInExpressions, and fInTree.

Referenced by SetInTree().

§ SetBinning()

void Corrector::SetBinning ( UInt_t  num,
Double_t  min,
Double_t  max 
)
inline

Set the binning when the histograms do not store the correct x values.

Definition at line 95 of file Corrector.h.

References bin_max, bin_min, and bin_num.

§ SetCorrectionFile()

void Corrector::SetCorrectionFile ( TString  fileName)

Set the file containing the correction histogram by name.

Definition at line 36 of file Corrector.cc.

References Debug::eError, fCorrectionFile, and Debug::Message().

§ SetCorrectionHist() [1/2]

void Corrector::SetCorrectionHist ( TString  histName)

Set the correction histogram name within the correction file.

Definition at line 46 of file Corrector.cc.

References Debug::eError, fCorrectionFile, fCorrectionHist, Debug::Message(), and SetMinMax().

§ SetCorrectionHist() [2/2]

void Corrector::SetCorrectionHist ( TString  hist1,
TString  hist2 
)

Set two histograms to divide in order to obtain the correction histogram.

Definition at line 58 of file Corrector.cc.

References Debug::eError, fCorrectionFile, fCorrectionHist, Debug::Message(), and SetMinMax().

§ SetHistReader()

void Corrector::SetHistReader ( HistReader  reader)
inline

Set the type of histogram reader.

Definition at line 87 of file Corrector.h.

References fHistReader.

§ SetInCut()

void Corrector::SetInCut ( TString  cut)
inline

Set a cut for the corrector.

Definition at line 68 of file Corrector.h.

References fInCut.

§ SetInTree()

virtual void Corrector::SetInTree ( TTree *  tree)
inlinevirtual

Set the pointer to the TTree this Corrector is reading.

Reimplemented in TwoScaleFactorCorrector, and FormulaCorrector.

Definition at line 70 of file Corrector.h.

References fInTree, GetFormulas(), and InitializeTree().

Referenced by FormulaCorrector::SetInTree(), and TwoScaleFactorCorrector::SetInTree().

§ SetMatchFileName()

void Corrector::SetMatchFileName ( TString  regexpr)
inline

Set a RegEx for the Corrector to check against the filename. If no match, corrections are not applied.

Definition at line 90 of file Corrector.h.

References fMatchFileName.

§ SetMinMax()

void Corrector::SetMinMax ( )
private

Set the mininum and maximum values for each histogram axis.

Definition at line 191 of file Corrector.cc.

References Debug::eError, fCorrectionHist, fMaxs, fMins, fNumDims, and Debug::Message().

Referenced by SetCorrectionHist().

Member Data Documentation

§ bin_max

Double_t Corrector::bin_max = 0
private

Definition at line 128 of file Corrector.h.

Referenced by DoEval(), GetFormulaResult(), and SetBinning().

§ bin_min

Double_t Corrector::bin_min = 0
private

Definition at line 127 of file Corrector.h.

Referenced by DoEval(), GetFormulaResult(), and SetBinning().

§ bin_num

UInt_t Corrector::bin_num = 0
private

Used if the binning of the histograms is off.

Definition at line 126 of file Corrector.h.

Referenced by DoEval(), GetFormulaResult(), and SetBinning().

§ fCorrectionFile

TFile* Corrector::fCorrectionFile = NULL
private

Name of file containing correction histogram.

Definition at line 115 of file Corrector.h.

Referenced by SetCorrectionFile(), SetCorrectionHist(), and ~Corrector().

§ fCorrectionHist

TH1* Corrector::fCorrectionHist = NULL
private

Name of correction histogram.

Definition at line 116 of file Corrector.h.

Referenced by DoEval(), SetCorrectionHist(), and SetMinMax().

§ fCutFormula

TTreeFormula* Corrector::fCutFormula = NULL
protected

Formula for cut.

Definition at line 105 of file Corrector.h.

Referenced by EvaluateWithFlag(), InitializeTree(), and ~Corrector().

§ fFormulas

std::vector<TTreeFormula*> Corrector::fFormulas
private

Formulae of fInExpressions.

Definition at line 121 of file Corrector.h.

Referenced by GetFormulaResult(), InitializeTree(), and ~Corrector().

§ fHistReader

HistReader Corrector::fHistReader = eValue
private

The method to reading histograms.

Definition at line 124 of file Corrector.h.

Referenced by EvaluateWithFlag(), and SetHistReader().

§ fInCut

TString Corrector::fInCut = "1"
protected

Corrector cut.

Definition at line 104 of file Corrector.h.

Referenced by GetFormulas(), InitializeTree(), and SetInCut().

§ fInExpressions

std::vector<TString> Corrector::fInExpressions
private

Expressions to read from tree.

Definition at line 120 of file Corrector.h.

Referenced by AddInExpression(), GetFormulas(), and InitializeTree().

§ fInTree

TTree* Corrector::fInTree = NULL
protected

Pointer to tree being read.

Definition at line 103 of file Corrector.h.

Referenced by EvaluateWithFlag(), InitializeTree(), FormulaCorrector::SetInTree(), and SetInTree().

§ fIsCopy

Bool_t Corrector::fIsCopy = false
protected

Track if instance is a copy.

Definition at line 106 of file Corrector.h.

Referenced by FormulaCorrector::Copy(), TMVACorrector::Copy(), Copy(), TwoScaleFactorCorrector::Copy(), and ~Corrector().

§ fMatchedFileName

Bool_t Corrector::fMatchedFileName
protected

A flag telling this corrector if the file has been matched.

Definition at line 107 of file Corrector.h.

Referenced by CompareFileName(), and EvaluateWithFlag().

§ fMatchFileName

TString Corrector::fMatchFileName = ""
private

Definition at line 130 of file Corrector.h.

Referenced by CompareFileName(), and SetMatchFileName().

§ fMaxs

std::vector<Double_t> Corrector::fMaxs
private

Maximum possible values of each axis.

Definition at line 123 of file Corrector.h.

Referenced by GetFormulaResult(), and SetMinMax().

§ fMins

std::vector<Double_t> Corrector::fMins
private

Minimum possible values of each axis.

Definition at line 122 of file Corrector.h.

Referenced by GetFormulaResult(), and SetMinMax().

§ fName

TString Corrector::fName
protected

Name of branch to write to.

Definition at line 99 of file Corrector.h.

Referenced by TMVACorrector::Copy(), GetName(), and TMVACorrector::ReadVarConfig().

§ fNumDims

Int_t Corrector::fNumDims = 0
private

Number of dimensions in the correction histogram.

Definition at line 119 of file Corrector.h.

Referenced by AddInExpression(), DoEval(), GetNumDims(), and SetMinMax().

§ Merge

bool Corrector::Merge = true

Flag determining whether or not to merge into the CorrectorApplicator branch.

Definition at line 92 of file Corrector.h.


The documentation for this class was generated from the following files: