]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Class for TRD reconstruction // | |
21 | // // | |
22 | // For the special options which can be used during reconstruction and their // | |
23 | // default values pls. see function SetOption(). // | |
24 | // // | |
25 | /////////////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | #include <TObjString.h> | |
28 | #include <TObjArray.h> | |
29 | #include <TTreeStream.h> | |
30 | #include <TDirectory.h> | |
31 | ||
32 | #include "AliRawReader.h" | |
33 | ||
34 | #include "AliTRDReconstructor.h" | |
35 | #include "AliTRDclusterizer.h" | |
36 | #include "AliTRDrawData.h" | |
37 | #include "AliTRDrawStreamBase.h" | |
38 | #include "AliTRDdigitsManager.h" | |
39 | #include "AliTRDtrackerV1.h" | |
40 | ||
41 | #define SETFLG(n,f) ((n) |= f) | |
42 | #define CLRFLG(n,f) ((n) &= ~f) | |
43 | ||
44 | ClassImp(AliTRDReconstructor) | |
45 | ||
46 | TClonesArray *AliTRDReconstructor::fgClusters = NULL; | |
47 | TClonesArray *AliTRDReconstructor::fgTracklets = NULL; | |
48 | Char_t const * AliTRDReconstructor::fgSteerNames[kNsteer] = { | |
49 | "DigitsConversion " | |
50 | ,"Write Clusters " | |
51 | ,"Write Online Tracklets " | |
52 | ,"Stand Alone Tracking " | |
53 | ,"HLT Mode " | |
54 | ,"Process Online Trklts " | |
55 | ,"Debug Streaming " | |
56 | ,"Cl. Radial Correction " | |
57 | }; | |
58 | Char_t const * AliTRDReconstructor::fgSteerFlags[kNsteer] = { | |
59 | "dc"// digits conversion [false] | |
60 | ,"cw"// write clusters [true] | |
61 | ,"tw"// write online tracklets [false] | |
62 | ,"sa"// track seeding (stand alone tracking) [true] | |
63 | ,"hlt"// HLT reconstruction [false] | |
64 | ,"tp"// also use online tracklets for reconstruction [false] | |
65 | ,"deb"// Write debug stream [false] | |
66 | ,"cc" // Cluster radial correction during reconstruction [false] | |
67 | }; | |
68 | Char_t const * AliTRDReconstructor::fgTaskNames[AliTRDrecoParam::kTRDreconstructionTasks] = { | |
69 | "Clusterizer" | |
70 | ,"Tracker" | |
71 | ,"PID" | |
72 | }; | |
73 | Char_t const * AliTRDReconstructor::fgTaskFlags[AliTRDrecoParam::kTRDreconstructionTasks] = { | |
74 | "cl" | |
75 | ,"tr" | |
76 | ,"pd" | |
77 | }; | |
78 | Int_t AliTRDReconstructor::fgNTimeBins = -1; | |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliTRDReconstructor::AliTRDReconstructor() | |
82 | :AliReconstructor() | |
83 | ,fSteerParam(0) | |
84 | ,fClusterizer(NULL) | |
85 | { | |
86 | // setting default "ON" steering parameters | |
87 | // owner of debug streamers | |
88 | SETFLG(fSteerParam, kOwner); | |
89 | // write clusters [cw] | |
90 | SETFLG(fSteerParam, kWriteClusters); | |
91 | // track seeding (stand alone tracking) [sa] | |
92 | SETFLG(fSteerParam, kSeeding); | |
93 | // Cluster radial correction during reconstruction [cc] | |
94 | //SETFLG(fSteerParam, kClRadialCorr); | |
95 | memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * AliTRDrecoParam::kTRDreconstructionTasks); | |
96 | } | |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | AliTRDReconstructor::~AliTRDReconstructor() | |
100 | { | |
101 | // | |
102 | // Destructor | |
103 | // | |
104 | ||
105 | if(fgClusters) { | |
106 | fgClusters->Delete(); | |
107 | delete fgClusters; | |
108 | fgClusters = NULL; | |
109 | } | |
110 | if(fgTracklets) { | |
111 | fgTracklets->Delete(); | |
112 | delete fgTracklets; | |
113 | fgTracklets = NULL; | |
114 | } | |
115 | if(fSteerParam&kOwner){ | |
116 | for(Int_t itask = 0; itask < AliTRDrecoParam::kTRDreconstructionTasks; itask++) | |
117 | if(fDebugStream[itask]) delete fDebugStream[itask]; | |
118 | } | |
119 | if(fClusterizer){ | |
120 | delete fClusterizer; | |
121 | fClusterizer = NULL; | |
122 | } | |
123 | } | |
124 | ||
125 | ||
126 | //_____________________________________________________________________________ | |
127 | void AliTRDReconstructor::Init(){ | |
128 | // | |
129 | // Init Options | |
130 | // | |
131 | SetOption(GetOption()); | |
132 | Options(fSteerParam); | |
133 | ||
134 | if(!fClusterizer){ | |
135 | fClusterizer = new AliTRDclusterizer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]); | |
136 | fClusterizer->SetReconstructor(this); | |
137 | } | |
138 | ||
139 | // Make Debug Streams when Debug Streaming | |
140 | if(IsDebugStreaming()){ | |
141 | for(Int_t task = 0; task < AliTRDrecoParam::kTRDreconstructionTasks; task++){ | |
142 | TDirectory *savedir = gDirectory; | |
143 | fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task])); | |
144 | savedir->cd(); | |
145 | SETFLG(fSteerParam, kOwner); | |
146 | } | |
147 | } | |
148 | } | |
149 | ||
150 | //_____________________________________________________________________________ | |
151 | void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader | |
152 | , TTree *digitsTree) const | |
153 | { | |
154 | // | |
155 | // Convert raw data digits into digit objects in a root tree | |
156 | // | |
157 | ||
158 | //AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]"); | |
159 | ||
160 | AliTRDrawData rawData; | |
161 | rawReader->Reset(); | |
162 | rawReader->Select("TRD"); | |
163 | AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data()); | |
164 | AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader); | |
165 | manager->MakeBranch(digitsTree); | |
166 | manager->WriteDigits(); | |
167 | delete manager; | |
168 | ||
169 | } | |
170 | ||
171 | //_____________________________________________________________________________ | |
172 | void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader | |
173 | , TTree *clusterTree) const | |
174 | { | |
175 | // | |
176 | // Reconstruct clusters | |
177 | // | |
178 | ||
179 | //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]"); | |
180 | ||
181 | ||
182 | rawReader->Reset(); | |
183 | rawReader->Select("TRD"); | |
184 | AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data()); | |
185 | ||
186 | if(!fClusterizer){ | |
187 | AliFatal("Clusterizer not available!"); | |
188 | return; | |
189 | } | |
190 | ||
191 | fClusterizer->ResetRecPoints(); | |
192 | ||
193 | fClusterizer->OpenOutput(clusterTree); | |
194 | fClusterizer->SetUseLabels(kFALSE); | |
195 | fClusterizer->Raw2ClustersChamber(rawReader); | |
196 | ||
197 | fgNTimeBins = fClusterizer->GetNTimeBins(); | |
198 | ||
199 | if(IsWritingClusters()) return; | |
200 | ||
201 | // take over ownership of clusters | |
202 | fgClusters = fClusterizer->RecPoints(); | |
203 | fClusterizer->SetClustersOwner(kFALSE); | |
204 | ||
205 | // take over ownership of online tracklets | |
206 | fgTracklets = fClusterizer->TrackletsArray(); | |
207 | fClusterizer->SetTrackletsOwner(kFALSE); | |
208 | } | |
209 | ||
210 | //_____________________________________________________________________________ | |
211 | void AliTRDReconstructor::Reconstruct(TTree *digitsTree | |
212 | , TTree *clusterTree) const | |
213 | { | |
214 | // | |
215 | // Reconstruct clusters | |
216 | // | |
217 | ||
218 | //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]"); | |
219 | ||
220 | AliTRDclusterizer clusterer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]); | |
221 | clusterer.SetReconstructor(this); | |
222 | clusterer.OpenOutput(clusterTree); | |
223 | clusterer.ReadDigits(digitsTree); | |
224 | clusterer.MakeClusters(); | |
225 | ||
226 | fgNTimeBins = clusterer.GetNTimeBins(); | |
227 | ||
228 | if(IsWritingClusters()) return; | |
229 | ||
230 | // take over ownership of clusters | |
231 | fgClusters = clusterer.RecPoints(); | |
232 | clusterer.SetClustersOwner(kFALSE); | |
233 | ||
234 | // take over ownership of online tracklets | |
235 | fgTracklets = clusterer.TrackletsArray(); | |
236 | clusterer.SetTrackletsOwner(kFALSE); | |
237 | ||
238 | } | |
239 | ||
240 | //_____________________________________________________________________________ | |
241 | AliTracker *AliTRDReconstructor::CreateTracker() const | |
242 | { | |
243 | // | |
244 | // Create a TRD tracker | |
245 | // | |
246 | ||
247 | //return new AliTRDtracker(NULL); | |
248 | AliTRDtrackerV1 *tracker = new AliTRDtrackerV1(); | |
249 | tracker->SetReconstructor(this); | |
250 | return tracker; | |
251 | ||
252 | } | |
253 | ||
254 | //_____________________________________________________________________________ | |
255 | void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/ | |
256 | , TTree* /*clusterTree*/ | |
257 | , AliESDEvent* /*esd*/) const | |
258 | { | |
259 | // | |
260 | // Fill ESD | |
261 | // | |
262 | ||
263 | } | |
264 | ||
265 | //_____________________________________________________________________________ | |
266 | void AliTRDReconstructor::SetOption(Option_t *opt) | |
267 | { | |
268 | // | |
269 | // Read option string into the steer param. | |
270 | // | |
271 | // The following string options are available during reconstruction. | |
272 | // In square brackets the default values are given. | |
273 | // "dc" : digits conversion [false] | |
274 | // "cw" : write clusters [true] | |
275 | // "tw" : write online tracklets [false] | |
276 | // "sa" : track seeding (stand alone tracking) [true] | |
277 | // "hlt" : HLT reconstruction [false] | |
278 | // "tp" : also use online tracklets for reconstruction [false] | |
279 | // "deb" : Write debug stream [false] | |
280 | // "cc" : Cluster radial correction during reconstruction [false] | |
281 | // | |
282 | // To check the actual options used during reconstruction include the following line in your rec.C script | |
283 | // AliLog::SetClassDebugLevel("AliTRDReconstructor", 1); | |
284 | ||
285 | AliReconstructor::SetOption(opt); | |
286 | ||
287 | TString s(opt); | |
288 | TObjArray *opar = s.Tokenize(","); | |
289 | for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){ | |
290 | Bool_t processed = kFALSE; | |
291 | TString sopt(((TObjString*)(*opar)[ipar])->String()); | |
292 | for(Int_t iopt=0; iopt<kNsteer; iopt++){ | |
293 | if(!sopt.Contains(fgSteerFlags[iopt])) continue; | |
294 | SETFLG(fSteerParam, BIT(iopt)); | |
295 | if(sopt.Contains("!")) CLRFLG(fSteerParam, BIT(iopt)); | |
296 | processed = kTRUE; | |
297 | break; | |
298 | } | |
299 | if(processed) continue; | |
300 | ||
301 | AliWarning(Form("Unknown option flag %s.", sopt.Data())); | |
302 | } | |
303 | } | |
304 | ||
305 | //_____________________________________________________________________________ | |
306 | void AliTRDReconstructor::Options(UInt_t steer) | |
307 | { | |
308 | // | |
309 | // Print the options | |
310 | // | |
311 | ||
312 | for(Int_t iopt=0; iopt<kNsteer; iopt++){ | |
313 | AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):"")); | |
314 | } | |
315 | } | |
316 |