expantion of recoParam (Markus) and fix bug in HLT mode
[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"
e3b2b5e5 39#include "AliTRDgtuTrack.h"
a8fbb161 40#include "AliTRDrawData.h"
41#include "AliTRDdigitsManager.h"
e4f2f73d 42#include "AliTRDtrackerV1.h"
43#include "AliTRDrecoParam.h"
121a60bd 44
45ClassImp(AliTRDReconstructor)
46
66f6bfd9 47TClonesArray *AliTRDReconstructor::fgClusters = 0x0;
eb38ed55 48//_____________________________________________________________________________
3a039a31 49AliTRDReconstructor::AliTRDReconstructor()
50 :AliReconstructor()
51 ,fSteerParam(0x00000007)
52{
53 memset(fStreamLevel, 0, 5*sizeof(UChar_t));
54 // Xe tail cancellation parameters
55 fTCParams[0] = 1.156; // r1
56 fTCParams[1] = 0.130; // r2
57 fTCParams[2] = 0.114; // c1
58 fTCParams[3] = 0.624; // c2
59 // Ar tail cancellation parameters
181c7f7e 60 fTCParams[4] = 6.; // r1
61 fTCParams[5] = 0.62; // r2
62 fTCParams[6] = 0.0087;// c1
63 fTCParams[7] = 0.07; // c2
eb38ed55 64}
65
3a039a31 66//_____________________________________________________________________________
67AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r)
68 :AliReconstructor(r)
181c7f7e 69 ,fSteerParam(r.fSteerParam)
3a039a31 70{
91834b8d 71 memcpy(fStreamLevel, r.fStreamLevel, 5*sizeof(UChar_t));
72 memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t));
3a039a31 73}
eb38ed55 74
48f8adf3 75//_____________________________________________________________________________
76AliTRDReconstructor::~AliTRDReconstructor()
77{
78 if(fgClusters) {
79 fgClusters->Delete(); delete fgClusters;
80 }
18c05eb3 81}
48f8adf3 82
91834b8d 83
acd241e9 84//_____________________________________________________________________________
91834b8d 85void AliTRDReconstructor::Init(){
18c05eb3 86 //
87 // Init Options
88 //
18c05eb3 89 SetOption(GetOption());
20bcdcc4 90
91 AliInfo("TRD reconstruction will use the following settings:");
92 printf("\tWrite Clusters [cw] : %s\n", fSteerParam&kWriteClusters?"yes":"no");
93 printf("\tWrite Online Tracklets [tw] : %s\n", fSteerParam&kWriteTracklets?"yes":"no");
94 printf("\tDrift Gas Argon [ar] : %s\n", fSteerParam&kDriftGas?"yes":"no");
95 printf("\tStand Alone Tracking [sa] : %s\n", fSteerParam&kSeeding?"yes":"no");
4302c900 96 printf("\tHLT Tracking [hlt] : %s\n", fSteerParam&kHLT?"yes":"no");
91834b8d 97 printf("\tCosmic Reconstruction [cos] : %s\n", fSteerParam&kCosmic?"yes":"no");
20bcdcc4 98 printf("\tNN PID [nn] : %s\n", fSteerParam&kSteerPID?"yes":"no");
91834b8d 99 printf("\tStreaming Levels : Clusterizer[%d] Tracker[%d] PID[%d]\n", fStreamLevel[kClusterizer], fStreamLevel[kTracker], fStreamLevel[kPID]);
acd241e9 100}
0397ce53 101
121a60bd 102//_____________________________________________________________________________
a8fbb161 103void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
91834b8d 104 , TTree *digitsTree) const
121a60bd 105{
3bc9d03e 106 //
25ca55ce 107 // Convert raw data digits into digit objects in a root tree
3bc9d03e 108 //
121a60bd 109
91834b8d 110 AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
111
a8fbb161 112 AliTRDrawData rawData;
3a0f6479 113 rawReader->Reset();
114 rawReader->Select("TRD");
a8fbb161 115 AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
116 manager->MakeBranch(digitsTree);
117 manager->WriteDigits();
c0ab62ff 118 delete manager;
0ee00e25 119
121a60bd 120}
121
25ca55ce 122//_____________________________________________________________________________
123void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
124 , TTree *clusterTree) const
125{
126 //
127 // Reconstruct clusters
128 //
129
91834b8d 130 //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
131
132
3a0f6479 133 rawReader->Reset();
134 rawReader->Select("TRD");
135
ca21baaa 136 // New (fast) cluster finder
3fe61b77 137 AliTRDclusterizer clusterer("clusterer","TRD clusterizer");
3a039a31 138 clusterer.SetReconstructor(this);
25ca55ce 139 clusterer.OpenOutput(clusterTree);
ca21baaa 140 clusterer.SetAddLabels(kFALSE);
141 clusterer.Raw2ClustersChamber(rawReader);
66f6bfd9 142
143 if(IsWritingClusters()) return;
d6e36038 144
66f6bfd9 145 // take over ownership of clusters
146 fgClusters = clusterer.RecPoints();
147 clusterer.SetClustersOwner(kFALSE);
25ca55ce 148}
149
150//_____________________________________________________________________________
a8fbb161 151void AliTRDReconstructor::Reconstruct(TTree *digitsTree
152 , TTree *clusterTree) const
25ca55ce 153{
154 //
155 // Reconstruct clusters
156 //
e4f2f73d 157
91834b8d 158 //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
159
3fe61b77 160 AliTRDclusterizer clusterer("clusterer","TRD clusterizer");
3a039a31 161 clusterer.SetReconstructor(this);
25ca55ce 162 clusterer.OpenOutput(clusterTree);
163 clusterer.ReadDigits(digitsTree);
164 clusterer.MakeClusters();
d6e36038 165
66f6bfd9 166 if(IsWritingClusters()) return;
167
168 // take over ownership of clusters
169 fgClusters = clusterer.RecPoints();
170 clusterer.SetClustersOwner(kFALSE);
25ca55ce 171}
172
173//_____________________________________________________________________________
44dbae42 174AliTracker *AliTRDReconstructor::CreateTracker() const
121a60bd 175{
3bc9d03e 176 //
177 // Create a TRD tracker
178 //
121a60bd 179
e4f2f73d 180 //return new AliTRDtracker(NULL);
3a039a31 181 AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
182 tracker->SetReconstructor(this);
183 return tracker;
25ca55ce 184
25ca55ce 185}
186
187//_____________________________________________________________________________
188void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
91834b8d 189 , TTree* /*clusterTree*/
190 , AliESDEvent* /*esd*/) const
25ca55ce 191{
192 //
af26ce80 193 // Fill ESD
25ca55ce 194 //
195
25ca55ce 196}
3a039a31 197
91834b8d 198
3a039a31 199//_____________________________________________________________________________
200void AliTRDReconstructor::SetOption(Option_t *opt)
201{
91834b8d 202// Read option string into the steer param.
203//
204// Default steer param values
205//
206// write clusters [cw] = true
207// track seeding (stand alone tracking) [sa] = true
208// PID method in reconstruction (NN) [nn] = true
209// write online tracklets [tw] = false
210// drift gas [ar] = false
211// HLT tracking [hlt] = false
212// Cosmic Reconstruction [cos] = false
213//
3a039a31 214 fSteerParam = 0x00000007;
215
216 TString s(opt);
217 TObjArray *opar = s.Tokenize(",");
218 for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
219 TString sopt(((TObjString*)(*opar)[ipar])->String());
220 if(sopt.Contains("!cw")){
221 fSteerParam &= ~kWriteClusters;
222 continue;
223 } else if(sopt.Contains("!sa")){
224 fSteerParam &= ~kSeeding;
225 continue;
226 } else if(sopt.Contains("!nn")){
227 fSteerParam &= ~kSteerPID;
228 continue;
229 } else if(sopt.Contains("tw")){
20bcdcc4 230 if(!sopt.Contains("!")) fSteerParam |= kWriteTracklets;
3a039a31 231 continue;
232 } else if(sopt.Contains("ar")){
20bcdcc4 233 if(!sopt.Contains("!")) fSteerParam |= kDriftGas;
3a039a31 234 continue;
4302c900 235 } else if(sopt.Contains("hlt")){
236 if(!sopt.Contains("!")) fSteerParam |= kHLT;
237 continue;
91834b8d 238 } else if(sopt.Contains("cos")){
239 if(!sopt.Contains("!")) fSteerParam |= kCosmic;
acd241e9 240 } else if(sopt.Contains("sl")){
91834b8d 241 TObjArray *stl = sopt.Tokenize("_");
242 if(stl->GetEntriesFast() < 3) continue;
243 TString taskstr(((TObjString*)(*stl)[1])->String());
244 TString levelstring(((TObjString*)(*stl)[2])->String());
245 // Set the stream Level
246 Int_t level = levelstring.Atoi();
247 AliTRDReconstructorTask task = kTracker;
248 if(taskstr.CompareTo("cl") == 0) task = kClusterizer;
249 else if(taskstr.CompareTo("tr") == 0) task = kTracker;
250 else if(taskstr.CompareTo("pi") == 0) task = kPID;
251 SetStreamLevel(level, task);
252 continue;
253 }
3a039a31 254 }
255}
256
acd241e9 257//_____________________________________________________________________________
91834b8d 258void AliTRDReconstructor::SetStreamLevel(Int_t level, AliTRDReconstructorTask task){
18c05eb3 259 //
260 // Set the Stream Level for one of the tasks Clusterizer, Tracker or PID
261 //
18c05eb3 262 TString taskname;
91834b8d 263 switch(task){
264 case kClusterizer:
265 taskname = "Clusterizer";
266 break;
267 case kTracker:
268 taskname = "Tracker";
269 break;
270 case kPID:
271 taskname = "PID";
272 break;
18c05eb3 273 }
91834b8d 274 //AliInfo(Form("Setting Stream Level for Task %s to %d", taskname.Data(),level));
18c05eb3 275 fStreamLevel[(Int_t)task] = level;
acd241e9 276}