NAGASH 0.9.8
Next Generation Analysis System
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
NAGASH::NGHist< HistType > Class Template Reference

NAGASH interface for using ROOT histograms. More...

#include "NAGASH/NGHist.h"

Inheritance diagram for NAGASH::NGHist< HistType >:
NAGASH::HistBase NAGASH::Result

Public Member Functions

 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name)
 Auxliary constructor, construct an empty NGHist object, suitable for Recover().
 
template<typename... Args>
 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename, const Args &...args)
 Constructor.
 
 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename, const int &binnumx, const double &startx, const double &endx, const std::vector< double > &bindivy)
 partial specialization for the constructor of NGHist<TH2D>.
 
 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename, const std::vector< double > &bindiv)
 partial specialization for the constructor of NGHist<TH1D>.
 
 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename, const std::vector< double > &bindivx, const int &binnumy, const double &starty, const double &endy)
 partial specialization for the constructor of NGHist<TH2D>.
 
 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename, const std::vector< double > &bindivx, const std::vector< double > &bindivy)
 partial specialization for the constructor of NGHist<TH2D>.
 
 NGHist (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename, const std::vector< double > &bindivx, const std::vector< double > &bindivy, const std::vector< double > &bindivz)
 partial specialization for the constructor of NGHist<TH3D>.
 
virtual ~NGHist ()
 Destructor.
 
bool BookSystematicVariation (const std::vector< TString > &names, double corr_factor=0, SystPolicy policy=SystPolicy::Maximum) override
 Book systematic variations.
 
bool BookSystematicVariation (const TString &name, double corr_factor=0, SystPolicy policy=SystPolicy::Maximum) override
 Book a systematic variation.
 
bool BookSystematicVariation (const TString &name1, const TString &name2, double corr_factor=0, SystPolicy policy=SystPolicy::Maximum) override
 Book systematic variations.
 
void ClearLinkPlot () override
 Clear all linked plots.
 
std::shared_ptr< NGHist< HistType > > Clone (const TString &name)
 Clone the current NGHist with the given name.
 
void Combine (std::shared_ptr< Result > result) override
 Combine the current NGHist with another NGHist.
 
template<typename... Args>
void Fill (Args &&...args)
 Fill the current variation using TH1::Fill().
 
template<typename... Args>
double GetBinContent (Args &&...args)
 Get the bin content of the current variation using TH1::GetBinContent().
 
template<typename... Args>
double GetBinError (Args &&...args)
 Get the bin error of the current variation using TH1::GetBinError().
 
template<typename... Args>
double GetBinFinalError (Args &&...args)
 Get the total bin error of the final histogram using TH1::GetBinError().
 
template<typename... Args>
double GetBinNominalError (Args &&...args)
 Get the bin error of the nominal histogram using TH1::GetBinError().
 
template<typename... Args>
double GetBinSystematicError (Args &&...args)
 Get the total systematic error of ith bin.
 
template<typename... Args>
double GetBinTotalError (Args &&...args)
 Get the total bin error of the final histogram using TH1::GetBinError().
 
TH2D * GetCorrelation ()
 Get the pointer to the correlation histogram.
 
TH2D * GetCovariance ()
 Get the pointer to the covariance histogram.
 
HistType * GetFillHist ()
 Get the pointer to the current variation histogram.
 
HistType * GetFinalHist ()
 Get the pointer to the final histogram, whose contents are nominal contents and errors are the total uncertainties.
 
HistType * GetNominalHist ()
 Get the pointer to the nominal variation histogram.
 
TH1 * GetNominalHistVirtual () override
 Virtual function to get the nominal histogram.
 
size_t GetNVariations () override
 Get the number of systematic variations.
 
std::vector< std::vector< double > > GetPartialCovariance (const std::vector< TString > &systlist)
 Get the covariance matrix for the given list of systematic variations.
 
HistType * GetVariation (const TString &name)
 Get the pointer to the variation histogram based on the name.
 
HistType * GetVariation (uint64_t index)
 Get the pointer to the variation histogram based on the index.
 
double GetVariationCorrelationFactor (const TString &name) override
 Get the correlation factor for the systematic variation with the given name.
 
TString GetVariationName (uint64_t index) override
 Get the name of the ith systematic variation.
 
std::vector< TString > GetVariationNames ()
 Get the vector of the name of all systematic variations.
 
std::vector< std::tuple< std::vector< TString >, double, SystPolicy > > GetVariationTypes () override
 Get the structure of the systematic variations.
 
TH1 * GetVariationVirtual (const TString &name) override
 Virtual function to get the variation histogram.
 
TH1 * GetVariationVirtual (uint64_t index) override
 Virtual function to get the variation histogram.
 
bool IsBackupVariation (const TString &) override
 If the variation of given name is a backup variation.
 
bool IsBackupVariation (uint64_t) override
 If ith variation is a backup variation.
 
bool Process () override
 process the NGHist.
 
std::shared_ptr< NGHist< HistType > > Rebin (const TString &name, int rebinnum)
 Rebin 1D histogram with the given rebin number, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.
 
std::shared_ptr< NGHist< HistType > > Rebin (const TString &name, std::vector< double > bindiv)
 Rebin with the given bin division, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.
 
