1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Class for TRD reconstruction //
22 ///////////////////////////////////////////////////////////////////////////////
25 #include <TObjString.h>
26 #include <TObjArray.h>
27 #include <TClonesArray.h>
29 #include "AliRunLoader.h"
30 #include "AliRawReader.h"
32 #include "AliESDTrdTrack.h"
33 #include "AliESDEvent.h"
35 #include "AliTRDReconstructor.h"
36 #include "AliTRDclusterizer.h"
37 #include "AliTRDtracker.h"
38 #include "AliTRDpidESD.h"
39 #include "AliTRDrawData.h"
40 #include "AliTRDdigitsManager.h"
41 #include "AliTRDtrackerV1.h"
42 #include "AliTRDrecoParam.h"
44 #include "TTreeStream.h"
46 #define SETFLG(n,f) ((n) |= f)
47 #define CLRFLG(n,f) ((n) &= ~f)
49 ClassImp(AliTRDReconstructor)
51 TClonesArray *AliTRDReconstructor::fgClusters = 0x0;
52 Char_t* AliTRDReconstructor::fgSteerNames[kNsteer] = {
59 ,"8 dEdx slices in ESD "
61 ,"Write Online Tracklets "
63 ,"Stand Alone Tracking "
67 ,"Cosmic Reconstruction "
69 Char_t* AliTRDReconstructor::fgSteerFlags[kNsteer] = {
70 "dc"// digits conversion [false]
71 ,"tc"// apply tail cancellation [true]
72 ,"lut"// look-up-table for cluster shape in the r-phi direction
73 ,"gs"// gauss cluster shape in the r-phi direction
74 ,"sh"// cluster sharing between tracks
75 ,"nn"// PID method in reconstruction (NN) [true]
76 ,"8s"// 8 dEdx slices in ESD [true]
77 ,"cw"// write clusters [true]
78 ,"tw"// write online tracklets [false]
79 ,"ar"// drift gas [false] - do not update the number of exponentials in the TC !
80 ,"sa"// track seeding (stand alone tracking) [true]
81 ,"vc"// vertex constrain on stand alone track finder [false]
82 ,"ti"// improve tracklets in stand alone track finder [true]
83 ,"hlt"// HLT reconstruction [false]
84 ,"cos"// Cosmic Reconstruction [false]
86 Char_t* AliTRDReconstructor::fgTaskNames[kNtasks] = {
92 Char_t* AliTRDReconstructor::fgTaskFlags[kNtasks] = {
99 //_____________________________________________________________________________
100 AliTRDReconstructor::AliTRDReconstructor()
104 // setting default "ON" steering parameters
105 // owner of debug streamers
106 SETFLG(fSteerParam, kOwner);
107 // write clusters [cw]
108 SETFLG(fSteerParam, kWriteClusters);
109 // track seeding (stand alone tracking) [sa]
110 SETFLG(fSteerParam, kSeeding);
111 // PID method in reconstruction (NN) [nn]
112 SETFLG(fSteerParam, kSteerPID);
113 // number of dEdx slices in the ESD track [8s]
114 SETFLG(fSteerParam, kEightSlices);
115 // vertex constrain for stand alone track finder
116 SETFLG(fSteerParam, kVertexConstrained);
117 // improve tracklets for stand alone track finder
118 SETFLG(fSteerParam, kImproveTracklet);
119 // use look up table for cluster r-phi position
120 SETFLG(fSteerParam, kLUT);
121 // use tail cancellation
122 SETFLG(fSteerParam, kTC);
124 memset(fStreamLevel, 0, kNtasks*sizeof(UChar_t));
125 memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * kNtasks);
126 // Xe tail cancellation parameters
127 fTCParams[0] = 1.156; // r1
128 fTCParams[1] = 0.130; // r2
129 fTCParams[2] = 0.114; // c1
130 fTCParams[3] = 0.624; // c2
131 // Ar tail cancellation parameters
132 fTCParams[4] = 6.; // r1
133 fTCParams[5] = 0.62; // r2
134 fTCParams[6] = 0.0087;// c1
135 fTCParams[7] = 0.07; // c2
138 //_____________________________________________________________________________
139 AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r)
141 ,fSteerParam(r.fSteerParam)
143 memcpy(fStreamLevel, r.fStreamLevel, kNtasks*sizeof(UChar_t));
144 memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t));
145 memcpy(fDebugStream, r.fDebugStream, sizeof(TTreeSRedirector *) *kNtasks);
146 // ownership of debug streamers is not taken
147 CLRFLG(fSteerParam, kOwner);
150 //_____________________________________________________________________________
151 AliTRDReconstructor::~AliTRDReconstructor()
154 fgClusters->Delete(); delete fgClusters;
156 if(fSteerParam&kOwner){
157 for(Int_t itask = 0; itask < kNtasks; itask++)
158 if(fDebugStream[itask]) delete fDebugStream[itask];
163 //_____________________________________________________________________________
164 void AliTRDReconstructor::Init(){
168 SetOption(GetOption());
169 Options(fSteerParam, fStreamLevel);
172 //_____________________________________________________________________________
173 void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
174 , TTree *digitsTree) const
177 // Convert raw data digits into digit objects in a root tree
179 AliInfo("Feature not available for the moment."); return;
181 AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
183 AliTRDrawData rawData;
185 rawReader->Select("TRD");
186 AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
187 manager->MakeBranch(digitsTree);
188 manager->WriteDigits();
193 //_____________________________________________________________________________
194 void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
195 , TTree *clusterTree) const
198 // Reconstruct clusters
201 //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
205 rawReader->Select("TRD");
207 // New (fast) cluster finder
208 AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]);
209 clusterer.SetReconstructor(this);
210 clusterer.OpenOutput(clusterTree);
211 clusterer.SetUseLabels(kFALSE);
212 clusterer.Raw2ClustersChamber(rawReader);
214 if(IsWritingClusters()) return;
216 // take over ownership of clusters
217 fgClusters = clusterer.RecPoints();
218 clusterer.SetClustersOwner(kFALSE);
221 //_____________________________________________________________________________
222 void AliTRDReconstructor::Reconstruct(TTree *digitsTree
223 , TTree *clusterTree) const
226 // Reconstruct clusters
229 //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
231 AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]);
232 clusterer.SetReconstructor(this);
233 clusterer.OpenOutput(clusterTree);
234 clusterer.ReadDigits(digitsTree);
235 clusterer.MakeClusters();
237 if(IsWritingClusters()) return;
239 // take over ownership of clusters
240 fgClusters = clusterer.RecPoints();
241 clusterer.SetClustersOwner(kFALSE);
244 //_____________________________________________________________________________
245 AliTracker *AliTRDReconstructor::CreateTracker() const
248 // Create a TRD tracker
251 //return new AliTRDtracker(NULL);
252 AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
253 tracker->SetReconstructor(this);
258 //_____________________________________________________________________________
259 void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
260 , TTree* /*clusterTree*/
261 , AliESDEvent* /*esd*/) const
270 //_____________________________________________________________________________
271 void AliTRDReconstructor::SetOption(Option_t *opt)
273 // Read option string into the steer param.
276 AliReconstructor::SetOption(opt);
279 TObjArray *opar = s.Tokenize(",");
280 for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
281 Bool_t PROCESSED = kFALSE;
282 TString sopt(((TObjString*)(*opar)[ipar])->String());
283 for(Int_t iopt=0; iopt<kNsteer; iopt++){
284 if(!sopt.Contains(fgSteerFlags[iopt])) continue;
285 SETFLG(fSteerParam, BIT(iopt));
286 if(sopt.Contains("!")) CLRFLG(fSteerParam, BIT(iopt));
291 if(sopt.Contains("gs") && !sopt.Contains("!")){
292 CLRFLG(fSteerParam, kLUT); PROCESSED = kTRUE;
295 if(PROCESSED) continue;
297 if(sopt.Contains("sl")){
298 TObjArray *stl = sopt.Tokenize("_");
299 if(stl->GetEntriesFast() < 3) continue;
300 TString taskstr(((TObjString*)(*stl)[1])->String());
301 TString levelstring(((TObjString*)(*stl)[2])->String());
302 Int_t level = levelstring.Atoi();
304 // Set the stream Level
306 for(Int_t it=0; it<kNtasks; it++){
307 if(taskstr.CompareTo(fgTaskFlags[it]) != 0) continue;
308 SetStreamLevel(level, ETRDReconstructorTask(it));
312 if(PROCESSED) continue;
314 AliWarning(Form("Unknown option flag %s.", sopt.Data()));
318 //_____________________________________________________________________________
319 void AliTRDReconstructor::SetStreamLevel(Int_t level, ETRDReconstructorTask task){
321 // Set the Stream Level for one of the tasks Clusterizer, Tracker or PID
323 const Int_t minLevel[4] = {1, 1, 2, 1}; // the minimum debug level upon which a debug stream is created for different tasks
324 //AliInfo(Form("Setting Stream Level for Task %s to %d", taskname.Data(),level));
325 fStreamLevel[(Int_t)task] = level;
326 // Initialize DebugStreamer if not yet done
327 if(level >= minLevel[task] && !fDebugStream[task]){
328 TDirectory *savedir = gDirectory;
329 fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task]));
331 SETFLG(fSteerParam, kOwner);
335 //_____________________________________________________________________________
336 void AliTRDReconstructor::Options(UInt_t steer, UChar_t *stream)
338 for(Int_t iopt=0; iopt<kNsteer; iopt++){
339 AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):""));
341 AliDebugGeneral("AliTRDReconstructor", 1, " Debug Streaming");
342 for(Int_t it=0; it<kNtasks; it++)
343 AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s [sl_%s] %d", fgTaskNames[it], fgTaskFlags[it], stream ? stream[it] : 0));