24 #include "RooUnfoldResponse.h" 44 AliInfo(Form(
"Scaled merging for list %s is %sactivated.", hlist->GetName(),(
fUseScaling) ?
"" :
"not "));
54 if(!(xsection && ntrials))
55 AliFatal(
"Scaled merging is active but AliEmcalList does not contain fHistXsection or fHistTrials. Do not activate scaling for those lists or include these histograms.");
64 AliInfo(Form(
"===== LAST LEVEL OF MERGING ====="));
71 TIter listIterator(hlist);
72 while (
AliEmcalList* tmpList = static_cast<AliEmcalList*>(listIterator()))
74 xsection =
static_cast<TH1*
>(tmpList->FindObject(
"fHistXsection"));
75 ntrials =
static_cast<TH1*
>(tmpList->FindObject(
"fHistTrials"));
81 AliInfo(
"Merge() done.");
84 return hlist->GetEntries() + 1;
91 TIter listIterator(hlist);
92 while (
TObject* listObject = listIterator())
103 if (!(listObject->InheritsFrom(TH1::Class()) || listObject->InheritsFrom(THnBase::Class())))
107 TString histogram_class (listObject->ClassName());
108 TString histogram_name (listObject->GetName());
109 if (histogram_name.Contains(
"fHistXsection") || histogram_name.Contains(
"fHistTrials") || histogram_name.Contains(
"fHistEvents"))
111 AliInfo(Form(
"Histogram %s will not be scaled, because a scaling histogram", listObject->GetName()));
114 if (histogram_class.Contains(
"TProfile"))
116 AliInfo(Form(
"Histogram %s will not be scaled, because it is a TProfile", listObject->GetName()));
120 TH1 *histogram =
dynamic_cast<TH1 *
>(listObject);
124 histogram->Scale(scalingFactor);
125 }
else if(listObject->InheritsFrom(THnBase::Class())){
127 THnBase *histogramND =
dynamic_cast<THnBase *
>(listObject);
128 histogramND->Sumw2();
129 histogramND->Scale(scalingFactor);
131 #ifdef WITH_ROOUNFOLD 132 else if(listObject->InheritsFrom(RooUnfoldResponse::Class())){
133 RooUnfoldResponse *response =
dynamic_cast<RooUnfoldResponse *
>(listObject);
134 if(
auto measured = response->Hmeasured()) measured->Scale(scalingFactor);
135 if(
auto fakes = response->Hfakes()) fakes->Scale(scalingFactor);
136 if(
auto truth = response->Htruth()) truth->Scale(scalingFactor);
137 if(
auto responseND = response->Hresponse()) responseND->Scale(scalingFactor);
140 AliInfo(Form(
"Histogram %s (%s) was scaled...", listObject->GetName(), histogram_class.Data()));
152 AliInfo(
"List already scaled or scaling invalid. Scaling factor = 1.");
156 Double_t valNTRIALS = ntrials->GetBinContent(binNumber);
157 Double_t valXSEC = xsection->GetBinContent(binNumber);
160 scalingFactor = valXSEC/valNTRIALS;
162 AliInfo(Form(
"## Bin %i: trials=%f, xsec=%f -> scaling=%f", binNumber, valNTRIALS, valXSEC, scalingFactor));
163 return scalingFactor;
175 TIter listIterator(collection);
176 while (
AliEmcalList* tmpList = static_cast<AliEmcalList*>(listIterator()))
179 xsection =
static_cast<TH1*
>(tmpList->FindObject(
"fHistXsection"));
192 AliInfo(Form(
"%s: nbinsX=%i", hist->GetName(), hist->GetNbinsX()));
195 for(
Int_t i=1; i<=hist->GetNbinsX(); i++)
197 AliInfo(Form(
"%s: bin=%i, val=%f", hist->GetName(), i, hist->GetBinContent(i)));
198 if(hist->GetBinContent(i))
210 AliError(
"No bin filled in scaling histogram.");
Bool_t fUseScaling
if true, scaling will be done. if false AliEmcalList simplifies to TList
Int_t GetFilledBinNumber(TH1 *hist)
void ScaleAllHistograms(TCollection *hlist, Double_t scalingFactor)
Function that does the scaling of all histograms in hlist recursively.
Bool_t IsLastMergeLevel(TCollection *collection)
Double_t GetScalingFactor(TH1 *xsection, TH1 *ntrials)
Helper function scaling factor.
Long64_t Merge(TCollection *hlist)
Overridden Merge function.
TH1 * Merge(const TH1 *cen, const TH1 *fwd, Double_t &xlow, Double_t &xhigh)
TObject * FindObject(int bin, const char *nameH, const TList *lst, Bool_t normPerEvent=kTRUE)
Enhanced TList-derived class that implements correct merging for pt_hard binned production.