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
9 gSystem->Load("libANALYSIS.so");
10 gSystem->Load("libANALYSISalice.so");
11 gSystem->Load("libAOD.so");
12 gSystem->Load("libPWG3base.so");
13 gSystem->Load("libPWG3vertexingHF.so");
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");
26 // open input file and get the TTree
27 TFile inFile(aodFileName,"READ");
28 if (!inFile.IsOpen()) return;
30 TTree *aodTree = (TTree*)inFile.Get("aodTree");
31 aodTree->AddFriend("aodTree",aodHFFileName);
33 AliAODEvent *aod = new AliAODEvent();
35 aod->ReadFromTree(aodTree);
37 // load heavy flavour vertices
38 TClonesArray *arrayVerticesHF =
39 (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
41 // load D0->Kpi candidates
42 TClonesArray *arrayD0toKpi =
43 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
45 // load 3prong candidates
46 TClonesArray *array3Prong =
47 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
51 // cutsD0[0] = inv. mass half width [GeV]
52 // cutsD0[1] = dca [cm]
53 // cutsD0[2] = cosThetaStar
54 // cutsD0[3] = pTK [GeV/c]
55 // cutsD0[4] = pTPi [GeV/c]
56 // cutsD0[5] = d0K [cm] upper limit!
57 // cutsD0[6] = d0Pi [cm] upper limit!
58 // cutsD0[7] = d0d0 [cm^2]
59 // cutsD0[8] = cosThetaPoint
70 Int_t nTotHF=0,nTotD0toKpi=0,nTot3Prong=0;
74 Int_t nEvents = aodTree->GetEntries();
75 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
76 cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl;
79 aodTree->GetEvent(nEv);
80 //aodTree->BranchRef();
83 aod->GetHeader()->Print();
86 vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
89 // make trkIDtoEntry register (temporary)
90 Int_t trkIDtoEntry[100000];
91 for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
92 AliAODTrack *track = aod->GetTrack(it);
93 trkIDtoEntry[track->GetID()]=it;
96 // loop over D0->Kpi candidates
97 Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
98 nTotD0toKpi += nD0toKpi;
99 cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
101 for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
102 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
103 Bool_t unsetvtx=kFALSE;
104 if(!d->GetOwnPrimaryVtx()) {
105 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
108 Int_t okD0=0,okD0bar=0;
109 if(d->SelectD0(cutsD0,okD0,okD0bar)) {
110 //cout<<1e8*d->Prodd0d0()<<endl;
111 hMass->Fill(d->InvMassD0(),0.5);
112 hMass->Fill(d->InvMassD0bar(),0.5);
113 hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
114 hSecVtxZ->Fill(d->GetSecVtxZ());
115 //cout<<d->GetSecVtxZ() <<endl;
117 // get daughter AOD tracks
118 AliAODTrack *trk0=aod->GetTrack(trkIDtoEntry[d->GetProngID(0)]);
119 AliAODTrack *trk1=aod->GetTrack(trkIDtoEntry[d->GetProngID(1)]);
120 cout<<"pt of positive track: "<<trk0->Pt()<<endl;
121 // this will be replaced by
122 //AliAODTrack *trk0 = (AliAODTrack*)(d->GetSecondaryVtx()->GetDaughter(0));
124 if(unsetvtx) d->UnsetOwnPrimaryVtx();
127 // count 3prong candidates
128 Int_t n3Prong = array3Prong->GetEntriesFast();
129 nTot3Prong += n3Prong;
130 cout<<"Number of Charm->3Prong: "<<n3Prong<<endl;
132 // loop over HF vertices
133 Int_t nVtxsHF = arrayVerticesHF->GetEntriesFast();
135 cout<<"Number of heavy-flavour vertices: "<<nVtxsHF<<endl;
136 for (Int_t iVtx = 0; iVtx < nVtxsHF; iVtx++) {
137 AliAODVertex *vtxHF = (AliAODVertex*)arrayVerticesHF->UncheckedAt(iVtx);
139 //cout << iVtx << ": vertex z position: " << vtxHF->GetZ() << endl;
144 printf("\n Total HF vertices: %d\n",nTotHF);
145 printf("\n Total D0->Kpi: %d\n",nTotD0toKpi);
146 printf("\n Total Charm->3Prong: %d\n",nTot3Prong);
148 TCanvas *c = new TCanvas("c","c",0,0,1000,1000);
151 hCPtaVSd0d0->Draw("colz");
153 hMass->SetFillColor(4);
156 hSecVtxZ->SetFillColor(2);
161 //------------------------------------------------------------------------
162 void ReadAODVertexingHFsa(const char *aodHFFileName="AliAOD.VertexingHF.sa.root")
165 // Example macro to read D0->Kpi candidates from a stand-alone
166 // heavy-flavour AOD (i.e. without standard AOD) and apply cuts
169 gSystem->Load("libANALYSIS.so");
170 gSystem->Load("libANALYSISalice.so");
171 gSystem->Load("libAOD.so");
172 gSystem->Load("libPWG3base.so");
174 // create a test histogram
175 TH2F *hCPtaVSd0d0 = new TH2F("hCPtaVSd0d0","D^{0} correlation plot",1000,-50000,50000,1000,-1,1);
176 hCPtaVSd0d0->SetXTitle("Product of impact parameters [#mu m^{2}]");
177 hCPtaVSd0d0->SetYTitle("Cosine of pointing angle");
178 TH1F *hMass = new TH1F("hMass","D^{0} mass plot",100,1.7,2);
179 hMass->SetXTitle("Invariant mass [GeV]");
180 hMass->SetYTitle("Entries");
181 TH1F *hSecVtxZ = new TH1F("hSecVtxZ","D^{0} decay vertex z",1000,-10,10);
182 hSecVtxZ->SetXTitle("z of decay vertex [cm]");
183 hSecVtxZ->SetYTitle("Entries");
185 // open input file and get the TTree
186 TFile inFile(aodHFFileName,"READ");
187 if (!inFile.IsOpen()) return;
189 TTree *aodTree = (TTree*)inFile.Get("aodTree");
191 AliAODEvent *aod = new AliAODEvent();
193 aod->ReadFromTree(aodTree);
195 // load heavy flavour vertices
196 TClonesArray *arrayVerticesHF =
197 (TClonesArray*)aod->GetList()->FindObject("VerticesHF");
199 // load D0->Kpi candidates
200 TClonesArray *arrayD0toKpi =
201 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
205 // cutsD0[0] = inv. mass half width [GeV]
206 // cutsD0[1] = dca [cm]
207 // cutsD0[2] = cosThetaStar
208 // cutsD0[3] = pTK [GeV/c]
209 // cutsD0[4] = pTPi [GeV/c]
210 // cutsD0[5] = d0K [cm] upper limit!
211 // cutsD0[6] = d0Pi [cm] upper limit!
212 // cutsD0[7] = d0d0 [cm^2]
213 // cutsD0[8] = cosThetaPoint
224 Int_t nTotHF=0,nTotD0toKpi=0;
225 AliAODVertex *vtx1=0;
228 Int_t nEvents = aodTree->GetEntries();
229 for (Int_t nEv = 0; nEv < nEvents; nEv++) {
230 cout<<"\n------------ Event: "<<nEv<<" ------------------"<<endl;
233 aodTree->GetEvent(nEv);
234 //aodTree->BranchRef();
237 // loop over D0->Kpi candidates
238 Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
239 nTotD0toKpi += nD0toKpi;
240 cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
242 for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
243 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
244 Int_t okD0=0,okD0bar=0;
245 if(d->SelectD0(cutsD0,okD0,okD0bar)) {
246 //cout<<1e8*d->Prodd0d0()<<endl;
247 hMass->Fill(d->InvMassD0(),0.5);
248 hMass->Fill(d->InvMassD0bar(),0.5);
249 hCPtaVSd0d0->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
250 hSecVtxZ->Fill(d->GetSecVtxZ());
251 //cout<<d->GetSecVtxZ() <<endl;
258 printf("\n Total D0->Kpi: %d\n",nTotD0toKpi);
260 TCanvas *c = new TCanvas("c","c",0,0,1000,1000);
263 hCPtaVSd0d0->Draw("colz");
265 hMass->SetFillColor(4);
268 hSecVtxZ->SetFillColor(2);