16 # include <TCollection.h>
22 # include <TBrowser.h>
25 # include <TLegendEntry.h>
45 const char*
parFmt =
"%-10s | %5.3f |";
46 const char*
rowFmt =
" %5.2f | %5.2f | %5.2f | %5.2f |";
61 if (!o->IsA()->InheritsFrom(c)) {
62 ::Warning(
"ChkC",
"Object %s is not a %s but a %s",
63 o->GetName(), c->GetName(), o->ClassName());
80 ::Warning(
"ChkO",
"Object %s not found in %s", name, src->GetName());
95 static TObject*
GetO(TDirectory* d,
const char* name, TClass* cls)
98 ::Warning(
"GetO",
"No directory passed for %s", name);
116 ::Warning(
"GetO",
"No collection passed for %s", name);
119 TObject* o = d->FindObject(name);
156 return static_cast<TH1*
>(
GetO(d, name, TH1::Class()));
168 return static_cast<TH2*
>(
GetO(d, name, TH2::Class()));
180 return static_cast<THStack*
>(
GetO(d, name, THStack::Class()));
230 return (i ==
kPs ?
Ps :
341 THStack* hp =
GetHS(pc,
"rows");
342 THStack* hs =
GetHS(sc,
"rows");
343 THStack* hc =
GetHS(cc,
"rows");
344 TH1* rps =
GetH1(hp->GetHists(),
"rowSig");
345 TH1* rss =
GetH1(hs->GetHists(),
"rowSig");
346 TH1* rcs =
GetH1(hc->GetHists(),
"rowSig");
347 TH1* rcb =
GetH1(hc->GetHists(),
"rowBg");
349 TH1* si =
GetH1(sc,
"totalIntegrals");
350 TH1* ci =
GetH1(cc,
"totalIntegrals");
351 TH1* pj =
GetH1(po,
"totalIntegrals");
352 TH1* sj =
GetH1(so,
"totalIntegrals");
353 TH1* cj =
GetH1(co,
"totalIntegrals");
357 if (
n.IsNull())
n = rps->GetXaxis()->GetBinLabel(bn);
359 ret.
Ps = ww*pi->GetBinContent(2)*rps->GetBinContent(bn);
360 ret.
Ss = ww*si->GetBinContent(2)*rss->GetBinContent(bn);
361 ret.
Cs = ww*ci->GetBinContent(2)*rcs->GetBinContent(bn);
362 ret.
Cb = ww*ci->GetBinContent(3)*rcb->GetBinContent(bn);
363 ret.
ePs = ww*pi->GetBinContent(2)*rps->GetBinError (bn);
364 ret.
eSs = ww*si->GetBinContent(2)*rss->GetBinError (bn);
365 ret.
eCs = ww*ci->GetBinContent(2)*rcs->GetBinError (bn);
366 ret.
eCb = ww*ci->GetBinContent(3)*rcb->GetBinError (bn);
369 ret.
Ps = ww*rps->GetBinContent(bn);
370 ret.
Ss = ww*rss->GetBinContent(bn);
371 ret.
Cs = ww*rcs->GetBinContent(bn);
372 ret.
Cb = ww*rcb->GetBinContent(bn);
373 ret.
ePs = ww*rps->GetBinError (bn);
374 ret.
eSs = ww*rss->GetBinError (bn);
375 ret.
eCs = ww*rcs->GetBinError (bn);
376 ret.
eCb = ww*rcb->GetBinError (bn);
399 printf(
"%-18s |",
"Sample");
400 printf(
" %-29s |",
"Reduced");
401 printf(
" %-29s |",
"Expected");
402 printf(
" %-29s |",
"Reweighed");
403 printf(
" %-29s |",
"As-is");
407 head.ReplaceAll(
"%5.3f",
"%5s");
408 head.ReplaceAll(
"%5.2f",
"%5s");
410 lne.ReplaceAll(
"|",
"+");
411 lne.ReplaceAll(
"%5s",
"-----");
412 lne.ReplaceAll(
"%10s",
"----------");
413 lne.ReplaceAll(
" ",
"-");
414 Printf(head.Data(),
"Type",
"W",
415 "Ps",
"Ss",
"Cs",
"Cb",
416 "Ps",
"Ss",
"Cs",
"Cb",
417 "Ps",
"Ss",
"Cs",
"Cb",
418 "Ps",
"Ss",
"Cs",
"Cb");
420 for (ParticleList::const_iterator i =
particles.begin();
431 for (
Int_t i = 0; i < 4; i++) {
436 for (ParticleList::const_iterator j =
particles.begin();
438 sum += (*j)->expected.Get(c);
439 for (ParticleList::const_iterator j =
particles.begin();
441 (*j)->expected.Scale(c,100/sum);
472 ret->Read(
kReduced, kind, reduced, sub, oth, abso);
474 ret->Read(
kReweighed, kind, reweighed, sub, oth, abso);
475 ret->Read(
kAsIs, kind, asis, sub, oth, abso);
493 const char* names[] = {
"red",
"exp",
"rew",
"asi" };
494 const char* titles[] = {
"Reduced",
"Expected",
"Reweighed",
"As-is" };
495 const Color_t
colors[] = { kRed+1, kMagenta+1, kBlue+1, kGreen+1 };
501 THStack*
stack =
new THStack(name, title);
502 for (
Int_t i = 0; i < 4; i++) {
506 TH1* h =
new TH1D(names[i],titles[i],nPart,0,nPart);
507 h->SetFillColor(colors[i]);
508 h->SetLineColor(colors[i]);
509 h->SetMarkerColor(colors[i]);
510 h->SetBarOffset(bO+i*(bW+bS));
511 h->SetMarkerSize(mode == 2 ? 3.5 : 2);
514 stack->Add(h,
"bar0 text90");
516 for (
Int_t j = 0; j < nPart; j++) {
519 h->GetXaxis()->SetBinLabel(j+1,p->n);
520 h->SetBinContent (j+1,r.
Get (column));
521 h->SetBinError (j+1,r.
GetE(column));
542 TVirtualPad* p = mother->cd(column+1);
546 if (logy) p->SetLogy();
547 if (mode==2 || (p->GetNumber() % (mode==1 ? 4 : 2)) == 0)
548 p->SetRightMargin(0.01);
550 stack->SetMinimum(0.019);
551 stack->SetMaximum(logy ? (mode == 2 ? 900 : 400) : 110);
553 gStyle->SetTitleFontSize(0.02/p->GetHNDC());
554 stack->Draw(
"nostack hist");
555 stack->GetHistogram()->GetYaxis()->SetNdivisions(210);
556 stack->GetHistogram()->GetYaxis()->SetLabelSize(0.03/p->GetHNDC());
557 stack->GetHistogram()->GetYaxis()->SetTitleSize(0.03/p->GetHNDC());
558 stack->GetHistogram()->GetXaxis()->SetLabelSize(0.03/p->GetHNDC());
559 TString tit = abso ?
"#it{N}_{tracklet}" :
"Fraction [%]";
560 if ((mode == 2 || mode == 0) && p->GetNumber() != 1) tit=
"";
561 stack->GetHistogram()->GetYaxis()->SetTitle(tit);
562 stack->GetHistogram()->GetYaxis()->SetTitleOffset(mode == 2 ? 0.5 : 1);
580 bin.Form(
"cent%03dd%02d_%03dd%02d",
584 TFile* redFile = TFile::Open(
"stk.root",
"READ");
585 TFile* rweFile = TFile::Open(
"wstk.root",
"READ");
586 TFile* trhFile = TFile::Open(
"hijing.root",
"READ");
587 if (!redFile || !rweFile || !trhFile)
return;
588 TString sub = (mid ?
"mid" :
"fwd");
589 TString oth = (mid ?
"fwd" :
"mid");
594 Create(1.52233,
kK0S, redTop, rweTop, trhTop, sub, oth, abso);
595 Create(1.41178,
kKpm, redTop, rweTop, trhTop, sub, oth, abso);
596 Create(2.75002,
kLambda, redTop, rweTop, trhTop, sub, oth, abso);
597 Create(3.24110,
kXi, redTop, rweTop, trhTop, sub, oth, abso);
598 Create(2.75002,
kSigma, redTop, rweTop, trhTop, sub, oth, abso);
599 Create(1,
kOther, redTop, rweTop, trhTop, sub, oth, abso);
604 THStack* Ps =
MakeStack(
kPs,
"Ps",
"Signal primaries", mode);
605 THStack* Ss =
MakeStack(
kSs,
"Ss",
"Signal secondaries", mode);
606 THStack* Cs =
MakeStack(
kCs,
"Cs",
"Signal fake", mode);
607 THStack* Cb =
MakeStack(
kCb,
"Cb",
"Background fake", mode);
609 gStyle->SetPaintTextFormat(
"5.2f%%");
611 Int_t cw = (mode == 1 ? 1600 : mode == 2 ? 800 : 1000);
612 Int_t ch = (mode == 1 ? cw/2 : mode == 2 ? 1.5*cw : cw);
613 TCanvas*
c =
new TCanvas(
"c",
"c",cw,ch);
614 c->SetTopMargin(0.01);
615 c->SetRightMargin(0.01);
616 c->SetLeftMargin(mode == 1 ? 0.09 : 0.13);
618 case 1: c->Divide(4,1,0,0);
break;
619 case 2: c->Divide(1,4,0,0);
break;
620 default: c->Divide(2,2,0,0);
break;
628 TVirtualPad* p = c->cd(1);
629 TString t = mid ?
"|#eta|<1" :
"|#eta|>1";
630 if (c1 >= c2) t.Append(
" MB");
631 else t.Append(Form(
" %4.1f#minus%4.1f%%", c1, c2));
633 ? p->BuildLegend(0.45,(mode==2?0.3:0.5),0.95,0.9, t)
634 : p->BuildLegend(0.16,0.4,0.6,0.8, t));
638 c->SaveAs(Form(
"expected_%s_%s.png", bin.Data(), mid ?
"mid" :
"fwd"));
static TObject * ChkO(TObject *src, TObject *o, const char *name)
THStack * GetHS(TCollection *d, const char *name)
void Run(Double_t c1=0, Double_t c2=0, Bool_t mid=true)
static TObject * GetO(TDirectory *d, const char *name, TClass *cls)
TCollection * GetC(TDirectory *d, const char *name)
static TH1 * GetH1(TCollection *d, const char *name)
static TCollection * GetC(TCollection *d, const char *name)
Double_t Get(Int_t i) const
Particle * Create(Double_t w, Int_t bin, THStack *hp, THStack *hs, THStack *hc)
static TCollection * GetC(TDirectory *d, const char *name)
Particle * Read(ERow row, EKind kind, TCollection *bin, const TString &sub, const TString &oth, Bool_t abso=true)
static TObject * GetO(TCollection *d, const char *name, TClass *cls)
static TH2 * GetH2(TCollection *d, const char *name)
Particle * Create(Double_t w, EKind kind, TCollection *reduced, TCollection *reweighed, TCollection *asis, const TString &sub, const TString &oth, Bool_t abso)
static TObject * ChkC(TObject *o, TClass *c)
static THStack * GetHS(TCollection *d, const char *name)
Double_t Get(EColumn i) const
Double_t GetE(EColumn i) const
TH1 * GetH1(TCollection *d, const char *name)
void DrawStack(TVirtualPad *mother, EColumn column, THStack *stack, Bool_t logy, Bool_t abso, Int_t mode)
void Run(const char *fileName, const char *binName, Bool_t mid=true)
void Expectations(Bool_t mid=true, Double_t c1=0, Double_t c2=5)
void Scale(EColumn i, Double_t s)
std::vector< Particle * > ParticleList
THStack * MakeStack(EColumn column, const char *name, const char *title, Int_t mode)