]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFReconstructor.cxx
update to port TOF trigger mask in TOF header
[u/mrichter/AliRoot.git] / TOF / AliTOFReconstructor.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 TOF reconstruction                                              //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <cstdlib>
25 #include "TObjArray.h"
26 #include "TString.h"
27
28 #include "AliLog.h"
29 #include "AliESDEvent.h"
30 #include "AliESDpid.h"
31 #include "AliRawReader.h"
32 #include "AliTOFHeader.h"
33
34 #include "AliTOFClusterFinder.h"
35 #include "AliTOFClusterFinderV1.h"
36 #include "AliTOFcalib.h"
37 #include "AliTOFtrackerMI.h"
38 #include "AliTOFtracker.h"
39 #include "AliTOFtrackerV1.h"
40 #include "AliTOFT0maker.h"
41 #include "AliTOFReconstructor.h"
42 #include "AliTOFTriggerMask.h"
43 #include "AliTOFTrigger.h"
44
45 class TTree;
46
47 ClassImp(AliTOFReconstructor)
48
49  //____________________________________________________________________
50 AliTOFReconstructor::AliTOFReconstructor() :
51   AliReconstructor(),
52   fTOFcalib(0),
53   /*fTOFT0maker(0),*/
54   fNumberOfTofClusters(0),
55   fNumberOfTofTrgPads(0),
56   fClusterFinder(0),
57   fClusterFinderV1(0)
58 {
59 //
60 // ctor
61 //
62   
63   //Retrieving the TOF calibration info  
64   fTOFcalib = new AliTOFcalib();
65   fTOFcalib->Init();
66   fClusterFinder = new AliTOFClusterFinder(fTOFcalib);
67   fClusterFinderV1 = new AliTOFClusterFinderV1(fTOFcalib);
68
69   TString optionString = GetOption();
70   if (optionString.Contains("DecoderV0")) {
71     fClusterFinder->SetDecoderVersion(0);
72     fClusterFinderV1->SetDecoderVersion(0);
73   }
74   else if (optionString.Contains("DecoderV1")) {
75     fClusterFinder->SetDecoderVersion(1);
76     fClusterFinderV1->SetDecoderVersion(1);
77   }
78   else {
79     fClusterFinder->SetDecoderVersion(2);
80     fClusterFinderV1->SetDecoderVersion(2);
81   }
82
83
84
85 #if 0
86   fTOFcalib->CreateCalObjects();
87
88   if(!fTOFcalib->ReadParOnlineDelayFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
89   if(!fTOFcalib->ReadParOnlineStatusFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
90
91   if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
92
93
94   if(!fTOFcalib->ReadDeltaBCOffsetFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
95   if(!fTOFcalib->ReadCTPLatencyFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
96   if(!fTOFcalib->ReadT0FillFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
97   if(!fTOFcalib->ReadRunParamsFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
98 #endif
99
100 }
101
102 //_____________________________________________________________________________
103 AliTOFReconstructor::~AliTOFReconstructor() 
104 {
105 //
106 // dtor
107 //
108
109   delete fTOFcalib;
110
111   //delete fTOFT0maker;
112   fNumberOfTofClusters = 0;
113   fNumberOfTofTrgPads = 0;
114
115   delete fClusterFinder;
116   delete fClusterFinderV1;
117 }
118
119 //_____________________________________________________________________________
120 void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
121                                       TTree *clustersTree) const
122 {
123   //
124   // reconstruct clusters from Raw Data
125   //
126
127   TString optionString = GetOption();
128
129   // use V1 cluster finder if selected
130   if (optionString.Contains("ClusterizerV1")) {
131     /*
132     AliTOFClusterFinderV1 tofClus(fTOFcalib);
133
134     // decoder version option
135     if (optionString.Contains("DecoderV0")) {
136       tofClus.SetDecoderVersion(0);
137     }
138     else if (optionString.Contains("DecoderV1")) {
139       tofClus.SetDecoderVersion(1);
140     }
141     else {
142       tofClus.SetDecoderVersion(2);
143     }
144
145     tofClus.Digits2RecPoints(rawReader, clustersTree);
146     */
147
148     fClusterFinderV1->Digits2RecPoints(rawReader, clustersTree);    
149   }
150   else {
151     /*
152     AliTOFClusterFinder tofClus(fTOFcalib);
153       
154     // decoder version option
155     if (optionString.Contains("DecoderV0")) {
156       tofClus.SetDecoderVersion(0);
157     }
158     else if (optionString.Contains("DecoderV1")) {
159       tofClus.SetDecoderVersion(1);
160     }
161     else {
162       tofClus.SetDecoderVersion(2);
163     }
164
165     tofClus.Digits2RecPoints(rawReader, clustersTree);
166
167     */
168
169     fClusterFinder->Digits2RecPoints(rawReader, clustersTree);
170   }
171   AliTOFTrigger::PrepareTOFMapFromRaw(rawReader,13600); // 13600 +/- 400 is the value to select the richt bunch crossing (in future from OCDB)
172 }
173
174 //_____________________________________________________________________________
175 void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
176                                       TTree *clustersTree) const
177 {
178   //
179   // reconstruct clusters from digits
180   //
181
182   AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree")); 
183
184   TString optionString = GetOption();
185   // use V1 cluster finder if selected
186   if (optionString.Contains("ClusterizerV1")) {
187     /*
188     AliTOFClusterFinderV1 tofClus(fTOFcalib);
189
190     // decoder version option
191     if (optionString.Contains("DecoderV0")) {
192       tofClus.SetDecoderVersion(0);
193     }
194     else if (optionString.Contains("DecoderV1")) {
195       tofClus.SetDecoderVersion(1);
196     }
197     else {
198       tofClus.SetDecoderVersion(2);
199     }
200     
201     tofClus.Digits2RecPoints(digitsTree, clustersTree);
202     */
203     fClusterFinderV1->Digits2RecPoints(digitsTree, clustersTree);
204   }
205   else {
206     /*
207     AliTOFClusterFinder tofClus(fTOFcalib);
208
209     // decoder version option
210     if (optionString.Contains("DecoderV0")) {
211       tofClus.SetDecoderVersion(0);
212     }
213     else if (optionString.Contains("DecoderV1")) {
214       tofClus.SetDecoderVersion(1);
215     }
216     else {
217       tofClus.SetDecoderVersion(2);
218     }
219     
220     tofClus.Digits2RecPoints(digitsTree, clustersTree);
221     */
222
223     fClusterFinder->Digits2RecPoints(digitsTree, clustersTree);
224     AliTOFTrigger::PrepareTOFMapFromDigit(digitsTree);
225
226   }
227
228 }
229 //_____________________________________________________________________________
230   void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
231 {
232 // reconstruct clusters from digits
233
234   AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree")); 
235
236   TString optionString = GetOption();
237   // use V1 cluster finder if selected
238   if (optionString.Contains("ClusterizerV1")) {
239     /*
240     AliTOFClusterFinderV1 tofClus(fTOFcalib);
241
242     // decoder version option
243     if (optionString.Contains("DecoderV0")) {
244       tofClus.SetDecoderVersion(0);
245     }
246     else if (optionString.Contains("DecoderV1")) {
247       tofClus.SetDecoderVersion(1);
248     }
249     else {
250       tofClus.SetDecoderVersion(2);
251     }
252     
253     tofClus.Raw2Digits(reader, digitsTree);
254     */
255
256     fClusterFinderV1->Digits2RecPoints(reader, digitsTree);
257   }
258   else {
259     /*
260     AliTOFClusterFinder tofClus(fTOFcalib);
261
262     // decoder version option
263     if (optionString.Contains("DecoderV0")) {
264       tofClus.SetDecoderVersion(0);
265     }
266     else if (optionString.Contains("DecoderV1")) {
267       tofClus.SetDecoderVersion(1);
268     }
269     else {
270       tofClus.SetDecoderVersion(2);
271     }
272     
273     tofClus.Raw2Digits(reader, digitsTree);
274     */
275
276     fClusterFinder->Digits2RecPoints(reader, digitsTree);
277
278   }
279
280 }
281
282 //_____________________________________________________________________________
283 AliTracker* AliTOFReconstructor::CreateTracker() const
284 {
285
286   // 
287   // create a TOF tracker using 
288   // TOF Reco Param collected by STEER
289   //
290
291   TString selectedTracker = GetOption();
292  
293   AliTracker *tracker;
294   // use MI tracker if selected
295   if (selectedTracker.Contains("TrackerMI")) {
296     tracker = new AliTOFtrackerMI();
297   }
298   // use V1 tracker if selected
299   else if (selectedTracker.Contains("TrackerV1")) {
300     tracker =  new AliTOFtrackerV1();
301   }
302   else {
303     tracker = new AliTOFtracker();
304   }
305   return tracker;
306
307 }
308
309 //_____________________________________________________________________________
310 void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
311 {
312   //
313   // Fill AliESDEvent::fTOFHeader variable
314   // It contains the event_time estiamted by the TOF combinatorial algorithm
315   //
316
317
318   // Set here F. Noferini
319   AliTOFTriggerMask *mapTrigger = AliTOFTrigger::GetTOFTriggerMap();
320
321
322   TString optionString = GetOption();
323   if (optionString.Contains("ClusterizerV1")) {
324     fNumberOfTofClusters=fClusterFinderV1->GetNumberOfTOFclusters();
325     fNumberOfTofTrgPads=fClusterFinderV1->GetNumberOfTOFtrgPads();
326     AliInfo(Form(" Number of TOF cluster readout = %d ",fNumberOfTofClusters));
327     AliInfo(Form(" Number of TOF cluster readout in trigger window = %d ",fNumberOfTofTrgPads));
328   } else {
329     fNumberOfTofClusters=fClusterFinder->GetNumberOfTOFclusters();
330     fNumberOfTofTrgPads=fClusterFinder->GetNumberOfTOFtrgPads();
331     AliInfo(Form(" Number of TOF cluster readout = %d ",fNumberOfTofClusters));
332     AliInfo(Form(" Number of TOF cluster readout in trigger window = %d ",fNumberOfTofTrgPads));
333   }
334
335   if (!GetRecoParam()) AliFatal("cannot get TOF RECO params");
336
337   Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
338   AliTOFT0maker *tofT0maker = new AliTOFT0maker(esdPID);
339   tofT0maker->SetTimeResolution(tofResolution);
340   tofT0maker->ComputeT0TOF(event);
341   tofT0maker->WriteInESD(event);
342   tofT0maker->~AliTOFT0maker();
343   delete tofT0maker;
344
345   esdPID->SetTOFResponse(event,(AliESDpid::EStartTimeType_t)GetRecoParam()->GetStartTimeType());
346
347
348   event->GetTOFHeader()->SetNumberOfTOFclusters(fNumberOfTofClusters);
349   event->GetTOFHeader()->SetNumberOfTOFtrgPads(fNumberOfTofTrgPads);
350   event->GetTOFHeader()->SetTriggerMask(mapTrigger);
351   AliInfo(Form(" Number of readout cluster in trigger window = %d ; number of trgPads from Trigger map = %d",
352                event->GetTOFHeader()->GetNumberOfTOFtrgPads(),
353                event->GetTOFHeader()->GetNumberOfTOFmaxipad()));
354
355   fClusterFinderV1->ResetDigits();
356   fClusterFinderV1->ResetRecpoint();
357   fClusterFinder->ResetRecpoint();
358   fClusterFinderV1->Clear();
359   fClusterFinder->Clear();
360
361 }
362
363 //_____________________________________________________________________________
364 void 
365 AliTOFReconstructor::FillESD(TTree *, TTree *, AliESDEvent * /*esdEvent*/) const
366 {
367   //
368   // correct Texp 
369   // 
370   //
371
372   //  fTOFcalib->CalibrateTExp(esdEvent);
373 }