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 ///////////////////////////////////////////////////////////////////////////////
24 #include <TObjString.h>
25 #include <TObjArray.h>
26 #include <TTreeStream.h>
27 #include <TDirectory.h>
29 #include "AliRawReader.h"
31 #include "AliTRDReconstructor.h"
32 #include "AliTRDclusterizer.h"
33 #include "AliTRDrawData.h"
34 #include "AliTRDrawStreamBase.h"
35 #include "AliTRDdigitsManager.h"
36 #include "AliTRDtrackerV1.h"
38 #define SETFLG(n,f) ((n) |= f)
39 #define CLRFLG(n,f) ((n) &= ~f)
41 ClassImp(AliTRDReconstructor)
43 TClonesArray *AliTRDReconstructor::fgClusters = NULL;
44 TClonesArray *AliTRDReconstructor::fgTracklets = NULL;
45 Char_t const * AliTRDReconstructor::fgSteerNames[kNsteer] = {
48 ,"Write Online Tracklets "
49 ,"Stand Alone Tracking "
51 ,"Process Online Tracklets"
54 Char_t const * AliTRDReconstructor::fgSteerFlags[kNsteer] = {
55 "dc"// digits conversion [false]
56 ,"cw"// write clusters [true]
57 ,"tw"// write online tracklets [false]
58 ,"sa"// track seeding (stand alone tracking) [true]
59 ,"hlt"// HLT reconstruction [false]
60 ,"tp"// also use online tracklets for reconstruction [false]
61 ,"deb"// Write debug stream [false]
63 Char_t const * AliTRDReconstructor::fgTaskNames[AliTRDrecoParam::kTRDreconstructionTasks] = {
68 Char_t const * AliTRDReconstructor::fgTaskFlags[AliTRDrecoParam::kTRDreconstructionTasks] = {
73 Int_t AliTRDReconstructor::fgNTimeBins = -1;
75 //_____________________________________________________________________________
76 AliTRDReconstructor::AliTRDReconstructor()
81 // setting default "ON" steering parameters
82 // owner of debug streamers
83 SETFLG(fSteerParam, kOwner);
84 // write clusters [cw]
85 SETFLG(fSteerParam, kWriteClusters);
86 // track seeding (stand alone tracking) [sa]
87 SETFLG(fSteerParam, kSeeding);
89 memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * AliTRDrecoParam::kTRDreconstructionTasks);
92 //_____________________________________________________________________________
93 AliTRDReconstructor::~AliTRDReconstructor()
100 fgClusters->Delete();
105 fgTracklets->Delete();
109 if(fSteerParam&kOwner){
110 for(Int_t itask = 0; itask < AliTRDrecoParam::kTRDreconstructionTasks; itask++)
111 if(fDebugStream[itask]) delete fDebugStream[itask];
120 //_____________________________________________________________________________
121 void AliTRDReconstructor::Init(){
125 SetOption(GetOption());
126 Options(fSteerParam);
129 fClusterizer = new AliTRDclusterizer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]);
130 fClusterizer->SetReconstructor(this);
133 // Make Debug Streams when Debug Streaming
134 if(IsDebugStreaming()){
135 for(Int_t task = 0; task < AliTRDrecoParam::kTRDreconstructionTasks; task++){
136 TDirectory *savedir = gDirectory;
137 fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task]));
139 SETFLG(fSteerParam, kOwner);
144 //_____________________________________________________________________________
145 void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
146 , TTree *digitsTree) const
149 // Convert raw data digits into digit objects in a root tree
152 //AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
154 AliTRDrawData rawData;
156 rawReader->Select("TRD");
157 rawData.OpenOutput();
158 AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data());
159 AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
160 manager->MakeBranch(digitsTree);
161 manager->WriteDigits();
166 //_____________________________________________________________________________
167 void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
168 , TTree *clusterTree) const
171 // Reconstruct clusters
174 //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
178 rawReader->Select("TRD");
179 AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data());
182 AliFatal("Clusterizer not available!");
186 fClusterizer->ResetRecPoints();
188 fClusterizer->OpenOutput(clusterTree);
189 fClusterizer->OpenTrackletOutput();
190 fClusterizer->SetUseLabels(kFALSE);
191 fClusterizer->Raw2ClustersChamber(rawReader);
193 if(IsWritingClusters()) return;
195 // take over ownership of clusters
196 fgClusters = fClusterizer->RecPoints();
197 fClusterizer->SetClustersOwner(kFALSE);
199 // take over ownership of online tracklets
200 fgTracklets = fClusterizer->TrackletsArray();
201 fClusterizer->SetTrackletsOwner(kFALSE);
203 fgNTimeBins = fClusterizer->GetNTimeBins();
206 //_____________________________________________________________________________
207 void AliTRDReconstructor::Reconstruct(TTree *digitsTree
208 , TTree *clusterTree) const
211 // Reconstruct clusters
214 //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
217 AliFatal("Clusterizer not available!");
221 fClusterizer->ResetRecPoints();
223 fClusterizer->OpenOutput(clusterTree);
224 fClusterizer->ReadDigits(digitsTree);
225 fClusterizer->MakeClusters();
227 if(IsWritingClusters()) return;
229 // take over ownership of clusters
230 fgClusters = fClusterizer->RecPoints();
231 fClusterizer->SetClustersOwner(kFALSE);
233 // take over ownership of online tracklets
234 fgTracklets = fClusterizer->TrackletsArray();
235 fClusterizer->SetTrackletsOwner(kFALSE);
237 fgNTimeBins = fClusterizer->GetNTimeBins();
240 //_____________________________________________________________________________
241 AliTracker *AliTRDReconstructor::CreateTracker() const
244 // Create a TRD tracker
247 //return new AliTRDtracker(NULL);
248 AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
249 tracker->SetReconstructor(this);
254 //_____________________________________________________________________________
255 void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
256 , TTree* /*clusterTree*/
257 , AliESDEvent* /*esd*/) const
265 //_____________________________________________________________________________
266 void AliTRDReconstructor::SetOption(Option_t *opt)
269 // Read option string into the steer param.
272 AliReconstructor::SetOption(opt);
275 TObjArray *opar = s.Tokenize(",");
276 for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
277 Bool_t processed = kFALSE;
278 TString sopt(((TObjString*)(*opar)[ipar])->String());
279 for(Int_t iopt=0; iopt<kNsteer; iopt++){
280 if(!sopt.Contains(fgSteerFlags[iopt])) continue;
281 SETFLG(fSteerParam, BIT(iopt));
282 if(sopt.Contains("!")) CLRFLG(fSteerParam, BIT(iopt));
286 if(processed) continue;
288 AliWarning(Form("Unknown option flag %s.", sopt.Data()));
292 //_____________________________________________________________________________
293 void AliTRDReconstructor::Options(UInt_t steer)
299 for(Int_t iopt=0; iopt<kNsteer; iopt++){
300 AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):""));