]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFReconstructor.cxx
consolidate zero-length arrays (aka struct hack)
[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
115179c6 16/* $Id: AliTOFReconstructor.cxx 59948 2012-12-12 11:05:59Z fnoferin $ */
121a60bd 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"
115179c6 40#include "AliTOFtrackerV2.h"
f858b00e 41#include "AliTOFT0maker.h"
d08a92dd 42#include "AliTOFReconstructor.h"
6786addd 43#include "AliTOFTriggerMask.h"
44#include "AliTOFTrigger.h"
121a60bd 45
0e46b9ae 46class TTree;
47
121a60bd 48ClassImp(AliTOFReconstructor)
49
a98acac1 50 //____________________________________________________________________
6786addd 51AliTOFReconstructor::AliTOFReconstructor() :
52 AliReconstructor(),
53 fTOFcalib(0),
54 /*fTOFT0maker(0),*/
55 fNumberOfTofClusters(0),
56 fNumberOfTofTrgPads(0),
57 fClusterFinder(0),
58 fClusterFinderV1(0)
a98acac1 59{
60//
61// ctor
62//
6b025efd 63
a98acac1 64 //Retrieving the TOF calibration info
5b4ed716 65 fTOFcalib = new AliTOFcalib();
66 fTOFcalib->Init();
6786addd 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
5b4ed716 85
86#if 0
24d1e16e 87 fTOFcalib->CreateCalObjects();
17149e6b 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
ba66add8 92 if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
2bf4d9d6 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);}
f04b3a69 98 if(!fTOFcalib->ReadRunParamsFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
5b4ed716 99#endif
100
a98acac1 101}
102
a98acac1 103//_____________________________________________________________________________
104AliTOFReconstructor::~AliTOFReconstructor()
105{
106//
107// dtor
108//
f858b00e 109
a98acac1 110 delete fTOFcalib;
f858b00e 111
112 //delete fTOFT0maker;
6786addd 113 fNumberOfTofClusters = 0;
114 fNumberOfTofTrgPads = 0;
f858b00e 115
6786addd 116 delete fClusterFinder;
117 delete fClusterFinderV1;
a98acac1 118}
119
d08a92dd 120//_____________________________________________________________________________
121void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
122 TTree *clustersTree) const
123{
e3bd5504 124 //
125 // reconstruct clusters from Raw Data
126 //
127
17bb1d52 128 TString optionString = GetOption();
5b4ed716 129
e3bd5504 130 // use V1 cluster finder if selected
17bb1d52 131 if (optionString.Contains("ClusterizerV1")) {
6786addd 132 /*
133 AliTOFClusterFinderV1 tofClus(fTOFcalib);
17bb1d52 134
135 // decoder version option
5b4ed716 136 if (optionString.Contains("DecoderV0")) {
17bb1d52 137 tofClus.SetDecoderVersion(0);
5b4ed716 138 }
139 else if (optionString.Contains("DecoderV1")) {
22f79281 140 tofClus.SetDecoderVersion(1);
5b4ed716 141 }
142 else {
143 tofClus.SetDecoderVersion(2);
144 }
6786addd 145
e3bd5504 146 tofClus.Digits2RecPoints(rawReader, clustersTree);
6786addd 147 */
148
149 fClusterFinderV1->Digits2RecPoints(rawReader, clustersTree);
e3bd5504 150 }
151 else {
6786addd 152 /*
153 AliTOFClusterFinder tofClus(fTOFcalib);
154
17bb1d52 155 // decoder version option
5b4ed716 156 if (optionString.Contains("DecoderV0")) {
17bb1d52 157 tofClus.SetDecoderVersion(0);
5b4ed716 158 }
159 else if (optionString.Contains("DecoderV1")) {
22f79281 160 tofClus.SetDecoderVersion(1);
5b4ed716 161 }
162 else {
163 tofClus.SetDecoderVersion(2);
164 }
17bb1d52 165
e3bd5504 166 tofClus.Digits2RecPoints(rawReader, clustersTree);
121a60bd 167
6786addd 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)
121a60bd 173}
174
a98acac1 175//_____________________________________________________________________________
176void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
177 TTree *clustersTree) const
178{
e3bd5504 179 //
180 // reconstruct clusters from digits
181 //
a98acac1 182
183 AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree"));
e3bd5504 184
17bb1d52 185 TString optionString = GetOption();
e3bd5504 186 // use V1 cluster finder if selected
17bb1d52 187 if (optionString.Contains("ClusterizerV1")) {
6786addd 188 /*
189 AliTOFClusterFinderV1 tofClus(fTOFcalib);
17bb1d52 190
191 // decoder version option
5b4ed716 192 if (optionString.Contains("DecoderV0")) {
17bb1d52 193 tofClus.SetDecoderVersion(0);
5b4ed716 194 }
195 else if (optionString.Contains("DecoderV1")) {
22f79281 196 tofClus.SetDecoderVersion(1);
5b4ed716 197 }
198 else {
199 tofClus.SetDecoderVersion(2);
200 }
17bb1d52 201
e3bd5504 202 tofClus.Digits2RecPoints(digitsTree, clustersTree);
6786addd 203 */
204 fClusterFinderV1->Digits2RecPoints(digitsTree, clustersTree);
e3bd5504 205 }
206 else {
6786addd 207 /*
208 AliTOFClusterFinder tofClus(fTOFcalib);
17bb1d52 209
210 // decoder version option
5b4ed716 211 if (optionString.Contains("DecoderV0")) {
17bb1d52 212 tofClus.SetDecoderVersion(0);
5b4ed716 213 }
214 else if (optionString.Contains("DecoderV1")) {
22f79281 215 tofClus.SetDecoderVersion(1);
5b4ed716 216 }
217 else {
218 tofClus.SetDecoderVersion(2);
219 }
17bb1d52 220
e3bd5504 221 tofClus.Digits2RecPoints(digitsTree, clustersTree);
6786addd 222 */
223
224 fClusterFinder->Digits2RecPoints(digitsTree, clustersTree);
225 AliTOFTrigger::PrepareTOFMapFromDigit(digitsTree);
226
e3bd5504 227 }
a98acac1 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"));
e3bd5504 236
17bb1d52 237 TString optionString = GetOption();
e3bd5504 238 // use V1 cluster finder if selected
17bb1d52 239 if (optionString.Contains("ClusterizerV1")) {
6786addd 240 /*
241 AliTOFClusterFinderV1 tofClus(fTOFcalib);
17bb1d52 242
243 // decoder version option
5b4ed716 244 if (optionString.Contains("DecoderV0")) {
17bb1d52 245 tofClus.SetDecoderVersion(0);
5b4ed716 246 }
247 else if (optionString.Contains("DecoderV1")) {
22f79281 248 tofClus.SetDecoderVersion(1);
5b4ed716 249 }
250 else {
251 tofClus.SetDecoderVersion(2);
252 }
17bb1d52 253
e3bd5504 254 tofClus.Raw2Digits(reader, digitsTree);
6786addd 255 */
256
257 fClusterFinderV1->Digits2RecPoints(reader, digitsTree);
e3bd5504 258 }
259 else {
6786addd 260 /*
261 AliTOFClusterFinder tofClus(fTOFcalib);
17bb1d52 262
263 // decoder version option
5b4ed716 264 if (optionString.Contains("DecoderV0")) {
17bb1d52 265 tofClus.SetDecoderVersion(0);
5b4ed716 266 }
267 else if (optionString.Contains("DecoderV1")) {
22f79281 268 tofClus.SetDecoderVersion(1);
5b4ed716 269 }
270 else {
271 tofClus.SetDecoderVersion(2);
272 }
17bb1d52 273
e3bd5504 274 tofClus.Raw2Digits(reader, digitsTree);
6786addd 275 */
276
277 fClusterFinder->Digits2RecPoints(reader, digitsTree);
278
e3bd5504 279 }
a98acac1 280
281}
282
121a60bd 283//_____________________________________________________________________________
d76c31f4 284AliTracker* AliTOFReconstructor::CreateTracker() const
121a60bd 285{
3a646035 286
287 //
288 // create a TOF tracker using
289 // TOF Reco Param collected by STEER
290 //
121a60bd 291
d88fbf15 292 TString selectedTracker = GetOption();
3a646035 293
294 AliTracker *tracker;
d88fbf15 295 // use MI tracker if selected
17bb1d52 296 if (selectedTracker.Contains("TrackerMI")) {
3a646035 297 tracker = new AliTOFtrackerMI();
298 }
299 // use V1 tracker if selected
a572506f 300 else if (selectedTracker.Contains("TrackerV1")) {
3a646035 301 tracker = new AliTOFtrackerV1();
302 }
115179c6 303 else if (selectedTracker.Contains("TrackerV2")) {
304 tracker = new AliTOFtrackerV2();
305 }
3a646035 306 else {
307 tracker = new AliTOFtracker();
308 }
309 return tracker;
121a60bd 310
e3bd5504 311}
f858b00e 312
313//_____________________________________________________________________________
314void 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
6786addd 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
5c1e5810 339 if (!GetRecoParam()) AliFatal("cannot get TOF RECO params");
340
f858b00e 341 Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
d486a5ef 342 AliTOFT0maker *tofT0maker = new AliTOFT0maker(esdPID);
f858b00e 343 tofT0maker->SetTimeResolution(tofResolution);
344 tofT0maker->ComputeT0TOF(event);
345 tofT0maker->WriteInESD(event);
346 tofT0maker->~AliTOFT0maker();
347 delete tofT0maker;
348
d486a5ef 349 esdPID->SetTOFResponse(event,(AliESDpid::EStartTimeType_t)GetRecoParam()->GetStartTimeType());
350
6786addd 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
f858b00e 365}
366
c2fb5b09 367//_____________________________________________________________________________
368void
35b6d6a6 369AliTOFReconstructor::FillESD(TTree *, TTree *, AliESDEvent * /*esdEvent*/) const
c2fb5b09 370{
371 //
372 // correct Texp
373 //
374 //
375
5a388465 376 // fTOFcalib->CalibrateTExp(esdEvent);
c2fb5b09 377}