std::shared_ptr< NGHist< HistType > > Rebin2D (const TString &name, int rebinnum_x, int rebinum_y)
 Rebin 2D histogram with the given rebin numbers, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.
 
std::shared_ptr< NGHist< HistType > > Rebin2D (const TString &name, std::vector< double > bindiv_x, std::vector< double > bindiv_y)
 Rebin 2D histogram with the given bin division, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.
 
std::shared_ptr< NGHist< HistType > > Rebin3D (const TString &name, int rebinnum_x, int rebinum_y, int rebinum_z)
 Rebin 3D histogram with the given rebin numbers, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.
 
std::shared_ptr< NGHist< HistType > > Rebin3D (const TString &name, std::vector< double > bindiv_x, std::vector< double > bindiv_y, std::vector< double > bindiv_z)
 Rebin 3D histogram with the given bin division, store the result in a new NGHist.
 
bool Recover () override
 Recover the NGHist from a ROOT file with the name passed to the constructor.
 
bool Recover (const TString &filename) override
 Recover the NGHist from a ROOT file.
 
bool Recover (std::shared_ptr< TFileHelper >) override
 Recover the NGHist from a ROOT file.
 
bool Recover (TFile *file) override
 Recover the NGHist from a ROOT file.
 
bool RegroupSystematicVariation (const std::vector< TString > &names, SystPolicy policy) override
 Regroup the backup variations with the give name of policy.
 
bool RemoveSystematicVariation (const TString &name) override
 Move a systematic variation to backup the variations in the same group will also be moved to the backup.
 
bool RenameSystematicVariation (const TString &name_old, const TString &name_new) override
 Rename a systematic variation.
 
void Reset () override
 Reset all histograms.
 
void Scale (double) override
 Scale all histograms using TH1::Scale().
 
template<typename... Args>
void SetBinContent (Args &&...args)
 Set bin content of the current variation using TH1::SetBinContent().
 
template<typename... Args>
void SetBinError (Args &&...args)
 Set bin error of the current variation using TH1::SetBinError().
 
void SetLinkPlot (uint64_t index, std::shared_ptr< HistBase > subplot) override
 Link this NGHist to anothe one.
 
void SetLinkType (const TString &type) override
 Set the type of the link.
 
void SetLinkType (std::function< double(const std::vector< double > &)>, std::function< double(const std::vector< double > &, const std::vector< double > &)>) override
 Set the type of the links.
 
void SetLinkType (std::function< void(const std::vector< TH1 * > &, TH1 *)>) override
 Set the type of the links.
 
bool SetSystematicVariation (const TString &name="Nominal") override
 Set the NGHist to the give variation name.
 
bool SetSystematicVariation (uint64_t index) override
 Set the NGHist to the give variation index.
 
void SetUnprocessed () override
 Set this NGHist to a unprocessed state.
 
void Write () override
 Write the NGHist to a ROOT file.
 
void WriteToFile () override
 Write the NGHist to a ROOT file.
 
- Public Member Functions inherited from NAGASH::HistBase
virtual ~HistBase ()=default
 
- Public Member Functions inherited from NAGASH::Result
const TString & GetOutputFileName ()
 Return the name of the result.
 
const TString & GetResultName ()
 

Static Public Member Functions

static double Variance (const std::vector< double > &v)
 Calculate the variance of the given vector.
 

Protected Member Functions

std::shared_ptr< HistBaseCloneVirtual (const TString &name) override
 
- Protected Member Functions inherited from NAGASH::HistBase
 HistBase (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &name, const TString &filename)
 
- Protected Member Functions inherited from NAGASH::Result
 Result ()=delete
 
 Result (const Result &result)=delete
 
 Result (Result &&result)=delete
 
 Result (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &rname, const TString &fname="")
 virtual interface to write the result to a file.
 
virtual ~Result ()=default
 
std::shared_ptr< ConfigToolConfigUser ()
 Return the internal ConfigTool.>
 
std::shared_ptr< MSGToolMSGUser ()
 Return the internal MSGTool.
 
Resultoperator= (const Result &result)=delete
 
Resultoperator= (Result &&result)=delete
 
void SetOutputFileName (const TString &fileName)
 Set the output file name of the result.
 
ToolkitToolkitUser ()
 Return the internal Toolkit.
 

Private Attributes

TH2D * Correlation = nullptr
 
std::vector< double > CorrelationFactors
 
TH2D * Covariance = nullptr
 
HistType * FillHist = nullptr
 
HistType * Final = nullptr
 
std::function< double(const std::vector< double > &)> LinkContentFunction
 
std::vector< std::shared_ptr< HistBase > > LinkedPlots
 
std::function< double(const std::vector< double > &, const std::vector< double > &)> LinkErrorFunction
 
std::function< void(const std::vector< TH1 * > &, TH1 *)> LinkHistFunction
 
TString LinkType = ""
 
HistType * Nominal = nullptr
 
bool Processed = false
 
std::map< TString, int > SystematicIndexMap
 
std::map< TString, int > SystematicVariationBackup
 
std::vector< std::vector< size_t > > SystematicVariationIndices
 
std::vector< TString > SystematicVariationNames
 
std::vector< SystPolicySystematicVariationPolicies
 
std::vector< HistType * > SystematicVariations
 

Friends

class PlotGroup
 

Additional Inherited Members

