3 #if !defined(__CINT__) || defined(__MAKECINT__)
4 //-- --- standard headers-------------
6 //--------Root headers ---------------
10 #include <TStopwatch.h>
14 #include <TParticle.h>
16 //----- AliRoot headers ---------------
19 #include "AliKalmanTrack.h"
20 #include "AliITStrackV2.h"
21 #include "AliHeader.h"
22 #include "AliGenEventHeader.h"
23 #include "AliV0vertex.h"
24 #include "AliV0vertexer.h"
25 #include "AliITSVertex.h"
26 #include "AliITSVertexer.h"
27 #include "AliITSVertexerTracks.h"
28 #include "AliD0Trigger.h"
30 //-------------------------------------
32 const Double_t kBz = 0.4;
35 double primaryvertex[3]={0.,0.,0.};
41 const Double_t kPtCut = 0.5; // 0.5 GeV/c
42 const Double_t kd0Cut = 50.; // 50 micron
43 const Double_t kd0CutHigh = 400.; // 200 micron
46 //cuts for combined tracks
47 const Double_t cuts[7] = {0.005, // 0.005 cuts[0] = lowest V0 cut (cm)
48 0.800, // 0.015 cuts[1] = highest V0 cut (cm)
49 0.012, // 0.012 cuts[2] = inv. mass cut (diferense) (Gev/c)
50 0.8, // 0.8 cuts[3] = min. cosine value for pointing angle
51 -5000, // -5000 cuts[4] = d0d0
52 0, // 0.8 cuts[5] = costhetastar
53 0.5}; // 0.5 cuts[6] = ptchild
54 //cut for distance of closest aprach
55 double cutDCA=0.05; //0.05
57 // this function applies single track cuts
58 Bool_t TrkCuts(const AliITStrackV2& trk);
60 // this function creates TObjArrays with positive and negative tracks
61 void SelectTracks(TTree& itsTree,
62 TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
63 TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN);
65 //void GetPrimaryVertex(int i,Char_t* path="./");
67 //void PtD0(Char_t* path="./");
69 Int_t iTrkP,iTrkN,itsEntries;
71 Int_t nTrksP=0,nTrksN=0;
78 void RunD0offline(Char_t* path="./",bool h=false,bool PtD0=false) {
80 sprintf(falice,"%s/galice.root",path);
81 TFile *f = new TFile(falice);
82 gAlice=(AliRun*)f->Get("gAlice");
83 int nEvent=gAlice->GetEventsPerRun();
87 const Char_t *name="AliD0offline";
88 cerr<<'\n'<<name<<"...\n";
89 cout<<"#Events: "<<nEvent<<endl;
90 gBenchmark->Start(name);
92 AliKalmanTrack::SetConvConst(100/0.299792458/kBz);
94 // Open file with ITS tracks
95 Char_t fnameTrack[1024];
96 //sprintf(fnameTrack,"%s/AliITStracksV2.root",path);
97 sprintf(fnameTrack,"%s/AliITStracksV2.root",path);
98 TFile* itstrks = TFile::Open(fnameTrack);
101 // define the cuts for vertexing
102 Double_t vtxcuts[]={33., // max. allowed chi2
103 0.0, // min. allowed negative daughter's impact param
104 0.0, // min. allowed positive daughter's impact param
105 1.0, // max. allowed DCA between the daughter tracks
106 -1.0, // min. allowed cosine of V0's pointing angle
107 0.0, // min. radius of the fiducial volume
108 2.9};// max. radius of the fiducial volume
110 TH1F *h1 = new TH1F("h1","Transvers momentun of reconstructed D0",100,0,10);
111 TH1F *h2 = new TH1F("h2","Transvers momentun of D0 with |Eta|<0.9",100,0,10);
112 TH1F *h3 = new TH1F("h3","Eta reconstructed of D0",100,-5,5);
113 TH1F *h4 = new TH1F("h4","Eta of D0",100,-5,5);
115 for(ev=0;ev<nEvent;ev++) {
117 cout<<"\n Event: "<<ev<<endl;
120 sprintf(trksName,"TreeT_ITS_%d",ev);
121 TTree *itsTree=(TTree*)itstrks->Get(trksName);
122 if(!itsTree) continue;
123 itsEntries = (Int_t)itsTree->GetEntries();
124 printf("+++\n+++ Number of tracks in ITS: %d\n+++\n\n",itsEntries);
126 //Getting primary Vertex
127 GetPrimaryVertex(ev,path);
129 // call function which applies sigle track selection and
130 // separetes positives and negatives
131 TObjArray trksP(itsEntries/2);
132 Int_t *itsEntryP = new Int_t[itsEntries];
133 TObjArray trksN(itsEntries/2);
134 Int_t *itsEntryN = new Int_t[itsEntries];
135 SelectTracks(*itsTree,trksP,itsEntryP,nTrksP,trksN,itsEntryN,nTrksN);
137 cout<<"#pos: "<<nTrksP<<endl;
138 cout<<"#neg: "<<nTrksN<<endl;
140 // create the AliV0vertexer object
141 AliV0vertexer *vertexer2 = new AliV0vertexer(vtxcuts);
143 AliD0Trigger * D0 = new AliD0Trigger(cuts,kBz,primaryvertex);
145 double ptP,alphaP,phiP,ptN,alphaN,phiN,dca;
147 for(iTrkP=0; iTrkP<nTrksP; iTrkP++) {
148 postrack = (AliITStrackV2*)trksP.At(iTrkP);
149 for(iTrkN=0; iTrkN<nTrksN; iTrkN++) {
150 negtrack = (AliITStrackV2*)trksN.At(iTrkN);
151 D0->SetTracks(postrack,negtrack);
153 // ----------- DCA MINIMIZATION ------------------
155 // find the DCA and propagate the tracks to the DCA
156 double dca = vertexer2->PropagateToDCA(negtrack,postrack);
159 // define the AliV0vertex object
160 AliV0vertex *vertex2 = new AliV0vertex(*negtrack,*postrack);
161 // get position of the vertex
162 vertex2->GetXYZ(v2[0],v2[1],v2[2]);
164 //if(D0->FindV0offline(v2) && D0->d0d0()){
167 D0->FindMomentaOffline();
168 if(D0->FindInvMass() && D0->CosThetaStar() && D0->PointingAngle() && D0->pTchild()){
170 event[index]=ev; index++;
181 cout<<"\n#D0: "<<nD0<<endl;
182 for(int i=0;i<nD0;i++)
183 cout<<event[i]<<endl;
184 gBenchmark->Stop(name);
185 gBenchmark->Show(name);
189 TCanvas *c = new TCanvas("c","c",700,1000);
193 pt = new TPaveText(7.3,0.4,11,1.8,"br");
195 pt->SetBorderSize(1);
196 pt->AddText("Cuts:");
198 sprintf(st,"First Pt: %g",kPtCut);
200 sprintf(st,"d0 low: %g",kd0Cut);
202 sprintf(st,"d0 high: %g",kd0CutHigh);
204 sprintf(st,"V0 low: %g",cuts[0]);
206 sprintf(st,"V0 high: %g",cuts[1]);
208 sprintf(st,"InvMass Diff: %g",cuts[2]);
210 sprintf(st,"cosPointingAngle: %g",cuts[3]);
212 sprintf(st,"d0d0: %g",cuts[4]);
214 sprintf(st,"cosThetaStar: %g",cuts[5]);
216 sprintf(st,"PtChild: %g",cuts[6]);
218 sprintf(st,"DCA: %g",cutDCA);
228 TCanvas *c = new TCanvas("c","c",1000,700);
232 pt = new TPaveText(7.3,0.4,11,1.8,"br");
234 pt->SetBorderSize(1);
235 pt->AddText("Cuts:");
237 sprintf(st,"First Pt: %g",kPtCut);
239 sprintf(st,"d0 low: %g",kd0Cut);
241 sprintf(st,"d0 high: %g",kd0CutHigh);
243 sprintf(st,"V0 low: %g",cuts[0]);
245 sprintf(st,"V0 high: %g",cuts[1]);
247 sprintf(st,"InvMass Diff: %g",cuts[2]);
249 sprintf(st,"cosPointingAngle: %g",cuts[3]);
251 sprintf(st,"d0d0: %g",cuts[4]);
253 sprintf(st,"cosThetaStar: %g",cuts[5]);
255 sprintf(st,"PtChild: %g",cuts[6]);
257 sprintf(st,"DCA: %g",cutDCA);
269 //TFile *outfile = new TFile("results.root","recreate");
275 //___________________________________________________________________________
276 void SelectTracks(TTree& itsTree,
277 TObjArray& trksP,Int_t* itsEntryP,Int_t& nTrksP,
278 TObjArray& trksN,Int_t* itsEntryN,Int_t& nTrksN) {
280 // this function creates two TObjArrays with positive and negative tracks
285 Int_t entr = (Int_t)itsTree.GetEntries();
287 // trasfer tracks from tree to arrays
288 for(Int_t i=0; i<entr; i++) {
290 AliITStrackV2 *itstrack = new AliITStrackV2;
291 itsTree.SetBranchAddress("tracks",&itstrack);
295 // single track selection
296 if(!TrkCuts(*itstrack)) { delete itstrack; continue; }
298 if(itstrack->Get1Pt()>0.) { // negative track
299 trksN.AddLast(itstrack);
300 itsEntryN[nTrksN] = i;
302 } else { // positive track
303 trksP.AddLast(itstrack);
304 itsEntryP[nTrksP] = i;
312 //____________________________________________________________________________
313 Bool_t TrkCuts(const AliITStrackV2& trk) {
315 // this function tells if track passes some kinematical cuts
317 if(TMath::Abs(1./trk.Get1Pt()) < kPtCut) return kFALSE;
318 if(TMath::Abs(10000.*trk.GetD(primaryvertex[0],primaryvertex[1])) < kd0Cut) return kFALSE;
319 //if(TMath::Abs(10000.*trk.GetD(primaryvertex[0],primaryvertex[1])) > kd0CutHigh) return kFALSE;
323 //____________________________________________________________________________
324 void GetPrimaryVertex(int i,Char_t* path="./") {
329 sprintf(falice,"%s/galice.root",path);
330 TFile * galice = new TFile(falice);
337 sprintf(vname,"Vertex_%d",event);
340 AliHeader * header = 0;
342 TTree * treeE = (TTree*)gDirectory->Get("TE");
343 treeE->SetBranchAddress("Header",&header);
344 treeE->GetEntry(event);
345 AliGenEventHeader* genHeader = header->GenEventHeader();
347 genHeader->PrimaryVertex(o);
348 primaryvertex[0] = (Double_t)o[0];
349 primaryvertex[1] = (Double_t)o[1];
350 primaryvertex[2] = (Double_t)o[2];
353 printf("Can't find Header");
358 //____________________________________________________________________________
359 PtD0(Char_t* path="./",TH1F * h1,TH1F * h4){
362 sprintf(falice,"%s/galice.root",path);
363 TFile *f = new TFile(falice);
364 gAlice=(AliRun*)f->Get("gAlice");
370 int nEvent=gAlice->GetEventsPerRun();
372 for (Int_t i = 0; i <nEvent; i++) {
373 cout<<"Event: "<<i<<endl;
375 Int_t nPart = gAlice->GetNtrack();
376 for (Int_t iPart = 0; iPart < nPart; iPart++) {
377 //cout<<"Particlenr.: "<<iPart<<endl;
378 p = (TParticle*)gAlice->Particle(iPart);
379 if (p->GetPdgCode()==421){
380 if(fabs(p->Eta())<0.9) h1->Fill(p.Pt());
384 if (p->GetPdgCode()==-321){
387 if (p->GetPdgCode()==211){