1 ////////////////////////////////////////////////////////////////////////
6 // author: Thomas Kuhr based on AliTPCTracking.C
9 // reconstructs of tracks in TRD in the following steps:
10 // TRD cluster finding
13 // Int_t nEvents ... nr of events to process
14 // Int_t firstEventNr ... first event number (starts from 0)
15 // const char* fileNameParam ... name of file with TPC parameters
16 // const char* fileNameHits ... name of file with hits
17 // const char* fileNameDigits .. name of file with TRD digits
18 // const char* fileNameSeeds .. name of file with TPC track seeds
19 // const char* fileNameClusters .. name of file with TRD clusters (output)
20 // const char* fileNameTracks .. name of file with TRD tracks (output)
22 // default file names correspond to pp production (2002-04)
24 ////////////////////////////////////////////////////////////////////////
26 #if !defined(__CINT__) || defined(__MAKECINT__)
27 #include "Riostream.h"
29 #include "TBenchmark.h"
31 #include "AliTRDparameter.h"
32 #include "AliTRDtracker.h"
33 #include "AliTRDclusterizerV1.h"
35 #include "AliTPCParamSR.h"
36 #include "AliTPCtracker.h"
38 #include "AliITSgeom.h"
39 #include "AliITStrackerV2.h"
45 Int_t AliTRDTracking(Int_t nEvents=1, Int_t firstEvent=0,
46 const char* fileNameParam="trd.sdigits.root",
47 const char* fileNameDigits="trd.digits.root",
48 const char* fileNameSeed="tpc.tracks.root",
49 const char* fileNameClusters="trd.clusters.root",
50 const char* fileNameTracks="trd.tracks.root");
52 Bool_t ITSPropagateBack(Int_t nEvents=1, Int_t firstEvent=0,
53 const char* fileNameClusters="its.clusters.root",
54 const char* fileNameTracks="its.tracks.root",
55 const char* fileNameBackTracks="its.back.tracks.root");
56 Bool_t TPCPropagateBack(Int_t nEvents=1, Int_t firstEvent=0,
57 const char* fileNameClusters="tpc.clusters.root",
58 const char* fileNameTracks="tpc.tracks.root",
59 const char* fileNameITSBackTracks="its.back.tracks.root",
60 const char* fileNameBackTracks="tpc.back.tracks.root");
61 Bool_t TRDFindClusters(Int_t nEvents=1, Int_t firstEvent=0,
62 const char* fileNameParam="trd.sdigits.root",
63 const char* fileNameDigits="trd.digits.root",
64 const char* fileNameClusters="trd.clusters.root");
65 Bool_t TRDFindTracks(Int_t nEvents=1, Int_t firstEvent=0,
66 const char* fileNameSeeds="tpc.tracks.root",
67 const char* fileNameClusters="trd.clusters.root",
68 const char* fileNameTracks="trd.tracks.root",
69 Bool_t inwards = kTRUE, Bool_t addSeeds = kTRUE);
72 ////////////////////////////////////////////////////////////////////////
73 Int_t AliTRDTracking( Int_t nEvents, Int_t firstEvent,
74 const char* fileNameParam,
75 const char* fileNameDigits,
76 const char* fileNameSeeds,
77 const char* fileNameClusters,
78 const char* fileNameTracks) {
80 AliTracker::SetFieldFactor(fileNameParam,kFALSE);
82 // ********** Find TRD clusters *********** //
83 if (fileNameParam && fileNameDigits && fileNameClusters){
84 if (!TRDFindClusters(nEvents,firstEvent,fileNameParam,fileNameDigits,fileNameClusters)) {
85 cerr<<"Failed to get TRD clusters: !\n";
90 // ********** Find TRD tracks *********** //
91 if (fileNameSeeds && fileNameClusters && fileNameTracks) {
92 if (!TRDFindTracks(nEvents,firstEvent,fileNameSeeds,fileNameClusters,fileNameTracks)) {
93 cerr<<"Failed to get TRD tracks !\n";
101 ////////////////////////////////////////////////////////////////////////
102 ////////////////////////////////////////////////////////////////////////
103 Bool_t ITSPropagateBack(Int_t nEvents, Int_t firstEvent,
104 const char* fileNameClusters,
105 const char* fileNameTracks,
106 const char* fileNameBackTracks)
108 const char *name="ITSPropagateBack";
109 if (gDEBUG>1) cout<<name<<" starts...\n";
110 if (gDEBUG>1) gBenchmark->Start(name);
112 TFile* clustersFile = TFile::Open(fileNameClusters);
113 if (!clustersFile->IsOpen()) {
114 cerr<<"Cannot open "<<fileNameClusters<<" !\n";
117 TFile* tracksFile = NULL;
118 TFile* backTracksFile = NULL;
119 if (strcmp(fileNameTracks, fileNameBackTracks) == 0) {
120 tracksFile = backTracksFile = TFile::Open(fileNameTracks, "UPDATE");
122 backTracksFile = TFile::Open(fileNameBackTracks, "RECREATE");
123 tracksFile = TFile::Open(fileNameTracks);
125 if (!tracksFile->IsOpen()) {
126 cerr<<"Cannot open "<<fileNameTracks<<" !\n";
131 AliITSgeom* geom = (AliITSgeom*) clustersFile->Get("AliITSgeom");
132 AliITStrackerV2 tracker(geom);
135 for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
136 tracker.SetEventNumber(iEvent);
137 tracker.PropagateBack(tracksFile, backTracksFile);
140 if (tracksFile != backTracksFile) {
141 backTracksFile->Close();
142 delete backTracksFile;
146 clustersFile->Close();
149 if (gDEBUG>1) gBenchmark->Show(name);
152 ////////////////////////////////////////////////////////////////////////
153 Bool_t TPCPropagateBack(Int_t nEvents, Int_t firstEvent,
154 const char* fileNameClusters,
155 const char* fileNameTracks,
156 const char* fileNameITSBackTracks,
157 const char* fileNameBackTracks)
159 const char *name="TPCPropagateBack";
160 if (gDEBUG>1) cout<<name<<" starts...\n";
161 if (gDEBUG>1) gBenchmark->Start(name);
163 TFile* clustersFile = TFile::Open(fileNameClusters);
164 if (!clustersFile->IsOpen()) {
165 cerr<<"Cannot open "<<fileNameClusters<<" !\n";
168 TFile* itsBackFile = NULL;
169 if (fileNameITSBackTracks) {
170 itsBackFile = TFile::Open(fileNameITSBackTracks);
171 if (!itsBackFile->IsOpen()) {
172 cerr<<"Cannot open "<<fileNameITSBackTracks<<" !\n";
176 TFile* tracksFile = NULL;
177 TFile* backTracksFile = NULL;
178 if (strcmp(fileNameTracks, fileNameBackTracks) == 0) {
179 tracksFile = backTracksFile = TFile::Open(fileNameTracks, "UPDATE");
181 backTracksFile = TFile::Open(fileNameBackTracks, "RECREATE");
182 tracksFile = TFile::Open(fileNameTracks);
184 if (!tracksFile->IsOpen()) {
185 cerr<<"Cannot open "<<fileNameTracks<<" !\n";
190 AliTPCParam* tpcParam = (AliTPCParam*)
191 clustersFile->Get("75x40_100x60_150x60");
192 if (!tpcParam) tpcParam = new AliTPCParamSR;
193 AliTPCtracker tracker(tpcParam);
196 for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
197 tracker.SetEventNumber(iEvent);
198 tracker.PropagateBack(tracksFile, itsBackFile, backTracksFile);
201 if (tracksFile != backTracksFile) {
202 backTracksFile->Close();
203 delete backTracksFile;
207 clustersFile->Close();
210 if (gDEBUG>1) gBenchmark->Show(name);
213 ////////////////////////////////////////////////////////////////////////
214 Bool_t TRDFindClusters(Int_t nEvents, Int_t firstEvent,
215 const char* fileNameParam,
216 const char* fileNameDigits, const char* fileNameClusters) {
218 const char *name="TRDFindClusters";
219 if (gDEBUG>1) cout<<name<<" starts...\n";
220 if (gDEBUG>1) gBenchmark->Start(name);
222 TFile* paramFile = TFile::Open(fileNameParam);
223 if (!paramFile->IsOpen()) {
224 cerr<<"Cannot open "<<fileNameParam<<" !\n";
227 AliTRDparameter* trdParam =
228 (AliTRDparameter*) paramFile->Get("TRDparameter");
230 cerr << "TRD parameters have not been found !\n";
234 AliTRDclusterizerV1 clusterizer("clusterizer", "Clusterizer class");
235 clusterizer.SetParameter(trdParam);
237 for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
238 clusterizer.Open(fileNameDigits, fileNameClusters, iEvent);
239 clusterizer.ReadDigits();
240 clusterizer.MakeClusters();
241 clusterizer.WriteClusters(-1);
247 if (gDEBUG>1) gBenchmark->Show(name);
250 ////////////////////////////////////////////////////////////////////////
251 Bool_t TRDFindTracks(Int_t nEvents, Int_t firstEvent,
252 const char* fileNameSeeds,
253 const char* fileNameClusters, const char* fileNameTracks,
254 Bool_t inwards, Bool_t addSeeds) {
256 const char *name="TRDFindTracks";
257 if (gDEBUG>1) cout<<name<<" starts...\n";
258 if (gDEBUG>1) gBenchmark->Start(name);
260 TFile* seedsFile = TFile::Open(fileNameSeeds);
261 if (!seedsFile->IsOpen()) {
262 cerr<<"Cannot open "<<fileNameSeeds<<" !\n";
265 TFile* clustersFile = TFile::Open(fileNameClusters);
266 if (!clustersFile->IsOpen()) {
267 cerr<<"Cannot open "<<fileNameClusters<<" !\n";
270 TFile* tracksFile = TFile::Open(fileNameTracks, "recreate");
271 if (!tracksFile->IsOpen()) {
272 cerr<<"Cannot open "<<fileNameTracks<<" !\n";
276 AliTRDtracker tracker(clustersFile);
277 if (addSeeds) tracker.SetAddTRDseeds();
279 for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
280 printf("Processing event %d\n", iEvent);
281 tracker.SetEventNumber(iEvent);
282 tracker.PropagateBack(seedsFile, tracksFile);
283 if (inwards) tracker.Clusters2Tracks(tracksFile, tracksFile);
288 clustersFile->Close();
293 if (gDEBUG>1) gBenchmark->Show(name);