]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////// | |
2 | // | |
3 | // AliTPCTracking.C | |
4 | // | |
5 | // date: 22.08.2002 | |
6 | // author: Jiri Chudoba based on code of Jourij Belikov | |
7 | // version: 1.0 | |
8 | // description: | |
9 | // reconstructs of tracks in TPC in the following steps: | |
10 | // TPC cluster finding | |
11 | // TPC track finding | |
12 | // input parameters: | |
13 | // Int_t nEvents ... nr of events to process (<0 means all) | |
14 | // Int_t firstEventNr ... first event number (starts from 0) | |
15 | // const char* fileName ... name of galice file | |
16 | // Bool_t makeClusters ... run the cluster finder or not? | |
17 | // Bool_t makeTracks ... run the track finder or not? | |
18 | // const char* fileNameRaw ... if not NULL, the cluster finder uses | |
19 | // the given file as raw data input | |
20 | // | |
21 | // History: | |
22 | // | |
23 | // 21.07.2003 ... NewIO | |
24 | // | |
25 | // 18.03.2003 ... Char_t* replaced by const char* | |
26 | // | |
27 | // 03.03.2003 ... SetFieldFactor moved to AliTracker class and | |
28 | // LoadTPCParam moved to AliTPC class | |
29 | // TString replaced by Char_t* | |
30 | // | |
31 | // 20.11.2002 ... Changes due to a changed interface of AliTPCtracker. | |
32 | // Use Riostream.h instead of iostream.h | |
33 | // | |
34 | // 22.08.2002 ... first version | |
35 | // | |
36 | //////////////////////////////////////////////////////////////////////// | |
37 | ||
38 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
39 | #include <Riostream.h> | |
40 | #include <TFile.h> | |
41 | #include <TTree.h> | |
42 | #include <TBenchmark.h> | |
43 | #include "AliRunLoader.h" | |
44 | #include "AliTPC.h" | |
45 | #include "AliTPCParam.h" | |
46 | #include "AliTPCclustererMI.h" | |
47 | #include "AliTPCtrackerMI.h" | |
48 | #include "AliRawReaderRoot.h" | |
49 | #endif | |
50 | ||
51 | Bool_t AliTPCTracking(Int_t nEvents = -1, Int_t firstEvent = 0, | |
52 | const char* fileName = "galice.root", | |
53 | Bool_t makeClusters = kTRUE, | |
54 | Bool_t makeTracks = kTRUE, | |
55 | const char* fileNameRaw = NULL); | |
56 | ||
57 | /* | |
58 | Int_t TPCRefitInward(Int_t nEvents=1, Int_t firstEvent=0, | |
59 | const char* fileNameClusters="tpc.clusters.root", | |
60 | const char* fileNameTracks="tpc.tracks.root", | |
61 | const char* fileNameTRDTracks="trd.tracks.root", | |
62 | const char* fileNameRefittedTracks="tpc.refitted.tracks.root"); | |
63 | */ | |
64 | ||
65 | //////////////////////////////////////////////////////////////////////// | |
66 | Bool_t AliTPCTracking(Int_t nEvents, Int_t firstEvent, | |
67 | const char* fileName, | |
68 | Bool_t makeClusters, | |
69 | Bool_t makeTracks, | |
70 | const char* fileNameRaw) | |
71 | { | |
72 | // get the loaders | |
73 | AliRunLoader* runLoader = AliRunLoader::Open(fileName); | |
74 | if (!runLoader) { | |
75 | cerr << "AliTPCTracking: no run loader found\n"; | |
76 | return kFALSE; | |
77 | } | |
78 | AliLoader* tpcLoader = runLoader->GetLoader("TPCLoader"); | |
79 | if (!tpcLoader) { | |
80 | cerr << "AliTPCTracking: no TPC loader found\n"; | |
81 | return kFALSE; | |
82 | } | |
83 | ||
84 | // get the TPC parameters | |
85 | runLoader->CdGAFile(); | |
86 | AliTPCParam* param = AliTPC::LoadTPCParam(gFile); | |
87 | if (!param) { | |
88 | cerr << "AliTPCTracking: no TPC parameters found\n"; | |
89 | return kFALSE; | |
90 | } | |
91 | ||
92 | // create the clusterer object | |
93 | AliTPCclustererMI* clusterer = NULL; | |
94 | if (makeClusters) { | |
95 | clusterer = new AliTPCclustererMI(param); | |
96 | if (!fileNameRaw) tpcLoader->LoadDigits(); | |
97 | tpcLoader->LoadRecPoints("recreate"); | |
98 | } | |
99 | ||
100 | // create the tracker object | |
101 | AliTPCtrackerMI* tracker = NULL; | |
102 | if (makeTracks) { | |
103 | // tracker = new AliTPCtrackerMI(param); | |
104 | if (!makeClusters) tpcLoader->LoadRecPoints(); | |
105 | tpcLoader->LoadTracks("recreate"); | |
106 | } | |
107 | ||
108 | // get the event number range | |
109 | Int_t maxEvent = 0; | |
110 | if (fileNameRaw) { | |
111 | TFile* file = TFile::Open(fileNameRaw); | |
112 | if (file && file->IsOpen()) { | |
113 | TTree* tree = (TTree*) file->Get("T"); | |
114 | if (tree) maxEvent = (Int_t) tree->GetEntries(); | |
115 | } | |
116 | } else { | |
117 | maxEvent = runLoader->GetNumberOfEvents(); | |
118 | } | |
119 | if (nEvents < 0) nEvents = maxEvent - firstEvent; | |
120 | Int_t lastEvent = firstEvent + nEvents; | |
121 | if (lastEvent > maxEvent) lastEvent = maxEvent; | |
122 | ||
123 | // loop over the events | |
124 | for (Int_t iEvent = firstEvent; iEvent < lastEvent; iEvent++) { | |
125 | ||
126 | runLoader->GetEvent(iEvent); | |
127 | ||
128 | // run the cluster finder | |
129 | if (makeClusters) { | |
130 | if (!tpcLoader->TreeR()) tpcLoader->MakeRecPointsContainer(); | |
131 | clusterer->SetOutput(tpcLoader->TreeR()); | |
132 | if (fileNameRaw) { | |
133 | AliRawReaderRoot rawReader(fileNameRaw, iEvent); | |
134 | clusterer->Digits2Clusters(&rawReader); | |
135 | } else { | |
136 | clusterer->SetInput(tpcLoader->TreeD()); | |
137 | clusterer->Digits2Clusters(); | |
138 | } | |
139 | tpcLoader->WriteRecPoints("OVERWRITE"); | |
140 | } | |
141 | ||
142 | // run the track finder | |
143 | if (makeTracks) { | |
144 | tracker = new AliTPCtrackerMI(param); | |
145 | tracker->Clusters2Tracks(); | |
146 | delete tracker; | |
147 | } | |
148 | } | |
149 | ||
150 | if (tracker) delete tracker; | |
151 | if (clusterer) delete clusterer; | |
152 | ||
153 | return kTRUE; | |
154 | } | |
155 | ||
156 | /* | |
157 | //////////////////////////////////////////////////////////////////////// | |
158 | Int_t TPCRefitInward(Int_t nEvents, Int_t firstEvent, | |
159 | const char* fileNameClusters, | |
160 | const char* fileNameTracks, | |
161 | const char* fileNameTRDTracks, | |
162 | const char* fileNameRefittedTracks) | |
163 | { | |
164 | Int_t rc = 0; | |
165 | const Char_t *name="TPCRefitInward"; | |
166 | if (gDEBUG>1) cout<<name<<" starts"<<endl; | |
167 | if (gDEBUG>1) gBenchmark->Start(name); | |
168 | TFile *fileClusters = TFile::Open(fileNameClusters); | |
169 | TFile *fileTracks = TFile::Open(fileNameTracks); | |
170 | TFile *fileTRDTracks = TFile::Open(fileNameTRDTracks); | |
171 | TFile *fileRefittedTracks = TFile::Open(fileNameRefittedTracks, "recreate"); | |
172 | ||
173 | AliTPCParam* paramTPC = AliTPC::LoadTPCParam(fileClusters); | |
174 | if (!paramTPC) return 1; | |
175 | ||
176 | for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){ | |
177 | if (gDEBUG > 2) cout<<"TPCRefitInward: event "<<iEvent<<endl; | |
178 | AliTPCtracker *tracker = new AliTPCtracker(paramTPC); | |
179 | tracker->SetEventNumber(iEvent); | |
180 | fileClusters->cd(); | |
181 | rc = tracker->RefitInward(fileTRDTracks, fileTracks, fileRefittedTracks); | |
182 | delete tracker; | |
183 | if (rc) return rc; | |
184 | } | |
185 | ||
186 | fileClusters->Close(); | |
187 | fileTracks->Close(); | |
188 | fileTRDTracks->Close(); | |
189 | fileRefittedTracks->Close(); | |
190 | delete fileClusters; | |
191 | delete fileTracks; | |
192 | delete fileTRDTracks; | |
193 | delete fileRefittedTracks; | |
194 | if (gDEBUG>1) gBenchmark->Show(name); | |
195 | return rc; | |
196 | } | |
197 | */ |