1 const Color_t
cc[] = { kMagenta+2,
16 TString dname; dname.Form(
"cent%06.2f_%06.2f", c1, c2);
17 dname.ReplaceAll(
".",
"d");
18 TDirectory* d = top->GetDirectory(dname);
20 Warning(
"GetCetnK",
"Directory %s not found in %s",
21 dname.Data(), top->GetName());
25 TDirectory* det = d->GetDirectory(
"details");
27 Warning(
"GetCetnK",
"Directory details not found in %s",
33 TObject* o = det->Get(
"scalar");
35 Warning(
"GetCetnK",
"Object scalar not found in %s",
40 if (!o->IsA()->InheritsFrom(TH1::Class())) {
41 Warning(
"GetCetnK",
"Object %s is not a TH1, but a %s",
42 o->GetName(), o->ClassName());
45 TH1* h =
static_cast<TH1*
>(o->Clone());
46 Color_t col =
cc[(s-1)%10];
48 h->SetMarkerColor(col);
50 h->SetFillStyle(1001);
52 h->SetTitle(Form(
"%2.0f-%2.0f%% + %d", c1, c2, s-1));
53 TF1* f =
new TF1(
"",
"[0]",-2.2,2.2);
54 f->SetParameter(0,s-1);
60 h->GetListOfFunctions()->Add(f);
62 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
63 if (TMath::Abs(h->GetBinCenter(i)) > 2) {
64 h->SetBinContent(i,0);
69 TLegendEntry* e = l->AddEntry(h, h->GetTitle(),
"f");
71 e->SetFillStyle(1001);
80 TFile*
file = TFile::Open(filename,
"READ");
82 Warning(
"DrawKs",
"File %s couldn't be opened", filename);
86 TH1* cent =
static_cast<TH1*
>(file->Get(
"cent"));
88 Warning(
"DrawKs",
"Failed to find cent in %s", file->GetName());
93 t.ReplaceAll(
"results/",
"");
94 t.ReplaceAll(
"combine_",
"");
95 t.ReplaceAll(
"_0x3.root",
"");
97 nm.ReplaceAll(
".root",
"");
98 nm.ReplaceAll(
"results/",
"plots/");
99 nm.ReplaceAll(
"combine",
"ks");
100 if (t.Contains(
"none"))
101 t.ReplaceAll(
"none",
"No weights");
103 t.Append(
" weights");
107 TCanvas*
c =
new TCanvas(nm,t,cW, cH);
108 c->SetTopMargin(0.07);
109 c->SetRightMargin(0.20);
112 TLegend* l =
new TLegend(1-c->GetRightMargin(),
113 c->GetBottomMargin(),
115 1-c->GetTopMargin());
119 THStack* s =
new THStack(
"ks",
"");
120 Int_t nCent = cent->GetXaxis()->GetNbins();
121 for (
Int_t i = 1; i <= nCent; i++) {
122 Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
123 Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i);
131 TH1* f = s->GetHistogram();
133 f->SetXTitle(
"#eta");
134 f->SetYTitle(
"#it{k}(#eta)");
137 TLatex* tit =
new TLatex(0.55, 0.99, t);
138 tit->SetTextFont(42);
139 tit->SetTextAlign(23);
140 tit->SetTextSize(0.03);
155 TCanvas*
c =
DrawKs(Form(
"results/combine_%s_0x%x.root", var, flags));
156 c->SaveAs(Form(
"plots/ks_%s_0x%x.png", var, flags));
TH1 * GetCentK(TDirectory *top, Double_t c1, Double_t c2, Int_t s, TLegend *l)
TCanvas * DrawKs(const char *filename)