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