]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDReconstructor.cxx
Stuff from aldaqdqm09
[u/mrichter/AliRoot.git] / TRD / AliTRDReconstructor.cxx
CommitLineData
121a60bd 1/**************************************************************************
91834b8d 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**************************************************************************/
121a60bd 15
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
4fad09c9 20// Class for TRD reconstruction //
121a60bd 21// //
22///////////////////////////////////////////////////////////////////////////////
23
e3b2b5e5 24#include <TFile.h>
3a039a31 25#include <TObjString.h>
26#include <TObjArray.h>
66f6bfd9 27#include <TClonesArray.h>
121a60bd 28
121a60bd 29#include "AliRunLoader.h"
3bc9d03e 30#include "AliRawReader.h"
31#include "AliLog.h"
3bc9d03e 32#include "AliESDTrdTrack.h"
af885e0f 33#include "AliESDEvent.h"
3bc9d03e 34
35#include "AliTRDReconstructor.h"
3fe61b77 36#include "AliTRDclusterizer.h"
121a60bd 37#include "AliTRDtracker.h"
b0f03c34 38#include "AliTRDpidESD.h"
a8fbb161 39#include "AliTRDrawData.h"
40#include "AliTRDdigitsManager.h"
e4f2f73d 41#include "AliTRDtrackerV1.h"
42#include "AliTRDrecoParam.h"
121a60bd 43
29f95561 44#include "TTreeStream.h"
45
97b6dfac 46#define SETFLG(n,f) ((n) |= f)
47#define CLRFLG(n,f) ((n) &= ~f)
48
121a60bd 49ClassImp(AliTRDReconstructor)
50
66f6bfd9 51TClonesArray *AliTRDReconstructor::fgClusters = 0x0;
a5b99acd 52TClonesArray *AliTRDReconstructor::fgTracklets = 0x0;
b72f4eaf 53Char_t* AliTRDReconstructor::fgSteerNames[kNsteer] = {
54 "DigitsConversion "
55 ,"Tail Cancellation "
56 ,"Clusters LUT "
57 ,"Clusters GAUSS "
58 ,"Clusters Sharing "
59 ,"NN PID "
60 ,"8 dEdx slices in ESD "
61 ,"Write Clusters "
62 ,"Write Online Tracklets "
63 ,"Drift Gas Argon "
64 ,"Stand Alone Tracking "
65 ,"Vertex Constrain "
66 ,"Tracklet Improve "
67 ,"HLT Mode "
68 ,"Cosmic Reconstruction "
a5b99acd 69 ,"Process Online Tracklets"
b72f4eaf 70};
71Char_t* AliTRDReconstructor::fgSteerFlags[kNsteer] = {
72 "dc"// digits conversion [false]
73 ,"tc"// apply tail cancellation [true]
c96d03ba 74 ,"lut"// look-up-table for cluster shape in the r-phi direction
b72f4eaf 75 ,"gs"// gauss cluster shape in the r-phi direction
76 ,"sh"// cluster sharing between tracks
77 ,"nn"// PID method in reconstruction (NN) [true]
78 ,"8s"// 8 dEdx slices in ESD [true]
79 ,"cw"// write clusters [true]
80 ,"tw"// write online tracklets [false]
81 ,"ar"// drift gas [false] - do not update the number of exponentials in the TC !
82 ,"sa"// track seeding (stand alone tracking) [true]
83 ,"vc"// vertex constrain on stand alone track finder [false]
84 ,"ti"// improve tracklets in stand alone track finder [true]
85 ,"hlt"// HLT reconstruction [false]
86 ,"cos"// Cosmic Reconstruction [false]
a5b99acd 87 ,"tp"// also use online tracklets for reconstruction [false]
b72f4eaf 88};
89Char_t* AliTRDReconstructor::fgTaskNames[kNtasks] = {
90 "RawReader"
91 ,"Clusterizer"
92 ,"Tracker"
93 ,"PID"
94};
95Char_t* AliTRDReconstructor::fgTaskFlags[kNtasks] = {
96 "rr"
97 ,"cl"
98 ,"tr"
99 ,"pd"
100};
101
eb38ed55 102//_____________________________________________________________________________
3a039a31 103AliTRDReconstructor::AliTRDReconstructor()
104 :AliReconstructor()
97b6dfac 105 ,fSteerParam(0)
3a039a31 106{
97b6dfac 107 // setting default "ON" steering parameters
89971837 108 // owner of debug streamers
109 SETFLG(fSteerParam, kOwner);
97b6dfac 110 // write clusters [cw]
111 SETFLG(fSteerParam, kWriteClusters);
112 // track seeding (stand alone tracking) [sa]
113 SETFLG(fSteerParam, kSeeding);
114 // PID method in reconstruction (NN) [nn]
115 SETFLG(fSteerParam, kSteerPID);
89971837 116 // number of dEdx slices in the ESD track [8s]
b72f4eaf 117 SETFLG(fSteerParam, kEightSlices);
118 // vertex constrain for stand alone track finder
119 SETFLG(fSteerParam, kVertexConstrained);
120 // improve tracklets for stand alone track finder
121 SETFLG(fSteerParam, kImproveTracklet);
122 // use look up table for cluster r-phi position
123 SETFLG(fSteerParam, kLUT);
124 // use tail cancellation
125 SETFLG(fSteerParam, kTC);
97b6dfac 126
89971837 127 memset(fStreamLevel, 0, kNtasks*sizeof(UChar_t));
128 memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * kNtasks);
3a039a31 129 // Xe tail cancellation parameters
130 fTCParams[0] = 1.156; // r1
131 fTCParams[1] = 0.130; // r2
132 fTCParams[2] = 0.114; // c1
133 fTCParams[3] = 0.624; // c2
134 // Ar tail cancellation parameters
181c7f7e 135 fTCParams[4] = 6.; // r1
136 fTCParams[5] = 0.62; // r2
137 fTCParams[6] = 0.0087;// c1
138 fTCParams[7] = 0.07; // c2
eb38ed55 139}
140
3a039a31 141//_____________________________________________________________________________
142AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r)
143 :AliReconstructor(r)
181c7f7e 144 ,fSteerParam(r.fSteerParam)
3a039a31 145{
89971837 146 memcpy(fStreamLevel, r.fStreamLevel, kNtasks*sizeof(UChar_t));
91834b8d 147 memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t));
89971837 148 memcpy(fDebugStream, r.fDebugStream, sizeof(TTreeSRedirector *) *kNtasks);
149 // ownership of debug streamers is not taken
150 CLRFLG(fSteerParam, kOwner);
3a039a31 151}
eb38ed55 152
48f8adf3 153//_____________________________________________________________________________
154AliTRDReconstructor::~AliTRDReconstructor()
155{
156 if(fgClusters) {
157 fgClusters->Delete(); delete fgClusters;
158 }
a5b99acd 159 if(fgTracklets) {
160 fgTracklets->Delete(); delete fgTracklets;
161 }
f29f13a6 162 if(fSteerParam&kOwner){
89971837 163 for(Int_t itask = 0; itask < kNtasks; itask++)
29f95561 164 if(fDebugStream[itask]) delete fDebugStream[itask];
165 }
18c05eb3 166}
48f8adf3 167
91834b8d 168
acd241e9 169//_____________________________________________________________________________
91834b8d 170void AliTRDReconstructor::Init(){
18c05eb3 171 //
172 // Init Options
173 //
18c05eb3 174 SetOption(GetOption());
b72f4eaf 175 Options(fSteerParam, fStreamLevel);
acd241e9 176}
0397ce53 177
121a60bd 178//_____________________________________________________________________________
a8fbb161 179void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
91834b8d 180 , TTree *digitsTree) const
121a60bd 181{
3bc9d03e 182 //
25ca55ce 183 // Convert raw data digits into digit objects in a root tree
3bc9d03e 184 //
121a60bd 185
ad5dd6ec 186 //AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
91834b8d 187
a8fbb161 188 AliTRDrawData rawData;
3a0f6479 189 rawReader->Reset();
190 rawReader->Select("TRD");
92c7f341 191 rawData.OpenOutput();
a8fbb161 192 AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
193 manager->MakeBranch(digitsTree);
194 manager->WriteDigits();
c0ab62ff 195 delete manager;
0ee00e25 196
121a60bd 197}
198
25ca55ce 199//_____________________________________________________________________________
200void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
201 , TTree *clusterTree) const
202{
203 //
204 // Reconstruct clusters
205 //
206
91834b8d 207 //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
208
209
3a0f6479 210 rawReader->Reset();
211 rawReader->Select("TRD");
212
ca21baaa 213 // New (fast) cluster finder
b72f4eaf 214 AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]);
3d0c7d6d 215 clusterer.SetReconstructor(this);
216 clusterer.OpenOutput(clusterTree);
11d0be11 217 clusterer.OpenTrackletOutput();
b72f4eaf 218 clusterer.SetUseLabels(kFALSE);
ca21baaa 219 clusterer.Raw2ClustersChamber(rawReader);
66f6bfd9 220
221 if(IsWritingClusters()) return;
d6e36038 222
66f6bfd9 223 // take over ownership of clusters
224 fgClusters = clusterer.RecPoints();
225 clusterer.SetClustersOwner(kFALSE);
a5b99acd 226
227 // take over ownership of online tracklets
228 fgTracklets = clusterer.TrackletsArray();
229 clusterer.SetTrackletsOwner(kFALSE);
25ca55ce 230}
231
232//_____________________________________________________________________________
a8fbb161 233void AliTRDReconstructor::Reconstruct(TTree *digitsTree
234 , TTree *clusterTree) const
25ca55ce 235{
236 //
237 // Reconstruct clusters
238 //
e4f2f73d 239
91834b8d 240 //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
241
b72f4eaf 242 AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]);
3d0c7d6d 243 clusterer.SetReconstructor(this);
244 clusterer.OpenOutput(clusterTree);
25ca55ce 245 clusterer.ReadDigits(digitsTree);
246 clusterer.MakeClusters();
d6e36038 247
66f6bfd9 248 if(IsWritingClusters()) return;
249
250 // take over ownership of clusters
251 fgClusters = clusterer.RecPoints();
252 clusterer.SetClustersOwner(kFALSE);
a5b99acd 253
254 // take over ownership of online tracklets
255 fgTracklets = clusterer.TrackletsArray();
256 clusterer.SetTrackletsOwner(kFALSE);
25ca55ce 257}
258
259//_____________________________________________________________________________
44dbae42 260AliTracker *AliTRDReconstructor::CreateTracker() const
121a60bd 261{
3bc9d03e 262 //
263 // Create a TRD tracker
264 //
121a60bd 265
e4f2f73d 266 //return new AliTRDtracker(NULL);
3a039a31 267 AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
268 tracker->SetReconstructor(this);
269 return tracker;
25ca55ce 270
25ca55ce 271}
272
273//_____________________________________________________________________________
274void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
91834b8d 275 , TTree* /*clusterTree*/
276 , AliESDEvent* /*esd*/) const
25ca55ce 277{
278 //
af26ce80 279 // Fill ESD
25ca55ce 280 //
281
25ca55ce 282}
3a039a31 283
91834b8d 284
3a039a31 285//_____________________________________________________________________________
286void AliTRDReconstructor::SetOption(Option_t *opt)
287{
91834b8d 288// Read option string into the steer param.
91834b8d 289//
97b6dfac 290
291 AliReconstructor::SetOption(opt);
3a039a31 292
293 TString s(opt);
294 TObjArray *opar = s.Tokenize(",");
295 for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
b72f4eaf 296 Bool_t PROCESSED = kFALSE;
3a039a31 297 TString sopt(((TObjString*)(*opar)[ipar])->String());
b72f4eaf 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 }
17de99aa 305 // extra rules
306 if(sopt.Contains("gs") && !sopt.Contains("!")){
307 CLRFLG(fSteerParam, kLUT); PROCESSED = kTRUE;
308 }
309
b72f4eaf 310 if(PROCESSED) continue;
311
312 if(sopt.Contains("sl")){
91834b8d 313 TObjArray *stl = sopt.Tokenize("_");
314 if(stl->GetEntriesFast() < 3) continue;
315 TString taskstr(((TObjString*)(*stl)[1])->String());
316 TString levelstring(((TObjString*)(*stl)[2])->String());
91834b8d 317 Int_t level = levelstring.Atoi();
b72f4eaf 318
319 // Set the stream Level
320 PROCESSED = kFALSE;
321 for(Int_t it=0; it<kNtasks; it++){
322 if(taskstr.CompareTo(fgTaskFlags[it]) != 0) continue;
323 SetStreamLevel(level, ETRDReconstructorTask(it));
324 PROCESSED = kTRUE;
325 }
326 }
327 if(PROCESSED) continue;
328
329 AliWarning(Form("Unknown option flag %s.", sopt.Data()));
3a039a31 330 }
331}
332
acd241e9 333//_____________________________________________________________________________
89971837 334void AliTRDReconstructor::SetStreamLevel(Int_t level, ETRDReconstructorTask task){
18c05eb3 335 //
336 // Set the Stream Level for one of the tasks Clusterizer, Tracker or PID
337 //
29f95561 338 const Int_t minLevel[4] = {1, 1, 2, 1}; // the minimum debug level upon which a debug stream is created for different tasks
91834b8d 339 //AliInfo(Form("Setting Stream Level for Task %s to %d", taskname.Data(),level));
18c05eb3 340 fStreamLevel[(Int_t)task] = level;
29f95561 341 // Initialize DebugStreamer if not yet done
342 if(level >= minLevel[task] && !fDebugStream[task]){
343 TDirectory *savedir = gDirectory;
b72f4eaf 344 fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task]));
29f95561 345 savedir->cd();
89971837 346 SETFLG(fSteerParam, kOwner);
29f95561 347 }
acd241e9 348}
b72f4eaf 349
350//_____________________________________________________________________________
351void AliTRDReconstructor::Options(UInt_t steer, UChar_t *stream)
352{
353 for(Int_t iopt=0; iopt<kNsteer; iopt++){
9e8fdff4 354 AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):""));
b72f4eaf 355 }
9e8fdff4 356 AliDebugGeneral("AliTRDReconstructor", 1, " Debug Streaming");
b72f4eaf 357 for(Int_t it=0; it<kNtasks; it++)
9e8fdff4 358 AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s [sl_%s] %d", fgTaskNames[it], fgTaskFlags[it], stream ? stream[it] : 0));
b72f4eaf 359}
360