- Public Types inherited from NAGASH::HistBase
enum class  SystPolicy {
  Average , Maximum , Variance , CTEQ ,
  Backup
}
 Policies of dealing with systematic uncertainties. More...
 

Detailed Description

template<typename HistType>
class NAGASH::NGHist< HistType >

NAGASH interface for using ROOT histograms.

Definition at line 17 of file NGHist.h.

Constructor & Destructor Documentation

◆ ~NGHist()

template<typename HistType >
virtual NAGASH::NGHist< HistType >::~NGHist ( )
inlinevirtual

Destructor.

Definition at line 213 of file NGHist.h.

◆ NGHist() [1/7]

template<typename HistType >
template<typename... Args>
NAGASH::NGHist< HistType >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name,
const TString &  filename,
const Args &...  args 
)
inline

Constructor.

Template Parameters
...Argstypes of the binning info.
Parameters
MSGinput MSGTool.
cinput ConfigTool.
namename of the histogram.
filenamename of the output file.
...argsbinning info, should be compatible with ROOT histograms.

Definition at line 355 of file NGHist.h.

◆ NGHist() [2/7]

template<typename HistType >
NAGASH::NGHist< HistType >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name 
)
inline

Auxliary constructor, construct an empty NGHist object, suitable for Recover().

Parameters
MSGinput MSGTool.
cinput ConfigTool.
namename of the NGHist object.

Definition at line 374 of file NGHist.h.

◆ NGHist() [3/7]

NAGASH::NGHist< TH1D >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name,
const TString &  filename,
const std::vector< double > &  bindiv 
)
inline

partial specialization for the constructor of NGHist<TH1D>.

Parameters
MSGinput MSGTool.
cinput ConfigTool.
namethe name of the histogram.
filenamethe file name of the histogram to be saved in.
bindivthe binning of the histogram.

Definition at line 24 of file Plot1D.h.

◆ NGHist() [4/7]

NAGASH::NGHist< TH2D >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name,
const TString &  filename,
const int &  binnumx,
const double &  startx,
const double &  endx,
const std::vector< double > &  bindivy 
)
inline

partial specialization for the constructor of NGHist<TH2D>.

Parameters
MSGinput MSGTool.
cinput ConfigTool.
namethe name of the histogram.
filenamethe file name of the histogram to be saved in.
binnumxnumber of bins in the x axis.
startxstart value of the x axis.
endxend value of the x axis.
bindivybinning in the y axis.

Definition at line 27 of file Plot2D.h.

◆ NGHist() [5/7]

NAGASH::NGHist< TH2D >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name,
const TString &  filename,
const std::vector< double > &  bindivx,
const int &  binnumy,
const double &  starty,
const double &  endy 
)
inline

partial specialization for the constructor of NGHist<TH2D>.

Parameters
MSGinput MSGTool.
cinput ConfigTool.
namethe name of the histogram.
filenamethe file name of the histogram to be saved in.
bindivxbinning in the x axis.
binnumynumber of bins in the y axis.
startystart value of the y axis.
endyend value of the y axis.

Definition at line 47 of file Plot2D.h.

◆ NGHist() [6/7]

NAGASH::NGHist< TH2D >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name,
const TString &  filename,
const std::vector< double > &  bindivx,
const std::vector< double > &  bindivy 
)
inline

partial specialization for the constructor of NGHist<TH2D>.

Parameters
MSGinput MSGTool.
cinput ConfigTool.
namethe name of the histogram.
filenamethe file name of the histogram to be saved in.
bindivxbinning in the x axis.
bindivybinning in the y axis.

Definition at line 65 of file Plot2D.h.

◆ NGHist() [7/7]

NAGASH::NGHist< TH3D >::NGHist ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  name,
const TString &  filename,
const std::vector< double > &  bindivx,
const std::vector< double > &  bindivy,
const std::vector< double > &  bindivz 
)
inline

partial specialization for the constructor of NGHist<TH3D>.

Parameters
MSGinput MSGTool.
cinput ConfigTool.
namethe name of the histogram.
filenamethe file name of the histogram to be saved in.
bindivxbinning in the x axis.
bindivybinning in the y axis.
bindivzbinning in the z axis.

Definition at line 26 of file Plot3D.h.

Member Function Documentation

◆ BookSystematicVariation() [1/3]

template<typename HistType >
bool NAGASH::NGHist< HistType >::BookSystematicVariation ( const std::vector< TString > &  names,
double  corr_factor = 0,
SystPolicy  policy = SystPolicy::Maximum 
)
inlineoverridevirtual

Book systematic variations.

Template Parameters
HistTypetype of NGHist.
Parameters
namessystematic variation names.
corr_factorcorrelation factor of the systematic variations.
policypolicy on how to deal with this systematic variations.
Returns
booking procedure success or not.

Reimplemented from NAGASH::HistBase.

Definition at line 949 of file NGHist.h.

◆ BookSystematicVariation() [2/3]

template<typename HistType >
bool NAGASH::NGHist< HistType >::BookSystematicVariation ( const TString &  name,
double  corr_factor = 0,
SystPolicy  policy = SystPolicy::Maximum 
)
inlineoverridevirtual

Book a systematic variation.

Template Parameters
HistTypetype of NGHist.
Parameters
namename of the systematic variation.
corr_factorcorrelation factor of the systematic variation.
policypolicy on how to deal with this systematic variation.
Returns
booking procedure success or not.

