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 **************************************************************************/
16 /* $Id: AliTOFReconstructor.cxx 59948 2012-12-12 11:05:59Z fnoferin $ */
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 "AliTOFtrackerV2.h"
41 #include "AliTOFT0maker.h"
42 #include "AliTOFReconstructor.h"
43 #include "AliTOFTriggerMask.h"
44 #include "AliTOFTrigger.h"
48 ClassImp(AliTOFReconstructor)
50 //____________________________________________________________________
51 AliTOFReconstructor::AliTOFReconstructor() :
55 fNumberOfTofClusters(0),
56 fNumberOfTofTrgPads(0),
64 //Retrieving the TOF calibration info
65 fTOFcalib = new AliTOFcalib();
67 fClusterFinder = new AliTOFClusterFinder(fTOFcalib);
68 fClusterFinderV1 = new AliTOFClusterFinderV1(fTOFcalib);
70 TString optionString = GetOption();
71 if (optionString.Contains("DecoderV0")) {
72 fClusterFinder->SetDecoderVersion(0);
73 fClusterFinderV1->SetDecoderVersion(0);
75 else if (optionString.Contains("DecoderV1")) {
76 fClusterFinder->SetDecoderVersion(1);
77 fClusterFinderV1->SetDecoderVersion(1);
80 fClusterFinder->SetDecoderVersion(2);
81 fClusterFinderV1->SetDecoderVersion(2);
87 fTOFcalib->CreateCalObjects();
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);}
92 if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
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);}
103 //_____________________________________________________________________________
104 AliTOFReconstructor::~AliTOFReconstructor()
112 //delete fTOFT0maker;
113 fNumberOfTofClusters = 0;
114 fNumberOfTofTrgPads = 0;
116 delete fClusterFinder;
117 delete fClusterFinderV1;
120 //_____________________________________________________________________________
121 void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
122 TTree *clustersTree) const
125 // reconstruct clusters from Raw Data
128 TString optionString = GetOption();
130 // use V1 cluster finder if selected
131 if (optionString.Contains("ClusterizerV1")) {
133 AliTOFClusterFinderV1 tofClus(fTOFcalib);
135 // decoder version option
136 if (optionString.Contains("DecoderV0")) {
137 tofClus.SetDecoderVersion(0);
139 else if (optionString.Contains("DecoderV1")) {
140 tofClus.SetDecoderVersion(1);
143 tofClus.SetDecoderVersion(2);
146 tofClus.Digits2RecPoints(rawReader, clustersTree);
149 fClusterFinderV1->Digits2RecPoints(rawReader, clustersTree);
153 AliTOFClusterFinder tofClus(fTOFcalib);
155 // decoder version option
156 if (optionString.Contains("DecoderV0")) {
157 tofClus.SetDecoderVersion(0);
159 else if (optionString.Contains("DecoderV1")) {
160 tofClus.SetDecoderVersion(1);
163 tofClus.SetDecoderVersion(2);
166 tofClus.Digits2RecPoints(rawReader, clustersTree);
170 fClusterFinder->Digits2RecPoints(rawReader, clustersTree);
172 AliTOFTrigger::PrepareTOFMapFromRaw(rawReader,13600); // 13600 +/- 400 is the value to select the richt bunch crossing (in future from OCDB)
175 //_____________________________________________________________________________
176 void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
177 TTree *clustersTree) const
180 // reconstruct clusters from digits
183 AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree"));
185 TString optionString = GetOption();
186 // use V1 cluster finder if selected
187 if (optionString.Contains("ClusterizerV1")) {
189 AliTOFClusterFinderV1 tofClus(fTOFcalib);
191 // decoder version option
192 if (optionString.Contains("DecoderV0")) {
193 tofClus.SetDecoderVersion(0);
195 else if (optionString.Contains("DecoderV1")) {
196 tofClus.SetDecoderVersion(1);
199 tofClus.SetDecoderVersion(2);
202 tofClus.Digits2RecPoints(digitsTree, clustersTree);
204 fClusterFinderV1->Digits2RecPoints(digitsTree, clustersTree);
208 AliTOFClusterFinder tofClus(fTOFcalib);
210 // decoder version option
211 if (optionString.Contains("DecoderV0")) {
212 tofClus.SetDecoderVersion(0);
214 else if (optionString.Contains("DecoderV1")) {
215 tofClus.SetDecoderVersion(1);
218 tofClus.SetDecoderVersion(2);
221 tofClus.Digits2RecPoints(digitsTree, clustersTree);
224 fClusterFinder->Digits2RecPoints(digitsTree, clustersTree);
225 AliTOFTrigger::PrepareTOFMapFromDigit(digitsTree);
230 //_____________________________________________________________________________
231 void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
233 // reconstruct clusters from digits
235 AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree"));
237 TString optionString = GetOption();
238 // use V1 cluster finder if selected
239 if (optionString.Contains("ClusterizerV1")) {
241 AliTOFClusterFinderV1 tofClus(fTOFcalib);
243 // decoder version option
244 if (optionString.Contains("DecoderV0")) {
245 tofClus.SetDecoderVersion(0);
247 else if (optionString.Contains("DecoderV1")) {
248 tofClus.SetDecoderVersion(1);
251 tofClus.SetDecoderVersion(2);
254 tofClus.Raw2Digits(reader, digitsTree);
257 fClusterFinderV1->Digits2RecPoints(reader, digitsTree);
261 AliTOFClusterFinder tofClus(fTOFcalib);
263 // decoder version option
264 if (optionString.Contains("DecoderV0")) {
265 tofClus.SetDecoderVersion(0);
267 else if (optionString.Contains("DecoderV1")) {
268 tofClus.SetDecoderVersion(1);
271 tofClus.SetDecoderVersion(2);
274 tofClus.Raw2Digits(reader, digitsTree);
277 fClusterFinder->Digits2RecPoints(reader, digitsTree);
283 //_____________________________________________________________________________
284 AliTracker* AliTOFReconstructor::CreateTracker() const
288 // create a TOF tracker using
289 // TOF Reco Param collected by STEER
292 TString selectedTracker = GetOption();
295 // use MI tracker if selected
296 if (selectedTracker.Contains("TrackerMI")) {
297 tracker = new AliTOFtrackerMI();
299 // use V1 tracker if selected
300 else if (selectedTracker.Contains("TrackerV1")) {
301 tracker = new AliTOFtrackerV1();
303 else if (selectedTracker.Contains("TrackerV2")) {
304 tracker = new AliTOFtrackerV2();
307 tracker = new AliTOFtracker();
313 //_____________________________________________________________________________
314 void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
317 // Fill AliESDEvent::fTOFHeader variable
318 // It contains the event_time estiamted by the TOF combinatorial algorithm
322 // Set here F. Noferini
323 AliTOFTriggerMask *mapTrigger = AliTOFTrigger::GetTOFTriggerMap();
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));
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));
339 if (!GetRecoParam()) AliFatal("cannot get TOF RECO params");
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();
349 esdPID->SetTOFResponse(event,(AliESDpid::EStartTimeType_t)GetRecoParam()->GetStartTimeType());
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()));
359 fClusterFinderV1->ResetDigits();
360 fClusterFinderV1->ResetRecpoint();
361 fClusterFinder->ResetRecpoint();
362 fClusterFinderV1->Clear();
363 fClusterFinder->Clear();
367 //_____________________________________________________________________________
369 AliTOFReconstructor::FillESD(TTree *, TTree *, AliESDEvent * /*esdEvent*/) const
376 // fTOFcalib->CalibrateTExp(esdEvent);