16 # include <TCollection.h>
22 # include <TBrowser.h>
25 # include <TLegendEntry.h>
45 const char*
parFmt =
"%-10s | %6.3f |";
46 const char*
rowFmt =
" %5.2f | %5.2f | %5.2f | %5.2f |";
47 const char*
eRowFmt =
" %5.2f+/-%5.2f | %5.2f+/-%5.2f | "
48 "%5.2f+/-%5.2f | %5.2f+/-%5.2f |";
63 if (!o->IsA()->InheritsFrom(c)) {
64 ::Warning(
"ChkC",
"Object %s is not a %s but a %s",
65 o->GetName(), c->GetName(), o->ClassName());
82 ::Warning(
"ChkO",
"Object %s not found in %s", name, src->GetName());
97 static TObject*
GetO(TDirectory* d,
const char* name, TClass* cls)
100 ::Warning(
"GetO",
"No directory passed for %s", name);
118 ::Warning(
"GetO",
"No collection passed for %s", name);
121 TObject* o = d->FindObject(name);
158 return static_cast<TH1*
>(
GetO(d, name, TH1::Class()));
170 return static_cast<TH2*
>(
GetO(d, name, TH2::Class()));
182 return static_cast<THStack*
>(
GetO(d, name, THStack::Class()));
232 return (i ==
kPs ?
Ps :
344 THStack* hp =
GetHS(pc,
"rows");
345 THStack* hs =
GetHS(sc,
"rows");
346 THStack* hc =
GetHS(cc,
"rows");
347 TH1* rps =
GetH1(hp->GetHists(),
"rowSig");
348 TH1* rss =
GetH1(hs->GetHists(),
"rowSig");
349 TH1* rcs =
GetH1(hc->GetHists(),
"rowSig");
350 TH1* rcb =
GetH1(hc->GetHists(),
"rowBg");
352 TH1* si =
GetH1(sc,
"totalIntegrals");
353 TH1* ci =
GetH1(cc,
"totalIntegrals");
354 TH1* pj =
GetH1(po,
"totalIntegrals");
355 TH1* sj =
GetH1(so,
"totalIntegrals");
356 TH1* cj =
GetH1(co,
"totalIntegrals");
360 if (
n.IsNull())
n = rps->GetXaxis()->GetBinLabel(bn);
362 ret.
Ps = ww*pi->GetBinContent(2)*rps->GetBinContent(bn);
363 ret.
Ss = ww*si->GetBinContent(2)*rss->GetBinContent(bn);
364 ret.
Cs = ww*ci->GetBinContent(2)*rcs->GetBinContent(bn);
365 ret.
Cb = ww*ci->GetBinContent(3)*rcb->GetBinContent(bn);
366 ret.
ePs = ww*pi->GetBinContent(2)*rps->GetBinError (bn);
367 ret.
eSs = ww*si->GetBinContent(2)*rss->GetBinError (bn);
368 ret.
eCs = ww*ci->GetBinContent(2)*rcs->GetBinError (bn);
369 ret.
eCb = ww*ci->GetBinContent(3)*rcb->GetBinError (bn);
372 ret.
Ps = ww*rps->GetBinContent(bn);
373 ret.
Ss = ww*rss->GetBinContent(bn);
374 ret.
Cs = ww*rcs->GetBinContent(bn);
375 ret.
Cb = ww*rcb->GetBinContent(bn);
376 ret.
ePs = ww*rps->GetBinError (bn);
377 ret.
eSs = ww*rss->GetBinError (bn);
378 ret.
eCs = ww*rcs->GetBinError (bn);
379 ret.
eCb = ww*rcb->GetBinError (bn);
402 printf(
"%-18s |",
"Sample");
404 printf(
" %-29s |",
"Reduced");
405 printf(
" %-29s |",
"Expected");
406 printf(
" %-29s |",
"Reweighed");
407 printf(
" %-29s |",
"As-is");
410 printf(
" %-61s |",
"Reduced");
411 printf(
" %-61s |",
"Expected");
412 printf(
" %-61s |",
"Reweighed");
413 printf(
" %-61s |",
"As-is");
418 head.ReplaceAll(
"%6.3f",
"%6s");
419 head.ReplaceAll(
"%5.2f", err ?
"%13s" :
"%5s");
421 lne.ReplaceAll(
"|",
"+");
422 lne.ReplaceAll(
"%5s",
"-----");
423 lne.ReplaceAll(
"%6s",
"------");
424 lne.ReplaceAll(
"%10s",
"----------");
425 lne.ReplaceAll(
"%13s",
"-------------");
426 lne.ReplaceAll(
" ",
"-");
427 Printf(head.Data(),
"Type",
"W",
428 "Ps",
"Ss",
"Cs",
"Cb",
429 "Ps",
"Ss",
"Cs",
"Cb",
430 "Ps",
"Ss",
"Cs",
"Cb",
431 "Ps",
"Ss",
"Cs",
"Cb");
433 for (ParticleList::const_iterator i =
particles.begin();
444 for (
Int_t i = 0; i < 4; i++) {
449 for (ParticleList::const_iterator j =
particles.begin();
451 sum += (*j)->expected.Get(c);
452 for (ParticleList::const_iterator j =
particles.begin();
454 (*j)->expected.Scale(c,100/sum);
488 ret->
Read(
kAsIs, kind, asis, sub, oth, abso);
506 const char* names[] = {
"red",
"exp",
"rew",
"asi" };
507 const char* titles[] = {
"Reduced",
"Expected",
"Reweighed",
"As-is" };
508 const Color_t
colors[] = { kRed+1, kMagenta+1, kBlue+1, kGreen+1 };
514 THStack* stack =
new THStack(name, title);
515 for (
Int_t i = 0; i < 4; i++) {
519 TH1* h =
new TH1D(names[i],titles[i],nPart,0,nPart);
520 h->SetFillColor(colors[i]);
521 h->SetLineColor(colors[i]);
522 h->SetMarkerColor(colors[i]);
523 h->SetBarOffset(bO+i*(bW+bS));
524 h->SetMarkerSize(mode == 2 ? 3.5 : 2);
527 h->SetYTitle(
"Fraction [%]");
528 stack->Add(h,
"bar0 text90");
530 for (
Int_t j = 0; j < nPart; j++) {
533 h->GetXaxis()->SetBinLabel(j+1,p->
n);
534 h->SetBinContent (j+1,r.
Get (column));
535 h->SetBinError (j+1,r.
GetE(column));
556 TVirtualPad* p = mother->cd(column+1);
560 if (logy) p->SetLogy();
561 if (mode==2 || (p->GetNumber() % (mode==1 ? 4 : 2)) == 0)
562 p->SetRightMargin(0.01);
564 stack->SetMinimum(0.003);
565 stack->SetMaximum(logy ? (mode == 2 ? 900 : 400) : 110);
567 gStyle->SetTitleFontSize(0.02/p->GetHNDC());
568 stack->Draw(
"nostack hist");
569 stack->GetHistogram()->GetYaxis()->SetNdivisions(210);
570 stack->GetHistogram()->GetYaxis()->SetLabelSize(0.03/p->GetHNDC());
571 stack->GetHistogram()->GetYaxis()->SetTitleSize(0.03/p->GetHNDC());
572 stack->GetHistogram()->GetXaxis()->SetLabelSize(0.03/p->GetHNDC());
573 TString tit = abso ?
"#it{N}_{tracklet}" :
"Fraction [%]";
574 if ((mode == 2 || mode == 0) && p->GetNumber() != 1) tit=
"";
575 stack->GetHistogram()->GetYaxis()->SetTitle(tit);
576 stack->GetHistogram()->GetYaxis()->SetTitleOffset(mode == 2 ? 0.5 : 1);
594 bin.Form(
"cent%03dd%02d_%03dd%02d",
598 TFile* redFile = TFile::Open(
"stk.root",
"READ");
599 TFile* rweFile = TFile::Open(
"wstk.root",
"READ");
600 TFile* trhFile = TFile::Open(
"hijing.root",
"READ");
601 if (!redFile || !rweFile || !trhFile)
return;
602 TString sub = (mid ?
"mid" :
"fwd");
603 TString oth = (mid ?
"fwd" :
"mid");
608 Create(1.52233,
kK0S, redTop, rweTop, trhTop, sub, oth, abso);
609 Create(1.41178,
kKpm, redTop, rweTop, trhTop, sub, oth, abso);
610 Create(2.75002,
kLambda, redTop, rweTop, trhTop, sub, oth, abso);
611 Create(3.24110,
kXi, redTop, rweTop, trhTop, sub, oth, abso);
612 Create(2.75002,
kSigma, redTop, rweTop, trhTop, sub, oth, abso);
613 Create(1,
kOther, redTop, rweTop, trhTop, sub, oth, abso);
618 THStack* Ps =
MakeStack(
kPs,
"Ps",
"Signal primaries", mode);
619 THStack* Ss =
MakeStack(
kSs,
"Ss",
"Signal secondaries", mode);
620 THStack* Cs =
MakeStack(
kCs,
"Cs",
"Signal fake", mode);
621 THStack* Cb =
MakeStack(
kCb,
"Cb",
"Background fake", mode);
623 gStyle->SetPaintTextFormat(
"5.2f%%");
625 Int_t cw = (mode == 1 ? 1600 : mode == 2 ? 800 : 1000);
626 Int_t ch = (mode == 1 ? cw/2 : mode == 2 ? 1.2*cw : cw);
627 TCanvas*
c =
new TCanvas(Form(
"deltaExpectation_%s_%s",
628 bin.Data(), mid?
"mid":
"fwd"),
629 "DeltaCanvas",cw,ch);
630 c->SetTopMargin(0.01);
631 c->SetRightMargin(0.01);
632 c->SetLeftMargin(mode == 1 ? 0.09 : 0.13);
634 case 1: c->Divide(4,1,0,0);
break;
635 case 2: c->Divide(1,4,0,0);
break;
636 default: c->Divide(2,2,0,0);
break;
644 TVirtualPad* p = c->cd(1);
645 TString t = mid ?
"|#eta|<1" :
"|#eta|>1";
646 if (c1 >= c2) t.Append(
" MB");
647 else t.Append(Form(
" %4.1f#minus%4.1f%%", c1, c2));
649 ? p->BuildLegend(0.45,(mode==2?0.3:0.5),0.95,0.9, t)
650 : p->BuildLegend(0.16,0.4,0.6,0.8, t));
654 TFile* output = TFile::Open(Form(
"%s.root", c->GetName()),
"RECREATE");
656 THStack* stacks[] = { Ps, Ss, Cs, Cb, 0 };
657 THStack** ptr = stacks;
659 THStack* stack = *ptr;
660 TString name = stack->GetTitle(); name.ReplaceAll(
" ",
"");
661 TDirectory* dir = output->mkdir(name);
664 TIter next(stack->GetHists());
666 while ((hist = static_cast<TH1*>(next()))) {
667 name = hist->GetTitle(); name.ReplaceAll(
"-",
"");
676 c->SaveAs(Form(
"%s.png",c->GetName()));
696 cf.
Run(c1, c2, !mid);
Particle * Read(ERow row, EKind kind, TCollection *bin, const TString &sub, const TString &oth, Bool_t abso=true)
static TObject * ChkO(TObject *src, TObject *o, const char *name)
static TObject * GetO(TDirectory *d, const char *name, TClass *cls)
static TH1 * GetH1(TCollection *d, const char *name)
static TCollection * GetC(TCollection *d, const char *name)
static TCollection * GetC(TDirectory *d, const char *name)
void Print(Bool_t err=false)
void Scale(EColumn i, Double_t s)
static TObject * GetO(TCollection *d, const char *name, TClass *cls)
void DeltaExpectations(Double_t c1=0, Double_t c2=5)
void Run(Double_t c1=0, Double_t c2=0, Bool_t mid=true)
static TH2 * GetH2(TCollection *d, const char *name)
void Print(Bool_t err=false) const
Double_t Get(EColumn i) const
Double_t GetE(EColumn i) const
static TObject * ChkC(TObject *o, TClass *c)
static THStack * GetHS(TCollection *d, const char *name)
void Print(Bool_t err=false)
Particle * Create(Double_t w, EKind kind, TCollection *reduced, TCollection *reweighed, TCollection *asis, const TString &sub, const TString &oth, Bool_t abso)
THStack * MakeStack(EColumn column, const char *name, const char *title, Int_t mode)
std::vector< Particle * > ParticleList
void DrawStack(TVirtualPad *mother, EColumn column, THStack *stack, Bool_t logy, Bool_t abso, Int_t mode)