Reimplemented from NAGASH::HistBase.

Definition at line 924 of file NGHist.h.

◆ BookSystematicVariation() [3/3]

template<typename HistType >
bool NAGASH::NGHist< HistType >::BookSystematicVariation ( const TString &  name1,
const TString &  name2,
double  corr_factor = 0,
SystPolicy  policy = SystPolicy::Maximum 
)
inlineoverridevirtual

Book systematic variations.

Template Parameters
HistTypetype of NGHist.
Parameters
name1name of the first systematic variation.
name2name of the second systematic variation.
corr_factorcorrelation factor of the systematic variations.
policypolicy on how to deal with this systematic variations.
Returns
booking procedure success or not.

Reimplemented from NAGASH::HistBase.

Definition at line 937 of file NGHist.h.

◆ ClearLinkPlot()

template<typename HistType >
void NAGASH::NGHist< HistType >::ClearLinkPlot ( )
inlineoverridevirtual

Clear all linked plots.

Reimplemented from NAGASH::HistBase.

Definition at line 1013 of file NGHist.h.

◆ Clone()

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Clone ( const TString &  name)
inline

Clone the current NGHist with the given name.

Definition at line 1024 of file NGHist.h.

◆ CloneVirtual()

template<typename HistType >
std::shared_ptr< HistBase > NAGASH::NGHist< HistType >::CloneVirtual ( const TString &  name)
inlineoverrideprotectedvirtual

Reimplemented from NAGASH::HistBase.

Definition at line 305 of file NGHist.h.

◆ Combine()

template<typename HistType >
void NAGASH::NGHist< HistType >::Combine ( std::shared_ptr< Result result)
inlineoverridevirtual

Combine the current NGHist with another NGHist.

Reimplemented from NAGASH::Result.

Definition at line 1031 of file NGHist.h.

◆ Fill()

template<typename HistType >
template<typename... Args>
void NAGASH::NGHist< HistType >::Fill ( Args &&...  args)
inline

Fill the current variation using TH1::Fill().

Definition at line 51 of file NGHist.h.

◆ GetBinContent()

template<typename HistType >
template<typename... Args>
double NAGASH::NGHist< HistType >::GetBinContent ( Args &&...  args)
inline

Get the bin content of the current variation using TH1::GetBinContent().

Definition at line 103 of file NGHist.h.

◆ GetBinError()

template<typename HistType >
template<typename... Args>
double NAGASH::NGHist< HistType >::GetBinError ( Args &&...  args)
inline

Get the bin error of the current variation using TH1::GetBinError().

Definition at line 106 of file NGHist.h.

◆ GetBinFinalError()

template<typename HistType >
template<typename... Args>
double NAGASH::NGHist< HistType >::GetBinFinalError ( Args &&...  args)
inline

Get the total bin error of the final histogram using TH1::GetBinError().

Definition at line 123 of file NGHist.h.

◆ GetBinNominalError()

template<typename HistType >
template<typename... Args>
double NAGASH::NGHist< HistType >::GetBinNominalError ( Args &&...  args)
inline

Get the bin error of the nominal histogram using TH1::GetBinError().

Definition at line 109 of file NGHist.h.

◆ GetBinSystematicError()

template<typename HistType >
template<typename... Args>
double NAGASH::NGHist< HistType >::GetBinSystematicError ( Args &&...  args)
inline

Get the total systematic error of ith bin.

Definition at line 133 of file NGHist.h.

◆ GetBinTotalError()

template<typename HistType >
template<typename... Args>
double NAGASH::NGHist< HistType >::GetBinTotalError ( Args &&...  args)
inline

Get the total bin error of the final histogram using TH1::GetBinError().

Definition at line 113 of file NGHist.h.

◆ GetCorrelation()

template<typename HistType >
TH2D * NAGASH::NGHist< HistType >::GetCorrelation ( )
inline

Get the pointer to the correlation histogram.

Definition at line 85 of file NGHist.h.

◆ GetCovariance()

template<typename HistType >
TH2D * NAGASH::NGHist< HistType >::GetCovariance ( )
inline

Get the pointer to the covariance histogram.

Definition at line 74 of file NGHist.h.

◆ GetFillHist()

template<typename HistType >
HistType * NAGASH::NGHist< HistType >::GetFillHist ( )
inline

Get the pointer to the current variation histogram.

Definition at line 57 of file NGHist.h.

◆ GetFinalHist()

template<typename HistType >
HistType * NAGASH::NGHist< HistType >::GetFinalHist ( )
inline

Get the pointer to the final histogram, whose contents are nominal contents and errors are the total uncertainties.

Definition at line 63 of file NGHist.h.

◆ GetNominalHist()

template<typename HistType >
HistType * NAGASH::NGHist< HistType >::GetNominalHist ( )
inline

Get the pointer to the nominal variation histogram.

Definition at line 54 of file NGHist.h.

◆ GetNominalHistVirtual()

template<typename HistType >
TH1 * NAGASH::NGHist< HistType >::GetNominalHistVirtual ( )
inlineoverridevirtual

Virtual function to get the nominal histogram.

Reimplemented from NAGASH::HistBase.

Definition at line 1077 of file NGHist.h.

◆ GetNVariations()

