11 #ifndef ALITRACKLETWEIGHTS_C 12 #define ALITRACKLETWEIGHTS_C 21 # include <TBrowser.h> 27 # include <TParameter.h> 28 # include <TParticle.h> 51 TObject* o = l->FindObject(name);
53 Warning(
"GetPar",
"Didn't find parameter %s in %s",
58 if (!o->IsA()->InheritsFrom(cls)) {
59 Warning(
"GetPar",
"Object %s is a %s, not a %s",
60 name, o->ClassName(), cls->GetName());
142 const char*
title=
"Sim. tracklet weights")
160 fInverse(o.fInverse),
177 if (&o ==
this)
return *
this;
178 TNamed::operator=(o);
269 UChar_t flags = tracklet->
GetFlags();
270 if (fMask != 0xFF && (fMask & flags) == 0) {
272 Info(
"LookupWeight",
"Tracklet 0x%02x does not fullfill mask 0x%02x",
276 if ((fVeto & flags) != 0) {
278 Info(
"LookupWeight",
"Tracklet 0x%02x vetoed by 0x%02x",flags, fVeto);
298 if (!CheckTracklet(tracklet))
return 1;
299 Double_t w = CalcWeight(tracklet, cent, ipz, corr);
300 if (fInverse) w = 1/w;
316 Double_t w = CalcWeight(particle, cent, ipz);
317 if (fInverse) w = 1/w;
334 TH2* corr)
const = 0;
344 virtual Double_t CalcWeight(TParticle* particle,
355 top->SetName(GetName());
376 "Collection %s not found in %s", GetName(), in->GetName());
380 fCalc = GetPar<int>(
"calc", top);
381 fMask = GetPar<int>(
"mask", top);
382 fVeto = GetPar<int>(
"veto", top);
396 gROOT->IndentLevel();
397 Printf(
"%s : %s", ClassName(), GetName());
398 Printf(
" Weight calculation: %s",
399 fCalc == kProduct ?
"product" :
400 fCalc == kSquare ?
"square" :
401 fCalc == kSum ?
"sum" :
"average");
402 Printf(
" Tracklet mask: 0x%02x", fMask);
403 Printf(
" Tracklet veto: 0x%02x", fVeto);
404 Printf(
" Take inverse: %s", fInverse ?
"yes" :
"no");
432 kDisabled = (0x4) << 14
454 const char*
title=
"Sim. tracklet weights");
488 virtual Double_t CalcWeight(TParticle* particle,
502 AddPdgWeight(fAbundance, pdg, h,
mode);
515 AddPdgWeight(fStrangeness, pdg, h,
mode);
540 SetPdgMode(fAbundance, pdg, mode);
555 SetPdgMode(fStrangeness, pdg, mode);
607 return GetPdgWeight(fAbundance, apdg, cent);
620 return GetPdgWeight(fStrangeness, apdg, cent);
644 TH1D* GetPdgHist(
const PdgMap& m,
Short_t pdg)
const;
654 virtual Double_t GetPdgWeight(
const PdgMap& m,
687 void StoreMap(
TCollection* parent,
const char* name, PdgMap& m);
703 void ModStack(THStack*
stack);
711 void PrintMap(
const PdgMap& m,
const char* name,
Option_t* options=
"")
const;
718 void PrintHist(
const char* tag,
TH1* h)
const;
745 for (PdgMap::const_iterator i = o.
fAbundance.begin();
756 if (&o ==
this)
return *
this;
762 for (PdgMap::const_iterator i = o.
fAbundance.begin();
777 TH1D* copy =
static_cast<TH1D*
>(w->Clone(Form(
"w%d", apdg)));
778 copy->SetDirectory(0);
779 copy->SetXTitle(
"Centrality [%]");
781 PdgMap::iterator i = m.find(apdg);
783 Warning(
"AddPdgWeight",
"Replacing weight for %d", pdg);
799 if (!h)
return false;
800 fPt =
static_cast<TH2D*
>(h->Clone(
"centPt"));
801 fPt->SetDirectory(0);
802 fPt->SetXTitle(
"Centrality [%]");
803 fPt->SetYTitle(
"#it{p}_{T} [GeV]");
810 if (
fPt)
fPt->SetBit(mode);
818 if (h) h->SetBit(mode);
824 PdgMap::const_iterator i = m.find(apdg);
825 if (i == m.end())
return 0;
834 if (m.size() < 1)
return 1;
836 if (!h || h->TestBit(
kDisabled))
return 1;
839 Int_t bC = h->GetXaxis()->FindBin(cent);
840 if (bC < 1 || bC > h->GetNbinsX())
return 1;
845 h->TestBit(
kDown) ? -1 : 0) * h->GetBinError(bC);
846 return h->GetBinContent(bC) + add;
856 Int_t bC =
fPt->GetXaxis()->FindBin(cent);
857 Int_t bpT =
fPt->GetYaxis()->FindBin(pT);
858 if (bC >= 1 && bC <= fPt->GetXaxis()->GetNbins() &&
859 bpT >= 1 && bpT <= fPt->GetYaxis()->GetNbins()) {
861 (
fPt->TestBit(
kUp) ? 1.3 :
866 Info(
"CalcWeight",
"pT=%5.2f -> %4.2f * %6.4f = %6.4f",
867 pT, fac, ptW, fac*ptW);
875 Info(
"CalcWeight",
"pdg=%4d -> %6.4f * %6.4f = %6.4f -> %6.4f",
876 pdg, aW, sW, aW*sW, w);
901 Warning(
"CalcWeight",
"Not a simulated tracklet");
915 if (corr && mc->
IsMeasured()) corr->Fill(w1, w2);
918 const char* cm =
"?";
920 case kProduct: ret = w1 * w2; cm=
"product";
break;
921 case kSquare: ret = TMath::Sqrt(w1 * w2); cm=
"square";
break;
922 case kSum: ret = 1+(w1-1)+(w2-1); cm=
"sum";
break;
923 case kAverage: ret = 1+((w1-1)+(w2-1))/2; cm=
"average";
break;
927 Printf(
"pdg1=%5d -> %6.4f pdg2=%5d -> %6.4f (%10s) -> %6.4f",
928 pdg1, w1, pdg2, w2, cm, ret);
935 if (!stack || !stack->GetHists())
return;
936 TIter next(stack->GetHists());
938 Color_t
colors[] = { kPink+2, kRed+2, kOrange+2, kYellow+2,
939 kSpring+2, kGreen+2, kTeal+2, kCyan+2,
940 kBlue+2, kViolet+2 };
942 while ((hist = static_cast<TH1*>(next()))) {
943 Color_t
c = colors[idx % 10];
945 hist->SetLineColor(c);
946 hist->SetMarkerColor(c);
947 hist->SetMarkerStyle(20+idx%20);
959 TH2* copy =
static_cast<TH2*
>(
fPt->Clone(
"centPt"));
960 copy->SetDirectory(0);
961 copy->SetBinContent(0,0,1);
979 for (PdgMap::const_iterator i = m.begin(); i != m.end(); ++i) {
980 TH1* copy =
static_cast<TH1*
>(i->second->Clone(Form(
"w%d",i->first)));
981 copy->SetDirectory(0);
982 copy->SetBinContent(0,1);
995 fPt =
static_cast<TH2D*
>(top->FindObject(
"centPt"));
997 Warning(
"Retrieve",
"centPt histogram not found in %s", GetName());
999 fPt->SetDirectory(0);
1001 fPt->Scale(1/scale);
1016 TList* top =
static_cast<TList*
>(parent->FindObject(name));
1018 Warning(
"RetrieveMap",
1019 "Collection %s not found in %s", name, parent->GetName());
1024 while ((o = next())) {
1025 if (!o->IsA()->InheritsFrom(TH1D::Class()))
continue;
1026 TH1D* copy =
static_cast<TH1D*
>(o);
1027 copy->SetDirectory(0);
1028 Double_t scale = copy->GetBinContent(0);
1029 copy->Scale(1/scale);
1033 Int_t apdg = nme.Atoi();
1043 TVirtualPad* master = TVirtualPad::Pad();
1045 Warning(
"Draw",
"No current pad to draw in");
1053 TString opt(option); opt.ToUpper();
1055 master->Divide(nPad,1);
1057 THStack*
stack =
new THStack(
fPt, (opt.Contains(
"C") ?
"x" :
"y"));
1059 stack->SetTitle(
"#it{p}_{T} weights");
1061 stack->Draw(
"nostack");
1062 stack->GetHistogram()->SetXTitle((opt.Contains(
"C") ?
1063 "Centrality [%]" :
"#it{p}_{T}"));
1064 master->GetPad(iPad)->BuildLegend();
1065 master->GetPad(iPad)->Modified();
1069 THStack* ha =
new THStack(
"abundance",
"Abundance weights");
1070 for (PdgMap::const_iterator i =
fAbundance.begin();
1076 ha->Draw(
"nostack");
1077 ha->GetHistogram()->SetXTitle(
"Centrality [%]");
1078 master->GetPad(iPad)->BuildLegend();
1082 THStack* hs =
new THStack(
"strangeness",
"Strangeness weights");
1089 hs->Draw(
"nostack");
1090 hs->GetHistogram()->SetXTitle(
"Centrality [%]");
1091 master->GetPad(iPad)->BuildLegend();
1101 gROOT->IncreaseDirLevel();
1106 gROOT->DecreaseDirLevel();
1113 gROOT->IndentLevel();
1114 Printf(
"%10s (%c): %p %s/%s", tag,
1116 h->TestBit(
kUp) ?
'+' :
1117 h->TestBit(
kDown) ?
'-' :
'=',
1118 h, h->GetName(), h->GetTitle());
1127 gROOT->IndentLevel();
1128 Printf(
"Map of PDG codes: %s", name);
1129 gROOT->IncreaseDirLevel();
1130 for (PdgMap::const_iterator i = m.begin(); i != m.end(); ++i)
1131 PrintHist(Form(
"%10d", i->first), i->second);
1133 gROOT->DecreaseDirLevel();
1160 const char*
title=
"Sim. tracklet weights");
1185 void SetCentAxis(
const TAxis& axis);
1255 TH1* Project(
TH1* h,
char which,
const char* name);
1310 for (
Int_t i = 0; i < o.
fHistos.GetEntriesFast(); i++) {
1313 h =
static_cast<TH1*
>(h->Clone());
1322 if (&o ==
this)
return *
this;
1325 for (
Int_t i = 0; i < o.
fHistos.GetEntriesFast(); i++) {
1328 h =
static_cast<TH1*
>(h->Clone());
1339 if (a.GetNbins() && a.GetXbins()->GetArray())
1340 SetCentAxis(a.GetNbins(), a.GetXbins()->GetArray());
1342 SetCentAxis(a.GetNbins(), a.GetXmin(), a.GetXmax());
1362 if (bin < 1 || bin >
fCentAxis.GetNbins()) {
1363 Warning(
"SetHisto",
"Centrality bin %d out of range [%d,%d]",
1370 name.Form(
"cent%03dd%02d_%03dd%02d",
1373 TH1* cpy =
static_cast<TH1*
>(h->Clone(name));
1374 cpy->SetDirectory(0);
1375 cpy->SetTitle(Form(
"%6.2f%% - %6.2f%%", c1, c2));
1376 fHistos.AddAtAndExpand(cpy, bin-1);
1385 if (bin >=
fHistos.GetEntriesFast())
return 0;
1394 if (!axis)
return 1;
1396 if (bin < 1) bin = 1;
1397 else if (bin > axis->GetNbins()) bin = axis->GetNbins();
1417 return h->GetBinContent(etaBin, deltaBin, ipzBin);
1437 return h->GetBinContent(etaBin, deltaBin, ipzBin);
1444 TString n; n.Form(
"%s_%s",h->GetName(),name);
1458 func = &TH3::ProjectionX;
1464 func = &TH3::ProjectionY;
1470 func = &TH3::ProjectionZ;
1473 Int_t nx = a0->GetNbins();
1474 if (nx <= 1)
return 0;
1475 if (a0->GetXbins() && a0->GetXbins()->GetArray())
1476 ret =
new TH1D(n,t,nx,a0->GetXbins()->GetArray());
1478 ret =
new TH1D(n,t,nx,a0->GetXmin(),a0->GetXmax());
1480 ret->SetXTitle(a0->GetTitle());
1481 static_cast<const TAttAxis*
>(a0)->Copy(*(ret->GetXaxis()));
1482 ret->SetDirectory(0);
1483 ret->SetLineColor(h->GetMarkerColor());
1484 ret->SetMarkerColor(h->GetMarkerColor());
1485 ret->SetFillColor(kWhite);
1486 ret->SetFillStyle(0);
1487 ret->SetMarkerStyle(20);
1489 for (
Int_t i0 = 1; i0 <= ret->GetNbinsX(); i0++) {
1493 for (
Int_t i1 = 1; i1 <= a1->GetNbins(); i1++) {
1494 for (
Int_t i2 = 1; i2 <= a2->GetNbins(); i2++) {
1497 case 'x': bin = h->GetBin(i0, i1, i1);
break;
1498 case 'y': bin = h->GetBin(i1, i0, i2);
break;
1499 case 'z': bin = h->GetBin(i1, i2, i0);
break;
1503 if (c < 1e-3 || e < 1e-6)
continue;
1511 ret->SetBinContent(i0, sum/count);
1512 ret->SetBinError (i0, TMath::Sqrt(sumE2)/count);
1525 gROOT->IncreaseDirLevel();
1526 gROOT->IndentLevel();
1527 Printf(
"%d centrality bins",
fCentAxis.GetNbins());
1533 gROOT->DecreaseDirLevel();
1548 if (h->IsA()->InheritsFrom(TH2::Class()))
1549 tmp = static_cast<TH2*>(h)->ProjectionY(
"tmp", etaBin, etaBin);
1550 if (h->IsA()->InheritsFrom(TH3::Class()))
1551 tmp = static_cast<TH3*>(h)->ProjectionY(
"tmp", etaBin, etaBin);
1553 tmp =
static_cast<TH1*
>(h->Clone(
"tmp"));
1555 tmp->SetDirectory(0);
1568 if (!stack->GetHists())
return;
1569 stack->SetMinimum(min);
1570 stack->SetMaximum(max);
1574 stack->Draw(
"nostack");
1575 TH1* h = stack->GetHistogram();
1576 h->SetXTitle(xtitle);
1577 h->SetYTitle(stack->GetTitle());
1578 h->GetXaxis()->SetNdivisions(205);
1579 h->GetYaxis()->SetNdivisions(205);
1580 h->GetXaxis()->SetLabelOffset(0.005*pad->GetWNDC());
1581 h->GetXaxis()->SetTitleOffset(1.5*pad->GetWNDC());
1582 h->GetXaxis()->SetLabelSize(0.03/pad->GetWNDC());
1583 h->GetYaxis()->SetLabelSize(0.03/pad->GetWNDC());
1584 h->GetXaxis()->SetTitleSize(0.03/pad->GetWNDC());
1585 h->GetYaxis()->SetTitleSize(0.03/pad->GetWNDC());
1593 TVirtualPad* master = TVirtualPad::Pad();
1595 Warning(
"Draw",
"No current pad to draw in");
1599 TString opt(option); opt.ToUpper();
1600 THStack* stackEta =
new THStack(
"eta",
"#LTw#GT_{#Delta,IP_{z}}");
1601 THStack* stackDelta =
new THStack(
"delta",
"#LTw#GT_{#eta,IP_{z}}");
1602 THStack* stackIPz =
new THStack(
"ipz",
"#LTw#GT_{#eta,#Delta}");
1611 stackEta ->Add(etaProj);
1612 stackDelta->Add(deltaProj);
1613 stackIPz ->Add(ipzProj);
1618 if (stackDelta->GetHists()) nPad++;
1621 master->SetTopMargin(0.01);
1622 master->SetRightMargin(0.01);
1623 master->SetLeftMargin(0.07*nPad);
1624 if (opt.Contains(
"V"))
1625 master->Divide(1,nPad);
1627 master->Divide(nPad,1, 0, 0);
1629 if (nPad >= 1)
DrawStack(master->cd(1), nPad, stackEta,
"#eta");
1630 if (nPad >= 2)
DrawStack(master->cd(2), nPad, stackDelta,
"#Delta");
1631 if (nPad >= 3)
DrawStack(master->cd(3), nPad, stackIPz,
"IP_{z}");
1632 master->GetPad(nPad)->SetRightMargin(0.01);
virtual Double_t CalcWeight(AliAODTracklet *tracklet, Double_t cent, Double_t ipz, TH2 *corr=0) const
void SetPtMode(UShort_t mode)
Double_t LookupWeight(TParticle *particle, Double_t cent, Double_t ipz) const
void Print(std::ostream &o, const char *name, Double_t dT, Double_t dVM, Double_t alldT, Double_t alldVM)
static Int_t FindBin(Double_t value, const TAxis *axis)
void Draw(const char *filename, const char *title="", const char *others="ALL", const char *options="DEFAULT", const char *outFlg="ALL", UShort_t rebin=5, Float_t eff=0, const char *base="")
Bool_t AddAbundanceWeight(Short_t pdg, const TH1D *h, UShort_t mode=0)
TCollection * Store(TCollection *out)
virtual TCollection * Store(TCollection *parent)
AliTrackletBaseWeights & operator=(const AliTrackletBaseWeights &o)
void Draw(Option_t *option="")
AliTrackletBaseWeights(const char *name, const char *title="Sim. tracklet weights")
void SetCalc(UChar_t mode=kProduct)
Bool_t AddStrangenessWeight(Short_t pdg, const TH1D *h, UShort_t mode=0)
void SetStrangenessMode(Short_t pdg, UShort_t mode)
void StoreMap(TCollection *parent, const char *name, PdgMap &m)
Bool_t SetHisto(Int_t bin, TH1 *h)
Bool_t RetrieveMap(TCollection *parent, const char *name, PdgMap &m)
THStack * DrawOne(TVirtualPad *p, Double_t yr, Bool_t top, TDirectory *dir, const char *name)
void SetHisto(TH1 *Histo, TString Xtitel, TString Ytitel, Bool_t longhisto)
void SetInverse(Bool_t inv)
virtual ~AliTrackletBaseWeights()
void DrawStack(TVirtualPad *pad, Int_t nPad, THStack *stack, const char *xtitle, Double_t min=0, Double_t max=2.5)
AliTrackletDeltaWeights & operator=(const AliTrackletDeltaWeights &o)
void Print(Option_t *option="") const
void Draw(Option_t *option="")
virtual Real_t GetParentPt(Bool_t second=false) const
void DrawStack(TVirtualPad *p, THStack *s, Double_t min, Double_t max)
void SetMask(UChar_t mask)
UShort_t T(UShort_t m, UShort_t t)
virtual TCollection * Retrieve(TCollection *in)
Bool_t IsSimulated() const
void ModStack(THStack *stack)
void SetCentAxis(const TAxis &axis)
TCollection * Retrieve(TCollection *in)
AliTrackletBaseWeights(const AliTrackletBaseWeights &o)
AliTrackletDeltaWeights()
Bool_t IsMeasured() const
virtual Short_t GetParentPdg(Bool_t second=false) const
virtual void Print(Option_t *option="") const
virtual Double_t CalcWeight(AliAODTracklet *tracklet, Double_t cent, Double_t ipZ, TH2 *corr=0) const
Bool_t SetPtWeight(const TH2D *h, UShort_t mode=0)
Double_t GetStrangenessWeight(UShort_t apdg, Double_t cent) const
TH1D * GetPdgHist(const PdgMap &m, Short_t pdg) const
void SetVeto(UChar_t veto)
Bool_t AddPdgWeight(PdgMap &map, Short_t pdg, const TH1D *w, UShort_t mode=0)
Double_t LookupWeight(AliAODTracklet *tracklet, Double_t cent, Double_t ipz, TH2 *corr=0) const
virtual ~AliTrackletPtPidStrWeights()
AliTrackletPtPidStrWeights()
Bool_t IsGenerated() const
void SetPdgMode(PdgMap &map, Short_t pdg, UShort_t mode)
std::map< short, TH1D * > PdgMap
void DrawOne(Double_t cent=2.5, Double_t eta=0, Double_t ipz=0) const
void PrintHist(const char *tag, TH1 *h) const
void SetAbundanceMode(Short_t pdg, UShort_t mode)
void Print(Option_t *option="") const
virtual Double_t GetPdgWeight(const PdgMap &m, UShort_t apdg, Double_t cent) const
virtual ~AliTrackletDeltaWeights()
void PrintMap(const PdgMap &m, const char *name, Option_t *options="") const
TList * GetHists(UShort_t flags, const char *var, const char *stackName="result", const char *sub="")
TH1 * FindHisto(Double_t cent) const
Double_t GetAbundanceWeight(UShort_t apdg, Double_t cent) const
AliTrackletPtPidStrWeights & operator=(const AliTrackletPtPidStrWeights &o)
Bool_t CheckTracklet(const AliAODTracklet *tracklet) const
TH1 * Project(TH1 *h, char which, const char *name)