]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDclusterizer.cxx
Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of...
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizer.cxx
CommitLineData
f7336fa3 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/*
17$Log$
3e1a3ad8 18Revision 1.7 2001/03/30 14:40:14 cblume
19Update of the digitization parameter
20
a3c76cdc 21Revision 1.6 2000/11/01 14:53:20 cblume
22Merge with TRD-develop
23
793ff80c 24
25Revision 1.1.4.5 2000/10/15 23:40:01 cblume
26Remove AliTRDconst
27
28Revision 1.1.4.4 2000/10/06 16:49:46 cblume
29Made Getters const
30
31Revision 1.1.4.3 2000/10/04 16:34:58 cblume
32Replace include files by forward declarations
33
34Revision 1.1.4.2 2000/09/22 14:49:49 cblume
35Adapted to tracking code
36
37Revision 1.5 2000/10/02 21:28:19 fca
38Removal of useless dependecies via forward declarations
39
40Revision 1.4 2000/06/09 11:10:07 cblume
41Compiler warnings and coding conventions, next round
42
43Revision 1.3 2000/06/08 18:32:58 cblume
44Make code compliant to coding conventions
45
46Revision 1.2 2000/05/08 16:17:27 cblume
47Merge TRD-develop
48
49Revision 1.1.4.1 2000/05/08 15:08:03 cblume
50Remove the class AliTRDcluster
51
94de3818 52Revision 1.4 2000/06/09 11:10:07 cblume
53Compiler warnings and coding conventions, next round
54
dd9a6ee3 55Revision 1.3 2000/06/08 18:32:58 cblume
56Make code compliant to coding conventions
57
8230f242 58Revision 1.2 2000/05/08 16:17:27 cblume
59Merge TRD-develop
60
6f1e466d 61Revision 1.1.4.1 2000/05/08 15:08:03 cblume
62Remove the class AliTRDcluster
63
64Revision 1.1 2000/02/28 18:57:58 cblume
65Add new TRD classes
66
f7336fa3 67*/
68
69///////////////////////////////////////////////////////////////////////////////
70// //
71// TRD cluster finder base class //
72// //
73///////////////////////////////////////////////////////////////////////////////
74
94de3818 75#include <TROOT.h>
76#include <TTree.h>
793ff80c 77#include <TFile.h>
f7336fa3 78
94de3818 79#include "AliRun.h"
f7336fa3 80#include "AliTRD.h"
81#include "AliTRDclusterizer.h"
3e1a3ad8 82#include "AliTRDcluster.h"
793ff80c 83#include "AliTRDrecPoint.h"
84#include "AliTRDgeometry.h"
f7336fa3 85
86ClassImp(AliTRDclusterizer)
87
88//_____________________________________________________________________________
89AliTRDclusterizer::AliTRDclusterizer():TNamed()
90{
91 //
92 // AliTRDclusterizer default constructor
93 //
94
3e1a3ad8 95 fInputFile = NULL;
96 fOutputFile = NULL;
97 fClusterTree = NULL;
98 fEvent = 0;
99 fVerbose = 0;
f7336fa3 100
101}
102
103//_____________________________________________________________________________
104AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
105 :TNamed(name, title)
106{
107 //
108 // AliTRDclusterizer default constructor
109 //
110
3e1a3ad8 111 fInputFile = NULL;
112 fOutputFile = NULL;
113 fClusterTree = NULL;
114 fEvent = 0;
115 fVerbose = 0;
f7336fa3 116
117}
118
8230f242 119//_____________________________________________________________________________
dd9a6ee3 120AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
8230f242 121{
122 //
123 // AliTRDclusterizer copy constructor
124 //
125
dd9a6ee3 126 ((AliTRDclusterizer &) c).Copy(*this);
8230f242 127
128}
129
f7336fa3 130//_____________________________________________________________________________
131AliTRDclusterizer::~AliTRDclusterizer()
132{
8230f242 133 //
134 // AliTRDclusterizer destructor
135 //
f7336fa3 136
137 if (fInputFile) {
138 fInputFile->Close();
139 delete fInputFile;
140 }
141
3e1a3ad8 142 if (fOutputFile) {
143 fOutputFile->Close();
144 delete fOutputFile;
145 }
146
147 if (fClusterTree) {
148 delete fClusterTree;
149 }
150
f7336fa3 151}
152
8230f242 153//_____________________________________________________________________________
dd9a6ee3 154AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
155{
156 //
157 // Assignment operator
158 //
159
160 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
161 return *this;
162
163}
164
165//_____________________________________________________________________________
166void AliTRDclusterizer::Copy(TObject &c)
8230f242 167{
168 //
169 // Copy function
170 //
171
3e1a3ad8 172 ((AliTRDclusterizer &) c).fInputFile = NULL;
173 ((AliTRDclusterizer &) c).fOutputFile = NULL;
174 ((AliTRDclusterizer &) c).fClusterTree = NULL;
175 ((AliTRDclusterizer &) c).fEvent = 0;
176 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
8230f242 177
178}
179
f7336fa3 180//_____________________________________________________________________________
3e1a3ad8 181Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
f7336fa3 182{
183 //
3e1a3ad8 184 // Opens the AliROOT file. Output and input are in the same file
f7336fa3 185 //
186
3e1a3ad8 187 OpenInput(name,nEvent);
188 OpenOutput(name);
189
190 return kTRUE;
191
f7336fa3 192}
193
194//_____________________________________________________________________________
3e1a3ad8 195Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
196 , Int_t nEvent)
197{
198 //
199 // Opens the AliROOT file. Output and input are in different files
200 //
201
202 OpenInput(inname,nEvent);
203 OpenOutput(outname);
204
205 return kTRUE;
206
207}
208
209//_____________________________________________________________________________
210Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
211{
212 //
213 // Open the output file
214 //
215
216 TDirectory *savedir = NULL;
217
218 if (!fInputFile) return kFALSE;
219
220 if (strcmp(name,fInputFile->GetName()) != 0) {
221 savedir = gDirectory;
222 printf("AliTRDclusterizer::OpenOutput -- ");
223 printf("Open the output file %s.\n",name);
224 fOutputFile = new TFile(name,"RECREATE");
225 }
226
227 // Create a tree for the cluster
228 fClusterTree = new TTree("ClusterTree","Tree with TRDcluster");
229 TObjArray *ioArray = 0;
230 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
231
232 if (savedir) {
233 savedir->cd();
234 }
235
236 return kTRUE;
237
238}
239
240//_____________________________________________________________________________
241Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
f7336fa3 242{
243 //
244 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
245 //
246
247 // Connect the AliRoot file containing Geometry, Kine, and Hits
248 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
249 if (!fInputFile) {
3e1a3ad8 250 printf("AliTRDclusterizer::OpenInput -- ");
f7336fa3 251 printf("Open the ALIROOT-file %s.\n",name);
252 fInputFile = new TFile(name,"UPDATE");
253 }
254 else {
3e1a3ad8 255 printf("AliTRDclusterizer::OpenInput -- ");
f7336fa3 256 printf("%s is already open.\n",name);
257 }
258
3e1a3ad8 259 // Get AliRun object from file
260 gAlice = (AliRun *) fInputFile->Get("gAlice");
a3c76cdc 261 if (!(gAlice)) {
3e1a3ad8 262 printf("AliTRDclusterizer::OpenInput -- ");
263 printf("Could not find AliRun object.\n");
264 return kFALSE;
a3c76cdc 265 }
f7336fa3 266
267 fEvent = nEvent;
268
269 // Import the Trees for the event nEvent in the file
270 Int_t nparticles = gAlice->GetEvent(fEvent);
271 if (nparticles <= 0) {
3e1a3ad8 272 printf("AliTRDclusterizer::OpenInput -- ");
f7336fa3 273 printf("No entries in the trees for event %d.\n",fEvent);
274 return kFALSE;
275 }
276
3e1a3ad8 277 // Get the TRD object
278 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
279 if (!fTRD) {
280 printf("AliTRDclusterizer::OpenInput -- ");
281 printf("No TRD detector object found\n");
282 return kFALSE;
283 }
a3c76cdc 284
f7336fa3 285 return kTRUE;
286
287}
288
289//_____________________________________________________________________________
793ff80c 290Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
f7336fa3 291{
292 //
3e1a3ad8 293 // Fills TRDcluster branch in the tree with the clusters
793ff80c 294 // found in detector = det. For det=-1 writes the tree.
a3c76cdc 295 //
793ff80c 296
3e1a3ad8 297 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
298 printf("AliTRDclusterizer::WriteClusters -- ");
299 printf("Unexpected detector index %d.\n",det);
300 return kFALSE;
793ff80c 301 }
3e1a3ad8 302
303 TDirectory *savedir = gDirectory;
f7336fa3 304
3e1a3ad8 305 if (fOutputFile) {
306 fOutputFile->cd();
307 }
f7336fa3 308
3e1a3ad8 309 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
310 if (!branch) {
793ff80c 311 TObjArray *ioArray = 0;
3e1a3ad8 312 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
793ff80c 313 }
314
315 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
316
3e1a3ad8 317 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
318 TObjArray *detRecPoints = new TObjArray(400);
319
320 for (Int_t i = 0; i < nRecPoints; i++) {
321 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
322 if (det == c->GetDetector()) {
323 detRecPoints->AddLast(c);
324 }
325 else {
326 printf("AliTRDclusterizer::WriteClusters --");
327 printf("Attempt to write a cluster with unexpected detector index\n");
328 }
793ff80c 329 }
330
3e1a3ad8 331 branch->SetAddress(&detRecPoints);
332 fClusterTree->Fill();
333
793ff80c 334 return kTRUE;
3e1a3ad8 335
793ff80c 336 }
337
338 if (det == -1) {
339
3e1a3ad8 340 printf("AliTRDclusterizer::WriteClusters -- ");
793ff80c 341 printf("Writing the cluster tree %-18s for event %d.\n"
3e1a3ad8 342 ,fClusterTree->GetName(),fEvent);
793ff80c 343
3e1a3ad8 344 fClusterTree->Write();
345
793ff80c 346 return kTRUE;
3e1a3ad8 347
793ff80c 348 }
349
3e1a3ad8 350 savedir->cd();
351
352 printf("AliTRDclusterizer::WriteClusters -- ");
353 printf("Unexpected detector index %d.\n",det);
354
793ff80c 355 return kFALSE;
f7336fa3 356
357}
793ff80c 358
359
360