NAGASH 0.9.8
Next Generation Analysis System
|
NAGASH interface for using ROOT histograms. More...
#include "NAGASH/NGHist.h"
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< HistBase > | CloneVirtual (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< ConfigTool > | ConfigUser () |
Return the internal ConfigTool.> | |
std::shared_ptr< MSGTool > | MSGUser () |
Return the internal MSGTool. | |
Result & | operator= (const Result &result)=delete |
Result & | operator= (Result &&result)=delete |
void | SetOutputFileName (const TString &fileName) |
Set the output file name of the result. | |
Toolkit * | ToolkitUser () |
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< SystPolicy > | SystematicVariationPolicies |
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... | |
NAGASH interface for using ROOT histograms.
|
inlinevirtual |
|
inline |
Constructor.
...Args | types of the binning info. |
MSG | input MSGTool. |
c | input ConfigTool. |
name | name of the histogram. |
filename | name of the output file. |
...args | binning info, should be compatible with ROOT histograms. |
|
inline |
|
inline |
partial specialization for the constructor of NGHist<TH1D>.
MSG | input MSGTool. |
c | input ConfigTool. |
name | the name of the histogram. |
filename | the file name of the histogram to be saved in. |
bindiv | the binning of the histogram. |
|
inline |
partial specialization for the constructor of NGHist<TH2D>.
MSG | input MSGTool. |
c | input ConfigTool. |
name | the name of the histogram. |
filename | the file name of the histogram to be saved in. |
binnumx | number of bins in the x axis. |
startx | start value of the x axis. |
endx | end value of the x axis. |
bindivy | binning in the y axis. |
|
inline |
partial specialization for the constructor of NGHist<TH2D>.
MSG | input MSGTool. |
c | input ConfigTool. |
name | the name of the histogram. |
filename | the file name of the histogram to be saved in. |
bindivx | binning in the x axis. |
binnumy | number of bins in the y axis. |
starty | start value of the y axis. |
endy | end value of the y axis. |
|
inline |
partial specialization for the constructor of NGHist<TH2D>.
MSG | input MSGTool. |
c | input ConfigTool. |
name | the name of the histogram. |
filename | the file name of the histogram to be saved in. |
bindivx | binning in the x axis. |
bindivy | binning in the y axis. |
|
inline |
partial specialization for the constructor of NGHist<TH3D>.
MSG | input MSGTool. |
c | input ConfigTool. |
name | the name of the histogram. |
filename | the file name of the histogram to be saved in. |
bindivx | binning in the x axis. |
bindivy | binning in the y axis. |
bindivz | binning in the z axis. |
|
inlineoverridevirtual |
Book systematic variations.
HistType | type of NGHist. |
names | systematic variation names. |
corr_factor | correlation factor of the systematic variations. |
policy | policy on how to deal with this systematic variations. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Book a systematic variation.
HistType | type of NGHist. |
name | name of the systematic variation. |
corr_factor | correlation factor of the systematic variation. |
policy | policy on how to deal with this systematic variation. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Book systematic variations.
HistType | type of NGHist. |
name1 | name of the first systematic variation. |
name2 | name of the second systematic variation. |
corr_factor | correlation factor of the systematic variations. |
policy | policy on how to deal with this systematic variations. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Clear all linked plots.
Reimplemented from NAGASH::HistBase.
|
inline |
|
inlineoverrideprotectedvirtual |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Combine the current NGHist with another NGHist.
Reimplemented from NAGASH::Result.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Virtual function to get the nominal histogram.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Get the number of systematic variations.
Reimplemented from NAGASH::HistBase.
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Get the correlation factor for the systematic variation with the given name.
name | name of the systematic variation. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Get the name of the ith systematic variation.
Reimplemented from NAGASH::HistBase.
|
inline |
|
inlineoverridevirtual |
Get the structure of the systematic variations.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Virtual function to get the variation histogram.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Virtual function to get the variation histogram.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
If the variation of given name is a backup variation.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
If ith variation is a backup variation.
Reimplemented from NAGASH::HistBase.
|
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:
Reimplemented from NAGASH::HistBase.
|
inline |
|
inline |
|
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.
name | Name of the new NGHist. |
rebinnum_x | Number of bins to be combined in x-axis. |
rebinnum_y | Number of bins to be combined in y-axis. |
|
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.
name | Name of the new NGHist. |
bindiv_x | Bin divisions of the new binning in x-axis (empty vector for not rebinning) |
bindiv_y | Bin divisions of the new binning in y-axis (empty vector for not rebinning) |
|
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.
name | Name of the new NGHist. |
rebinnum_x | Number of bins to be combined in x-axis. |
rebinnum_y | Number of bins to be combined in y-axis. |
rebinnum_z | Number of bins to be combined in z-axis. |
|
inline |
Rebin 3D histogram with the given bin division, store the result in a new NGHist.
name | Name of the new NGHist. |
bindiv_x | Bin divisions of the new binning in x-axis (empty vector for not rebinning) |
bindiv_y | Bin divisions of the new binning in y-axis (empty vector for not rebinning) |
bindiv_z | Bin divisions of the new binning in z-axis (empty vector for not rebinning) |
|
inlineoverridevirtual |
Recover the NGHist from a ROOT file with the name passed to the constructor.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Recover the NGHist from a ROOT file.
filename | name of the ROOT file. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Recover the NGHist from a ROOT file.
infile | input TFileHelper. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Recover the NGHist from a ROOT file.
file | the pointer of the ROOT file |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Regroup the backup variations with the give name of policy.
names | variation names that you want to regroup |
policy | policy for the new group of variations. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Move a systematic variation to backup the variations in the same group will also be moved to the backup.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Rename a systematic variation.
name_old | old name. |
name_new | new name. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Reset all histograms.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Scale all histograms using TH1::Scale().
sf | scale factor. |
Reimplemented from NAGASH::HistBase.
|
inline |
|
inline |
|
inlineoverridevirtual |
Link this NGHist to anothe one.
The link will be calculated in Process() via NAGASH::HistTool::ProcessHistLink()
index | the index of the link. |
subplot | the linked NGHist. |
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Set the type of the link.
type | the 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:
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Set the type of the links.
contentfunction | function to calculate the content of the links, the argument is the vector of the contents of all linked histograms. |
errorfunction | function 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:
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Set the type of the links.
f | the 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:
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Set the NGHist to the give variation name.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Set the NGHist to the give variation index.
Reimplemented from NAGASH::HistBase.
|
inlineoverridevirtual |
Set this NGHist to a unprocessed state.
Reimplemented from NAGASH::HistBase.
|
inlinestatic |
|
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.
|
inlineoverridevirtual |
Write the NGHist to a ROOT file.
Reimplemented from NAGASH::Result.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |