75PlotGroup::PlotGroup(std::shared_ptr<MSGTool> MSG, std::shared_ptr<ConfigTool> c,
const TString &rname,
const TString &fname) :
Result(MSG, c, rname, fname), maptool(MSG)
82 MSGUser()->StartTitle(
"PlotGroup::Combine");
83 auto subPlotGroup = std::dynamic_pointer_cast<std::remove_pointer<
decltype(
this)>::type>(result);
84 if (subPlotGroup !=
nullptr)
86 for (
auto &sub : subPlotGroup->PlotMap)
88 auto findresult = this->
PlotMap.find(sub.first);
89 if (findresult != this->
PlotMap.end())
91 findresult->second->Combine(sub.second);
95 auto subname = sub.first;
96 auto newPlot = sub.second->CloneVirtual(this->
GetResultName() +
" " + subname);
97 this->
PlotMap.emplace(std::pair<TString, std::shared_ptr<HistBase>>(subname, newPlot));
139 auto titleguard =
MSGUser()->StartTitleWithGuard(
"PlotGroup::ScaleVariation");
142 if (
auto h = t->GetVariationVirtual(varname); h)
145 MSGUser()->MSG_WARNING(
"plot ", t->GetResultName(),
" does not have variation ", varname,
", will not scale this variation");
150void PlotGroup::SetLinkType(std::function<
double(
const std::vector<double> &)> cf, std::function<
double(
const std::vector<double> &,
const std::vector<double> &)> ef)
153 t->SetLinkType(cf, ef);
160 t->SetLinkType(type);
173 for (
auto &t : pg->PlotMap)
175 auto findresult = this->
PlotMap.find(t.first);
176 if (findresult != this->
PlotMap.end())
177 findresult->second->SetLinkPlot(index, t.second);
193 auto titleguard =
MSGUser()->StartTitleWithGuard(
"Plot1D::WriteToFile");
212 auto titlegurad =
MSGUser()->StartTitleWithGuard(
"PlotGroup::Reset");
221 auto titlegurad =
MSGUser()->StartTitleWithGuard(
"PlotGroup::Recover");
222 TFile *file =
new TFile(filename.TString::Data());
225 MSGUser()->MSG_ERROR(
"ROOT file ", filename,
" does not exist");
238 auto titlegurad =
MSGUser()->StartTitleWithGuard(
"PlotGroup::Recover");
241 MSGUser()->MSG_ERROR(
"ROOT file does not exist");
253 auto titlegurad =
MSGUser()->StartTitleWithGuard(
"PlotGroup::Recover");
265 auto newplot = t.second->CloneVirtual(name +
"_" + t.first);
266 newPlotGroup->PlotMap.insert(std::pair<TString, std::shared_ptr<HistBase>>(t.first, newplot));
286 t->BookSystematicVariation(name, corr_factor, policy);
297 t->BookSystematicVariation(name1, name2, corr_factor, policy);
307 t->BookSystematicVariation(names, corr_factor, policy);
314 t->RegroupSystematicVariation(names, policy);
321 t->RemoveSystematicVariation(name);
328 t->RenameSystematicVariation(name_old, name_new);
336 t->SetSystematicVariation(name);
344 t->SetSystematicVariation(index);
SystPolicy
Policies of dealing with systematic uncertainties.
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 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
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.
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 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.
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.
PlotGroup(std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c, const TString &rname, const TString &fname="")
Constructor, same as that of Result.
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.
Provide virtual interface to manipulate all the results inside NAGASH.
const TString & GetOutputFileName()
Return the name of the result.
const TString & GetResultName()
std::shared_ptr< ConfigTool > ConfigUser()
Return the internal ConfigTool.>
std::shared_ptr< MSGTool > MSGUser()
Return the internal MSGTool.