1 void ReadAODVertexingHF(const char *aodFileName="AliAOD.root",
2 const char *aodHFFileName="AliAOD.VertexingHF.root")
5 // Example macro to read D0->Kpi candidates from AOD (having the
6 // standard AOD + a friend heavy-flavour AOD) and apply cuts
10 Bool_t useParFiles=kFALSE;
11 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/macros/LoadLibraries.C");
12 LoadLibraries(useParFiles);
14 // create a test histogram
15 TH2F *hCPtaVSd0d0 = new TH2F("hCPtaVSd0d0","D^{0} correlation plot",1000,-50000,50000,1000,-1,1);
16 hCPtaVSd0d0->SetXTitle("Product of impact parameters [#mu m^{2}]");
17 hCPtaVSd0d0->SetYTitle("Cosine of pointing angle");
18 TH1F *hMass = new TH1F("hMass","D^{0} mass plot",100,1.7,2);
19 hMass->SetXTitle("Invariant mass [GeV]");
20 hMass->SetYTitle("Entries");
21 TH1F *hSecVtxZ = new TH1F("hSecVtxZ","D^{0} decay vertex z",1000,-10,10);
22 hSecVtxZ->SetXTitle("z of decay vertex [cm]");
23 hSecVtxZ->SetYTitle("Entries");
24 TH1F *hDeltaMassDstar = new TH1F("hDeltaMassDstar","D* delta mass plot",100,0,0.3);
25 hDeltaMassDstar->SetXTitle("M(Kpipi)-M(Kpi) [GeV]");
26 hDeltaMassDstar->SetYTitle("Entries");
29 // open input file and get the TTree
30 TFile inFile(aodFileName,"READ");
31 if (!inFile.IsOpen()) return;
33 TTree *aodTree = (TTree*)inFile.Get("aodTree");
34 aodTree->AddFriend("aodTree",aodHFFileName);
36 AliAODEvent *aod = new AliAODEvent();
38 aod->ReadFromTree(aodTree);
40 // load heavy flavour vertices
41 TClonesArray *arrayVerticesHF =
42 (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
44 // load D0->Kpi candidates
45 TClonesArray *arrayD0toKpi =
46 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
48 // load 3prong candidates
49 TClonesArray *array3Prong =
50 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
53 TClonesArray *arrayDstar =
54 (TClonesArray*)aod->GetList()->FindObject("Dstar");
56 // load cascade (V0+track) candidates
57 TClonesArray *arrayCascades =
58 (TClonesArray*)aod->GetList()->FindObject("CascadesHF");
62 // cutsD0[0] = inv. mass half width [GeV]
63 // cutsD0[1] = dca [cm]
64 // cutsD0[2] = cosThetaStar
65 // cutsD0[3] = pTK [GeV/c]
66 // cutsD0[4] = pTPi [GeV/c]
67 // cutsD0[5] = d0K [cm] upper limit!
68 // cutsD0[6] = d0Pi [cm] upper limit!
69 // cutsD0[7] = d0d0 [cm^2]
70 // cutsD0[8] = cosThetaPoint
80 Double_t cutsDstar[5]=
81 // (to be passed to AliAODRecoCascadeHF::SelectDstar())
82 // 0 = inv. mass half width of D* [GeV]
83 // 1 = half width of (M_Kpipi-M_Kpi) [GeV]
84 // 2 = PtMin of pi_s [GeV/c]
85 // 3 = PtMax of pi_s [GeV/c]
86 // 4 = theta, angle between the trace of pi_s and D0 decay plane [rad]
93 Double_t cutsLctoV0[9]=// cuts on Lambdac candidates to V0+bachelor
94 // (to be passed to AliAODRecoDecayHF3Prong::SelectLctoV0())
95 // 0 = inv. mass half width in K0s hypothesis [GeV]
96 // 1 = inv. mass half width in Lambda hypothesis [GeV]
97 // 2 = inv. mass V0 in K0s hypothesis half width [GeV]
98 // 3 = inv. mass V0 in Lambda hypothesis half width [GeV]
99 // 4 = pT min Bachelor track [GeV/c]
100 // 5 = pT min V0-Positive track [GeV/c]
101 // 6 = pT min V0-Negative track [GeV/c]
102 // 7 = dca cut on the V0 (cm)
103 // 8 = dca cut on the cascade (cm)
104 {2.0,2.0,1.0,1.0,0.0,0.0,0.0,1000.,1000.};
106 Int_t nTotHF=0,nTotD0toKpi=0,nTotDstar=0,nTot3Prong=0,nTotCasc=0;
107 AliAODVertex *vtx1=0;
110 Int_t nEvents = aodTree->GetEntries();
111 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
112 cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl;
115 aodTree->GetEvent(nEv);
116 //aodTree->BranchRef();
119 aod->GetHeader()->Print();
122 vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
125 // make trkIDtoEntry register (temporary)
126 Int_t trkIDtoEntry[100000];
127 for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
128 AliAODTrack *track = aod->GetTrack(it);
129 trkIDtoEntry[track->GetID()]=it;
133 // loop over D0->Kpi candidates
134 Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
135 nTotD0toKpi += nD0toKpi;
136 cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
138 for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
139 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
141 d->GetPrimaryVtx()->Print();
143 Bool_t unsetvtx=kFALSE;
144 //if(!d->GetOwnPrimaryVtx()) {
145 //d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
148 Int_t okD0=0,okD0bar=0;
149 if(d->SelectD0(cutsD0,okD0,okD0bar)) {
150 //cout<<1e8*d->Prodd0d0()<<endl;
151 hMass->Fill(d->InvMassD0(),0.5);
152 hMass->Fill(d->InvMassD0bar(),0.5);
153 hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
154 hSecVtxZ->Fill(d->GetSecVtxZ());
155 //cout<<d->GetSecVtxX() <<endl;
157 // get daughter AOD tracks
158 AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
159 AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
161 trk0=aod->GetTrack(trkIDtoEntry[d->GetProngID(0)]);
162 trk1=aod->GetTrack(trkIDtoEntry[d->GetProngID(1)]);
163 cout<<"references to standard AOD not available"<<endl;
165 //cout<<"pt of positive track: "<<trk0->Pt()<<endl;
167 // make a AliNeutralTrackParam from the D0
168 // and calculate impact parameters to primary vertex
169 AliNeutralTrackParam trackD0(d);
170 //cout<<"pt of D0: "<<d->Pt()<<" (AliAODRecoDecay); "<<trackD0.Pt()<<" (track)"<<endl;
172 Double_t dz[2],covdz[3];
173 trackD0.PropagateToDCA(vtx1,aod->GetMagneticField(),1000.,dz,covdz);
174 //cout<<"D0 impact parameter rphi: "<<dz[0]<<" +- "<<TMath::Sqrt(covdz[0])<<endl;
176 if(unsetvtx) d->UnsetOwnPrimaryVtx();
180 // loop over D* candidates
181 Int_t nDstar = arrayDstar->GetEntriesFast();
183 cout<<"Number of D*->D0pi: "<<nDstar<<endl;
185 for (Int_t iDstar = 0; iDstar < nDstar; iDstar++) {
186 AliAODRecoCascadeHF *c = (AliAODRecoCascadeHF*)arrayDstar->UncheckedAt(iDstar);
187 Bool_t unsetvtx=kFALSE;
188 //if(!c->GetOwnPrimaryVtx()) {
189 //c->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
190 //c->Get2Prong()->SetOwnPrimaryVtx(vtx1);
193 if(c->SelectDstar(cutsDstar,cutsD0)) {
194 hDeltaMassDstar->Fill(c->DeltaInvMass());
196 AliAODTrack *trk = (AliAODTrack*)c->GetBachelor();
197 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)c->Get2Prong();
198 //cout<<"pt of soft pi: "<<trk->Pt()<<endl;
199 //cout<<"pt of D0: "<<d->Pt()<<endl;
203 c->UnsetOwnPrimaryVtx();
204 c->Get2Prong()->UnsetOwnPrimaryVtx();
209 // count 3prong candidates
210 Int_t n3Prong = array3Prong->GetEntriesFast();
211 nTot3Prong += n3Prong;
212 cout<<"Number of Charm->3Prong: "<<n3Prong<<endl;
214 // loop over HF vertices
215 Int_t nVtxsHF = arrayVerticesHF->GetEntriesFast();
217 cout<<"Number of heavy-flavour vertices: "<<nVtxsHF<<endl;
218 for (Int_t iVtx = 0; iVtx < nVtxsHF; iVtx++) {
219 AliAODVertex *vtxHF = (AliAODVertex*)arrayVerticesHF->UncheckedAt(iVtx);
221 //cout << iVtx << ": vertex z position: " << vtxHF->GetZ() << endl;
225 // count cascade candidates
227 Int_t nCasc = arrayCascades->GetEntriesFast();
229 cout << "Number of Cascades: "<<nCasc<<endl;
234 printf("\n Total HF vertices: %d\n",nTotHF);
235 printf("\n Total D0->Kpi: %d\n",nTotD0toKpi);
236 printf("\n Total D*->D0pi: %d\n",nTotDstar);
237 printf("\n Total Charm->3Prong: %d\n",nTot3Prong);
238 if (arrayCascades) printf("\n Total Cascades: %d\n",nTotCasc);
240 TCanvas *c1 = new TCanvas("c1","c1",0,0,800,700);
243 hCPtaVSd0d0->Draw("colz");
245 hMass->SetFillColor(4);
248 hSecVtxZ->SetFillColor(2);
251 hDeltaMassDstar->SetFillColor(3);
252 hDeltaMassDstar->Draw();
256 //------------------------------------------------------------------------
257 void ReadAODVertexingHFsa(const char *aodHFFileName="AliAOD.VertexingHF.sa.root")
260 // Example macro to read D0->Kpi candidates from a stand-alone
261 // heavy-flavour AOD (i.e. without standard AOD) and apply cuts
264 Bool_t useParFiles=kFALSE;
265 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/LoadLibraries.C");
266 LoadLibraries(useParFiles);
268 // create a test histogram
269 TH2F *hCPtaVSd0d0 = new TH2F("hCPtaVSd0d0","D^{0} correlation plot",1000,-50000,50000,1000,-1,1);
270 hCPtaVSd0d0->SetXTitle("Product of impact parameters [#mu m^{2}]");
271 hCPtaVSd0d0->SetYTitle("Cosine of pointing angle");
272 TH1F *hMass = new TH1F("hMass","D^{0} mass plot",100,1.7,2);
273 hMass->SetXTitle("Invariant mass [GeV]");
274 hMass->SetYTitle("Entries");
275 TH1F *hSecVtxZ = new TH1F("hSecVtxZ","D^{0} decay vertex z",1000,-10,10);
276 hSecVtxZ->SetXTitle("z of decay vertex [cm]");
277 hSecVtxZ->SetYTitle("Entries");
279 // open input file and get the TTree
280 TFile inFile(aodHFFileName,"READ");
281 if (!inFile.IsOpen()) return;
283 TTree *aodTree = (TTree*)inFile.Get("aodTree");
285 AliAODEvent *aod = new AliAODEvent();
287 aod->ReadFromTree(aodTree);
289 // load heavy flavour vertices
290 TClonesArray *arrayVerticesHF =
291 (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
293 // load D0->Kpi candidates
294 TClonesArray *arrayD0toKpi =
295 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
299 // cutsD0[0] = inv. mass half width [GeV]
300 // cutsD0[1] = dca [cm]
301 // cutsD0[2] = cosThetaStar
302 // cutsD0[3] = pTK [GeV/c]
303 // cutsD0[4] = pTPi [GeV/c]
304 // cutsD0[5] = d0K [cm] upper limit!
305 // cutsD0[6] = d0Pi [cm] upper limit!
306 // cutsD0[7] = d0d0 [cm^2]
307 // cutsD0[8] = cosThetaPoint
318 Int_t nTotHF=0,nTotD0toKpi=0;
319 AliAODVertex *vtx1=0;
322 Int_t nEvents = aodTree->GetEntries();
323 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
324 cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl;
327 aodTree->GetEvent(nEv);
328 //aodTree->BranchRef();
331 // loop over D0->Kpi candidates
332 Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
333 nTotD0toKpi += nD0toKpi;
334 cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
336 for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
337 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
338 Int_t okD0=0,okD0bar=0;
339 if(d->SelectD0(cutsD0,okD0,okD0bar)) {
340 //cout<<1e8*d->Prodd0d0()<<endl;
341 hMass->Fill(d->InvMassD0(),0.5);
342 hMass->Fill(d->InvMassD0bar(),0.5);
343 hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
344 hSecVtxZ->Fill(d->GetSecVtxZ());
345 //cout<<d->GetSecVtxZ() <<endl;
352 printf("\n Total D0->Kpi: %d\n",nTotD0toKpi);
354 TCanvas *c = new TCanvas("c","c",0,0,1000,1000);
357 hCPtaVSd0d0->Draw("colz");
359 hMass->SetFillColor(4);
362 hSecVtxZ->SetFillColor(2);