template<typename HistType >
size_t NAGASH::NGHist< HistType >::GetNVariations ( )
inlineoverridevirtual

Get the number of systematic variations.

Reimplemented from NAGASH::HistBase.

Definition at line 60 of file NGHist.h.

◆ GetPartialCovariance()

template<typename HistType >
std::vector< std::vector< double > > NAGASH::NGHist< HistType >::GetPartialCovariance ( const std::vector< TString > &  systlist)
inline

Get the covariance matrix for the given list of systematic variations.

Parameters
systlistvector of systematic variation names.
Returns
covariance matrix.

Definition at line 386 of file NGHist.h.

◆ GetVariation() [1/2]

template<typename HistType >
HistType * NAGASH::NGHist< HistType >::GetVariation ( const TString &  name)
inline

Get the pointer to the variation histogram based on the name.

Parameters
namethe name of the systematic variation

Definition at line 164 of file NGHist.h.

◆ GetVariation() [2/2]

template<typename HistType >
HistType * NAGASH::NGHist< HistType >::GetVariation ( uint64_t  index)
inline

Get the pointer to the variation histogram based on the index.

Parameters
indexthe index of the systematic variation

Definition at line 182 of file NGHist.h.

◆ GetVariationCorrelationFactor()

template<typename HistType >
double NAGASH::NGHist< HistType >::GetVariationCorrelationFactor ( const TString &  name)
inlineoverridevirtual

Get the correlation factor for the systematic variation with the given name.

Parameters
namename of the systematic variation.

Reimplemented from NAGASH::HistBase.

Definition at line 198 of file NGHist.h.

◆ GetVariationName()

template<typename HistType >
TString NAGASH::NGHist< HistType >::GetVariationName ( uint64_t  index)
inlineoverridevirtual

Get the name of the ith systematic variation.

Reimplemented from NAGASH::HistBase.

Definition at line 146 of file NGHist.h.

◆ GetVariationNames()

template<typename HistType >
std::vector< TString > NAGASH::NGHist< HistType >::GetVariationNames ( )
inline

Get the vector of the name of all systematic variations.

Definition at line 157 of file NGHist.h.

◆ GetVariationTypes()

template<typename HistType >
std::vector< std::tuple< std::vector< TString >, double, HistBase::SystPolicy > > NAGASH::NGHist< HistType >::GetVariationTypes ( )
inlineoverridevirtual

Get the structure of the systematic variations.

Returns
a vector of tuples that represent a group of systematic variations, first element is the vector of systematic variation names, second element is the correlation factor, and third element is the policy.

Reimplemented from NAGASH::HistBase.

Definition at line 1085 of file NGHist.h.

◆ GetVariationVirtual() [1/2]

template<typename HistType >
TH1 * NAGASH::NGHist< HistType >::GetVariationVirtual ( const TString &  name)
inlineoverridevirtual

Virtual function to get the variation histogram.

Reimplemented from NAGASH::HistBase.

Definition at line 1063 of file NGHist.h.

◆ GetVariationVirtual() [2/2]

template<typename HistType >
TH1 * NAGASH::NGHist< HistType >::GetVariationVirtual ( uint64_t  index)
inlineoverridevirtual

Virtual function to get the variation histogram.

Reimplemented from NAGASH::HistBase.

Definition at line 1070 of file NGHist.h.

◆ IsBackupVariation() [1/2]

template<typename HistType >
bool NAGASH::NGHist< HistType >::IsBackupVariation ( const TString &  name)
inlineoverridevirtual

If the variation of given name is a backup variation.

Reimplemented from NAGASH::HistBase.

Definition at line 1136 of file NGHist.h.

◆ IsBackupVariation() [2/2]

template<typename HistType >
bool NAGASH::NGHist< HistType >::IsBackupVariation ( uint64_t  index)
inlineoverridevirtual

If ith variation is a backup variation.

Reimplemented from NAGASH::HistBase.

Definition at line 1113 of file NGHist.h.

◆ Process()

template<typename HistType >
bool NAGASH::NGHist< HistType >::Process ( )
inlineoverridevirtual

process the NGHist.

Calculate the final uncertainties for each bin, the covariance matrix and the correlation matrix. If this one is linked to other NGHists, also compute the contents and erros using the given link type.

Process logic:

  • book the variation of all linked plots, if there are conflicts, that means you are doing something wrong.
  • if two link plots have the same group of variations but different policies, use the first one.

Reimplemented from NAGASH::HistBase.

Definition at line 1155 of file NGHist.h.

◆ Rebin() [1/2]

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Rebin ( const TString &  name,
int  rebinnum 
)
inline

Rebin 1D histogram with the given rebin number, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.

Parameters
nameName of the new NGHist.
rebinnumNumber of bins to be combined.
Returns
Rebinned NGHist.

Definition at line 531 of file NGHist.h.

◆ Rebin() [2/2]

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Rebin ( const TString &  name,
std::vector< double >  bindiv 
)
inline

Rebin with the given bin division, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.

Parameters
nameName of the new NGHist.
bindivBin divisions of the new binning
Returns
Rebinned NGHist.

Definition at line 636 of file NGHist.h.

◆ Rebin2D() [1/2]

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Rebin2D ( const TString &  name,
int  rebinnum_x,
int  rebinnum_y 
)
inline

