NAGASH 0.9.8
Next Generation Analysis System
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
NAGASH::PlotGroup Class Reference

Provide a base class for manipulating a group of histograms at the same time. More...

#include "NAGASH/PlotGroup.h"

Inheritance diagram for NAGASH::PlotGroup:
NAGASH::Result

Public Member Functions

 PlotGroup (std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &rname, const TString &fname="")
 Constructor, same as that of Result.
 
virtual ~PlotGroup ()=default
 
template<typename HistType >
void AddNGHist (const TString &name, std::shared_ptr< NGHist< HistType > > plot)
 Append a NGHist to this PlotGroup.
 
void AddPlot1D (const TString &name, std::shared_ptr< Plot1D > plot)
 Append a NGHist<TH1D> to this PlotGroup.
 
void AddPlot2D (const TString &name, std::shared_ptr< Plot2D > plot)
 Append a NGHist<TH2D> to this PlotGroup.
 
void AddPlot3D (const TString &name, std::shared_ptr< Plot3D > plot)
 Append a NGHist<TH3D> to this PlotGroup.
 
template<typename HistType , typename... Args>
std::shared_ptr< NGHist< HistType > > BookNGHist (const TString &name, Args &&...args)
 Book NGHist and store in this PlotGroup.
 
template<typename... Args>
std::shared_ptr< Plot1DBookPlot1D (const TString &name, Args &&...args)
 Book NGHist<TH1D>
 
template<typename... Args>
std::shared_ptr< Plot2DBookPlot2D (const TString &name, Args &&...args)
 Book NGHist<TH2D>
 
template<typename... Args>
std::shared_ptr< Plot3DBookPlot3D (const TString &name, Args &&...args)
 Book NGHist<TH3D>
 
void BookSystematicVariation (const std::vector< TString > &names, double corr_factor=0, HistBase::SystPolicy policy=HistBase::SystPolicy::Maximum)
 Book systematic variations for each histogram inside this PlotGroup.
 
void BookSystematicVariation (const TString &name, double corr_factor=0, HistBase::SystPolicy policy=HistBase::SystPolicy::Maximum)
 Book systematic variations for each histogram inside this PlotGroup.
 
void BookSystematicVariation (const TString &name1, const TString &name2, double corr_factor=0, HistBase::SystPolicy policy=HistBase::SystPolicy::Maximum)
 Book systematic variations for each histogram inside this PlotGroup.
 
void ClearLinkPlotGroup ()
 Clear the linked plotgroup.
 
std::shared_ptr< PlotGroupClone (const TString &name)
 Clone this PlotGroup.
 
void Combine (std::shared_ptr< Result > result) override
 Combine two PlotGroups.
 
void ForEachPlot (std::function< void(std::shared_ptr< HistBase >)>)
 Apply the given function to each histogram inside this PlotGroup.
 
template<typename HistType >
std::shared_ptr< NGHist< HistType > > GetNGHist (const TString &name)
 Get booked NGHist with given name.
 
int GetNPlots ()
 Get the number of histograms stored inside this PlotGroup.
 
std::shared_ptr< Plot1DGetPlot1D (const TString &name)
 Get NGHist<TH1D>
 
std::shared_ptr< Plot2DGetPlot2D (const TString &name)
 Get NGHist<TH2D>
 
std::shared_ptr< Plot3DGetPlot3D (const TString &name)
 Get NGHist<TH3D>
 
void Process ()
 Call NGHist::Process() for each histogram inside this PlotGroup.
 
void Recover (const TString &filename)
 Retrieve histograms from the input file.
 
void Recover (std::shared_ptr< TFileHelper >)
 Retrieve histograms from the input file.
 
void Recover (TFile *file)
 Retrieve histograms from the input file.
 
void RegroupSystematicVariation (const std::vector< TString > &names, HistBase::SystPolicy policy)
 Call NGHist::RegroupSystematicVariation for each histogram inside this PlotGroup.
 
void RemoveSystematicVariation (const TString &name)
 Call NGHist::RemoveSystematicVariation for each histogram inside this PlotGroup.
 
void RenameSystematicVariation (const TString &name_old, const TString &name_new)
 Call NGHist::RenameSystematicVariation for each histogram inside this PlotGroup.
 
void Reset ()
 Call NGHist::Reset() for each histogram inside this PlotGroup.
 
