20 std::map<TString, std::shared_ptr<HistBase>>
PlotMap;
26 PlotGroup(std::shared_ptr<MSGTool> MSG, std::shared_ptr<ConfigTool> c,
const TString &rname,
const TString &fname =
"");
28 template <
typename... Args>
29 std::shared_ptr<Plot1D>
BookPlot1D(
const TString &name, Args &&...args);
30 template <
typename... Args>
31 std::shared_ptr<Plot2D>
BookPlot2D(
const TString &name, Args &&...args);
32 template <
typename... Args>
33 std::shared_ptr<Plot3D>
BookPlot3D(
const TString &name, Args &&...args);
35 std::shared_ptr<Plot1D>
GetPlot1D(
const TString &name);
36 std::shared_ptr<Plot2D>
GetPlot2D(
const TString &name);
37 std::shared_ptr<Plot3D>
GetPlot3D(
const TString &name);
39 void AddPlot1D(
const TString &name, std::shared_ptr<Plot1D> plot);
40 void AddPlot2D(
const TString &name, std::shared_ptr<Plot2D> plot);
41 void AddPlot3D(
const TString &name, std::shared_ptr<Plot3D> plot);
44 template <
typename HistType,
typename... Args>
45 std::shared_ptr<NGHist<HistType>>
BookNGHist(
const TString &name, Args &&...args);
46 template <
typename HistType>
47 std::shared_ptr<NGHist<HistType>>
GetNGHist(
const TString &name);
48 template <
typename HistType>
53 void ForEachPlot(std::function<
void(std::shared_ptr<HistBase>)>);
58 void SetLinkType(std::function<
double(
const std::vector<double> &)>, std::function<
double(
const std::vector<double> &,
const std::vector<double> &)>);
59 void SetLinkType(std::function<
void(
const std::vector<TH1 *> &, TH1 *)>);
63 void Recover(
const TString &filename);
65 void Recover(std::shared_ptr<TFileHelper>);
66 std::shared_ptr<PlotGroup>
Clone(
const TString &name);
75 void Combine(std::shared_ptr<Result> result)
override;
86 template <
typename HistType,
typename... Args>
92 PlotMap.emplace(std::pair<TString, std::shared_ptr<HistBase>>(name, tempplot));
98 auto guard =
MSGUser()->StartTitleWithGuard(
"PlotGroup::BookNGHist");
99 MSGUser()->MSG_WARNING(
"Plot ", name,
" has already been booked, returning nullptr");
108 template <
typename HistType>
111 auto guard =
MSGUser()->StartTitleWithGuard(
"PlotGroup::GetNGHist");
112 std::shared_ptr<NGHist<HistType>> plot =
nullptr;
114 if (findresult !=
PlotMap.end())
115 plot = std::dynamic_pointer_cast<NGHist<HistType>>(findresult->second);
121 MSGUser()->MSG_WARNING(
"Plot ", name,
" does not exist, returning nullptr");
130 template <
typename HistType>
133 PlotMap.emplace(std::pair<TString, std::shared_ptr<HistBase>>(name, plot));
144 template <
typename... Args>
147 return BookNGHist<TH1D>(name, std::forward<Args>(args)...);
155 template <
typename... Args>
158 return BookNGHist<TH2D>(name, std::forward<Args>(args)...);
166 template <
typename... Args>
169 return BookNGHist<TH3D>(name, std::forward<Args>(args)...);
177 return GetNGHist<TH1D>(name);
185 return GetNGHist<TH2D>(name);
193 return GetNGHist<TH3D>(name);
201 AddNGHist<TH1D>(name, plot);
209 AddNGHist<TH2D>(name, plot);
217 AddNGHist<TH3D>(name, plot);
SystPolicy
Policies of dealing with systematic uncertainties.
@ Maximum
take the maximum difference in the same group.
NAGASH interface for using ROOT histograms.
Provide a base class for manipulating a group of histograms at the same time.
std::shared_ptr< Plot2D > BookPlot2D(const TString &name, Args &&...args)
Book NGHist<TH2D>
void SetLinkPlotGroup(uint64_t, std::shared_ptr< PlotGroup >)
Set the linked plotgroup, should be the same structure of this one.
void WriteToFile() override
Write all histograms inside this PlotGroup to a file.
void AddNGHist(const TString &name, std::shared_ptr< NGHist< HistType > > plot)
Append a NGHist to this PlotGroup.
std::shared_ptr< NGHist< HistType > > GetNGHist(const TString &name)
Get booked NGHist with given name.
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 Reset()
Call NGHist::Reset() for each histogram inside this PlotGroup.
void Scale(double)
Call NGHist::Scale() for each histogram inside this PlotGroup.
void SetSystematicVariation(const TString &name="Nominal")
Set the systematic variation for each histogram inside this PlotGroup.
std::map< TString, std::shared_ptr< HistBase > > PlotMap
std::shared_ptr< NGHist< HistType > > BookNGHist(const TString &name, Args &&...args)
Book NGHist and store in this PlotGroup.
std::shared_ptr< Plot3D > GetPlot3D(const TString &name)
Get NGHist<TH3D>
void AddPlot2D(const TString &name, std::shared_ptr< Plot2D > plot)
Append a NGHist<TH2D> to this PlotGroup.
std::shared_ptr< Plot1D > GetPlot1D(const TString &name)
Get NGHist<TH1D>
std::shared_ptr< Plot3D > BookPlot3D(const TString &name, Args &&...args)
Book NGHist<TH3D>
void Process()
Call NGHist::Process() for each histogram inside this PlotGroup.
void ClearLinkPlotGroup()
Clear the linked plotgroup.
void Recover(const TString &filename)
Retrieve histograms from the input file.
std::vector< std::shared_ptr< HistBase > > PlotVector
void SetLinkType(const TString &)
Set the type of the link for each histogram inside this PlotGroup.
std::shared_ptr< Plot1D > BookPlot1D(const TString &name, Args &&...args)
Book NGHist<TH1D>
void Combine(std::shared_ptr< Result > result) override
Combine two PlotGroups.
void RegroupSystematicVariation(const std::vector< TString > &names, HistBase::SystPolicy policy)
Call NGHist::RegroupSystematicVariation for each histogram inside this PlotGroup.
void AddPlot3D(const TString &name, std::shared_ptr< Plot3D > plot)
Append a NGHist<TH3D> to 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.
std::shared_ptr< PlotGroup > Clone(const TString &name)
Clone this PlotGroup.
std::shared_ptr< Plot2D > GetPlot2D(const TString &name)
Get NGHist<TH2D>
void ScaleVariation(const TString &, double)
Scale a variation of each histogram inside this PlotGroup.
int GetNPlots()
Get the number of histograms stored inside this PlotGroup.
void ForEachPlot(std::function< void(std::shared_ptr< HistBase >)>)
Apply the given function to each histogram inside this PlotGroup.
void SetUnprocessed()
Call NGHist::SetUnprocessed() for each histogram inside this PlotGroup.
virtual ~PlotGroup()=default
void AddPlot1D(const TString &name, std::shared_ptr< Plot1D > plot)
Append a NGHist<TH1D> to this PlotGroup.
Provide virtual interface to manipulate all the results inside NAGASH.
const TString & GetResultName()
std::shared_ptr< ConfigTool > ConfigUser()
Return the internal ConfigTool.>
std::shared_ptr< MSGTool > MSGUser()
Return the internal MSGTool.