1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for TOF reconstruction //
22 ///////////////////////////////////////////////////////////////////////////////
25 #include "TObjArray.h"
29 #include "AliESDEvent.h"
30 #include "AliESDpid.h"
31 #include "AliRawReader.h"
32 #include "AliTOFHeader.h"
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"
47 ClassImp(AliTOFReconstructor)
49 //____________________________________________________________________
50 AliTOFReconstructor::AliTOFReconstructor() :
54 fNumberOfTofClusters(0),
55 fNumberOfTofTrgPads(0),
63 //Retrieving the TOF calibration info
64 fTOFcalib = new AliTOFcalib();
66 fClusterFinder = new AliTOFClusterFinder(fTOFcalib);
67 fClusterFinderV1 = new AliTOFClusterFinderV1(fTOFcalib);
69 TString optionString = GetOption();
70 if (optionString.Contains("DecoderV0")) {
71 fClusterFinder->SetDecoderVersion(0);
72 fClusterFinderV1->SetDecoderVersion(0);
74 else if (optionString.Contains("DecoderV1")) {
75 fClusterFinder->SetDecoderVersion(1);
76 fClusterFinderV1->SetDecoderVersion(1);
79 fClusterFinder->SetDecoderVersion(2);
80 fClusterFinderV1->SetDecoderVersion(2);
86 fTOFcalib->CreateCalObjects();
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);}
91 if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
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);}
102 //_____________________________________________________________________________
103 AliTOFReconstructor::~AliTOFReconstructor()
111 //delete fTOFT0maker;
112 fNumberOfTofClusters = 0;
113 fNumberOfTofTrgPads = 0;
115 delete fClusterFinder;
116 delete fClusterFinderV1;
119 //_____________________________________________________________________________
120 void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
121 TTree *clustersTree) const
124 // reconstruct clusters from Raw Data
127 TString optionString = GetOption();
129 // use V1 cluster finder if selected
130 if (optionString.Contains("ClusterizerV1")) {
132 AliTOFClusterFinderV1 tofClus(fTOFcalib);
134 // decoder version option
135 if (optionString.Contains("DecoderV0")) {
136 tofClus.SetDecoderVersion(0);
138 else if (optionString.Contains("DecoderV1")) {
139 tofClus.SetDecoderVersion(1);
142 tofClus.SetDecoderVersion(2);
145 tofClus.Digits2RecPoints(rawReader, clustersTree);
148 fClusterFinderV1->Digits2RecPoints(rawReader, clustersTree);
152 AliTOFClusterFinder tofClus(fTOFcalib);
154 // decoder version option
155 if (optionString.Contains("DecoderV0")) {
156 tofClus.SetDecoderVersion(0);
158 else if (optionString.Contains("DecoderV1")) {
159 tofClus.SetDecoderVersion(1);
162 tofClus.SetDecoderVersion(2);
165 tofClus.Digits2RecPoints(rawReader, clustersTree);
169 fClusterFinder->Digits2RecPoints(rawReader, clustersTree);
171 AliTOFTrigger::PrepareTOFMapFromRaw(rawReader,13600); // 13600 +/- 400 is the value to select the richt bunch crossing (in future from OCDB)
174 //_____________________________________________________________________________
175 void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
176 TTree *clustersTree) const
179 // reconstruct clusters from digits
182 AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree"));
184 TString optionString = GetOption();
185 // use V1 cluster finder if selected
186 if (optionString.Contains("ClusterizerV1")) {
188 AliTOFClusterFinderV1 tofClus(fTOFcalib);
190 // decoder version option
191 if (optionString.Contains("DecoderV0")) {
192 tofClus.SetDecoderVersion(0);
194 else if (optionString.Contains("DecoderV1")) {
195 tofClus.SetDecoderVersion(1);
198 tofClus.SetDecoderVersion(2);
201 tofClus.Digits2RecPoints(digitsTree, clustersTree);
203 fClusterFinderV1->Digits2RecPoints(digitsTree, clustersTree);
207 AliTOFClusterFinder tofClus(fTOFcalib);
209 // decoder version option
210 if (optionString.Contains("DecoderV0")) {
211 tofClus.SetDecoderVersion(0);
213 else if (optionString.Contains("DecoderV1")) {
214 tofClus.SetDecoderVersion(1);
217 tofClus.SetDecoderVersion(2);
220 tofClus.Digits2RecPoints(digitsTree, clustersTree);
223 fClusterFinder->Digits2RecPoints(digitsTree, clustersTree);
224 AliTOFTrigger::PrepareTOFMapFromDigit(digitsTree);
229 //_____________________________________________________________________________
230 void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
232 // reconstruct clusters from digits
234 AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree"));
236 TString optionString = GetOption();
237 // use V1 cluster finder if selected
238 if (optionString.Contains("ClusterizerV1")) {
240 AliTOFClusterFinderV1 tofClus(fTOFcalib);
242 // decoder version option
243 if (optionString.Contains("DecoderV0")) {
244 tofClus.SetDecoderVersion(0);
246 else if (optionString.Contains("DecoderV1")) {
247 tofClus.SetDecoderVersion(1);
250 tofClus.SetDecoderVersion(2);
253 tofClus.Raw2Digits(reader, digitsTree);
256 fClusterFinderV1->Digits2RecPoints(reader, digitsTree);
260 AliTOFClusterFinder tofClus(fTOFcalib);
262 // decoder version option
263 if (optionString.Contains("DecoderV0")) {
264 tofClus.SetDecoderVersion(0);
266 else if (optionString.Contains("DecoderV1")) {
267 tofClus.SetDecoderVersion(1);
270 tofClus.SetDecoderVersion(2);
273 tofClus.Raw2Digits(reader, digitsTree);
276 fClusterFinder->Digits2RecPoints(reader, digitsTree);
282 //_____________________________________________________________________________
283 AliTracker* AliTOFReconstructor::CreateTracker() const
287 // create a TOF tracker using
288 // TOF Reco Param collected by STEER
291 TString selectedTracker = GetOption();
294 // use MI tracker if selected
295 if (selectedTracker.Contains("TrackerMI")) {
296 tracker = new AliTOFtrackerMI();
298 // use V1 tracker if selected
299 else if (selectedTracker.Contains("TrackerV1")) {
300 tracker = new AliTOFtrackerV1();
303 tracker = new AliTOFtracker();
309 //_____________________________________________________________________________
310 void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
313 // Fill AliESDEvent::fTOFHeader variable
314 // It contains the event_time estiamted by the TOF combinatorial algorithm
318 // Set here F. Noferini
319 AliTOFTriggerMask *mapTrigger = AliTOFTrigger::GetTOFTriggerMap();
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));
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));
335 if (!GetRecoParam()) AliFatal("cannot get TOF RECO params");
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();
345 esdPID->SetTOFResponse(event,(AliESDpid::EStartTimeType_t)GetRecoParam()->GetStartTimeType());
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()));
355 fClusterFinderV1->ResetDigits();
356 fClusterFinderV1->ResetRecpoint();
357 fClusterFinder->ResetRecpoint();
358 fClusterFinderV1->Clear();
359 fClusterFinder->Clear();
363 //_____________________________________________________________________________
365 AliTOFReconstructor::FillESD(TTree *, TTree *, AliESDEvent * /*esdEvent*/) const
372 // fTOFcalib->CalibrateTExp(esdEvent);