]>
Commit | Line | Data |
---|---|---|
fcca9870 | 1 | void ReadAODVertexingHF(const char *aodFileName="AliAOD.root", |
2 | const char *aodHFFileName="AliAOD.VertexingHF.root") | |
3 | { | |
4 | // | |
0bd2832b | 5 | // Example macro to read D0->Kpi candidates from AOD (having the |
6 | // standard AOD + a friend heavy-flavour AOD) and apply cuts | |
fcca9870 | 7 | // Origin: A.Dainese |
8 | // | |
9 | gSystem->Load("libANALYSIS.so"); | |
10 | gSystem->Load("libANALYSISalice.so"); | |
11 | gSystem->Load("libAOD.so"); | |
12 | gSystem->Load("libPWG3base.so"); | |
7210449b | 13 | gSystem->Load("libPWG3vertexingHF.so"); |
fcca9870 | 14 | |
15 | // create a test histogram | |
16 | TH2F *hCPtaVSd0d0 = new TH2F("hCPtaVSd0d0","D^{0} correlation plot",1000,-50000,50000,1000,-1,1); | |
17 | hCPtaVSd0d0->SetXTitle("Product of impact parameters [#mu m^{2}]"); | |
18 | hCPtaVSd0d0->SetYTitle("Cosine of pointing angle"); | |
19 | TH1F *hMass = new TH1F("hMass","D^{0} mass plot",100,1.7,2); | |
20 | hMass->SetXTitle("Invariant mass [GeV]"); | |
21 | hMass->SetYTitle("Entries"); | |
22 | TH1F *hSecVtxZ = new TH1F("hSecVtxZ","D^{0} decay vertex z",1000,-10,10); | |
23 | hSecVtxZ->SetXTitle("z of decay vertex [cm]"); | |
24 | hSecVtxZ->SetYTitle("Entries"); | |
2ff20727 | 25 | TH1F *hDeltaMassDstar = new TH1F("hDeltaMassDstar","D* delta mass plot",100,0,0.3); |
26 | hDeltaMassDstar->SetXTitle("M(Kpipi)-M(Kpi) [GeV]"); | |
27 | hDeltaMassDstar->SetYTitle("Entries"); | |
fcca9870 | 28 | |
29 | // open input file and get the TTree | |
30 | TFile inFile(aodFileName,"READ"); | |
31 | if (!inFile.IsOpen()) return; | |
32 | ||
33 | TTree *aodTree = (TTree*)inFile.Get("aodTree"); | |
34 | aodTree->AddFriend("aodTree",aodHFFileName); | |
35 | ||
36 | AliAODEvent *aod = new AliAODEvent(); | |
37 | ||
38 | aod->ReadFromTree(aodTree); | |
39 | ||
40 | // load heavy flavour vertices | |
41 | TClonesArray *arrayVerticesHF = | |
42 | (TClonesArray*)aod->GetList()->FindObject("VerticesHF"); | |
43 | ||
44 | // load D0->Kpi candidates | |
45 | TClonesArray *arrayD0toKpi = | |
46 | (TClonesArray*)aod->GetList()->FindObject("D0toKpi"); | |
47 | ||
48 | // load 3prong candidates | |
49 | TClonesArray *array3Prong = | |
50 | (TClonesArray*)aod->GetList()->FindObject("Charm3Prong"); | |
51 | ||
2ff20727 | 52 | // load D* candidates |
53 | TClonesArray *arrayDstar = | |
54 | (TClonesArray*)aod->GetList()->FindObject("Dstar"); | |
55 | ||
fcca9870 | 56 | |
57 | Double_t cutsD0[9]= | |
58 | // cutsD0[0] = inv. mass half width [GeV] | |
59 | // cutsD0[1] = dca [cm] | |
60 | // cutsD0[2] = cosThetaStar | |
61 | // cutsD0[3] = pTK [GeV/c] | |
62 | // cutsD0[4] = pTPi [GeV/c] | |
63 | // cutsD0[5] = d0K [cm] upper limit! | |
64 | // cutsD0[6] = d0Pi [cm] upper limit! | |
65 | // cutsD0[7] = d0d0 [cm^2] | |
66 | // cutsD0[8] = cosThetaPoint | |
67 | {1000., | |
68 | 100000., | |
69 | 1.1, | |
70 | 0., | |
71 | 0., | |
72 | 100000., | |
73 | 100000., | |
74 | 100000000., | |
75 | -1.1}; | |
2ff20727 | 76 | Double_t cutsDstar[5]= |
77 | // (to be passed to AliAODRecoCascadeHF::SelectDstar()) | |
78 | // 0 = inv. mass half width of D* [GeV] | |
79 | // 1 = half width of (M_Kpipi-M_Kpi) [GeV] | |
80 | // 2 = PtMin of pi_s [GeV/c] | |
81 | // 3 = PtMax of pi_s [GeV/c] | |
82 | // 4 = theta, angle between the trace of pi_s and D0 decay plane [rad] | |
83 | {999999., | |
84 | 999999., | |
85 | 0.1, | |
86 | 1.0, | |
87 | 0.5}; | |
88 | ||
89 | ||
90 | Int_t nTotHF=0,nTotD0toKpi=0,nTotDstar=0,nTot3Prong=0; | |
fcca9870 | 91 | AliAODVertex *vtx1=0; |
92 | ||
93 | // loop over events | |
94 | Int_t nEvents = aodTree->GetEntries(); | |
95 | for (Int_t nEv = 0; nEv < nEvents; nEv++) { | |
96 | cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl; | |
97 | ||
98 | // read event | |
99 | aodTree->GetEvent(nEv); | |
100 | //aodTree->BranchRef(); | |
101 | ||
102 | //print event info | |
103 | aod->GetHeader()->Print(); | |
104 | ||
105 | // primary vertex | |
106 | vtx1 = (AliAODVertex*)aod->GetPrimaryVertex(); | |
107 | vtx1->Print(); | |
108 | ||
109 | // make trkIDtoEntry register (temporary) | |
110 | Int_t trkIDtoEntry[100000]; | |
111 | for(Int_t it=0;it<aod->GetNumberOfTracks();it++) { | |
112 | AliAODTrack *track = aod->GetTrack(it); | |
113 | trkIDtoEntry[track->GetID()]=it; | |
114 | } | |
115 | ||
2ff20727 | 116 | |
fcca9870 | 117 | // loop over D0->Kpi candidates |
118 | Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast(); | |
119 | nTotD0toKpi += nD0toKpi; | |
120 | cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl; | |
121 | ||
122 | for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) { | |
123 | AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi); | |
124 | Bool_t unsetvtx=kFALSE; | |
125 | if(!d->GetOwnPrimaryVtx()) { | |
126 | d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables | |
127 | unsetvtx=kTRUE; | |
128 | } | |
129 | Int_t okD0=0,okD0bar=0; | |
130 | if(d->SelectD0(cutsD0,okD0,okD0bar)) { | |
131 | //cout<<1e8*d->Prodd0d0()<<endl; | |
132 | hMass->Fill(d->InvMassD0(),0.5); | |
133 | hMass->Fill(d->InvMassD0bar(),0.5); | |
134 | hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle()); | |
135 | hSecVtxZ->Fill(d->GetSecVtxZ()); | |
2a57ff58 | 136 | //cout<<d->GetSecVtxX() <<endl; |
fcca9870 | 137 | |
138 | // get daughter AOD tracks | |
2a57ff58 | 139 | AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0); |
140 | AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1); | |
141 | if(!trk0 || !trk1) { | |
142 | trk0=aod->GetTrack(trkIDtoEntry[d->GetProngID(0)]); | |
143 | trk1=aod->GetTrack(trkIDtoEntry[d->GetProngID(1)]); | |
144 | cout<<"references to standard AOD not available"<<endl; | |
145 | } | |
fcca9870 | 146 | cout<<"pt of positive track: "<<trk0->Pt()<<endl; |
2ff20727 | 147 | |
148 | // make a AliExternalTrackParam from the D0 | |
149 | // and calculate impact parameters to primary vertex | |
150 | AliExternalTrackParam trackD0(d); | |
151 | cout<<"pt of D0: "<<d->Pt()<<" (AliAODRecoDecay); "<<trackD0.Pt()<<" (track)"<<endl; | |
152 | //trackD0.Print(); | |
153 | Double_t dz[2],covdz[3]; | |
154 | trackD0.PropagateToDCA(vtx1,aod->GetMagneticField(),1000.,dz,covdz); | |
155 | cout<<"D0 impact parameter rphi: "<<dz[0]<<" +- "<<TMath::Sqrt(covdz[0])<<endl; | |
fcca9870 | 156 | } |
157 | if(unsetvtx) d->UnsetOwnPrimaryVtx(); | |
158 | } | |
2ff20727 | 159 | |
160 | ||
161 | // loop over D* candidates | |
162 | Int_t nDstar = arrayDstar->GetEntriesFast(); | |
163 | nTotDstar += nDstar; | |
164 | cout<<"Number of D*->D0pi: "<<nDstar<<endl; | |
165 | ||
166 | for (Int_t iDstar = 0; iDstar < nDstar; iDstar++) { | |
167 | AliAODRecoCascadeHF *c = (AliAODRecoCascadeHF*)arrayDstar->UncheckedAt(iDstar); | |
168 | Bool_t unsetvtx=kFALSE; | |
169 | if(!c->GetOwnPrimaryVtx()) { | |
170 | c->SetOwnPrimaryVtx(vtx1); // needed to compute all variables | |
171 | c->Get2Prong()->SetOwnPrimaryVtx(vtx1); | |
172 | unsetvtx=kTRUE; | |
173 | } | |
174 | if(c->SelectDstar(cutsDstar,cutsD0)) { | |
175 | hDeltaMassDstar->Fill(c->DeltaInvMass()); | |
176 | // get daughters | |
177 | AliAODTrack *trk = (AliAODTrack*)c->GetBachelor(); | |
178 | AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)c->Get2Prong(); | |
179 | cout<<"pt of soft pi: "<<trk->Pt()<<endl; | |
180 | cout<<"pt of D0: "<<d->Pt()<<endl; | |
181 | } | |
182 | ||
183 | if(unsetvtx) { | |
184 | c->UnsetOwnPrimaryVtx(); | |
185 | c->Get2Prong()->UnsetOwnPrimaryVtx(); | |
186 | } | |
187 | } | |
188 | ||
fcca9870 | 189 | |
190 | // count 3prong candidates | |
191 | Int_t n3Prong = array3Prong->GetEntriesFast(); | |
192 | nTot3Prong += n3Prong; | |
193 | cout<<"Number of Charm->3Prong: "<<n3Prong<<endl; | |
194 | ||
195 | // loop over HF vertices | |
196 | Int_t nVtxsHF = arrayVerticesHF->GetEntriesFast(); | |
197 | nTotHF += nVtxsHF; | |
198 | cout<<"Number of heavy-flavour vertices: "<<nVtxsHF<<endl; | |
199 | for (Int_t iVtx = 0; iVtx < nVtxsHF; iVtx++) { | |
200 | AliAODVertex *vtxHF = (AliAODVertex*)arrayVerticesHF->UncheckedAt(iVtx); | |
201 | // print info | |
202 | //cout << iVtx << ": vertex z position: " << vtxHF->GetZ() << endl; | |
203 | } | |
204 | ||
205 | } | |
206 | ||
207 | printf("\n Total HF vertices: %d\n",nTotHF); | |
208 | printf("\n Total D0->Kpi: %d\n",nTotD0toKpi); | |
2ff20727 | 209 | printf("\n Total D*->D0pi: %d\n",nTotDstar); |
fcca9870 | 210 | printf("\n Total Charm->3Prong: %d\n",nTot3Prong); |
211 | ||
2ff20727 | 212 | TCanvas *c1 = new TCanvas("c1","c1",0,0,800,700); |
213 | c1->Divide(2,2); | |
214 | c1->cd(1); | |
fcca9870 | 215 | hCPtaVSd0d0->Draw("colz"); |
2ff20727 | 216 | c1->cd(2); |
fcca9870 | 217 | hMass->SetFillColor(4); |
218 | hMass->Draw(); | |
2ff20727 | 219 | c1->cd(3); |
fcca9870 | 220 | hSecVtxZ->SetFillColor(2); |
221 | hSecVtxZ->Draw(); | |
2ff20727 | 222 | c1->cd(4); |
223 | hDeltaMassDstar->SetFillColor(3); | |
224 | hDeltaMassDstar->Draw(); | |
fcca9870 | 225 | |
226 | return; | |
227 | } | |
0bd2832b | 228 | //------------------------------------------------------------------------ |
229 | void ReadAODVertexingHFsa(const char *aodHFFileName="AliAOD.VertexingHF.sa.root") | |
230 | { | |
231 | // | |
232 | // Example macro to read D0->Kpi candidates from a stand-alone | |
233 | // heavy-flavour AOD (i.e. without standard AOD) and apply cuts | |
234 | // Origin: A.Dainese | |
235 | // | |
236 | gSystem->Load("libANALYSIS.so"); | |
237 | gSystem->Load("libANALYSISalice.so"); | |
238 | gSystem->Load("libAOD.so"); | |
239 | gSystem->Load("libPWG3base.so"); | |
240 | ||
241 | // create a test histogram | |
242 | TH2F *hCPtaVSd0d0 = new TH2F("hCPtaVSd0d0","D^{0} correlation plot",1000,-50000,50000,1000,-1,1); | |
243 | hCPtaVSd0d0->SetXTitle("Product of impact parameters [#mu m^{2}]"); | |
244 | hCPtaVSd0d0->SetYTitle("Cosine of pointing angle"); | |
245 | TH1F *hMass = new TH1F("hMass","D^{0} mass plot",100,1.7,2); | |
246 | hMass->SetXTitle("Invariant mass [GeV]"); | |
247 | hMass->SetYTitle("Entries"); | |
248 | TH1F *hSecVtxZ = new TH1F("hSecVtxZ","D^{0} decay vertex z",1000,-10,10); | |
249 | hSecVtxZ->SetXTitle("z of decay vertex [cm]"); | |
250 | hSecVtxZ->SetYTitle("Entries"); | |
251 | ||
252 | // open input file and get the TTree | |
253 | TFile inFile(aodHFFileName,"READ"); | |
254 | if (!inFile.IsOpen()) return; | |
255 | ||
256 | TTree *aodTree = (TTree*)inFile.Get("aodTree"); | |
257 | ||
258 | AliAODEvent *aod = new AliAODEvent(); | |
259 | ||
260 | aod->ReadFromTree(aodTree); | |
261 | ||
262 | // load heavy flavour vertices | |
263 | TClonesArray *arrayVerticesHF = | |
264 | (TClonesArray*)aod->GetList()->FindObject("VerticesHF"); | |
265 | ||
266 | // load D0->Kpi candidates | |
267 | TClonesArray *arrayD0toKpi = | |
268 | (TClonesArray*)aod->GetList()->FindObject("D0toKpi"); | |
269 | ||
270 | ||
271 | Double_t cutsD0[9]= | |
272 | // cutsD0[0] = inv. mass half width [GeV] | |
273 | // cutsD0[1] = dca [cm] | |
274 | // cutsD0[2] = cosThetaStar | |
275 | // cutsD0[3] = pTK [GeV/c] | |
276 | // cutsD0[4] = pTPi [GeV/c] | |
277 | // cutsD0[5] = d0K [cm] upper limit! | |
278 | // cutsD0[6] = d0Pi [cm] upper limit! | |
279 | // cutsD0[7] = d0d0 [cm^2] | |
280 | // cutsD0[8] = cosThetaPoint | |
281 | {1000., | |
282 | 100000., | |
283 | 1.1, | |
284 | 0., | |
285 | 0., | |
286 | 100000., | |
287 | 100000., | |
288 | 100000000., | |
289 | -1.1}; | |
290 | ||
291 | Int_t nTotHF=0,nTotD0toKpi=0; | |
292 | AliAODVertex *vtx1=0; | |
293 | ||
294 | // loop over events | |
295 | Int_t nEvents = aodTree->GetEntries(); | |
296 | for (Int_t nEv = 0; nEv < nEvents; nEv++) { | |
297 | cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl; | |
298 | ||
299 | // read event | |
300 | aodTree->GetEvent(nEv); | |
301 | //aodTree->BranchRef(); | |
302 | ||
303 | ||
304 | // loop over D0->Kpi candidates | |
305 | Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast(); | |
306 | nTotD0toKpi += nD0toKpi; | |
307 | cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl; | |
308 | ||
309 | for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) { | |
310 | AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi); | |
311 | Int_t okD0=0,okD0bar=0; | |
312 | if(d->SelectD0(cutsD0,okD0,okD0bar)) { | |
313 | //cout<<1e8*d->Prodd0d0()<<endl; | |
314 | hMass->Fill(d->InvMassD0(),0.5); | |
315 | hMass->Fill(d->InvMassD0bar(),0.5); | |
316 | hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle()); | |
317 | hSecVtxZ->Fill(d->GetSecVtxZ()); | |
318 | //cout<<d->GetSecVtxZ() <<endl; | |
319 | ||
320 | } | |
321 | } | |
322 | ||
323 | } | |
324 | ||
325 | printf("\n Total D0->Kpi: %d\n",nTotD0toKpi); | |
326 | ||
327 | TCanvas *c = new TCanvas("c","c",0,0,1000,1000); | |
328 | c->Divide(2,2); | |
329 | c->cd(1); | |
330 | hCPtaVSd0d0->Draw("colz"); | |
331 | c->cd(2); | |
332 | hMass->SetFillColor(4); | |
333 | hMass->Draw(); | |
334 | c->cd(3); | |
335 | hSecVtxZ->SetFillColor(2); | |
336 | hSecVtxZ->Draw(); | |
337 | ||
338 | return; | |
339 | } |