Rebin 2D histogram with the given rebin numbers, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.

Parameters
nameName of the new NGHist.
rebinnum_xNumber of bins to be combined in x-axis.
rebinnum_yNumber of bins to be combined in y-axis.
Returns
Rebinned NGHist.

Definition at line 566 of file NGHist.h.

◆ Rebin2D() [2/2]

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Rebin2D ( const TString &  name,
std::vector< double >  bindiv_x,
std::vector< double >  bindiv_y 
)
inline

Rebin 2D histogram with the given bin division, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.

Parameters
nameName of the new NGHist.
bindiv_xBin divisions of the new binning in x-axis (empty vector for not rebinning)
bindiv_yBin divisions of the new binning in y-axis (empty vector for not rebinning)
Returns
Rebinned NGHist.

Definition at line 681 of file NGHist.h.

◆ Rebin3D() [1/2]

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Rebin3D ( const TString &  name,
int  rebinnum_x,
int  rebinnum_y,
int  rebinnum_z 
)
inline

Rebin 3D histogram with the given rebin numbers, store the result in a new NGHist. Note that the link info will be cleared in the new NGHist.

Parameters
nameName of the new NGHist.
rebinnum_xNumber of bins to be combined in x-axis.
rebinnum_yNumber of bins to be combined in y-axis.
rebinnum_zNumber of bins to be combined in z-axis.
Returns
Rebinned NGHist.

Definition at line 602 of file NGHist.h.

◆ Rebin3D() [2/2]

template<typename HistType >
std::shared_ptr< NGHist< HistType > > NAGASH::NGHist< HistType >::Rebin3D ( const TString &  name,
std::vector< double >  bindiv_x,
std::vector< double >  bindiv_y,
std::vector< double >  bindiv_z 
)
inline

Rebin 3D histogram with the given bin division, store the result in a new NGHist.

Parameters
nameName of the new NGHist.
bindiv_xBin divisions of the new binning in x-axis (empty vector for not rebinning)
bindiv_yBin divisions of the new binning in y-axis (empty vector for not rebinning)
bindiv_zBin divisions of the new binning in z-axis (empty vector for not rebinning)
Returns
Rebinned NGHist.

Definition at line 804 of file NGHist.h.

◆ Recover() [1/4]

template<typename HistType >
bool NAGASH::NGHist< HistType >::Recover ( )
inlineoverridevirtual

Recover the NGHist from a ROOT file with the name passed to the constructor.

Returns
Recover successfully or not.

Reimplemented from NAGASH::HistBase.

Definition at line 1664 of file NGHist.h.

◆ Recover() [2/4]

template<typename HistType >
bool NAGASH::NGHist< HistType >::Recover ( const TString &  filename)
inlineoverridevirtual

Recover the NGHist from a ROOT file.

Parameters
filenamename of the ROOT file.
Returns
Recover successfully or not.

Reimplemented from NAGASH::HistBase.

Definition at line 1645 of file NGHist.h.

◆ Recover() [3/4]

template<typename HistType >
bool NAGASH::NGHist< HistType >::Recover ( std::shared_ptr< TFileHelper infile)
inlineoverridevirtual

Recover the NGHist from a ROOT file.

Parameters
infileinput TFileHelper.
Returns
Recover successfully or not.

Reimplemented from NAGASH::HistBase.

Definition at line 1526 of file NGHist.h.

◆ Recover() [4/4]

template<typename HistType >
bool NAGASH::NGHist< HistType >::Recover ( TFile *  file)
inlineoverridevirtual

Recover the NGHist from a ROOT file.

Parameters
filethe pointer of the ROOT file
Returns
Recover successfully or not

Reimplemented from NAGASH::HistBase.

Definition at line 1412 of file NGHist.h.

◆ RegroupSystematicVariation()

template<typename HistType >
bool NAGASH::NGHist< HistType >::RegroupSystematicVariation ( const std::vector< TString > &  names,
SystPolicy  policy 
)
inlineoverridevirtual

Regroup the backup variations with the give name of policy.

Parameters
namesvariation names that you want to regroup
policypolicy for the new group of variations.

Reimplemented from NAGASH::HistBase.

Definition at line 1673 of file NGHist.h.

◆ RemoveSystematicVariation()

template<typename HistType >
bool NAGASH::NGHist< HistType >::RemoveSystematicVariation ( const TString &  name)
inlineoverridevirtual

Move a systematic variation to backup the variations in the same group will also be moved to the backup.

Reimplemented from NAGASH::HistBase.

Definition at line 1723 of file NGHist.h.

◆ RenameSystematicVariation()

template<typename HistType >
bool NAGASH::NGHist< HistType >::RenameSystematicVariation ( const TString &  name_old,
const TString &  name_new 
)
inlineoverridevirtual

Rename a systematic variation.

Parameters
name_oldold name.
name_newnew name.

Reimplemented from NAGASH::HistBase.

Definition at line 1763 of file NGHist.h.

◆ Reset()

template<typename HistType >
void NAGASH::NGHist< HistType >::Reset ( )
inlineoverridevirtual

Reset all histograms.

Reimplemented from NAGASH::HistBase.

Definition at line 1793 of file NGHist.h.

◆ Scale()

template<typename HistType >
void NAGASH::NGHist< HistType >::Scale ( double  sf)
inlineoverridevirtual