void Scale (double)
 Call NGHist::Scale() for each histogram inside this PlotGroup.
 
void ScaleVariation (const TString &, double)
 Scale a variation of each histogram inside this PlotGroup.
 
void SetLinkPlotGroup (uint64_t, std::shared_ptr< PlotGroup >)
 Set the linked plotgroup, should be the same structure of this one.
 
void SetLinkType (const TString &)
 Set the type of the link for each histogram inside this PlotGroup.
 
void SetLinkType (std::function< double(const std::vector< double > &)>, std::function< double(const std::vector< double > &, const std::vector< double > &)>)
 Set link function for each histogram inside this PlotGroup.
 
void SetLinkType (std::function< void(const std::vector< TH1 * > &, TH1 *)>)
 Set the type of the link for each histogram inside this PlotGroup.
 
void SetSystematicVariation (const TString &name="Nominal")
 Set the systematic variation for each histogram inside this PlotGroup.
 
void SetSystematicVariation (int index)
 Set the systematic variation for each histogram inside this PlotGroup.
 
void SetUnprocessed ()
 Call NGHist::SetUnprocessed() for each histogram inside this PlotGroup.
 
void WriteToFile () override
 Write all histograms inside this PlotGroup to a file.
 
- Public Member Functions inherited from NAGASH::Result
const TString & GetOutputFileName ()
 Return the name of the result.
 
const TString & GetResultName ()
 

Private Attributes

MapTool maptool
 
std::map< TString, std::shared_ptr< HistBase > > PlotMap
 
std::vector< std::shared_ptr< HistBase > > PlotVector
 

Additional Inherited Members

- 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.
 

Detailed Description

Provide a base class for manipulating a group of histograms at the same time.

Here is a simple demonstration of how to use PlotGroup:

// demonstration of creating user's own plotgroup
#pragma once
#include "NAGASH.h"
using namespace NAGASH;
class WEvent_Skim
{
public:
TLorentzVector Lepton;
TLorentzVector MET;
TLorentzVector Recoil;
double WMT;
};
// you can call :
// ResultGroupUser()->BookResult<WCommonPlot>("GroupName", "OutputFileName");
// inside NAGASH::LoopEvent::InitialUser
class WCommonPlot : public PlotGroup
{
public:
WCommonPlot(std::shared_ptr<MSGTool> MSG, std::shared_ptr<ConfigTool> c, const TString &rname, const TString &fname = "");
void FillPlots(const WEvent &);
virtual ~WCommonPlot();
std::shared_ptr<Plot1D> LeptonPt;
std::shared_ptr<Plot1D> LeptonEta;
std::shared_ptr<Plot1D> LeptonPhi;
std::shared_ptr<Plot1D> MT;
std::shared_ptr<Plot1D> MET;
std::shared_ptr<Plot1D> WPT;
};
inline WCommonPlot::WCommonPlot(std::shared_ptr<MSGTool> MSG, std::shared_ptr<ConfigTool> c, const TString &rname, const TString &fname) : PlotGroup(MSG, c, rname, fname)
{
LeptonPt = BookPlot1D("LeptonPt", 150, 25, 100);
LeptonEta = BookPlot1D("LeptonEta", 200, -2.5, 2.5);
LeptonPhi = BookPlot1D("LeptonPhi", 200, -3.1415926, 3.1415926);
MT = BookPlot1D("MT", 300, 0, 150);
MET = BookPlot1D("MET", 300, 0, 150);
WPT = BookPlot1D("WPT", 200, 0, 100);
}
inline WCommonPlot::FillPlots(const WEvent &event)
{
LeptonPt->Fill(event.Lepton.Pt());
LeptonEta->Fill(event.Lepton.Eta());
LeptonPhi->Fill(event.Lepton.Phi());
MT->Fill(event.WMT);
MET->Fill(event.MET.Pt());
WPT->Fill(event.Result.Pt());
}
Provide a base class for manipulating a group of histograms at the same time.
Definition PlotGroup.h:18

Definition at line 17 of file PlotGroup.h.

Constructor & Destructor Documentation

◆ PlotGroup()

PlotGroup::PlotGroup ( std::shared_ptr< MSGTool MSG,
std::shared_ptr< ConfigTool c,
const TString &  rname,
const TString &  fname = "" 
)

