]>
Commit | Line | Data |
---|---|---|
84d7440d | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include<Riostream.h> | |
3 | #include<AliRun.h> | |
4 | #include<TTree.h> | |
5 | #include<AliRunLoader.h> | |
6 | #include<AliESD.h> | |
7 | #include<TMath.h> | |
8 | #include<AliHeader.h> | |
9 | #include<AliGenEventHeader.h> | |
10 | #include<AliVertexerTracks.h> | |
11 | #include<AliITSVertexerTracks.h> | |
12 | #include<AliVertex.h> | |
13 | #include<AliESDVertex.h> | |
14 | #include<TFile.h> | |
15 | #endif | |
16 | ||
17 | void TestVertexerTracks(){ | |
18 | if (gAlice) { | |
19 | delete gAlice->GetRunLoader(); | |
20 | delete gAlice; | |
21 | gAlice = 0x0; | |
22 | } | |
23 | ||
24 | AliRunLoader *rl = AliRunLoader::Open("galice.root"); | |
25 | if (rl == 0x0) { | |
26 | cerr<<"Can not open session"<<endl; | |
27 | return; | |
28 | } | |
29 | ||
30 | rl->LoadgAlice(); | |
31 | AliMagF * magf = gAlice->Field(); | |
32 | AliTracker::SetFieldMap(magf,kTRUE); | |
33 | printf("MagneticField=%f\n",AliTracker::GetBz()); | |
34 | ||
35 | rl->LoadHeader(); | |
36 | rl->LoadKinematics(); | |
37 | Int_t totev=rl->GetNumberOfEvents(); | |
38 | cout<<"Number of events="<<totev<<endl; | |
39 | ||
40 | TFile *ef=TFile::Open("AliESDs.root"); | |
41 | if (!ef || !ef->IsOpen()) {cerr<<"Can't AliESDs.root !n";} | |
42 | AliESD* event = new AliESD; | |
43 | TTree* tree = (TTree*) ef->Get("esdTree"); | |
44 | if (!tree) {cerr<<"no ESD tree foundn";}; | |
45 | tree->SetBranchAddress("ESD", &event); | |
46 | ||
47 | Int_t e=0; | |
48 | tree->GetEvent(e); | |
49 | Int_t ntrk=event->GetNumberOfTracks(); | |
50 | cout<<"Number of ESD tracks : "<<ntrk<<endl; | |
51 | ||
52 | rl->GetEvent(e); | |
53 | AliESDVertex *vertESD = event->GetVertex(); | |
54 | Double_t mcVertex[3], recVertex[3]; | |
55 | vertESD->GetTruePos(mcVertex); | |
56 | cout<<"Primary vertex (MC) "; | |
57 | for(Int_t kk=0;kk<3;kk++)cout<<mcVertex[kk]<<" "; | |
58 | cout<<endl; | |
59 | vertESD->GetXYZ(recVertex); | |
60 | cout<<"Primary vertex (from SPD clusters) "; | |
61 | for(Int_t kk=0;kk<3;kk++)cout<<recVertex[kk]<<" "; | |
62 | cout<<endl; | |
63 | TObjArray *trkarr=new TObjArray(); | |
64 | trkarr->Expand(3); | |
65 | ||
66 | TTree *trkTree = new TTree("TreeT","tracks"); | |
67 | AliESDtrack *esdTrack = 0; | |
68 | trkTree->Branch("tracks","AliESDtrack",&esdTrack); | |
69 | ||
70 | esdTrack=(AliESDtrack*)event->GetTrack(2); | |
71 | trkarr->AddLast(esdTrack); | |
72 | trkTree->Fill(); | |
73 | ||
74 | esdTrack=(AliESDtrack*)event->GetTrack(3); | |
75 | trkarr->AddLast(esdTrack); | |
76 | trkTree->Fill(); | |
77 | ||
78 | esdTrack=(AliESDtrack*)event->GetTrack(4); | |
79 | trkarr->AddLast(esdTrack); | |
80 | trkTree->Fill(); | |
81 | ||
82 | // BEWARE: the method VertexForSelectedTracks returns the address of the data member fVert | |
83 | // which is always the same for all calls to VertexForSelectedTracks. | |
84 | ||
85 | printf("\n*****************************\n"); | |
86 | printf("Call VertexForSelectedTracks with different arguments\n"); | |
87 | printf("*****************************\n"); | |
88 | AliVertexerTracks *vtx=new AliVertexerTracks(); | |
89 | AliVertex *vert=vtx->VertexForSelectedTracks(trkarr); | |
90 | vert->Print(); | |
91 | AliVertex *vert2=vtx->VertexForSelectedTracks(trkTree); | |
92 | vert->Print(); | |
93 | vert2->Print(); | |
94 | ||
95 | printf("\n*****************************\n"); | |
96 | printf("Use different finder algorithms\n"); | |
97 | printf("*****************************\n"); | |
98 | vtx->SetFinderAlgorithm(1); | |
99 | AliVertex *v1=vtx->VertexForSelectedTracks(trkarr); | |
100 | v1->Print(); | |
101 | vtx->SetFinderAlgorithm(2); | |
102 | AliVertex *v2=vtx->VertexForSelectedTracks(trkarr); | |
103 | v2->Print(); | |
104 | vtx->SetFinderAlgorithm(3); | |
105 | AliVertex *v3=vtx->VertexForSelectedTracks(trkarr); | |
106 | v3->Print(); | |
107 | vtx->SetFinderAlgorithm(4); | |
108 | AliVertex *v4=vtx->VertexForSelectedTracks(trkarr); | |
109 | v4->Print(); | |
110 | vtx->SetFinderAlgorithm(5); | |
111 | AliVertex *v5=vtx->VertexForSelectedTracks(trkarr); | |
112 | v5->Print(); | |
113 | delete vtx; | |
114 | ||
115 | printf("\n*****************************\n"); | |
116 | printf("Call AliITSVertexerTracks::VertexForSelected Tracks\n"); | |
117 | printf("*****************************\n"); | |
118 | Int_t trkPos[3]={0,1,2}; | |
119 | AliITSVertexerTracks *itsvtx=new AliITSVertexerTracks(); | |
120 | itsvtx->SetDebug(0); | |
121 | AliVertex *vert3=itsvtx->VertexForSelectedTracks(event,3,trkPos,1); | |
122 | vert3->Print(); | |
123 | delete itsvtx; | |
124 | ||
125 | printf("\n*****************************\n"); | |
126 | printf("Find Primary Vertex\n"); | |
127 | printf("*****************************\n"); | |
128 | AliITSVertexerTracks *itsvtx2=new AliITSVertexerTracks(); | |
129 | itsvtx2->SetDebug(0); | |
130 | AliESDVertex* evert=itsvtx2->FindPrimaryVertexForCurrentEvent(event); | |
131 | evert->Print(); | |
132 | delete itsvtx2; | |
133 | } | |
134 | ||
135 | ||
136 |