Scale all histograms using TH1::Scale().

Parameters
sfscale factor.

Reimplemented from NAGASH::HistBase.

Definition at line 1813 of file NGHist.h.

◆ SetBinContent()

template<typename HistType >
template<typename... Args>
void NAGASH::NGHist< HistType >::SetBinContent ( Args &&...  args)
inline

Set bin content of the current variation using TH1::SetBinContent().

Definition at line 97 of file NGHist.h.

◆ SetBinError()

template<typename HistType >
template<typename... Args>
void NAGASH::NGHist< HistType >::SetBinError ( Args &&...  args)
inline

Set bin error of the current variation using TH1::SetBinError().

Definition at line 100 of file NGHist.h.

◆ SetLinkPlot()

template<typename HistType >
void NAGASH::NGHist< HistType >::SetLinkPlot ( uint64_t  index,
std::shared_ptr< HistBase subplot 
)
inlineoverridevirtual

Link this NGHist to anothe one.

The link will be calculated in Process() via NAGASH::HistTool::ProcessHistLink()

Parameters
indexthe index of the link.
subplotthe linked NGHist.

Reimplemented from NAGASH::HistBase.

Definition at line 1833 of file NGHist.h.

◆ SetLinkType() [1/3]

template<typename HistType >
void NAGASH::NGHist< HistType >::SetLinkType ( const TString &  type)
inlineoverridevirtual

Set the type of the link.

Parameters
typethe type of the link. Possible values are: Asymmetry, Delta, Ratio, Chi2 and Pull.

The link will be calculated in Process() via NAGASH::HistTool::ProcessHistLink(). For example, if you want to generate the forward-backward asymmetry plot, you can do it by:

AsymHist->SetLinkPlot(0, Forward);
AsymHist->SetLinkPlot(1, Backward);
AysmHist->SetLinkType("Asymmetry");
AysmHist->Process();

Reimplemented from NAGASH::HistBase.

Definition at line 1868 of file NGHist.h.

◆ SetLinkType() [2/3]

template<typename HistType >
void NAGASH::NGHist< HistType >::SetLinkType ( std::function< double(const std::vector< double > &)>  contentfunction,
std::function< double(const std::vector< double > &, const std::vector< double > &)>  errorfunction 
)
inlineoverridevirtual

Set the type of the links.

Parameters
contentfunctionfunction to calculate the content of the links, the argument is the vector of the contents of all linked histograms.
errorfunctionfunction to calculate the error of the links, the first and the second arguments are the vector of the contents and erros of all linked histograms.

The link will be calculated in Process() via NAGASH::HistTool::ProcessHistLink(). For example, if you want to substract background from data, you can do it by:

auto SubstractBkgContentFunc = [](const std::vector<double> &contents) -> double
{
if (contents.size() > 1)
{
double c = contents[0];
for (size_t i = 1; i < contents.size(); i++)
c -= contents[i];
return c;
}
else
return contents[0];
};
auto SubstractBkgErrorFunc = [](const std::vector<double> &contents, const std::vector<double> &errors) -> double
{
double e = 0;
for (auto &error : errors)
e += error * error;
return std::sqrt(std::fabs(e));
};
DataSubstractBkg->SetLinkType(SubstractBkgContentFunc, SubstractBkgErrorFunc);
DataSubstractBkg->SetLinkPlot(0, Data);
DataSubstractBkg->SetLinkPlot(1, Bkg1);
DataSubstractBkg->SetLinkPlot(2, Bkg2);
DataSubstractBkg->SetLinkPlot(3, Bkg3);
DataSubstractBkg->Process();

Reimplemented from NAGASH::HistBase.

Definition at line 1910 of file NGHist.h.

◆ SetLinkType() [3/3]

template<typename HistType >
void NAGASH::NGHist< HistType >::SetLinkType ( std::function< void(const std::vector< TH1 * > &, TH1 *)>  f)
inlineoverridevirtual

Set the type of the links.

Parameters
fthe function to calculate the link. The first argument is the vector of all linked histograms. The second argument is the target histogram.

The link will be calculated in Process() via NAGASH::HistTool::ProcessHistLink(). For example, if you want to substract background from data, you can do it by:

auto SubstractBkgFunc = [&](const std::vector<TH1 *> &vh, TH1 *h_target) -> void
{
for (auto &h : vh)
h_target->Add(h, -1);
};
DataSubstractBkg->SetLinkType(SubstractBkgFunc);
DataSubstractBkg->SetLinkPlot(0, Data);
DataSubstractBkg->SetLinkPlot(1, Bkg1);
DataSubstractBkg->SetLinkPlot(2, Bkg2);
DataSubstractBkg->SetLinkPlot(3, Bkg3);
DataSubstractBkg->Process();

Reimplemented from NAGASH::HistBase.

Definition at line 1937 of file NGHist.h.

◆ SetSystematicVariation() [1/2]

template<typename HistType >
bool NAGASH::NGHist< HistType >::SetSystematicVariation ( const TString &  name = "Nominal")
inlineoverridevirtual

Set the NGHist to the give variation name.

Reimplemented from NAGASH::HistBase.

Definition at line 1945 of file NGHist.h.

◆ SetSystematicVariation() [2/2]

