]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDReconstructor.cxx
move tracker config. params to AliTRDReconstructor class
[u/mrichter/AliRoot.git] / TRD / AliTRDReconstructor.cxx
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 const  Float_t  AliTRDReconstructor::fgkMinClustersInTrack =  0.5;  //
80 const  Float_t  AliTRDReconstructor::fgkLabelFraction      =  0.8;  //
81 const  Double_t AliTRDReconstructor::fgkMaxChi2            = 12.0;  //
82 const  Double_t AliTRDReconstructor::fgkMaxSnp             =  0.95; // Maximum local sine of the azimuthal angle
83 const  Double_t AliTRDReconstructor::fgkMaxStep            =  2.0;  // Maximal step size in propagation
84 const Double_t  AliTRDReconstructor::fgkEpsilon            = 1.e-5;                  // Precision of radial coordinate
85
86 //_____________________________________________________________________________
87 AliTRDReconstructor::AliTRDReconstructor()
88   :AliReconstructor()
89   ,fSteerParam(0)
90   ,fClusterizer(NULL)
91 {
92   // setting default "ON" steering parameters
93   // owner of debug streamers 
94   SETFLG(fSteerParam, kOwner);
95   // write clusters [cw]
96   SETFLG(fSteerParam, kWriteClusters);
97   // track seeding (stand alone tracking) [sa]
98   SETFLG(fSteerParam, kSeeding);
99   // Cluster radial correction during reconstruction [cc]
100   //SETFLG(fSteerParam, kClRadialCorr);
101   memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * AliTRDrecoParam::kTRDreconstructionTasks);
102 }
103
104 //_____________________________________________________________________________
105 AliTRDReconstructor::~AliTRDReconstructor()
106 {
107   //
108   // Destructor
109   //
110
111   if(fgClusters) {
112     fgClusters->Delete();
113     delete fgClusters;
114     fgClusters = NULL;
115   }
116   if(fgTracklets) {
117     fgTracklets->Delete();
118     delete fgTracklets;
119     fgTracklets = NULL;
120   }
121   if(fSteerParam&kOwner){
122     for(Int_t itask = 0; itask < AliTRDrecoParam::kTRDreconstructionTasks; itask++)
123       if(fDebugStream[itask]) delete fDebugStream[itask];
124   }
125   if(fClusterizer){
126     delete fClusterizer;
127     fClusterizer = NULL;
128   }
129 }
130
131
132 //_____________________________________________________________________________
133 void AliTRDReconstructor::Init(){
134   //
135   // Init Options
136   //
137   SetOption(GetOption());
138   Options(fSteerParam);
139
140   if(!fClusterizer){
141     fClusterizer = new AliTRDclusterizer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]);
142     fClusterizer->SetReconstructor(this);
143   }
144   
145   // Make Debug Streams when Debug Streaming
146   if(IsDebugStreaming()){
147     for(Int_t task = 0; task < AliTRDrecoParam::kTRDreconstructionTasks; task++){
148       TDirectory *savedir = gDirectory;
149       fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task]));
150       savedir->cd();
151       SETFLG(fSteerParam, kOwner);
152     }
153   }
154 }
155
156 //_____________________________________________________________________________
157 void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
158               , TTree *digitsTree) const
159 {
160   //
161   // Convert raw data digits into digit objects in a root tree
162   //
163
164   //AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
165
166   AliTRDrawData rawData;
167   rawReader->Reset();
168   rawReader->Select("TRD");
169   AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data());
170   AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
171   manager->MakeBranch(digitsTree);
172   manager->WriteDigits();
173   delete manager;
174
175 }
176
177 //_____________________________________________________________________________
178 void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
179                                     , TTree *clusterTree) const
180 {
181   //
182   // Reconstruct clusters
183   //
184
185   //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
186
187
188   rawReader->Reset();
189   rawReader->Select("TRD");
190   AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data());
191
192   if(!fClusterizer){
193     AliFatal("Clusterizer not available!");
194     return;
195   }
196
197   fClusterizer->ResetRecPoints();
198
199   fClusterizer->OpenOutput(clusterTree);
200   fClusterizer->SetUseLabels(kFALSE);
201   fClusterizer->Raw2ClustersChamber(rawReader);
202   
203   fgNTimeBins = fClusterizer->GetNTimeBins();
204   
205   if(IsWritingClusters()) return;
206
207   // take over ownership of clusters
208   fgClusters = fClusterizer->RecPoints();
209   fClusterizer->SetClustersOwner(kFALSE);
210
211   // take over ownership of online tracklets
212   fgTracklets = fClusterizer->TrackletsArray();
213   fClusterizer->SetTrackletsOwner(kFALSE);
214 }
215
216 //_____________________________________________________________________________
217 void AliTRDReconstructor::Reconstruct(TTree *digitsTree
218                                     , TTree *clusterTree) const
219 {
220   //
221   // Reconstruct clusters
222   //
223
224   //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
225   
226   AliTRDclusterizer clusterer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]);
227   clusterer.SetReconstructor(this);
228   clusterer.OpenOutput(clusterTree);
229   clusterer.ReadDigits(digitsTree);
230   clusterer.MakeClusters();
231
232   fgNTimeBins = clusterer.GetNTimeBins();
233
234   if(IsWritingClusters()) return;
235
236   // take over ownership of clusters
237   fgClusters = clusterer.RecPoints();
238   clusterer.SetClustersOwner(kFALSE);
239
240   // take over ownership of online tracklets
241   fgTracklets = clusterer.TrackletsArray();
242   clusterer.SetTrackletsOwner(kFALSE);
243
244 }
245
246 //_____________________________________________________________________________
247 AliTracker *AliTRDReconstructor::CreateTracker() const
248 {
249   //
250   // Create a TRD tracker
251   //
252
253   //return new AliTRDtracker(NULL);
254   AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
255   tracker->SetReconstructor(this);
256   return tracker;
257
258 }
259
260 //_____________________________________________________________________________
261 void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
262         , TTree* /*clusterTree*/
263         , AliESDEvent* /*esd*/) const
264 {
265   //
266   // Fill ESD
267   //
268
269 }
270
271 //_____________________________________________________________________________
272 void AliTRDReconstructor::SetOption(Option_t *opt)
273 {
274   //
275   // Read option string into the steer param.
276   //
277   // The following string options are available during reconstruction.
278   // In square brackets the default values are given.
279   //   "dc"  : digits conversion [false]
280   //   "cw"  : write clusters [true]
281   //   "tw"  : write online tracklets [false]
282   //   "sa"  : track seeding (stand alone tracking) [true]
283   //   "hlt" : HLT reconstruction [false]
284   //   "tp"  : also use online tracklets for reconstruction [false]
285   //   "deb" : Write debug stream [false]
286   //   "cc"  : Cluster radial correction during reconstruction [false]
287   //
288   // To check the actual options used during reconstruction include the following line in your rec.C script
289   // AliLog::SetClassDebugLevel("AliTRDReconstructor", 1);
290
291   AliReconstructor::SetOption(opt);
292
293   TString s(opt);
294   TObjArray *opar = s.Tokenize(",");
295   for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
296     Bool_t processed = kFALSE;
297     TString sopt(((TObjString*)(*opar)[ipar])->String());
298     for(Int_t iopt=0; iopt<kNsteer; iopt++){
299       if(!sopt.Contains(fgSteerFlags[iopt])) continue;
300       SETFLG(fSteerParam, BIT(iopt));
301       if(sopt.Contains("!")) CLRFLG(fSteerParam, BIT(iopt));
302       processed = kTRUE;
303       break;    
304     }
305     if(processed) continue;
306
307     AliWarning(Form("Unknown option flag %s.", sopt.Data()));
308   }
309 }
310
311 //_____________________________________________________________________________
312 void AliTRDReconstructor::Options(UInt_t steer)
313 {
314   //
315   // Print the options
316   //
317
318   for(Int_t iopt=0; iopt<kNsteer; iopt++){
319     AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):""));
320   }
321 }
322