Constructor, same as that of Result.

Definition at line 75 of file PlotGroup.cxx.

◆ ~PlotGroup()

virtual NAGASH::PlotGroup::~PlotGroup ( )
virtualdefault

Member Function Documentation

◆ AddNGHist()

template<typename HistType >
void NAGASH::PlotGroup::AddNGHist ( const TString &  name,
std::shared_ptr< NGHist< HistType > >  plot 
)
inline

Append a NGHist to this PlotGroup.

Template Parameters
HistTypethe template parameter passed to NGHist.
Parameters
namethe name of the NGHist.
plotthe NGHist to be appended.

Definition at line 131 of file PlotGroup.h.

◆ AddPlot1D()

void NAGASH::PlotGroup::AddPlot1D ( const TString &  name,
std::shared_ptr< Plot1D plot 
)
inline

Append a NGHist<TH1D> to this PlotGroup.

Parameters
namename of the NGHist.
plotthe pointer to the NGHist<TH1D> to be appended.

Definition at line 199 of file PlotGroup.h.

◆ AddPlot2D()

void NAGASH::PlotGroup::AddPlot2D ( const TString &  name,
std::shared_ptr< Plot2D plot 
)
inline

Append a NGHist<TH2D> to this PlotGroup.

Parameters
namename of the NGHist.
plotthe pointer to the NGHist<TH2D> to be appended.

Definition at line 207 of file PlotGroup.h.

◆ AddPlot3D()

void NAGASH::PlotGroup::AddPlot3D ( const TString &  name,
std::shared_ptr< Plot3D plot 
)
inline

Append a NGHist<TH3D> to this PlotGroup.

Parameters
namename of the NGHist.
plotthe pointer to the NGHist<TH3D> to be appended.

Definition at line 215 of file PlotGroup.h.

◆ BookNGHist()

template<typename HistType , typename... Args>
std::shared_ptr< NGHist< HistType > > NAGASH::PlotGroup::BookNGHist ( const TString &  name,
Args &&...  args 
)
inline

Book NGHist and store in this PlotGroup.

Template Parameters
HistTypethe template parameter passed to NGHist.
...Argscan be deduced by compiler.
Parameters
namethe name of the NGHist.
...argsthe binning parameters of NGHist.
Returns
the booked NGHist.

Definition at line 87 of file PlotGroup.h.

◆ BookPlot1D()

template<typename... Args>
std::shared_ptr< Plot1D > NAGASH::PlotGroup::BookPlot1D ( const TString &  name,
Args &&...  args 
)
inline

Book NGHist<TH1D>

Template Parameters
...Argsdeduced by compiler.
Parameters
namename of the NGHist.
...argsthe binning parameters of NGHist.
Returns
the booked NGHist<TH1D>.

Definition at line 145 of file PlotGroup.h.

◆ BookPlot2D()

template<typename... Args>
std::shared_ptr< Plot2D > NAGASH::PlotGroup::BookPlot2D ( const TString &  name,
Args &&...  args 
)
inline

Book NGHist<TH2D>

Template Parameters
...Argsdeduced by compiler.
Parameters
namename of the NGHist.
...argsthe binning parameters of NGHist.
Returns
the booked NGHist<TH2D>.

Definition at line 156 of file PlotGroup.h.

◆ BookPlot3D()

template<typename... Args>
std::shared_ptr< Plot3D > NAGASH::PlotGroup::BookPlot3D ( const TString &  name,
Args &&...  args 
)
inline

Book NGHist<TH3D>

Template Parameters
...Argsdeduced by compiler.
Parameters
namename of the NGHist.
...argsthe binning parameters of NGHist.
Returns
the booked NGHist<TH3D>.

Definition at line 167 of file PlotGroup.h.

◆ BookSystematicVariation() [1/3]

void PlotGroup::BookSystematicVariation ( const std::vector< TString > &  names,
double  corr_factor = 0,
HistBase::SystPolicy  policy = HistBase::SystPolicy::Maximum 
)

Book systematic variations for each histogram inside this PlotGroup.

Parameters
namesvector of names of the systematic variations.
corr_factorcorrelation factor.
policypolicy to deal with the systematic variations.

Definition at line 304 of file PlotGroup.cxx.

◆ BookSystematicVariation() [2/3]

