]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCReconstructor.cxx
Bug fixes (Jens)
[u/mrichter/AliRoot.git] / TPC / AliTPCReconstructor.cxx
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"
28 #include "AliRawReader.h"
29 #include "AliTPCclustererMI.h"
30 #include "AliTPCtrackerMI.h"
31 #include "AliTPCpidESD.h"
32 #include "AliTPCParam.h"
33 #include "AliTPCParamSR.h"
34 #include "AliTPCcalibDB.h"
35
36 ClassImp(AliTPCReconstructor)
37
38
39 AliTPCRecoParam *    AliTPCReconstructor::fgkRecoParam =0;  // reconstruction parameters
40 Int_t    AliTPCReconstructor::fgStreamLevel     = 0;        // stream (debug) level
41
42
43 AliTPCReconstructor::AliTPCReconstructor():
44 AliReconstructor(),
45 fClusterer(NULL)
46 {
47   //
48   // default constructor
49   //
50   if (!fgkRecoParam) {
51     AliError("The Reconstruction parameters nonitialized - Used default one");
52     fgkRecoParam = AliTPCRecoParam::GetHighFluxParam();
53   }
54
55   AliTPCParam* param = GetTPCParam();
56   if (!param) {
57     AliWarning("Loading default TPC parameters !");
58     param = new AliTPCParamSR;
59   }
60   fClusterer = new AliTPCclustererMI(param);
61 }
62
63 //_____________________________________________________________________________
64 AliTPCReconstructor::~AliTPCReconstructor()
65 {
66   if (fgkRecoParam) delete fgkRecoParam;
67   if (fClusterer)   delete fClusterer;
68 }
69
70 //_____________________________________________________________________________
71 void 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
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
99     fClusterer->SetInput(treeDigits);
100     fClusterer->SetOutput(treeClusters);
101     fClusterer->Digits2Clusters();
102          
103     loader->WriteRecPoints("OVERWRITE");
104   }
105
106   loader->UnloadRecPoints();
107   loader->UnloadDigits();
108 }
109
110 //_____________________________________________________________________________
111 void 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 //_____________________________________________________________________________
120 void 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
132   TString option = GetOption();
133   if (option.Contains("OldRCUFormat"))
134     fClusterer->SetOldRCUFormat(kTRUE);
135  
136   Int_t iEvent = 0;
137   while (rawReader->NextEvent()) {  
138     runLoader->GetEvent(iEvent++);
139
140     TTree* treeClusters = loader->TreeR();
141     if (!treeClusters) {
142       loader->MakeTree("R");
143       treeClusters = loader->TreeR();
144     }
145
146     fClusterer->SetOutput(treeClusters);
147     fClusterer->Digits2Clusters(rawReader);
148          
149     loader->WriteRecPoints("OVERWRITE");
150   }
151
152   loader->UnloadRecPoints();
153 }
154
155 //_____________________________________________________________________________
156 void 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 //_____________________________________________________________________________
168 AliTracker* AliTPCReconstructor::CreateTracker(AliRunLoader* /* runLoader */) const
169 {
170 // create a TPC tracker
171
172   AliTPCParam* param = GetTPCParam();
173   if (!param) {
174     AliWarning("Loading default TPC parameters !");
175     param = new AliTPCParamSR;
176   }
177   param->ReadGeoMatrices();
178   return new AliTPCtrackerMI(param);
179 }
180
181 //_____________________________________________________________________________
182 void AliTPCReconstructor::FillESD(AliRunLoader* /*runLoader*/, 
183                                   AliESDEvent* 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 //_____________________________________________________________________________
194 AliTPCParam* AliTPCReconstructor::GetTPCParam() const
195 {
196 // get the TPC parameters
197
198   AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
199
200   return param;
201 }