3 #include <AliPWG0Helper.h>
6 #include <TParticlePDG.h>
12 #include <AliESDVertex.h>
14 //____________________________________________________________________
15 ClassImp(AliPWG0Helper)
17 //____________________________________________________________________
18 Bool_t AliPWG0Helper::IsEventTriggered(AliESD* aEsd)
20 // check if the event was triggered
23 // ITS_SPD_GFO_L0 : 32
27 ULong64_t triggerMask = aEsd->GetTriggerMask();
29 if (triggerMask&32 && ((triggerMask&1) || (triggerMask&2)))
35 //____________________________________________________________________
36 Bool_t AliPWG0Helper::IsVertexReconstructed(AliESD* aEsd)
38 // checks if the vertex is reasonable
40 const AliESDVertex* vtxESD = aEsd->GetVertex();
42 // the vertex should be reconstructed
43 if (strcmp(vtxESD->GetName(), "default")==0)
47 vtx_res[0] = vtxESD->GetXRes();
48 vtx_res[1] = vtxESD->GetYRes();
49 vtx_res[2] = vtxESD->GetZRes();
51 if (vtx_res[2]==0 || vtx_res[2]>0.1)
57 //____________________________________________________________________
58 Bool_t AliPWG0Helper::IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries, Bool_t debug)
61 // this function checks if a particle from the event generator (i.e. among the nPrim particles in the stack)
62 // shall be counted as a primary particle
64 // This function or a equivalent should be available in some common place of AliRoot
67 // if the particle has a daughter primary, we do not want to count it
68 if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
71 printf("Dropping particle because it has a daughter among the primaries.\n");
75 Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
77 // skip quarks and gluon
78 if (pdgCode <= 10 || pdgCode == 21)
81 printf("Dropping particle because it is a quark or gluon.\n");
85 if (strcmp(aParticle->GetName(),"XXX") == 0)
88 printf("WARNING: There is a particle named XXX.\n");
92 TParticlePDG* pdgPart = aParticle->GetPDG();
94 if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
97 printf("WARNING: There is a particle with an unknown particle class (pdg code %d).\n", pdgCode);
101 if (pdgPart->Charge() == 0)
104 printf("Dropping particle because it is not charged.\n");
111 //____________________________________________________________________
112 void AliPWG0Helper::CreateProjections(TH3* hist)
114 // create projections of 3d hists to all 2d combinations
115 // the histograms are not returned, just use them from memory or use this to create them in a file
117 TH1* proj = hist->Project3D("yx");
118 proj->SetXTitle(hist->GetXaxis()->GetTitle());
119 proj->SetYTitle(hist->GetYaxis()->GetTitle());
121 proj = hist->Project3D("zx");
122 proj->SetXTitle(hist->GetXaxis()->GetTitle());
123 proj->SetYTitle(hist->GetZaxis()->GetTitle());
125 proj = hist->Project3D("zy");
126 proj->SetXTitle(hist->GetYaxis()->GetTitle());
127 proj->SetYTitle(hist->GetZaxis()->GetTitle());
130 //____________________________________________________________________
131 void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis, Bool_t putErrors)
133 // create projections of the 3d hists divides them
134 // axis decides to which plane, if axis is 0 to all planes
135 // the histograms are not returned, just use them from memory or use this to create them in a file
139 CreateDividedProjections(hist, hist2, "yx", putErrors);
140 CreateDividedProjections(hist, hist2, "zx", putErrors);
141 CreateDividedProjections(hist, hist2, "zy", putErrors);
146 TH1* proj = hist->Project3D(axis);
148 if (strlen(axis) == 2)
150 proj->SetYTitle(GetAxisTitle(hist, axis[0]));
151 proj->SetXTitle(GetAxisTitle(hist, axis[1]));
153 else if (strlen(axis) == 1)
154 proj->SetXTitle(GetAxisTitle(hist, axis[0]));
156 TH1* proj2 = hist2->Project3D(axis);
157 if (strlen(axis) == 2)
159 proj2->SetYTitle(GetAxisTitle(hist2, axis[0]));
160 proj2->SetXTitle(GetAxisTitle(hist2, axis[1]));
162 else if (strlen(axis) == 1)
163 proj2->SetXTitle(GetAxisTitle(hist2, axis[0]));
165 TH1* division = dynamic_cast<TH1*> (proj->Clone(Form("%s_div_%s", proj->GetName(), proj2->GetName())));
166 division->Divide(proj2);
171 if (division->GetDimension() == 1)
173 Int_t nBins = division->GetNbinsX();
174 for (Int_t i = 0; i <= nBins; ++i)
175 if (proj2->GetBinContent(i) != 0)
176 division->SetBinError(i, TMath::Sqrt(proj->GetBinContent(i)) / proj2->GetBinContent(i));
178 else if (division->GetDimension() == 2)
180 Int_t nBinsX = division->GetNbinsX();
181 Int_t nBinsY = division->GetNbinsY();
182 for (Int_t i = 0; i <= nBinsX; ++i)
183 for (Int_t j = 0; j <= nBinsY; ++j)
184 if (proj2->GetBinContent(i, j) != 0)
185 division->SetBinError(i, j, TMath::Sqrt(proj->GetBinContent(i, j)) / proj2->GetBinContent(i, j));
190 //____________________________________________________________________
191 const char* AliPWG0Helper::GetAxisTitle(TH3* hist, const char axis)
193 // returns the title of the axis given in axis (x, y, z)
196 return hist->GetXaxis()->GetTitle();
197 else if (axis == 'y')
198 return hist->GetYaxis()->GetTitle();
199 else if (axis == 'z')
200 return hist->GetZaxis()->GetTitle();