Adding a reminder for coders
[u/mrichter/AliRoot.git] / TOF / AliTOFReconstructor.cxx
CommitLineData
121a60bd 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
b09247a2 24#include <cstdlib>
6b025efd 25#include "TObjArray.h"
26#include "TString.h"
d08a92dd 27
28#include "AliLog.h"
f858b00e 29#include "AliESDEvent.h"
30#include "AliESDpid.h"
0e46b9ae 31#include "AliRawReader.h"
f858b00e 32#include "AliTOFHeader.h"
d08a92dd 33
0e46b9ae 34#include "AliTOFClusterFinder.h"
e3bd5504 35#include "AliTOFClusterFinderV1.h"
a98acac1 36#include "AliTOFcalib.h"
d88fbf15 37#include "AliTOFtrackerMI.h"
0e46b9ae 38#include "AliTOFtracker.h"
eeef0c5d 39#include "AliTOFtrackerV1.h"
f858b00e 40#include "AliTOFT0maker.h"
d08a92dd 41#include "AliTOFReconstructor.h"
121a60bd 42
0e46b9ae 43class TTree;
44
121a60bd 45ClassImp(AliTOFReconstructor)
46
a98acac1 47 //____________________________________________________________________
48AliTOFReconstructor::AliTOFReconstructor()
49 : AliReconstructor(),
f858b00e 50 fTOFcalib(0)/*,
51 fTOFT0maker(0)*/
a98acac1 52{
53//
54// ctor
55//
6b025efd 56
a98acac1 57 //Retrieving the TOF calibration info
5b4ed716 58 fTOFcalib = new AliTOFcalib();
59 fTOFcalib->Init();
60
61#if 0
24d1e16e 62 fTOFcalib->CreateCalObjects();
17149e6b 63
64 if(!fTOFcalib->ReadParOnlineDelayFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
65 if(!fTOFcalib->ReadParOnlineStatusFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
66
ba66add8 67 if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
2bf4d9d6 68
69
70 if(!fTOFcalib->ReadDeltaBCOffsetFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
71 if(!fTOFcalib->ReadCTPLatencyFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
72 if(!fTOFcalib->ReadT0FillFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
f04b3a69 73 if(!fTOFcalib->ReadRunParamsFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
5b4ed716 74#endif
75
a98acac1 76}
77
a98acac1 78//_____________________________________________________________________________
79AliTOFReconstructor::~AliTOFReconstructor()
80{
81//
82// dtor
83//
f858b00e 84
a98acac1 85 delete fTOFcalib;
f858b00e 86
87 //delete fTOFT0maker;
88
a98acac1 89}
90
121a60bd 91//_____________________________________________________________________________
d08a92dd 92void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
93 TTree *clustersTree) const
94{
e3bd5504 95 //
96 // reconstruct clusters from Raw Data
97 //
98
17bb1d52 99 TString optionString = GetOption();
5b4ed716 100
e3bd5504 101 // use V1 cluster finder if selected
17bb1d52 102 if (optionString.Contains("ClusterizerV1")) {
e3bd5504 103 static AliTOFClusterFinderV1 tofClus(fTOFcalib);
17bb1d52 104
105 // decoder version option
5b4ed716 106 if (optionString.Contains("DecoderV0")) {
17bb1d52 107 tofClus.SetDecoderVersion(0);
5b4ed716 108 }
109 else if (optionString.Contains("DecoderV1")) {
22f79281 110 tofClus.SetDecoderVersion(1);
5b4ed716 111 }
112 else {
113 tofClus.SetDecoderVersion(2);
114 }
17bb1d52 115
e3bd5504 116 tofClus.Digits2RecPoints(rawReader, clustersTree);
117 }
118 else {
119 static AliTOFClusterFinder tofClus(fTOFcalib);
17bb1d52 120
121 // decoder version option
5b4ed716 122 if (optionString.Contains("DecoderV0")) {
17bb1d52 123 tofClus.SetDecoderVersion(0);
5b4ed716 124 }
125 else if (optionString.Contains("DecoderV1")) {
22f79281 126 tofClus.SetDecoderVersion(1);
5b4ed716 127 }
128 else {
129 tofClus.SetDecoderVersion(2);
130 }
17bb1d52 131
e3bd5504 132 tofClus.Digits2RecPoints(rawReader, clustersTree);
133 }
121a60bd 134
135}
136
137//_____________________________________________________________________________
a98acac1 138void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
139 TTree *clustersTree) const
140{
e3bd5504 141 //
142 // reconstruct clusters from digits
143 //
a98acac1 144
145 AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree"));
e3bd5504 146
17bb1d52 147 TString optionString = GetOption();
e3bd5504 148 // use V1 cluster finder if selected
17bb1d52 149 if (optionString.Contains("ClusterizerV1")) {
e3bd5504 150 static AliTOFClusterFinderV1 tofClus(fTOFcalib);
17bb1d52 151
152 // decoder version option
5b4ed716 153 if (optionString.Contains("DecoderV0")) {
17bb1d52 154 tofClus.SetDecoderVersion(0);
5b4ed716 155 }
156 else if (optionString.Contains("DecoderV1")) {
22f79281 157 tofClus.SetDecoderVersion(1);
5b4ed716 158 }
159 else {
160 tofClus.SetDecoderVersion(2);
161 }
17bb1d52 162
e3bd5504 163 tofClus.Digits2RecPoints(digitsTree, clustersTree);
164 }
165 else {
166 static AliTOFClusterFinder tofClus(fTOFcalib);
17bb1d52 167
168 // decoder version option
5b4ed716 169 if (optionString.Contains("DecoderV0")) {
17bb1d52 170 tofClus.SetDecoderVersion(0);
5b4ed716 171 }
172 else if (optionString.Contains("DecoderV1")) {
22f79281 173 tofClus.SetDecoderVersion(1);
5b4ed716 174 }
175 else {
176 tofClus.SetDecoderVersion(2);
177 }
17bb1d52 178
e3bd5504 179 tofClus.Digits2RecPoints(digitsTree, clustersTree);
180 }
a98acac1 181
182}
183//_____________________________________________________________________________
184 void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
185{
186// reconstruct clusters from digits
187
188 AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree"));
e3bd5504 189
17bb1d52 190 TString optionString = GetOption();
e3bd5504 191 // use V1 cluster finder if selected
17bb1d52 192 if (optionString.Contains("ClusterizerV1")) {
e3bd5504 193 static AliTOFClusterFinderV1 tofClus(fTOFcalib);
17bb1d52 194
195 // decoder version option
5b4ed716 196 if (optionString.Contains("DecoderV0")) {
17bb1d52 197 tofClus.SetDecoderVersion(0);
5b4ed716 198 }
199 else if (optionString.Contains("DecoderV1")) {
22f79281 200 tofClus.SetDecoderVersion(1);
5b4ed716 201 }
202 else {
203 tofClus.SetDecoderVersion(2);
204 }
17bb1d52 205
e3bd5504 206 tofClus.Raw2Digits(reader, digitsTree);
207 }
208 else {
209 static AliTOFClusterFinder tofClus(fTOFcalib);
17bb1d52 210
211 // decoder version option
5b4ed716 212 if (optionString.Contains("DecoderV0")) {
17bb1d52 213 tofClus.SetDecoderVersion(0);
5b4ed716 214 }
215 else if (optionString.Contains("DecoderV1")) {
22f79281 216 tofClus.SetDecoderVersion(1);
5b4ed716 217 }
218 else {
219 tofClus.SetDecoderVersion(2);
220 }
17bb1d52 221
e3bd5504 222 tofClus.Raw2Digits(reader, digitsTree);
223 }
a98acac1 224
225}
226
227//_____________________________________________________________________________
d76c31f4 228AliTracker* AliTOFReconstructor::CreateTracker() const
121a60bd 229{
3a646035 230
231 //
232 // create a TOF tracker using
233 // TOF Reco Param collected by STEER
234 //
121a60bd 235
d88fbf15 236 TString selectedTracker = GetOption();
3a646035 237
238 AliTracker *tracker;
d88fbf15 239 // use MI tracker if selected
17bb1d52 240 if (selectedTracker.Contains("TrackerMI")) {
3a646035 241 tracker = new AliTOFtrackerMI();
242 }
243 // use V1 tracker if selected
a572506f 244 else if (selectedTracker.Contains("TrackerV1")) {
3a646035 245 tracker = new AliTOFtrackerV1();
246 }
247 else {
248 tracker = new AliTOFtracker();
249 }
250 return tracker;
121a60bd 251
e3bd5504 252}
f858b00e 253
254//_____________________________________________________________________________
255void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
256{
257 //
258 // Fill AliESDEvent::fTOFHeader variable
259 // It contains the event_time estiamted by the TOF combinatorial algorithm
260 //
261
5c1e5810 262 if (!GetRecoParam()) AliFatal("cannot get TOF RECO params");
263
f858b00e 264 Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
d486a5ef 265 AliTOFT0maker *tofT0maker = new AliTOFT0maker(esdPID);
f858b00e 266 tofT0maker->SetTimeResolution(tofResolution);
267 tofT0maker->ComputeT0TOF(event);
268 tofT0maker->WriteInESD(event);
269 tofT0maker->~AliTOFT0maker();
270 delete tofT0maker;
271
d486a5ef 272 esdPID->SetTOFResponse(event,(AliESDpid::EStartTimeType_t)GetRecoParam()->GetStartTimeType());
273
f858b00e 274}
275
c2fb5b09 276//_____________________________________________________________________________
277void
35b6d6a6 278AliTOFReconstructor::FillESD(TTree *, TTree *, AliESDEvent * /*esdEvent*/) const
c2fb5b09 279{
280 //
281 // correct Texp
282 //
283 //
284
5a388465 285 // fTOFcalib->CalibrateTExp(esdEvent);
c2fb5b09 286}