void PlotGroup::BookSystematicVariation ( const TString &  name,
double  corr_factor = 0,
HistBase::SystPolicy  policy = HistBase::SystPolicy::Maximum 
)

Book systematic variations for each histogram inside this PlotGroup.

Parameters
namename of the systematic variation.
corr_factorcorrelation factor.
policypolicy to deal with the systematic variation.

Definition at line 283 of file PlotGroup.cxx.

◆ BookSystematicVariation() [3/3]

void PlotGroup::BookSystematicVariation ( const TString &  name1,
const TString &  name2,
double  corr_factor = 0,
HistBase::SystPolicy  policy = HistBase::SystPolicy::Maximum 
)

Book systematic variations for each histogram inside this PlotGroup.

Parameters
name1name of the first systematic variation.
name2name of the second systematic variation.
corr_factorcorrelation factor.
policypolicy to deal with the systematic variations.

Definition at line 294 of file PlotGroup.cxx.

◆ ClearLinkPlotGroup()

void PlotGroup::ClearLinkPlotGroup ( )

Clear the linked plotgroup.

Definition at line 182 of file PlotGroup.cxx.

◆ Clone()

std::shared_ptr< PlotGroup > PlotGroup::Clone ( const TString &  name)

Clone this PlotGroup.

Parameters
namethe name of the new PlotGroup.

Definition at line 260 of file PlotGroup.cxx.

◆ Combine()

void PlotGroup::Combine ( std::shared_ptr< Result result)
overridevirtual

Combine two PlotGroups.

Reimplemented from NAGASH::Result.

Definition at line 80 of file PlotGroup.cxx.

◆ ForEachPlot()

void PlotGroup::ForEachPlot ( std::function< void(std::shared_ptr< HistBase >)>  func)

Apply the given function to each histogram inside this PlotGroup.

Parameters
functhe function to be applied to each histogram.

Definition at line 113 of file PlotGroup.cxx.

◆ GetNGHist()

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

Get booked NGHist with given name.

Template Parameters
HistTypethe template parameter passed to NGHist.
Parameters
namethe name of the NGHist.
Returns
the pointer to the booked NGHist, if not found, nullptr is returned.

Definition at line 109 of file PlotGroup.h.

◆ GetNPlots()

int PlotGroup::GetNPlots ( )

Get the number of histograms stored inside this PlotGroup.

Definition at line 274 of file PlotGroup.cxx.

◆ GetPlot1D()

std::shared_ptr< Plot1D > NAGASH::PlotGroup::GetPlot1D ( const TString &  name)
inline

Get NGHist<TH1D>

Parameters
namename of the NGHist.
Returns
the pointer to the NGHist<TH1D>, if not found, nullptr is returned.

Definition at line 175 of file PlotGroup.h.

◆ GetPlot2D()

std::shared_ptr< Plot2D > NAGASH::PlotGroup::GetPlot2D ( const TString &  name)
inline

Get NGHist<TH2D>

Parameters
namename of the NGHist.
Returns
the pointer to the NGHist<TH2D>, if not found, nullptr is returned.

Definition at line 183 of file PlotGroup.h.

◆ GetPlot3D()

std::shared_ptr< Plot3D > NAGASH::PlotGroup::GetPlot3D ( const TString &  name)
inline

Get NGHist<TH3D>

Parameters
namename of the NGHist.
Returns
the pointer to the NGHist<TH3D>, if not found, nullptr is returned.

Definition at line 191 of file PlotGroup.h.

◆ Process()

void PlotGroup::Process ( )

Call NGHist::Process() for each histogram inside this PlotGroup.

Definition at line 105 of file PlotGroup.cxx.

◆ Recover() [1/3]

void PlotGroup::Recover ( const TString &  filename)

Retrieve histograms from the input file.

Parameters
filenamethe name of the input ROOT file.

Definition at line 219 of file PlotGroup.cxx.

◆ Recover() [2/3]

void PlotGroup::Recover ( std::shared_ptr< TFileHelper file)

Retrieve histograms from the input file.

Parameters
filethe pointer to the TFileHelper.

Definition at line 251 of file PlotGroup.cxx.

◆ Recover() [3/3]

void PlotGroup::Recover ( TFile *  file)

Retrieve histograms from the input file.

