]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDReconstructor.cxx
The new background correction task for the FMD. It can loop over galice input files...
[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;
b72f4eaf 52Char_t* AliTRDReconstructor::fgSteerNames[kNsteer] = {
53 "DigitsConversion "
54 ,"Tail Cancellation "
55 ,"Clusters LUT "
56 ,"Clusters GAUSS "
57 ,"Clusters Sharing "
58 ,"NN PID "
59 ,"8 dEdx slices in ESD "
60 ,"Write Clusters "
61 ,"Write Online Tracklets "
62 ,"Drift Gas Argon "
63 ,"Stand Alone Tracking "
64 ,"Vertex Constrain "
65 ,"Tracklet Improve "
66 ,"HLT Mode "
67 ,"Cosmic Reconstruction "
68};
69Char_t* AliTRDReconstructor::fgSteerFlags[kNsteer] = {
70 "dc"// digits conversion [false]
71 ,"tc"// apply tail cancellation [true]
c96d03ba 72 ,"lut"// look-up-table for cluster shape in the r-phi direction
b72f4eaf 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]
85};
86Char_t* AliTRDReconstructor::fgTaskNames[kNtasks] = {
87 "RawReader"
88 ,"Clusterizer"
89 ,"Tracker"
90 ,"PID"
91};
92Char_t* AliTRDReconstructor::fgTaskFlags[kNtasks] = {
93 "rr"
94 ,"cl"
95 ,"tr"
96 ,"pd"
97};
98
eb38ed55 99//_____________________________________________________________________________
3a039a31 100AliTRDReconstructor::AliTRDReconstructor()
101 :AliReconstructor()
97b6dfac 102 ,fSteerParam(0)
3a039a31 103{
97b6dfac 104 // setting default "ON" steering parameters
89971837 105 // owner of debug streamers
106 SETFLG(fSteerParam, kOwner);
97b6dfac 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);
89971837 113 // number of dEdx slices in the ESD track [8s]
b72f4eaf 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);
97b6dfac 123
89971837 124 memset(fStreamLevel, 0, kNtasks*sizeof(UChar_t));
125 memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * kNtasks);
3a039a31 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
181c7f7e 132 fTCParams[4] = 6.; // r1
133 fTCParams[5] = 0.62; // r2
134 fTCParams[6] = 0.0087;// c1
135 fTCParams[7] = 0.07; // c2
eb38ed55 136}
137
3a039a31 138//_____________________________________________________________________________
139AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r)
140 :AliReconstructor(r)
181c7f7e 141 ,fSteerParam(r.fSteerParam)
3a039a31 142{
89971837 143 memcpy(fStreamLevel, r.fStreamLevel, kNtasks*sizeof(UChar_t));
91834b8d 144 memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t));
89971837 145 memcpy(fDebugStream, r.fDebugStream, sizeof(TTreeSRedirector *) *kNtasks);
146 // ownership of debug streamers is not taken
147 CLRFLG(fSteerParam, kOwner);
3a039a31 148}
eb38ed55 149
48f8adf3 150//_____________________________________________________________________________
151AliTRDReconstructor::~AliTRDReconstructor()
152{
153 if(fgClusters) {
154 fgClusters->Delete(); delete fgClusters;
155 }
f29f13a6 156 if(fSteerParam&kOwner){
89971837 157 for(Int_t itask = 0; itask < kNtasks; itask++)
29f95561 158 if(fDebugStream[itask]) delete fDebugStream[itask];
159 }
18c05eb3 160}
48f8adf3 161
91834b8d 162
acd241e9 163//_____________________________________________________________________________
91834b8d 164void AliTRDReconstructor::Init(){
18c05eb3 165 //
166 // Init Options
167 //
18c05eb3 168 SetOption(GetOption());
b72f4eaf 169 Options(fSteerParam, fStreamLevel);
acd241e9 170}
0397ce53 171
121a60bd 172//_____________________________________________________________________________
a8fbb161 173void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
91834b8d 174 , TTree *digitsTree) const
121a60bd 175{
3bc9d03e 176 //
25ca55ce 177 // Convert raw data digits into digit objects in a root tree
3bc9d03e 178 //
9926e335 179 AliInfo("Feature not available for the moment."); return;
121a60bd 180
91834b8d 181 AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
182
a8fbb161 183 AliTRDrawData rawData;
3a0f6479 184 rawReader->Reset();
185 rawReader->Select("TRD");
a8fbb161 186 AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
187 manager->MakeBranch(digitsTree);
188 manager->WriteDigits();
c0ab62ff 189 delete manager;
0ee00e25 190
121a60bd 191}
192
25ca55ce 193//_____________________________________________________________________________
194void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
195 , TTree *clusterTree) const
196{
197 //
198 // Reconstruct clusters
199 //
200
91834b8d 201 //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
202
203
3a0f6479 204 rawReader->Reset();
205 rawReader->Select("TRD");
206
ca21baaa 207 // New (fast) cluster finder
b72f4eaf 208 AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]);
3d0c7d6d 209 clusterer.SetReconstructor(this);
210 clusterer.OpenOutput(clusterTree);
b72f4eaf 211 clusterer.SetUseLabels(kFALSE);
ca21baaa 212 clusterer.Raw2ClustersChamber(rawReader);
66f6bfd9 213
214 if(IsWritingClusters()) return;
d6e36038 215
66f6bfd9 216 // take over ownership of clusters
217 fgClusters = clusterer.RecPoints();
218 clusterer.SetClustersOwner(kFALSE);
25ca55ce 219}
220
221//_____________________________________________________________________________
a8fbb161 222void AliTRDReconstructor::Reconstruct(TTree *digitsTree
223 , TTree *clusterTree) const
25ca55ce 224{
225 //
226 // Reconstruct clusters
227 //
e4f2f73d 228
91834b8d 229 //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
230
b72f4eaf 231 AliTRDclusterizer clusterer(fgTaskNames[kClusterizer], fgTaskNames[kClusterizer]);
3d0c7d6d 232 clusterer.SetReconstructor(this);
233 clusterer.OpenOutput(clusterTree);
25ca55ce 234 clusterer.ReadDigits(digitsTree);
235 clusterer.MakeClusters();
d6e36038 236
66f6bfd9 237 if(IsWritingClusters()) return;
238
239 // take over ownership of clusters
240 fgClusters = clusterer.RecPoints();
241 clusterer.SetClustersOwner(kFALSE);
25ca55ce 242}
243
244//_____________________________________________________________________________
44dbae42 245AliTracker *AliTRDReconstructor::CreateTracker() const
121a60bd 246{
3bc9d03e 247 //
248 // Create a TRD tracker
249 //
121a60bd 250
e4f2f73d 251 //return new AliTRDtracker(NULL);
3a039a31 252 AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
253 tracker->SetReconstructor(this);
254 return tracker;
25ca55ce 255
25ca55ce 256}
257
258//_____________________________________________________________________________
259void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
91834b8d 260 , TTree* /*clusterTree*/
261 , AliESDEvent* /*esd*/) const
25ca55ce 262{
263 //
af26ce80 264 // Fill ESD
25ca55ce 265 //
266
25ca55ce 267}
3a039a31 268
91834b8d 269
3a039a31 270//_____________________________________________________________________________
271void AliTRDReconstructor::SetOption(Option_t *opt)
272{
91834b8d 273// Read option string into the steer param.
91834b8d 274//
97b6dfac 275
276 AliReconstructor::SetOption(opt);
3a039a31 277
278 TString s(opt);
279 TObjArray *opar = s.Tokenize(",");
280 for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
b72f4eaf 281 Bool_t PROCESSED = kFALSE;
3a039a31 282 TString sopt(((TObjString*)(*opar)[ipar])->String());
b72f4eaf 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));
287 PROCESSED = kTRUE;
288 break;
289 }
17de99aa 290 // extra rules
291 if(sopt.Contains("gs") && !sopt.Contains("!")){
292 CLRFLG(fSteerParam, kLUT); PROCESSED = kTRUE;
293 }
294
b72f4eaf 295 if(PROCESSED) continue;
296
297 if(sopt.Contains("sl")){
91834b8d 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());
91834b8d 302 Int_t level = levelstring.Atoi();
b72f4eaf 303
304 // Set the stream Level
305 PROCESSED = kFALSE;
306 for(Int_t it=0; it<kNtasks; it++){
307 if(taskstr.CompareTo(fgTaskFlags[it]) != 0) continue;
308 SetStreamLevel(level, ETRDReconstructorTask(it));
309 PROCESSED = kTRUE;
310 }
311 }
312 if(PROCESSED) continue;
313
314 AliWarning(Form("Unknown option flag %s.", sopt.Data()));
3a039a31 315 }
316}
317
acd241e9 318//_____________________________________________________________________________
89971837 319void AliTRDReconstructor::SetStreamLevel(Int_t level, ETRDReconstructorTask task){
18c05eb3 320 //
321 // Set the Stream Level for one of the tasks Clusterizer, Tracker or PID
322 //
29f95561 323 const Int_t minLevel[4] = {1, 1, 2, 1}; // the minimum debug level upon which a debug stream is created for different tasks
91834b8d 324 //AliInfo(Form("Setting Stream Level for Task %s to %d", taskname.Data(),level));
18c05eb3 325 fStreamLevel[(Int_t)task] = level;
29f95561 326 // Initialize DebugStreamer if not yet done
327 if(level >= minLevel[task] && !fDebugStream[task]){
328 TDirectory *savedir = gDirectory;
b72f4eaf 329 fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task]));
29f95561 330 savedir->cd();
89971837 331 SETFLG(fSteerParam, kOwner);
29f95561 332 }
acd241e9 333}
b72f4eaf 334
335//_____________________________________________________________________________
336void AliTRDReconstructor::Options(UInt_t steer, UChar_t *stream)
337{
338 for(Int_t iopt=0; iopt<kNsteer; iopt++){
339 AliInfoGeneral("AliTRDReconstructor", Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):""));
340 }
341 AliInfoGeneral("AliTRDReconstructor", " Debug Streaming");
342 for(Int_t it=0; it<kNtasks; it++)
343 AliInfoGeneral("AliTRDReconstructor", Form(" %s [sl_%s] %d", fgTaskNames[it], fgTaskFlags[it], stream ? stream[it] : 0));
344}
345