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/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");
28 // open input file and get the TTree
29 TFile inFile(aodFileName,"READ");
30 if (!inFile.IsOpen()) return;
32 TTree *aodTree = (TTree*)inFile.Get("aodTree");
33 aodTree->AddFriend("aodTree",aodHFFileName);
35 AliAODEvent *aod = new AliAODEvent();
37 aod->ReadFromTree(aodTree);
39 // load heavy flavour vertices
40 TClonesArray *arrayVerticesHF =
41 (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
43 // load D0->Kpi candidates
44 TClonesArray *arrayD0toKpi =
45 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
47 // load 3prong candidates
48 TClonesArray *array3Prong =
49 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
52 TClonesArray *arrayDstar =
53 (TClonesArray*)aod->GetList()->FindObject("Dstar");
57 // cutsD0[0] = inv. mass half width [GeV]
58 // cutsD0[1] = dca [cm]
59 // cutsD0[2] = cosThetaStar
60 // cutsD0[3] = pTK [GeV/c]
61 // cutsD0[4] = pTPi [GeV/c]
62 // cutsD0[5] = d0K [cm] upper limit!
63 // cutsD0[6] = d0Pi [cm] upper limit!
64 // cutsD0[7] = d0d0 [cm^2]
65 // cutsD0[8] = cosThetaPoint
75 Double_t cutsDstar[5]=
76 // (to be passed to AliAODRecoCascadeHF::SelectDstar())
77 // 0 = inv. mass half width of D* [GeV]
78 // 1 = half width of (M_Kpipi-M_Kpi) [GeV]
79 // 2 = PtMin of pi_s [GeV/c]
80 // 3 = PtMax of pi_s [GeV/c]
81 // 4 = theta, angle between the trace of pi_s and D0 decay plane [rad]
89 Int_t nTotHF=0,nTotD0toKpi=0,nTotDstar=0,nTot3Prong=0;
93 Int_t nEvents = aodTree->GetEntries();
94 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
95 cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl;
98 aodTree->GetEvent(nEv);
99 //aodTree->BranchRef();
102 aod->GetHeader()->Print();
105 vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
108 // make trkIDtoEntry register (temporary)
109 Int_t trkIDtoEntry[100000];
110 for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
111 AliAODTrack *track = aod->GetTrack(it);
112 trkIDtoEntry[track->GetID()]=it;
116 // loop over D0->Kpi candidates
117 Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
118 nTotD0toKpi += nD0toKpi;
119 cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
121 for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
122 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
123 Bool_t unsetvtx=kFALSE;
124 if(!d->GetOwnPrimaryVtx()) {
125 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
128 Int_t okD0=0,okD0bar=0;
129 if(d->SelectD0(cutsD0,okD0,okD0bar)) {
130 //cout<<1e8*d->Prodd0d0()<<endl;
131 hMass->Fill(d->InvMassD0(),0.5);
132 hMass->Fill(d->InvMassD0bar(),0.5);
133 hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
134 hSecVtxZ->Fill(d->GetSecVtxZ());
135 //cout<<d->GetSecVtxX() <<endl;
137 // get daughter AOD tracks
138 AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
139 AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
141 trk0=aod->GetTrack(trkIDtoEntry[d->GetProngID(0)]);
142 trk1=aod->GetTrack(trkIDtoEntry[d->GetProngID(1)]);
143 cout<<"references to standard AOD not available"<<endl;
145 cout<<"pt of positive track: "<<trk0->Pt()<<endl;
147 // make a AliNeutralTrackParam from the D0
148 // and calculate impact parameters to primary vertex
149 AliNeutralTrackParam trackD0(d);
150 cout<<"pt of D0: "<<d->Pt()<<" (AliAODRecoDecay); "<<trackD0.Pt()<<" (track)"<<endl;
152 Double_t dz[2],covdz[3];
153 trackD0.PropagateToDCA(vtx1,aod->GetMagneticField(),1000.,dz,covdz);
154 cout<<"D0 impact parameter rphi: "<<dz[0]<<" +- "<<TMath::Sqrt(covdz[0])<<endl;
156 if(unsetvtx) d->UnsetOwnPrimaryVtx();
160 // loop over D* candidates
161 Int_t nDstar = arrayDstar->GetEntriesFast();
163 cout<<"Number of D*->D0pi: "<<nDstar<<endl;
165 for (Int_t iDstar = 0; iDstar < nDstar; iDstar++) {
166 AliAODRecoCascadeHF *c = (AliAODRecoCascadeHF*)arrayDstar->UncheckedAt(iDstar);
167 Bool_t unsetvtx=kFALSE;
168 if(!c->GetOwnPrimaryVtx()) {
169 c->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
170 c->Get2Prong()->SetOwnPrimaryVtx(vtx1);
173 if(c->SelectDstar(cutsDstar,cutsD0)) {
174 hDeltaMassDstar->Fill(c->DeltaInvMass());
176 AliAODTrack *trk = (AliAODTrack*)c->GetBachelor();
177 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)c->Get2Prong();
178 cout<<"pt of soft pi: "<<trk->Pt()<<endl;
179 cout<<"pt of D0: "<<d->Pt()<<endl;
183 c->UnsetOwnPrimaryVtx();
184 c->Get2Prong()->UnsetOwnPrimaryVtx();
189 // count 3prong candidates
190 Int_t n3Prong = array3Prong->GetEntriesFast();
191 nTot3Prong += n3Prong;
192 cout<<"Number of Charm->3Prong: "<<n3Prong<<endl;
194 // loop over HF vertices
195 Int_t nVtxsHF = arrayVerticesHF->GetEntriesFast();
197 cout<<"Number of heavy-flavour vertices: "<<nVtxsHF<<endl;
198 for (Int_t iVtx = 0; iVtx < nVtxsHF; iVtx++) {
199 AliAODVertex *vtxHF = (AliAODVertex*)arrayVerticesHF->UncheckedAt(iVtx);
201 //cout << iVtx << ": vertex z position: " << vtxHF->GetZ() << endl;
206 printf("\n Total HF vertices: %d\n",nTotHF);
207 printf("\n Total D0->Kpi: %d\n",nTotD0toKpi);
208 printf("\n Total D*->D0pi: %d\n",nTotDstar);
209 printf("\n Total Charm->3Prong: %d\n",nTot3Prong);
211 TCanvas *c1 = new TCanvas("c1","c1",0,0,800,700);
214 hCPtaVSd0d0->Draw("colz");
216 hMass->SetFillColor(4);
219 hSecVtxZ->SetFillColor(2);
222 hDeltaMassDstar->SetFillColor(3);
223 hDeltaMassDstar->Draw();
227 //------------------------------------------------------------------------
228 void ReadAODVertexingHFsa(const char *aodHFFileName="AliAOD.VertexingHF.sa.root")
231 // Example macro to read D0->Kpi candidates from a stand-alone
232 // heavy-flavour AOD (i.e. without standard AOD) and apply cuts
235 Bool_t useParFiles=kFALSE;
236 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/LoadLibraries.C");
237 LoadLibraries(useParFiles);
239 // create a test histogram
240 TH2F *hCPtaVSd0d0 = new TH2F("hCPtaVSd0d0","D^{0} correlation plot",1000,-50000,50000,1000,-1,1);
241 hCPtaVSd0d0->SetXTitle("Product of impact parameters [#mu m^{2}]");
242 hCPtaVSd0d0->SetYTitle("Cosine of pointing angle");
243 TH1F *hMass = new TH1F("hMass","D^{0} mass plot",100,1.7,2);
244 hMass->SetXTitle("Invariant mass [GeV]");
245 hMass->SetYTitle("Entries");
246 TH1F *hSecVtxZ = new TH1F("hSecVtxZ","D^{0} decay vertex z",1000,-10,10);
247 hSecVtxZ->SetXTitle("z of decay vertex [cm]");
248 hSecVtxZ->SetYTitle("Entries");
250 // open input file and get the TTree
251 TFile inFile(aodHFFileName,"READ");
252 if (!inFile.IsOpen()) return;
254 TTree *aodTree = (TTree*)inFile.Get("aodTree");
256 AliAODEvent *aod = new AliAODEvent();
258 aod->ReadFromTree(aodTree);
260 // load heavy flavour vertices
261 TClonesArray *arrayVerticesHF =
262 (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
264 // load D0->Kpi candidates
265 TClonesArray *arrayD0toKpi =
266 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
270 // cutsD0[0] = inv. mass half width [GeV]
271 // cutsD0[1] = dca [cm]
272 // cutsD0[2] = cosThetaStar
273 // cutsD0[3] = pTK [GeV/c]
274 // cutsD0[4] = pTPi [GeV/c]
275 // cutsD0[5] = d0K [cm] upper limit!
276 // cutsD0[6] = d0Pi [cm] upper limit!
277 // cutsD0[7] = d0d0 [cm^2]
278 // cutsD0[8] = cosThetaPoint
289 Int_t nTotHF=0,nTotD0toKpi=0;
290 AliAODVertex *vtx1=0;
293 Int_t nEvents = aodTree->GetEntries();
294 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
295 cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl;
298 aodTree->GetEvent(nEv);
299 //aodTree->BranchRef();
302 // loop over D0->Kpi candidates
303 Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
304 nTotD0toKpi += nD0toKpi;
305 cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
307 for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
308 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
309 Int_t okD0=0,okD0bar=0;
310 if(d->SelectD0(cutsD0,okD0,okD0bar)) {
311 //cout<<1e8*d->Prodd0d0()<<endl;
312 hMass->Fill(d->InvMassD0(),0.5);
313 hMass->Fill(d->InvMassD0bar(),0.5);
314 hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
315 hSecVtxZ->Fill(d->GetSecVtxZ());
316 //cout<<d->GetSecVtxZ() <<endl;
323 printf("\n Total D0->Kpi: %d\n",nTotD0toKpi);
325 TCanvas *c = new TCanvas("c","c",0,0,1000,1000);
328 hCPtaVSd0d0->Draw("colz");
330 hMass->SetFillColor(4);
333 hSecVtxZ->SetFillColor(2);