New AliTRDcluster constructor
[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
0e46b9ae 24#include "TFile.h"
d08a92dd 25
26#include "AliLog.h"
0e46b9ae 27#include "AliRawReader.h"
d08a92dd 28#include "AliRunLoader.h"
29
0e46b9ae 30#include "AliTOFClusterFinder.h"
d3c7bfac 31#include "AliTOFGeometry.h"
0f49d1bc 32#include "AliTOFGeometryV5.h"
a98acac1 33#include "AliTOFcalib.h"
d88fbf15 34#include "AliTOFtrackerMI.h"
0e46b9ae 35#include "AliTOFtracker.h"
d08a92dd 36#include "AliTOFReconstructor.h"
121a60bd 37
0e46b9ae 38class TTree;
39
40class AliESD;
41
42extern TDirectory *gDirectory;
43extern TFile *gFile;
44
121a60bd 45ClassImp(AliTOFReconstructor)
46
a98acac1 47 //____________________________________________________________________
48AliTOFReconstructor::AliTOFReconstructor()
49 : AliReconstructor(),
50 fTOFGeometry(0),
51 fTOFcalib(0)
52{
53//
54// ctor
55//
56 //Retrieving the TOF calibration info
57 fTOFGeometry = new AliTOFGeometryV5();
58 fTOFcalib = new AliTOFcalib(fTOFGeometry);
59 if(!fTOFcalib->ReadParFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}
60}
61
62//------------------------------------------------------------------------
63AliTOFReconstructor::AliTOFReconstructor(const AliTOFReconstructor &source)
64 : AliReconstructor(),
65 fTOFGeometry(0),
66 fTOFcalib(0)
67{
68//
69// copy ctor
70//
71 this->fTOFGeometry=source.fTOFGeometry;
72 this->fTOFcalib=source.fTOFcalib;
73}
74
75//------------------------------------------------------------------------
76AliTOFReconstructor & AliTOFReconstructor::operator=(const AliTOFReconstructor &source)
77{
78//
79// assignment op.
80//
81 this->fTOFGeometry=source.fTOFGeometry;
82 this->fTOFcalib=source.fTOFcalib;
83 return *this;
84}
85//_____________________________________________________________________________
86AliTOFReconstructor::~AliTOFReconstructor()
87{
88//
89// dtor
90//
91 delete fTOFGeometry;
92 delete fTOFcalib;
93}
94
121a60bd 95//_____________________________________________________________________________
7b61cd9c 96 void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader) const
121a60bd 97{
d08a92dd 98// reconstruct clusters from digits
7b61cd9c 99
a98acac1 100 AliTOFClusterFinder tofClus(runLoader, fTOFcalib);
4ab68796 101 tofClus.Load();
d08a92dd 102 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++)
103 {
a98acac1 104 AliDebug(2,Form("Local Event loop mode: Creating Recpoints from Digits, Event n. %i",iEvent));
4ab68796 105 tofClus.Digits2RecPoints(iEvent);
d08a92dd 106 }
4ab68796 107 tofClus.UnLoad();
7b61cd9c 108
d08a92dd 109}
110
111//_____________________________________________________________________________
112void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader,
113 AliRawReader *rawReader) const
114{
115// reconstruct clusters from Raw Data
116
a98acac1 117 AliTOFClusterFinder tofClus(runLoader, fTOFcalib);
d08a92dd 118 tofClus.LoadClusters();
119 Int_t iEvent = 0;
120 while (rawReader->NextEvent()) {
a98acac1 121 AliDebug(2,Form("Local Event loop mode: Creating Recpoints from Raw data, Event n. %i",iEvent));
7b61cd9c 122 tofClus.Digits2RecPoints(iEvent,rawReader);
d08a92dd 123 iEvent++;
124 }
125 tofClus.UnLoadClusters();
126
127}
128
129//_____________________________________________________________________________
130void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
131 TTree *clustersTree) const
132{
133// reconstruct clusters from Raw Data
134
a98acac1 135 AliTOFClusterFinder tofClus(fTOFcalib);
d08a92dd 136 tofClus.Digits2RecPoints(rawReader, clustersTree);
121a60bd 137
138}
139
140//_____________________________________________________________________________
a98acac1 141void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
142 TTree *clustersTree) const
143{
144// reconstruct clusters from Raw Data
145
146 AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree"));
147 AliTOFClusterFinder tofClus(fTOFcalib);
148 tofClus.Digits2RecPoints(digitsTree, clustersTree);
149
150}
151//_____________________________________________________________________________
152 void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
153{
154// reconstruct clusters from digits
155
156 AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree"));
157 AliTOFClusterFinder tofClus(fTOFcalib);
158 tofClus.Raw2Digits(reader, digitsTree);
159
160}
161
162//_____________________________________________________________________________
3a3ece53 163AliTracker* AliTOFReconstructor::CreateTracker(AliRunLoader* /*runLoader*/) const
121a60bd 164{
165// create a TOF tracker
166
d88fbf15 167 TString selectedTracker = GetOption();
168 // use MI tracker if selected
bc9f08da 169 if (selectedTracker.Contains("MI")) return new AliTOFtrackerMI();
170 return new AliTOFtracker();
121a60bd 171}
172
173//_____________________________________________________________________________
174void AliTOFReconstructor::FillESD(AliRunLoader* /*runLoader*/,
175 AliESD* /*esd*/) const
176{
177// nothing to be done
178
179}
180
121a60bd 181//_____________________________________________________________________________
182AliTOFGeometry* AliTOFReconstructor::GetTOFGeometry(AliRunLoader* runLoader) const
183{
184// get the TOF parameters
185
d3c7bfac 186 AliTOFGeometry *tofGeom;
187
d076c8d5 188 runLoader->CdGAFile();
d3c7bfac 189 TDirectory *savedir=gDirectory;
190 TFile *in=(TFile*)gFile;
191 if (!in->IsOpen()) {
192 AliWarning("Geometry file is not open default TOF geometry will be used");
0f49d1bc 193 tofGeom = new AliTOFGeometryV5();
d3c7bfac 194 }
195 else {
196 in->cd();
197 tofGeom = (AliTOFGeometry*) in->Get("TOFgeometry");
198 }
199
200 savedir->cd();
201
d076c8d5 202 if (!tofGeom) {
203 AliError("no TOF geometry available");
121a60bd 204 return NULL;
205 }
d076c8d5 206 return tofGeom;
121a60bd 207}