6 #include <TMultiGraph.h> 7 #include <TGraphAsymmErrors.h> 84 if (l <= 0 && h >= 100) n =
new TObjString(
"all");
85 else n =
new TObjString(Form(
"cent%03d_%03d", l, h));
86 n->SetUniqueID((h & 0xFFFF) << 16 | (l & 0xFFFF));
99 if (a->GetEntries() < 3) {
100 Error(
"SetOrder",
"Order must contain a pertubation of " 101 "\"sl\", \"sh\", and \"dc\", separated by spaces");
105 for (
Int_t i = 0; i < 3; i++) {
106 const TString& n =
static_cast<TObjString*
>(a->At(i))->String();
108 if (n.EqualTo(
"sl", TString::kIgnoreCase)) l = &
fSLCuts;
109 else if (n.EqualTo(
"sh", TString::kIgnoreCase)) l = &
fSHCuts;
110 else if (n.EqualTo(
"dc", TString::kIgnoreCase)) l = &
fDCCuts;
112 Error(
"SetOrder",
"Unknown cut \"%s\"", n.Data());
113 fOrder[0] = fOrder[1] = fOrder[2] = 0;
129 void Run(
const char* output=
"trending.root",
135 outName.ReplaceAll(
".pdf",
".root");
136 if (!outName.EndsWith(
".root")) outName.Append(
".root");
138 pdfName.ReplaceAll(
".root",
".pdf");
142 TFile* out = TFile::Open(outName,
"RECREATE");
143 TDirectory* refDir = out->mkdir(
"reference");
147 while ((pCent = iCent())) {
148 UShort_t low = (pCent->GetUniqueID() & 0xFFFF);
149 UShort_t high = (pCent->GetUniqueID() >> 16) & 0xFFFF;
153 TString name(graph->GetName());
154 name.Append(Form(
"_%s", pCent->GetName()));
155 graph->SetName(name);
163 while ((pRun = iRun())) {
164 TString sRun = pRun->GetName();
165 TDirectory* dRun = out->mkdir(sRun);
169 for (
Int_t i = 0; i < 1; i++) {
170 TString three(Form(
"%dstrip", i+2));
171 TDirectory* dStrip = dRun->mkdir(three);
175 three.Append(
"_slX_shX_dcX");
208 TString pre(Form(
"%s%s",(cuts3 ?
"" :
"_"), (cuts2 ?
"" :
"_")));
209 Printf(
"%s%s", pre.Data(), cur.Data());
211 TDirectory* dCut = out->mkdir(cuts1->GetName());
215 while ((pCut = iCut())) {
216 TString sMethod = pCut->GetName();
217 TDirectory* dMethod = dCut->mkdir(sMethod);
218 TString sValues = pCut->GetTitle();
219 TObjArray* aValues = sValues.Tokenize(
" ");
220 TIter iValue(aValues);
221 TObjString* pValue = 0;
222 TString templ(Form(
"%s%s", cuts1->GetName(), sMethod.Data()));
224 base.ReplaceAll(Form(
"%sX", cuts1->GetName()), templ);
225 aValues->SetName(cuts1->GetName());
232 dMethod->Add(ratios);
235 while ((pValue = static_cast<TObjString*>(iValue()))) {
236 TString sValue(Form(
"%05.2f", pValue->String().Atof()));
237 sValue.ReplaceAll(
".",
"d");
238 TDirectory* dValue = dMethod->mkdir(sValue);
240 TString sub(Form(
"%s%s", templ.Data(), sValue.Data()));
241 now.ReplaceAll(templ.Data(), sub.Data());
248 dValue, xbin, mean, ratios);
252 if (!
NextFile(run, now, dValue, xbin,
273 while ((pCent = iCent())) {
274 TH1* h =
static_cast<TH1*
>(mean->GetHists()->At(jCent));
287 TIter nextHist(ratios->GetHists());
289 while ((hist = static_cast<TH1*>(nextHist())))
297 if (mean && mean->GetHists()->GetEntries() > 0 &&
298 ratios && ratios->GetHists() &&
299 ratios->GetHists()->GetEntries() > 0) {
303 PrintCanvas(Form(
"%s_%s", pre.Data(), base.Data()), 0.5);
322 TDirectory* out,
Int_t binx,
323 THStack* mean, THStack* ratios)
325 TString dir(Form(
"%s_dndeta_%s", run.Data(), now.Data()));
326 TString path(Form(
"%s/forward_dndeta.root", dir.Data()));
327 if (
gSystem->AccessPathName(path.Data())) {
328 Warning(
"NextFile",
"%s not found", path.Data());
331 TFile*
file = TFile::Open(path,
"READ");
333 Warning(
"NextFile",
"Failed to open %s", path.Data());
339 if (!results)
return false;
343 THStack* all =
new THStack(
"all",
"All");
344 THStack* rat =
new THStack(
"ratios",
"Ratios");
349 while ((pCent = iCent())) {
350 TString folderName(pCent->GetName());
353 Warning(
"",
"Didn't get the centrality %s folder from %s",
354 folderName.Data(), results->GetName());
360 if (mcResults) mcCentFolder =
GetCollection(mcResults, folderName);
365 Warning(
"",
"Didn't get histogram for jCent=%d in %s",
370 dNdeta->SetDirectory(out);
371 dNdeta->SetName(folderName);
372 dNdeta->SetMarkerColor(jCent+1);
373 dNdeta->SetLineColor(jCent+1);
377 other =
GetH1(mcCentFolder, Form(
"dndetaMCTruth%s",
383 other =
G2H(graph, *(dNdeta->GetXaxis()));
387 Warning(
"",
"No other data found for %s", path.Data());
391 other->SetMarkerColor(dNdeta->GetMarkerColor());
392 other->SetMarkerSize(dNdeta->GetMarkerSize());
393 other->SetLineColor(dNdeta->GetLineColor());
394 other->SetDirectory(out);
395 folderName.ReplaceAll(
"cent",
"other");
396 folderName.ReplaceAll(
"all",
"other");
397 other->SetName(folderName);
402 folderName.ReplaceAll(
"other",
"ratio");
403 TH1* ratio =
static_cast<TH1*
>(dNdeta->Clone(folderName));
404 ratio->SetTitle(Form(
"%s %s", dir.Data(), pCent->GetName()));
405 ratio->SetDirectory(out);
406 ratio->Divide(other);
407 ratio->SetMarkerStyle(20+binx-1);
408 ratio->SetMarkerColor(jCent+1);
409 ratio->SetLineColor(kGray);
410 ratio->SetLineWidth(0);
424 fBody->Divide(1,2,0,0);
430 if (jCent <= 0)
return false;
448 mean =
new THStack(
"mean", run);
449 ratios =
new THStack(
"ratios", run);
452 Int_t nValues = values->GetEntriesFast();
456 while ((pcent = nextCent())) {
457 UShort_t low = (pcent->GetUniqueID() & 0xFFFF);
458 UShort_t high = (pcent->GetUniqueID() >> 16) & 0xFFFF;
460 TH1* hMean =
new TH1D(pcent->GetName(),
461 Form(
"%s %d%%-%d%% central", run.Data(),
463 nValues, .5, nValues+.5);
464 hMean->SetMarkerColor(col);
465 hMean->SetMarkerStyle(20);
466 hMean->SetLineColor(col);
467 hMean->SetXTitle(Form(
"Cut parameter X_{%s}", values->GetName()));
468 hMean->SetYTitle(
"Average, spread, and min/max of ratio");
469 hMean->SetDirectory(0);
471 TObjString* pvalue = 0;
473 while ((pvalue = static_cast<TObjString*>(nextV()))) {
474 TString& value = pvalue->String();
475 hMean->GetXaxis()->SetBinLabel(xbin, value);
480 gWSpread->SetName(
"minmax");
481 gWSpread->SetTitle(hMean->GetTitle());
482 gWSpread->SetMarkerColor(col);
483 gWSpread->SetLineColor(col);
484 gWSpread->SetFillColor(0);
485 gWSpread->SetFillStyle(0);
487 hMean->GetListOfFunctions()->Add(gWSpread,
"[]pl same");
488 mean->Add(hMean,
"x0 e1");
511 h->SetMinimum(0.95*min);
512 h->SetMaximum(1.1*max);
514 TH1* hMean =
static_cast<TH1*
>(stack->GetHists()->At(i));
515 hMean->SetBinContent(binx, avg);
516 hMean->SetBinError(binx,var);
518 TObject* pG = hMean->GetListOfFunctions()->FindObject(
"minmax");
520 hMean->GetListOfFunctions()->ls();
524 gWSpread->SetPoint(binx-1, binx, avg);
525 gWSpread->SetPointError(binx-1,0, 0,
526 TMath::Abs(avg-min), TMath::Abs(max-avg));
543 while ((pCent = iCent())) {
544 UShort_t low = (pCent->GetUniqueID() & 0xFFFF);
545 UShort_t high = (pCent->GetUniqueID() >> 16) & 0xFFFF;
547 TLegendEntry* e = l->AddEntry(
"dummy",
548 Form(
"%2d%% - %2d%% central", low, high),
550 e->SetFillColor(col);
551 e->SetMarkerColor(col);
552 e->SetLineColor(col);
553 e->SetMarkerStyle(20);
557 stack->GetHistogram()->GetListOfFunctions()->Add(l);
574 l->SetX1(p->GetLeftMargin());
575 l->SetX2(1-p->GetRightMargin());
580 TIter iHist(stack->GetHists());
582 while ((pHist = static_cast<TH1*>(iHist()))) {
586 if (idx != kNPOS)
title.Remove(idx, 5+3+3+1);
588 idx =
title.Index(
"_dndeta");
589 if (idx != kNPOS)
title.Remove(0, idx+6+1+1);
592 if (before)
continue;
594 seen.Add(
new TObjString(
title));
596 TLegendEntry* e = l->AddEntry(
"dummy",
title,
"p");
597 e->SetMarkerColor(kBlack);
598 e->SetMarkerStyle(pHist->GetMarkerStyle());
601 if (stack->GetHistogram()) {
602 stack->GetHistogram()->GetListOfFunctions()->Add(l);
623 Warning(
"DrawStacks",
"Stack is missing!");
626 if (!stack->GetHists() || stack->GetHists()->GetEntries() <= 0) {
627 Warning(
"DrawStacks",
"Stack is empty");
630 TH1* first =
static_cast<TH1*
>(stack->GetHists()->At(0));
631 TString xT = first->GetXaxis()->GetTitle();
634 stack->Draw(
"nostack");
636 stack->GetXaxis()->SetTitle(xT);
661 mean += (y - mean) / cnt;
662 var += (cnt > 1 ? (TMath::Power(y-mean,2)/(cnt-1)-var/cnt) : 0);
685 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
687 if (TMath::Abs(y) <= 1e-9)
continue;
688 min = TMath::Min(min, y);
689 max = TMath::Max(max, y);
703 TIter iHist(stack->GetHists());
707 while((pHist = static_cast<TH1*>(iHist()))) {
708 m1 = TMath::Min(m1, pHist->GetMinimum(1e-6));
709 m2 = TMath::Max(m2, pHist->GetMaximum());
714 stack->SetMinimum((m1 < 0 ? 1.05 : 0.95) * m1);
715 stack->SetMaximum((m2 > 0 ? 1.05 : 0.95) * m2);
729 if (axis.GetXbins()->GetArray())
730 h =
new TH1D(g->GetName(), g->GetTitle(),
731 axis.GetNbins(), axis.GetXbins()->GetArray());
733 h =
new TH1D(g->GetName(), g->GetTitle(),
734 axis.GetNbins(), axis.GetXmin(), axis.GetXmax());
735 h->SetMarkerColor(g->GetMarkerColor());
736 h->SetMarkerStyle(g->GetMarkerStyle());
737 h->SetMarkerSize(g->GetMarkerSize());
738 h->SetLineColor(g->GetLineColor());
739 h->SetLineStyle(g->GetLineStyle());
740 h->SetLineWidth(g->GetLineWidth());
741 h->SetFillColor(g->GetFillColor());
742 h->SetFillStyle(g->GetFillStyle());
745 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
746 Double_t x = h->GetXaxis()->GetBinCenter(i);
748 h->SetBinContent(i, y);
774 if (!gROOT->GetClass(
"RefData")) {
775 TString savPath(gROOT->GetMacroPath());
776 gROOT->SetMacroPath(Form(
"%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
777 gROOT->GetMacroPath()));
778 gROOT->LoadMacro(
"OtherData.C++");
779 gROOT->SetMacroPath(savPath);
781 Long_t ret = gROOT->ProcessLine(Form(
"RefData::GetData(%d,%d,%d,%d,%d,0x4)",
782 sys, sNN, trg, lowC, highC));
784 Warning(
"GetOther",
"No other data for %d %d %d %d%%-%d%% central",
785 sys, sNN, trg, lowC, highC);
788 TMultiGraph* others =
reinterpret_cast<TMultiGraph*
>(ret);
789 TGraph* other =
static_cast<TGraph*
>(others->GetListOfGraphs()->At(0));
791 Warning(
"GetOther",
"No ALICE data for %d %d %d %d%%-%d%% central",
792 sys, sNN, trg, lowC, highC);
void Run(const char *output="trending.root", UShort_t sys=2, UShort_t sNN=2760, UShort_t trg=1)
void AddSLCut(const TString &name, const TString &values)
Base class for classes to draw summaries.
static TH1 * GetH1(const TObject *parent, const TString &name, Bool_t verb=true)
void AddCentrality(UShort_t l, UShort_t h)
void MakeStacks(const TString &run, const TObjArray *values, THStack *&mean, THStack *&ratios)
static void Statistics(Double_t y, Int_t &cnt, Double_t &mean, Double_t &var)
void BuildCutLegend(TVirtualPad *p, UInt_t where, THStack *stack)
void LoopCuts(const TString &run, const TString &cur, const TList *cuts1, const TList *cuts2, const TList *cuts3, TDirectory *out, Int_t upBin=0, THStack *upMean=0, THStack *upRatios=0)
void MakeChapter(const TString &title)
void UpdateStacks(TH1 *h, Int_t i, Int_t binx, THStack *stack)
void AddDCCut(const TString &name, const TString &values)
static TGraph * GetOther(UShort_t sys, UShort_t sNN, UShort_t trg, UShort_t lowC, UShort_t highC)
static void HistStatistics(const TH1 *h, Double_t &mean, Double_t &var, Double_t &min, Double_t &max)
void CreateCanvas(const TString &pname, Bool_t landscape=false, Bool_t pdf=true, Bool_t useTop=true)
void BuildCentLegend(TVirtualPad *p, UInt_t where, THStack *stack=0)
TLegend * MakeLegend(TVirtualPad *p, UInt_t flags, Bool_t autoFill)
void AddRun(const TString &name)
static TH1 * G2H(const TGraph *g, const TAxis &axis)
void PrintCanvas(const TString &title, Float_t size=.7)
Bool_t NextFile(const TString &run, const TString &now, TDirectory *out, Int_t binx, THStack *mean, THStack *ratios)
void AddSHCut(const TString &name, const TString &values)
void SetOrder(const TString &order)
static void FixMinMax(THStack *stack)
TFile * file
TList with histograms for a given trigger.
void DrawStacks(TVirtualPad *p, THStack *stack, UInt_t cent=0, UInt_t cuts=0)
static TCollection * GetCollection(const TObject *parent, const TString &name, Bool_t verb=true)