]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDReconstructor.cxx
9468547462e8bd7ce1e18b3044373fa258429692
[u/mrichter/AliRoot.git] / TRD / AliTRDReconstructor.cxx
1 /**************************************************************************
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  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // Class for TRD reconstruction                                              //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <TFile.h>
25 #include <TObjString.h>
26 #include <TObjArray.h>
27 #include <TClonesArray.h>
28
29 #include "AliRunLoader.h"
30 #include "AliRawReader.h"
31 #include "AliLog.h"
32 #include "AliESDTrdTrack.h"
33 #include "AliESDEvent.h"
34
35 #include "AliTRDReconstructor.h"
36 #include "AliTRDclusterizer.h"
37 #include "AliTRDtracker.h"
38 #include "AliTRDpidESD.h"
39 #include "AliTRDgtuTrack.h"
40 #include "AliTRDrawData.h"
41 #include "AliTRDdigitsManager.h"
42 #include "AliTRDtrackerV1.h"
43 #include "AliTRDrecoParam.h"
44
45 ClassImp(AliTRDReconstructor)
46
47 TClonesArray *AliTRDReconstructor::fgClusters = 0x0;
48 //_____________________________________________________________________________
49 AliTRDReconstructor::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
60   fTCParams[4] = 6.;    // r1
61   fTCParams[5] = 0.62;  // r2
62   fTCParams[6] = 0.0087;// c1
63   fTCParams[7] = 0.07;  // c2
64 }
65
66 //_____________________________________________________________________________
67 AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r)
68   :AliReconstructor(r)
69   ,fSteerParam(r.fSteerParam)
70 {
71   memcpy(fStreamLevel, r.fStreamLevel, 5*sizeof(UChar_t));
72   memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t));
73 }
74
75 //_____________________________________________________________________________
76 void AliTRDReconstructor::Init(){
77         //
78         // Init Options
79         //
80         SetOption(GetOption());
81
82   AliInfo("TRD reconstruction will use the following settings:");
83   printf("\tWrite Clusters         [cw] : %s\n", fSteerParam&kWriteClusters?"yes":"no");
84   printf("\tWrite Online Tracklets [tw] : %s\n", fSteerParam&kWriteTracklets?"yes":"no");
85   printf("\tDrift Gas Argon        [ar] : %s\n", fSteerParam&kDriftGas?"yes":"no");
86   printf("\tStand Alone Tracking   [sa] : %s\n", fSteerParam&kSeeding?"yes":"no");
87   printf("\tNN PID                 [nn] : %s\n", fSteerParam&kSteerPID?"yes":"no");
88   printf("\tStreaming Levels            : Clusterizer[%d] Tracker[%d] PID[%d]\n", fStreamLevel[kClusterizer], fStreamLevel[kTracker], fStreamLevel[kPID]);
89 }
90
91 //_____________________________________________________________________________
92 void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
93                                       , TTree *digitsTree) const
94 {
95   //
96   // Convert raw data digits into digit objects in a root tree
97   //
98
99   AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
100
101   AliTRDrawData rawData;
102   rawReader->Reset();
103   rawReader->Select("TRD");
104   AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
105   manager->MakeBranch(digitsTree);
106   manager->WriteDigits();
107   delete manager;
108
109 }
110
111 //_____________________________________________________________________________
112 void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
113                                     , TTree *clusterTree) const
114 {
115   //
116   // Reconstruct clusters
117   //
118
119   //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
120
121
122   rawReader->Reset();
123   rawReader->Select("TRD");
124
125   // New (fast) cluster finder
126   AliTRDclusterizer clusterer("clusterer","TRD clusterizer");
127   clusterer.SetReconstructor(this);
128   clusterer.OpenOutput(clusterTree);
129   clusterer.SetAddLabels(kFALSE);
130   clusterer.Raw2ClustersChamber(rawReader);
131   
132   if(IsWritingClusters()) return;
133
134   // take over ownership of clusters
135   fgClusters = clusterer.RecPoints();
136   clusterer.SetClustersOwner(kFALSE);
137 }
138
139 //_____________________________________________________________________________
140 void AliTRDReconstructor::Reconstruct(TTree *digitsTree
141                                     , TTree *clusterTree) const
142 {
143   //
144   // Reconstruct clusters
145   //
146
147   //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
148
149   AliTRDclusterizer clusterer("clusterer","TRD clusterizer");
150   clusterer.SetReconstructor(this);
151   clusterer.OpenOutput(clusterTree);
152   clusterer.ReadDigits(digitsTree);
153   clusterer.MakeClusters();
154
155   if(IsWritingClusters()) return;
156
157   // take over ownership of clusters
158   fgClusters = clusterer.RecPoints();
159   clusterer.SetClustersOwner(kFALSE);
160 }
161
162 //_____________________________________________________________________________
163 AliTracker *AliTRDReconstructor::CreateTracker() const
164 {
165   //
166   // Create a TRD tracker
167   //
168
169   //return new AliTRDtracker(NULL);
170   AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
171   tracker->SetReconstructor(this);
172   return tracker;
173
174 }
175
176 //_____________________________________________________________________________
177 void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
178                                 , TTree* /*clusterTree*/
179                                 , AliESDEvent* /*esd*/) const
180 {
181   //
182   // Fill ESD
183   //
184
185 }
186
187
188 //_____________________________________________________________________________
189 void AliTRDReconstructor::SetOption(Option_t *opt)
190 {
191 // Read option string into the steer param.
192 //
193 // Default steer param values
194 //
195 // write clusters [cw] = true
196 // track seeding (stand alone tracking) [sa] = true
197 // PID method in reconstruction (NN) [nn] = true
198 // write online tracklets [tw] = false
199 // drift gas [ar] = false
200 //
201   fSteerParam = 0x00000007;
202
203   TString s(opt);
204   TObjArray *opar = s.Tokenize(",");
205   for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
206     TString sopt(((TObjString*)(*opar)[ipar])->String());
207     if(sopt.Contains("!cw")){ 
208       fSteerParam &= ~kWriteClusters;
209       continue;
210     } else if(sopt.Contains("!sa")){
211       fSteerParam &= ~kSeeding;
212       continue;
213     } else if(sopt.Contains("!nn")){
214       fSteerParam &= ~kSteerPID;
215       continue;
216     } else if(sopt.Contains("tw")){
217       if(!sopt.Contains("!")) fSteerParam |= kWriteTracklets;
218       continue; 
219     } else if(sopt.Contains("ar")){
220       if(!sopt.Contains("!")) fSteerParam |= kDriftGas;
221       continue; 
222     } else if(sopt.Contains("sl")){
223         TObjArray *stl = sopt.Tokenize("_");
224         if(stl->GetEntriesFast() < 3) continue;
225                         TString taskstr(((TObjString*)(*stl)[1])->String());
226                         TString levelstring(((TObjString*)(*stl)[2])->String());
227         // Set the stream Level
228         Int_t level = levelstring.Atoi();
229         AliTRDReconstructorTask task = kTracker;
230         if(taskstr.CompareTo("cl") == 0) task = kClusterizer;   
231         else if(taskstr.CompareTo("tr") == 0) task = kTracker;
232         else if(taskstr.CompareTo("pi") == 0) task = kPID;
233         SetStreamLevel(level, task);
234         continue;
235                 }
236   }
237 }
238
239 //_____________________________________________________________________________
240 void AliTRDReconstructor::SetStreamLevel(Int_t level, AliTRDReconstructorTask task){
241         //
242         // Set the Stream Level for one of the tasks Clusterizer, Tracker or PID
243         //
244         TString taskname;
245         switch(task){
246                 case kClusterizer: taskname = "Clusterizer";
247                                                                                          break;
248                 case kTracker: taskname = "Tracker";
249                                                                          break;
250                 case kPID: taskname = "PID";
251                                                          break;
252         }
253         //AliInfo(Form("Setting Stream Level for Task %s to %d", taskname.Data(),level));
254         fStreamLevel[(Int_t)task] = level;
255 }