11 #ifndef ALITRACKLETWEIGHTS_C
12 #define ALITRACKLETWEIGHTS_C
21 # include <TBrowser.h>
27 # include <TParameter.h>
49 TObject* o = l->FindObject(name);
51 Warning(
"GetPar",
"Didn't find parameter %s in %s",
56 if (!o->IsA()->InheritsFrom(cls)) {
57 Warning(
"GetPar",
"Object %s is a %s, not a %s",
58 name, o->ClassName(), cls->GetName());
138 const char*
title=
"Sim. tracklet weights")
171 if (&o ==
this)
return *
this;
172 TNamed::operator=(o);
256 UChar_t flags = tracklet->
GetFlags();
262 if ((
fVeto & flags) != 0) {
302 TH2* corr)
const = 0;
311 top->SetName(GetName());
331 "Collection %s not found in %s", GetName(), in->GetName());
335 fCalc = GetPar<int>(
"calc", top);
336 fMask = GetPar<int>(
"mask", top);
337 fVeto = GetPar<int>(
"veto", top);
351 gROOT->IndentLevel();
352 Printf(
"%s : %s", ClassName(), GetName());
353 Printf(
" Weight calculation: %s",
357 Printf(
" Tracklet mask: 0x%02x",
fMask);
358 Printf(
" Tracklet veto: 0x%02x",
fVeto);
407 const char*
title=
"Sim. tracklet weights");
661 void PrintMap(
const PdgMap& m,
const char* name,
Option_t* options=
"")
const;
695 for (PdgMap::const_iterator i = o.
fAbundance.begin();
706 if (&o ==
this)
return *
this;
712 for (PdgMap::const_iterator i = o.
fAbundance.begin();
727 TH1D* copy =
static_cast<TH1D*
>(w->Clone(Form(
"w%d", apdg)));
728 copy->SetDirectory(0);
729 copy->SetXTitle(
"Centrality [%]");
731 PdgMap::iterator i = m.find(apdg);
733 Warning(
"AddPdgWeight",
"Replacing weight for %d", pdg);
749 if (!h)
return false;
750 fPt =
static_cast<TH2D*
>(h->Clone(
"centPt"));
751 fPt->SetDirectory(0);
752 fPt->SetXTitle(
"Centrality [%]");
753 fPt->SetYTitle(
"#it{p}_{T} [GeV]");
760 if (
fPt)
fPt->SetBit(mode);
768 if (h) h->SetBit(mode);
774 PdgMap::const_iterator i = m.find(apdg);
775 if (i == m.end())
return 0;
784 if (m.size() < 1)
return 1;
786 if (!h || h->TestBit(
kDisabled))
return 1;
789 Int_t bC = h->GetXaxis()->FindBin(cent);
790 if (bC < 1 || bC > h->GetNbinsX())
return 1;
795 h->TestBit(
kDown) ? -1 : 0) * h->GetBinError(bC);
796 return h->GetBinContent(bC) + add;
806 Int_t bC =
fPt->GetXaxis()->FindBin(cent);
807 Int_t bpT =
fPt->GetYaxis()->FindBin(pT);
808 if (bC >= 1 && bC <= fPt->GetXaxis()->GetNbins() &&
809 bpT >= 1 && bpT <= fPt->GetYaxis()->GetNbins()) {
811 (
fPt->TestBit(
kUp) ? 1.3 :
813 w *= fac*
fPt->GetBinContent(bC, bpT);
833 Warning(
"LookupWeight",
"Not a simulated tracklet");
847 if (corr && mc->
IsMeasured()) corr->Fill(w1, w2);
851 case kSquare:
return TMath::Sqrt(w1 * w2);
852 case kSum:
return 1+(w1-1)+(w2-1);
853 case kAverage:
return 1+((w1-1)+(w2-1))/2;
861 if (!stack || !stack->GetHists())
return;
862 TIter next(stack->GetHists());
864 Color_t
colors[] = { kPink+2, kRed+2, kOrange+2, kYellow+2,
865 kSpring+2, kGreen+2, kTeal+2, kCyan+2,
866 kBlue+2, kViolet+2 };
868 while ((hist = static_cast<TH1*>(next()))) {
869 Color_t
c = colors[idx % 10];
871 hist->SetLineColor(c);
872 hist->SetMarkerColor(c);
873 hist->SetMarkerStyle(20+idx%20);
885 TH2* copy =
static_cast<TH2*
>(
fPt->Clone(
"centPt"));
886 copy->SetDirectory(0);
887 copy->SetBinContent(0,0,1);
905 for (PdgMap::const_iterator i = m.begin(); i != m.end(); ++i) {
906 TH1* copy =
static_cast<TH1*
>(i->second->Clone(Form(
"w%d",i->first)));
907 copy->SetDirectory(0);
908 copy->SetBinContent(0,1);
921 fPt =
static_cast<TH2D*
>(top->FindObject(
"centPt"));
923 Warning(
"Retrieve",
"centPt histogram not found in %s", GetName());
925 fPt->SetDirectory(0);
942 TList* top =
static_cast<TList*
>(parent->FindObject(name));
944 Warning(
"RetrieveMap",
945 "Collection %s not found in %s", name, parent->GetName());
950 while ((o = next())) {
951 if (!o->IsA()->InheritsFrom(TH1D::Class()))
continue;
953 copy->SetDirectory(0);
954 Double_t scale = copy->GetBinContent(0);
955 copy->Scale(1/scale);
959 Int_t apdg = nme.Atoi();
969 TVirtualPad* master = TVirtualPad::Pad();
971 Warning(
"Draw",
"No current pad to draw in");
979 TString opt(option); opt.ToUpper();
981 master->Divide(nPad,1);
983 THStack* stack =
new THStack(
fPt, (opt.Contains(
"C") ?
"x" :
"y"));
985 stack->SetTitle(
"#it{p}_{T} weights");
987 stack->Draw(
"nostack");
988 stack->GetHistogram()->SetXTitle((opt.Contains(
"C") ?
989 "Centrality [%]" :
"#it{p}_{T}"));
990 master->GetPad(iPad)->BuildLegend();
991 master->GetPad(iPad)->Modified();
995 THStack* ha =
new THStack(
"abundance",
"Abundance weights");
996 for (PdgMap::const_iterator i =
fAbundance.begin();
1002 ha->Draw(
"nostack");
1003 ha->GetHistogram()->SetXTitle(
"Centrality [%]");
1004 master->GetPad(iPad)->BuildLegend();
1008 THStack* hs =
new THStack(
"strangeness",
"Strangeness weights");
1015 hs->Draw(
"nostack");
1016 hs->GetHistogram()->SetXTitle(
"Centrality [%]");
1017 master->GetPad(iPad)->BuildLegend();
1027 gROOT->IncreaseDirLevel();
1032 gROOT->DecreaseDirLevel();
1039 gROOT->IndentLevel();
1040 Printf(
"%10s (%c): %p %s/%s", tag,
1042 h->TestBit(
kUp) ?
'+' :
1043 h->TestBit(
kDown) ?
'-' :
'=',
1044 h, h->GetName(), h->GetTitle());
1053 gROOT->IndentLevel();
1054 Printf(
"Map of PDG codes: %s", name);
1055 gROOT->IncreaseDirLevel();
1056 for (PdgMap::const_iterator i = m.begin(); i != m.end(); ++i)
1057 PrintHist(Form(
"%10d", i->first), i->second);
1059 gROOT->DecreaseDirLevel();
1086 const char*
title=
"Sim. tracklet weights");
1231 fCentAxis(o.fCentAxis)
1234 for (
Int_t i = 0; i < o.
fHistos.GetEntriesFast(); i++) {
1237 h =
static_cast<TH1*
>(h->Clone());
1246 if (&o ==
this)
return *
this;
1249 for (
Int_t i = 0; i < o.
fHistos.GetEntriesFast(); i++) {
1252 h =
static_cast<TH1*
>(h->Clone());
1263 if (a.GetNbins() && a.GetXbins()->GetArray())
1264 SetCentAxis(a.GetNbins(), a.GetXbins()->GetArray());
1266 SetCentAxis(a.GetNbins(), a.GetXmin(), a.GetXmax());
1286 if (bin < 1 || bin >
fCentAxis.GetNbins()) {
1287 Warning(
"SetHisto",
"Centrality bin %d out of range [%d,%d]",
1294 name.Form(
"cent%03dd%02d_%03dd%02d",
1297 TH1* cpy =
static_cast<TH1*
>(h->Clone(name));
1298 cpy->SetDirectory(0);
1299 cpy->SetTitle(Form(
"%6.2f%% - %6.2f%%", c1, c2));
1300 fHistos.AddAtAndExpand(cpy, bin-1);
1309 if (bin >=
fHistos.GetEntriesFast())
return 0;
1318 if (!axis)
return 1;
1320 if (bin < 1) bin = 1;
1321 else if (bin > axis->GetNbins()) bin = axis->GetNbins();
1343 return h->GetBinContent(etaBin, deltaBin, ipzBin);
1350 TString n; n.Form(
"%s_%s",h->GetName(),name);
1364 func = &TH3::ProjectionX;
1370 func = &TH3::ProjectionY;
1376 func = &TH3::ProjectionZ;
1379 Int_t nx = a0->GetNbins();
1380 if (nx <= 1)
return 0;
1381 if (a0->GetXbins() && a0->GetXbins()->GetArray())
1382 ret =
new TH1D(n,t,nx,a0->GetXbins()->GetArray());
1384 ret =
new TH1D(n,t,nx,a0->GetXmin(),a0->GetXmax());
1386 ret->SetXTitle(a0->GetTitle());
1387 static_cast<const TAttAxis*
>(a0)->Copy(*(ret->GetXaxis()));
1388 ret->SetDirectory(0);
1389 ret->SetLineColor(h->GetMarkerColor());
1390 ret->SetMarkerColor(h->GetMarkerColor());
1391 ret->SetFillColor(kWhite);
1392 ret->SetFillStyle(0);
1393 ret->SetMarkerStyle(20);
1395 for (
Int_t i0 = 1; i0 <= ret->GetNbinsX(); i0++) {
1399 for (
Int_t i1 = 1; i1 <= a1->GetNbins(); i1++) {
1400 for (
Int_t i2 = 1; i2 <= a2->GetNbins(); i2++) {
1403 case 'x': bin = h->GetBin(i0, i1, i1);
break;
1404 case 'y': bin = h->GetBin(i1, i0, i2);
break;
1405 case 'z': bin = h->GetBin(i1, i2, i0);
break;
1409 if (c < 1e-3 || e < 1e-6)
continue;
1417 ret->SetBinContent(i0, sum/count);
1418 ret->SetBinError (i0, TMath::Sqrt(sumE2)/count);
1431 gROOT->IncreaseDirLevel();
1432 gROOT->IndentLevel();
1433 Printf(
"%d centrality bins",
fCentAxis.GetNbins());
1439 gROOT->DecreaseDirLevel();
1454 if (h->IsA()->InheritsFrom(TH2::Class()))
1455 tmp = static_cast<TH2*>(h)->ProjectionY(
"tmp", etaBin, etaBin);
1456 if (h->IsA()->InheritsFrom(TH3::Class()))
1457 tmp = static_cast<TH3*>(h)->ProjectionY(
"tmp", etaBin, etaBin);
1459 tmp =
static_cast<TH1*
>(h->Clone(
"tmp"));
1461 tmp->SetDirectory(0);
1474 if (!stack->GetHists())
return;
1475 stack->SetMinimum(min);
1476 stack->SetMaximum(max);
1480 stack->Draw(
"nostack");
1481 TH1* h = stack->GetHistogram();
1482 h->SetXTitle(xtitle);
1483 h->SetYTitle(stack->GetTitle());
1484 h->GetXaxis()->SetNdivisions(205);
1485 h->GetYaxis()->SetNdivisions(205);
1486 h->GetXaxis()->SetLabelOffset(0.005*pad->GetWNDC());
1487 h->GetXaxis()->SetTitleOffset(1.5*pad->GetWNDC());
1488 h->GetXaxis()->SetLabelSize(0.03/pad->GetWNDC());
1489 h->GetYaxis()->SetLabelSize(0.03/pad->GetWNDC());
1490 h->GetXaxis()->SetTitleSize(0.03/pad->GetWNDC());
1491 h->GetYaxis()->SetTitleSize(0.03/pad->GetWNDC());
1499 TVirtualPad* master = TVirtualPad::Pad();
1501 Warning(
"Draw",
"No current pad to draw in");
1505 TString opt(option); opt.ToUpper();
1506 THStack* stackEta =
new THStack(
"eta",
"#LTw#GT_{#Delta,IP_{z}}");
1507 THStack* stackDelta =
new THStack(
"delta",
"#LTw#GT_{#eta,IP_{z}}");
1508 THStack* stackIPz =
new THStack(
"ipz",
"#LTw#GT_{#eta,#Delta}");
1517 stackEta ->Add(etaProj);
1518 stackDelta->Add(deltaProj);
1519 stackIPz ->Add(ipzProj);
1524 if (stackDelta->GetHists()) nPad++;
1527 master->SetTopMargin(0.01);
1528 master->SetRightMargin(0.01);
1529 master->SetLeftMargin(0.07*nPad);
1530 if (opt.Contains(
"V"))
1531 master->Divide(1,nPad);
1533 master->Divide(nPad,1, 0, 0);
1535 if (nPad >= 1)
DrawStack(master->cd(1), nPad, stackEta,
"#eta");
1536 if (nPad >= 2)
DrawStack(master->cd(2), nPad, stackDelta,
"#Delta");
1537 if (nPad >= 3)
DrawStack(master->cd(3), nPad, stackIPz,
"IP_{z}");
1538 master->GetPad(nPad)->SetRightMargin(0.01);
ClassDef(AliTrackletDeltaWeights, 1)
virtual Double_t CalcWeight(AliAODTracklet *tracklet, Double_t cent, Double_t ipz, TH2 *corr=0) const
void SetPtMode(UShort_t mode)
static Int_t FindBin(Double_t value, const TAxis *axis)
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)
void SetInverse(Bool_t inv)
virtual ~AliTrackletBaseWeights()
virtual Double_t CalcWeight(AliAODTracklet *tracklet, Double_t cent, Double_t ipz, TH2 *corr) const =0
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)
ClassDef(AliTrackletPtPidStrWeights, 3)
void Print(Option_t *option="") const
void Draw(Option_t *option="")
virtual Real_t GetParentPt(Bool_t second=false) const
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)
ClassDef(AliTrackletBaseWeights, 1)