template<typename HistType >
bool NAGASH::NGHist< HistType >::SetSystematicVariation ( uint64_t  index)
inlineoverridevirtual

Set the NGHist to the give variation index.

Reimplemented from NAGASH::HistBase.

Definition at line 1969 of file NGHist.h.

◆ SetUnprocessed()

template<typename HistType >
void NAGASH::NGHist< HistType >::SetUnprocessed ( )
inlineoverridevirtual

Set this NGHist to a unprocessed state.

Reimplemented from NAGASH::HistBase.

Definition at line 1992 of file NGHist.h.

◆ Variance()

template<typename HistType >
static double NAGASH::NGHist< HistType >::Variance ( const std::vector< double > &  v)
inlinestatic

Calculate the variance of the given vector.

Definition at line 282 of file NGHist.h.

◆ Write()

template<typename HistType >
void NAGASH::NGHist< HistType >::Write ( )
inlineoverridevirtual

Write the NGHist to a ROOT file.

When storing in a ROOT file, the name of the nominal histogram is the same as the name of the NGHist. For systematic variations, the name is in the form as "histname_Syst_systname", where "systname" is the name of the systematic variations. The final histogram, covariance histogram and correlation histogram are stored in the name as "Final_histname", "Covariance_histname" and "Correlation_histname". Also the structure of systematic variations is stored as a TTree object with the name as "histname_SystInfoTree".

Reimplemented from NAGASH::HistBase.

Definition at line 2022 of file NGHist.h.

◆ WriteToFile()

template<typename HistType >
void NAGASH::NGHist< HistType >::WriteToFile ( )
inlineoverridevirtual

Write the NGHist to a ROOT file.

Reimplemented from NAGASH::Result.

Definition at line 2078 of file NGHist.h.

Friends And Related Symbol Documentation

◆ PlotGroup

template<typename HistType >
friend class PlotGroup
friend

Definition at line 19 of file NGHist.h.

Member Data Documentation

◆ Correlation

template<typename HistType >
TH2D* NAGASH::NGHist< HistType >::Correlation = nullptr
private

Definition at line 35 of file NGHist.h.

◆ CorrelationFactors

template<typename HistType >
std::vector<double> NAGASH::NGHist< HistType >::CorrelationFactors
private

Definition at line 28 of file NGHist.h.

◆ Covariance

template<typename HistType >
TH2D* NAGASH::NGHist< HistType >::Covariance = nullptr
private

Definition at line 34 of file NGHist.h.

◆ FillHist

template<typename HistType >
HistType* NAGASH::NGHist< HistType >::FillHist = nullptr
private

Definition at line 22 of file NGHist.h.

◆ Final

template<typename HistType >
HistType* NAGASH::NGHist< HistType >::Final = nullptr
private

Definition at line 33 of file NGHist.h.

◆ LinkContentFunction

template<typename HistType >
std::function<double(const std::vector<double> &)> NAGASH::NGHist< HistType >::LinkContentFunction
private

Definition at line 41 of file NGHist.h.

◆ LinkedPlots

template<typename HistType >
std::vector<std::shared_ptr<HistBase> > NAGASH::NGHist< HistType >::LinkedPlots
private

Definition at line 39 of file NGHist.h.

◆ LinkErrorFunction

template<typename HistType >
std::function<double(const std::vector<double> &, const std::vector<double> &)> NAGASH::NGHist< HistType >::LinkErrorFunction
private

Definition at line 42 of file NGHist.h.

◆ LinkHistFunction

template<typename HistType >
std::function<void(const std::vector<TH1 *> &, TH1 *)> NAGASH::NGHist< HistType >::LinkHistFunction
private

Definition at line 43 of file NGHist.h.

◆ LinkType

template<typename HistType >
TString NAGASH::NGHist< HistType >::LinkType = ""
private

Definition at line 40 of file NGHist.h.

◆ Nominal

template<typename HistType >
HistType* NAGASH::NGHist< HistType >::Nominal = nullptr
private

Definition at line 23 of file NGHist.h.

◆ Processed

template<typename HistType >
bool NAGASH::NGHist< HistType >::Processed = false
private

Definition at line 36 of file NGHist.h.

◆ SystematicIndexMap

template<typename HistType >
std::map<TString, int> NAGASH::NGHist< HistType >::SystematicIndexMap
private

Definition at line 25 of file NGHist.h.

◆ SystematicVariationBackup

template<typename HistType >
std::map<TString, int> NAGASH::NGHist< HistType >::SystematicVariationBackup
private

Definition at line 31 of file NGHist.h.

◆ SystematicVariationIndices

template<typename HistType >
std::vector<std::vector<size_t> > NAGASH::NGHist< HistType >::SystematicVariationIndices
private

Definition at line 29 of file NGHist.h.

◆ SystematicVariationNames

template<typename HistType >
std::vector<TString> NAGASH::NGHist< HistType >::SystematicVariationNames
private

Definition at line 26 of file NGHist.h.

◆ SystematicVariationPolicies

template<typename HistType >
std::vector<SystPolicy> NAGASH::NGHist< HistType >::SystematicVariationPolicies
private

Definition at line 30 of file NGHist.h.

◆ SystematicVariations

template<typename HistType >
std::vector<HistType *> NAGASH::NGHist< HistType >::SystematicVariations
private

Definition at line 27 of file NGHist.h.


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