Memory leak fixed
[u/mrichter/AliRoot.git] / TPC / AliTPCReconstructor.cxx
CommitLineData
59697224 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 TPC reconstruction //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24
25#include "AliTPCReconstructor.h"
26#include "AliRunLoader.h"
27#include "AliRun.h"
38e6e547 28#include "AliRawReader.h"
59697224 29#include "AliTPCclustererMI.h"
30#include "AliTPCtrackerMI.h"
31#include "AliTPCpidESD.h"
4fb6310b 32#include "AliTPCParam.h"
90c7886e 33#include "AliTPCParamSR.h"
3d37b790 34#include "AliTPCcalibDB.h"
59697224 35
36ClassImp(AliTPCReconstructor)
37
194b0609 38
39AliTPCRecoParam * AliTPCReconstructor::fgkRecoParam =0; // reconstruction parameters
40Int_t AliTPCReconstructor::fgStreamLevel = 0; // stream (debug) level
41
42
3464c690 43AliTPCReconstructor::AliTPCReconstructor():
44AliReconstructor(),
45fClusterer(NULL)
46{
194b0609 47 //
48 // default constructor
49 //
50 if (!fgkRecoParam) {
51 AliError("The Reconstruction parameters nonitialized - Used default one");
52 fgkRecoParam = AliTPCRecoParam::GetHighFluxParam();
53 }
3464c690 54
55 AliTPCParam* param = GetTPCParam();
56 if (!param) {
57 AliWarning("Loading default TPC parameters !");
58 param = new AliTPCParamSR;
59 }
60 fClusterer = new AliTPCclustererMI(param);
194b0609 61}
62
3464c690 63//_____________________________________________________________________________
64AliTPCReconstructor::~AliTPCReconstructor()
65{
66 if (fgkRecoParam) delete fgkRecoParam;
67 if (fClusterer) delete fClusterer;
68}
194b0609 69
59697224 70//_____________________________________________________________________________
71void AliTPCReconstructor::Reconstruct(AliRunLoader* runLoader) const
72{
73// reconstruct clusters
74
75 AliLoader* loader = runLoader->GetLoader("TPCLoader");
76 if (!loader) {
77 Error("Reconstruct", "TPC loader not found");
78 return;
79 }
80 loader->LoadRecPoints("recreate");
81 loader->LoadDigits("read");
82
59697224 83 Int_t nEvents = runLoader->GetNumberOfEvents();
84
85 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
86 runLoader->GetEvent(iEvent);
87
88 TTree* treeClusters = loader->TreeR();
89 if (!treeClusters) {
90 loader->MakeTree("R");
91 treeClusters = loader->TreeR();
92 }
93 TTree* treeDigits = loader->TreeD();
94 if (!treeDigits) {
95 Error("Reconstruct", "Can't get digits tree !");
96 return;
97 }
98
3464c690 99 fClusterer->SetInput(treeDigits);
100 fClusterer->SetOutput(treeClusters);
101 fClusterer->Digits2Clusters();
59697224 102
103 loader->WriteRecPoints("OVERWRITE");
104 }
105
106 loader->UnloadRecPoints();
107 loader->UnloadDigits();
108}
109
110//_____________________________________________________________________________
3464c690 111void AliTPCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const {
112 // single event local reconstruction
113 // of TPC data
114 fClusterer->SetInput(digitsTree);
115 fClusterer->SetOutput(clustersTree);
116 fClusterer->Digits2Clusters();
117}
118
119//_____________________________________________________________________________
38e6e547 120void AliTPCReconstructor::Reconstruct(AliRunLoader* runLoader,
121 AliRawReader* rawReader) const
122{
123// reconstruct clusters from raw data
124
125 AliLoader* loader = runLoader->GetLoader("TPCLoader");
126 if (!loader) {
127 Error("Reconstruct", "TPC loader not found");
128 return;
129 }
130 loader->LoadRecPoints("recreate");
131
b6f060dc 132 TString option = GetOption();
c8c88e5d 133 if (option.Contains("OldRCUFormat"))
3464c690 134 fClusterer->SetOldRCUFormat(kTRUE);
b6f060dc 135
38e6e547 136 Int_t iEvent = 0;
2c7f22ff 137 while (rawReader->NextEvent()) {
38e6e547 138 runLoader->GetEvent(iEvent++);
139
140 TTree* treeClusters = loader->TreeR();
141 if (!treeClusters) {
142 loader->MakeTree("R");
143 treeClusters = loader->TreeR();
144 }
145
3464c690 146 fClusterer->SetOutput(treeClusters);
147 fClusterer->Digits2Clusters(rawReader);
38e6e547 148
149 loader->WriteRecPoints("OVERWRITE");
150 }
151
152 loader->UnloadRecPoints();
153}
154
155//_____________________________________________________________________________
3464c690 156void AliTPCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {
157 // single event local reconstruction
158 // of TPC data starting from raw data
159 TString option = GetOption();
160 if (option.Contains("OldRCUFormat"))
161 fClusterer->SetOldRCUFormat(kTRUE);
162
163 fClusterer->SetOutput(clustersTree);
164 fClusterer->Digits2Clusters(rawReader);
165}
166
167//_____________________________________________________________________________
168AliTracker* AliTPCReconstructor::CreateTracker(AliRunLoader* /* runLoader */) const
59697224 169{
170// create a TPC tracker
171
3464c690 172 AliTPCParam* param = GetTPCParam();
90c7886e 173 if (!param) {
174 AliWarning("Loading default TPC parameters !");
175 param = new AliTPCParamSR;
176 }
4fb6310b 177 param->ReadGeoMatrices();
59697224 178 return new AliTPCtrackerMI(param);
179}
180
181//_____________________________________________________________________________
182void AliTPCReconstructor::FillESD(AliRunLoader* /*runLoader*/,
183 AliESD* esd) const
184{
185// make PID
186
187 Double_t parTPC[] = {47., 0.10, 10.};
188 AliTPCpidESD tpcPID(parTPC);
189 tpcPID.MakePID(esd);
190}
191
192
193//_____________________________________________________________________________
3464c690 194AliTPCParam* AliTPCReconstructor::GetTPCParam() const
59697224 195{
196// get the TPC parameters
197
3464c690 198 AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
3d37b790 199
6d75e4b6 200 return param;
59697224 201}