3 GetO(TDirectory*
dir,
const char* name, TClass* cls=0)
6 Warning(
"GetO",
"No directory passed");
12 Warning(
"GetO",
"object %s not found in %s",
13 name, dir->GetPath());
17 if (!o->IsA()->InheritsFrom(cls)) {
18 Warning(
"GetO",
"Object %s in %s is not a %s, but a %s",
19 name, dir->GetPath(), cls->GetName(), o->ClassName());
25 TDirectory*
GetD(TDirectory*
dir,
const char* name)
27 return static_cast<TDirectory*
>(
GetO(dir,name,TDirectory::Class()));
33 return static_cast<TH1*
>(
GetO(dir,name,TH1::Class()));
46 name.Form(
"cent%03dd%02d_%03dd%02d",
49 TDirectory* newSubDir =
GetD(newDir, name);
50 TDirectory* oldSubDir =
GetD(oldDir, name);
51 if (!newSubDir || !oldSubDir)
return 0;
53 TH1* newRes =
GetH1(newSubDir,
"dndeta");
54 TH1* oldRes =
GetH1(oldSubDir,
"dndeta");
55 if (!newRes || !oldRes)
return 0;
57 TH1* ratio =
static_cast<TH1*
>(newRes->Clone(name));
58 ratio->SetDirectory(0);
59 ratio->SetTitle(Form(
"%5.1f - %5.1f%%", c1, c2));
60 ratio->SetYTitle(
"New / Old");
61 ratio->Divide(oldRes);
64 TLegendEntry* e = l->AddEntry(
"", Form(
"%3.0f - %3.0f%%", c1, c2),
"f");
65 e->SetFillStyle(1001);
66 e->SetFillColor(ratio->GetMarkerColor());
68 min = TMath::Min(min, ratio->GetMinimum());
69 max = TMath::Max(max, ratio->GetMaximum());
76 const char* oldName=
"OldTaskNewCorrect.root",
77 const char* newTitle=
"New",
78 const char* oldTitle=
"Old")
80 TFile* newFile = TFile::Open(newName,
"READ");
81 TFile* oldFile = TFile::Open(oldName,
"READ");
82 if (!newFile || !oldFile)
return;
84 TH1* newCent =
GetH1(newFile,
"realCent");
85 TH1* oldCent =
GetH1(oldFile,
"realCent");
86 if (!newCent || !oldCent)
return;
88 TString t; t.Form(
"#it{R}=#frac{%s}{%s}", oldTitle, newTitle);
89 TCanvas*
c =
new TCanvas(
"c", t, 1200, 800);
90 c->SetTopMargin(0.01);
91 c->SetRightMargin(0.20);
92 TLegend* l =
new TLegend(1-c->GetRightMargin(),
94 1, 1-c->GetTopMargin(),
98 THStack*
stack =
new THStack(
"ratios",
"");
103 for (
Int_t i = newCent->GetNbinsX(); i--;) {
104 Double_t c1 = newCent->GetXaxis()->GetBinLowEdge(i+1);
105 Double_t c2 = newCent->GetXaxis()->GetBinUpEdge(i+1);
106 Info(
"",
"c1=%f c2=%f", c1, c2);
110 one =
static_cast<TH1*
>(r->Clone(
"one"));
111 one->SetDirectory(0);
113 for (
Int_t j = 1; j <= one->GetNbinsX(); j++) {
114 one->SetBinContent(j,1);
115 one->SetBinError (j,0);
122 stack->Draw(
"nostack");
123 stack->SetMinimum(0.95*min);
124 stack->SetMaximum(1.05*max);
125 stack->GetHistogram()->SetXTitle(
"#eta");
126 stack->GetHistogram()->SetYTitle(
"#it{R}");
131 c->SaveAs(Form(
"%sover%s.png", oldTitle, newTitle));
TObject * GetO(TDirectory *dir, const char *name, TClass *cls=0)
TH1 * CompareOne(TDirectory *newDir, TDirectory *oldDir, Double_t c1, Double_t c2, Double_t &min, Double_t &max, TLegend *l)
TH1 * GetH1(TDirectory *dir, const char *name)
TDirectory * GetD(TDirectory *dir, const char *name)