1 ////////////////////////////////////////////////////////////////////////
6 // author: Jiri Chudoba based on code of Jourij Belikov
9 // reconstructs of tracks in TPC inthe following steps:
10 // TPC cluster finding
13 // Int_t nEvents ... nr of events to process
14 // Int_t firstEventNr ... first event number (starts from 0)
15 // Char_t* fileNameHits ... name of file with hits
16 // Char_t* fileNameDigits .. name of file with TPC digits
17 // Char_t* fileNameClusters .. name of file with TPC clusters (output)
18 // Char_t* fileNameTracks .. name of file with TPC tracks (output)
20 // default file names correspond to pp production (2002-04)
24 // 03.03.2003 ... SetFieldFactor moved to AliTracker class and
25 // LoadTPCParam moved to AliTPC class
26 // TString replaced by Char_t*
28 // 20.11.2002 ... Changes due to a changed interface of AliTPCtracker.
29 // Use Riostream.h instead of iostream.h
31 // 22.08.2002 ... first version
33 ////////////////////////////////////////////////////////////////////////
35 #if !defined(__CINT__) || defined(__MAKECINT__)
36 #include "Riostream.h"
40 #include "TPC/alles.h"
41 #include "TPC/AliTPCtracker.h"
42 #include "TPC/AliTPCclusterer.h"
43 #include "TPC/AliTPC.h"
44 #include "STEER/AliRun.h"
45 #include "STEER/AliHeader.h"
46 #include "STEER/AliGenEventHeader.h"
47 #include "STEER/AliMagF.h"
48 #include "STEER/AliTracker.h"
54 Int_t TPCFindClusters(Int_t nEvents=1, Int_t firstEvent=0,
55 Char_t* fileNameDigits="rfio:galiceSDR.root",
56 Char_t* fileNameClusters="tpc.clusters.root");
57 Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent,
58 TFile* fileDigits, TFile* fileClusters,
59 AliTPCParam* paramTPC=0);
60 Int_t TPCFindTracks(Int_t nEvents=1, Int_t firstEvent=0,
61 Char_t* fileNameClusters="tpc.clusters.root",
62 Char_t* fileNameTracks="tpc.tracks.root");
63 Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent,
64 TFile* fileClusters, TFile* fileTracks,
65 AliTPCParam* paramTPC=0);
67 void FindVertex(Int_t iEvent, Double_t *vertex);
68 void PrintVertex(TArrayF &primaryVertex);
70 Int_t AliTPCTracking(Int_t nEvents=1, Int_t firstEvent=0,
71 Char_t* fileNameHits="rfio:galice.root",
72 Char_t* fileNameDigits="rfio:galiceSDR.root",
73 Char_t* fileNameClusters="tpc.clusters.root",
74 Char_t* fileNameTracks="tpc.tracks.root");
76 ////////////////////////////////////////////////////////////////////////
77 Int_t AliTPCTracking( Int_t nEvents, Int_t firstEvent,
79 Char_t* fileNameDigits,
80 Char_t* fileNameClusters,
81 Char_t* fileNameTracks) {
83 AliTracker::SetFieldFactor(fileNameHits,kFALSE);
85 // ********** Find TPC clusters *********** //
86 if (TPCFindClusters(nEvents,firstEvent,fileNameDigits,fileNameClusters)) {
87 cerr<<"Failed to get TPC clusters: !\n";
91 // ********** Find TPC tracks *********** //
92 if (TPCFindTracks(nEvents,firstEvent,fileNameClusters,fileNameTracks)) {
93 cerr<<"Failed to get TPC tracks !\n";
100 ////////////////////////////////////////////////////////////////////////
101 Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent,
102 Char_t* fileNameDigits, Char_t* fileNameClusters) {
105 const Char_t *name="TPCFindClusters";
106 if (gDEBUG>1) cout<<name<<" starts...\n";
107 if (gDEBUG>1) gBenchmark->Start(name);
108 TFile *fileClusters = TFile::Open(fileNameClusters,"recreate");
109 TFile *fileDigits = TFile::Open(fileNameDigits);
110 if (!fileDigits->IsOpen()) {
111 cerr<<"Cannnot open "<<fileNameDigits<<" !\n";
114 if (!fileClusters->IsOpen()) {
115 cerr<<"Cannnot open "<<fileNameClusters<<" !\n";
119 rc = TPCFindClusters(nEvents,firstEvent,fileDigits,fileClusters);
122 fileClusters->Close();
125 if (gDEBUG>1) gBenchmark->Stop(name);
126 if (gDEBUG>1) gBenchmark->Show(name);
130 ////////////////////////////////////////////////////////////////////////
131 Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent,
132 TFile* fileDigits, TFile* fileClusters,
133 AliTPCParam* paramTPC) {
136 if (!paramTPC) paramTPC = AliTPC::LoadTPCParam(fileDigits);
137 if (!paramTPC) return 1;
139 for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){
140 if (gDEBUG > 2) cout<<"TPCFindClusters: event "<<iEvent<<endl;
141 AliTPCclusterer::Digits2Clusters(paramTPC, fileClusters, iEvent);
145 ////////////////////////////////////////////////////////////////////////
146 Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent,
147 Char_t* fileNameClusters, Char_t* fileNameTracks) {
150 const Char_t *name="TPCFindTracks";
151 if (gDEBUG>1) cout<<name<<" starts"<<endl;
152 if (gDEBUG>1) gBenchmark->Start(name);
153 TFile *fileTracks = TFile::Open(fileNameTracks,"recreate");
154 TFile *fileClusters =TFile::Open(fileNameClusters);
156 rc = TPCFindTracks(nEvents, firstEvent, fileClusters, fileTracks);
158 fileClusters->Close();
162 if (gDEBUG>1) gBenchmark->Stop(name);
163 if (gDEBUG>1) gBenchmark->Show(name);
167 ////////////////////////////////////////////////////////////////////////
168 Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent,
169 TFile *fileClusters, TFile * fileTracks,
170 AliTPCParam* paramTPC) {
173 if (!paramTPC) paramTPC = AliTPC::LoadTPCParam(fileClusters);
174 if (!paramTPC) return 1;
176 for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){
177 if (gDEBUG > 2) cout<<"TPCFindTracks: event "<<iEvent<<endl;
178 AliTPCtracker *tracker = new AliTPCtracker(paramTPC);
179 tracker->SetEventNumber(iEvent);
181 FindVertex(iEvent,vertex);
182 tracker->SetVertex(vertex);
184 rc = tracker->Clusters2Tracks(0,fileTracks);
190 ////////////////////////////////////////////////////////////////////////
191 void FindVertex(Int_t eventNr, Double_t *vertex) {
193 vertex[0] = vertex[1] = vertex[2] = 0.;
195 cerr<<"gAlice was not found! Using vertex position (0,0,0).\n";
199 gAlice->GetEvent(eventNr);
200 AliHeader *header = gAlice->GetHeader();
202 cerr<<"header was not found!\n";
205 AliGenEventHeader* genEventHeader = header->GenEventHeader();
206 if (!genEventHeader) {
207 cerr<<"AliGenEventHeader was not found!\n";
211 TArrayF primaryVertex(3);
212 genEventHeader->PrimaryVertex(primaryVertex);
213 PrintVertex(primaryVertex);
214 vertex[0] = static_cast<Double_t>(primaryVertex[0]);
215 vertex[1] = static_cast<Double_t>(primaryVertex[1]);
216 vertex[2] = static_cast<Double_t>(primaryVertex[2]);
218 delete genEventHeader;
222 ////////////////////////////////////////////////////////////////////////
223 void PrintVertex(TArrayF &primaryVertex)
226 <<primaryVertex[0]<<" "
227 <<primaryVertex[1]<<" "
228 <<primaryVertex[2]<<" "<<endl;
231 ////////////////////////////////////////////////////////////////////////