Parameters
filethe pointer to the ROOT TFile.

Definition at line 236 of file PlotGroup.cxx.

◆ RegroupSystematicVariation()

void PlotGroup::RegroupSystematicVariation ( const std::vector< TString > &  names,
HistBase::SystPolicy  policy 
)

Call NGHist::RegroupSystematicVariation for each histogram inside this PlotGroup.

Definition at line 311 of file PlotGroup.cxx.

◆ RemoveSystematicVariation()

void PlotGroup::RemoveSystematicVariation ( const TString &  name)

Call NGHist::RemoveSystematicVariation for each histogram inside this PlotGroup.

Definition at line 318 of file PlotGroup.cxx.

◆ RenameSystematicVariation()

void PlotGroup::RenameSystematicVariation ( const TString &  name_old,
const TString &  name_new 
)

Call NGHist::RenameSystematicVariation for each histogram inside this PlotGroup.

Definition at line 325 of file PlotGroup.cxx.

◆ Reset()

void PlotGroup::Reset ( )

Call NGHist::Reset() for each histogram inside this PlotGroup.

Definition at line 210 of file PlotGroup.cxx.

◆ Scale()

void PlotGroup::Scale ( double  sf)

Call NGHist::Scale() for each histogram inside this PlotGroup.

Parameters
sfthe scale factor.

Definition at line 128 of file PlotGroup.cxx.

◆ ScaleVariation()

void PlotGroup::ScaleVariation ( const TString &  varname,
double  sf 
)

Scale a variation of each histogram inside this PlotGroup.

Parameters
varnamethe name of the variation.
sfthe scale factor.

Definition at line 137 of file PlotGroup.cxx.

◆ SetLinkPlotGroup()

void PlotGroup::SetLinkPlotGroup ( uint64_t  index,
std::shared_ptr< PlotGroup pg 
)

Set the linked plotgroup, should be the same structure of this one.

Definition at line 171 of file PlotGroup.cxx.

◆ SetLinkType() [1/3]

void PlotGroup::SetLinkType ( const TString &  type)

Set the type of the link for each histogram inside this PlotGroup.

Definition at line 157 of file PlotGroup.cxx.

◆ SetLinkType() [2/3]

void PlotGroup::SetLinkType ( std::function< double(const std::vector< double > &)>  cf,
std::function< double(const std::vector< double > &, const std::vector< double > &)>  ef 
)

Set link function for each histogram inside this PlotGroup.

Definition at line 150 of file PlotGroup.cxx.

◆ SetLinkType() [3/3]

void PlotGroup::SetLinkType ( std::function< void(const std::vector< TH1 * > &, TH1 *)>  hf)

Set the type of the link for each histogram inside this PlotGroup.

Definition at line 164 of file PlotGroup.cxx.

◆ SetSystematicVariation() [1/2]

void PlotGroup::SetSystematicVariation ( const TString &  name = "Nominal")

Set the systematic variation for each histogram inside this PlotGroup.

Parameters
namethe name of the systematic variation.

Definition at line 333 of file PlotGroup.cxx.

◆ SetSystematicVariation() [2/2]

void PlotGroup::SetSystematicVariation ( int  index)

Set the systematic variation for each histogram inside this PlotGroup.

Parameters
indexindex of the systematic variation.

Definition at line 341 of file PlotGroup.cxx.

◆ SetUnprocessed()

void PlotGroup::SetUnprocessed ( )

Call NGHist::SetUnprocessed() for each histogram inside this PlotGroup.

Definition at line 120 of file PlotGroup.cxx.

◆ WriteToFile()

void PlotGroup::WriteToFile ( )
overridevirtual

Write all histograms inside this PlotGroup to a file.

Reimplemented from NAGASH::Result.

Definition at line 191 of file PlotGroup.cxx.

Member Data Documentation

◆ maptool

MapTool NAGASH::PlotGroup::maptool
private

Definition at line 23 of file PlotGroup.h.

◆ PlotMap

std::map<TString, std::shared_ptr<HistBase> > NAGASH::PlotGroup::PlotMap
private

Definition at line 20 of file PlotGroup.h.

◆ PlotVector

std::vector<std::shared_ptr<HistBase> > NAGASH::PlotGroup::PlotVector
private

Definition at line 21 of file PlotGroup.h.


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