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 **************************************************************************/
18 Revision 1.18 2003/03/19 17:16:23 hristov
19 Fixes for the file managment(T.Kuhr)
21 Revision 1.17 2003/02/10 11:09:26 cblume
22 Further modifications in OpenOutput and WriteCluster
24 Revision 1.16 2003/02/07 09:45:24 cblume
25 Modification in OpenOutput() for many events in single file
27 Revision 1.15 2002/11/07 15:52:09 cblume
28 Update of tracking code for tilted pads
30 Revision 1.14 2002/10/14 14:57:43 hristov
31 Merging the VirtualMC branch to the main development branch (HEAD)
33 Revision 1.11.6.2 2002/10/11 07:26:37 hristov
34 Updating VirtualMC to v3-09-02
36 Revision 1.13 2002/09/18 09:20:53 cblume
37 Write the parameter class into the cluster file
39 Revision 1.12 2002/06/12 09:54:35 cblume
40 Update of tracking code provided by Sergei
42 Revision 1.11 2001/11/27 08:50:33 hristov
43 BranchOld replaced by Branch
45 Revision 1.10 2001/11/14 10:50:45 cblume
46 Changes in digits IO. Add merging of summable digits
48 Revision 1.9 2001/10/21 18:30:02 hristov
49 Several pointers were set to zero in the default constructors to avoid memory management problems
51 Revision 1.8 2001/05/07 08:06:44 cblume
52 Speedup of the code. Create only AliTRDcluster
54 Revision 1.7 2001/03/30 14:40:14 cblume
55 Update of the digitization parameter
57 Revision 1.6 2000/11/01 14:53:20 cblume
58 Merge with TRD-develop
61 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
64 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
67 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
68 Replace include files by forward declarations
70 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
71 Adapted to tracking code
73 Revision 1.5 2000/10/02 21:28:19 fca
74 Removal of useless dependecies via forward declarations
76 Revision 1.4 2000/06/09 11:10:07 cblume
77 Compiler warnings and coding conventions, next round
79 Revision 1.3 2000/06/08 18:32:58 cblume
80 Make code compliant to coding conventions
82 Revision 1.2 2000/05/08 16:17:27 cblume
85 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
86 Remove the class AliTRDcluster
88 Revision 1.4 2000/06/09 11:10:07 cblume
89 Compiler warnings and coding conventions, next round
91 Revision 1.3 2000/06/08 18:32:58 cblume
92 Make code compliant to coding conventions
94 Revision 1.2 2000/05/08 16:17:27 cblume
97 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
98 Remove the class AliTRDcluster
100 Revision 1.1 2000/02/28 18:57:58 cblume
105 ///////////////////////////////////////////////////////////////////////////////
107 // TRD cluster finder base class //
109 ///////////////////////////////////////////////////////////////////////////////
117 #include "AliTRDclusterizer.h"
118 #include "AliTRDcluster.h"
119 #include "AliTRDrecPoint.h"
120 #include "AliTRDgeometry.h"
121 #include "AliTRDparameter.h"
123 ClassImp(AliTRDclusterizer)
125 //_____________________________________________________________________________
126 AliTRDclusterizer::AliTRDclusterizer():TNamed()
129 // AliTRDclusterizer default constructor
133 fInputFileCreated = kFALSE;
135 fOutputFileCreated = kFALSE;
144 //_____________________________________________________________________________
145 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
149 // AliTRDclusterizer default constructor
161 //_____________________________________________________________________________
162 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
165 // AliTRDclusterizer copy constructor
168 ((AliTRDclusterizer &) c).Copy(*this);
172 //_____________________________________________________________________________
173 AliTRDclusterizer::~AliTRDclusterizer()
176 // AliTRDclusterizer destructor
179 if (fInputFile && fInputFileCreated) {
184 if (fOutputFile && fOutputFileCreated) {
185 fOutputFile->Close();
191 //_____________________________________________________________________________
192 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
195 // Assignment operator
198 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
203 //_____________________________________________________________________________
204 void AliTRDclusterizer::Copy(TObject &c)
210 ((AliTRDclusterizer &) c).fInputFile = NULL;
211 ((AliTRDclusterizer &) c).fOutputFile = NULL;
212 ((AliTRDclusterizer &) c).fClusterTree = NULL;
213 ((AliTRDclusterizer &) c).fEvent = 0;
214 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
215 ((AliTRDclusterizer &) c).fPar = 0;
219 //_____________________________________________________________________________
220 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
223 // Opens the AliROOT file. Output and input are in the same file
226 OpenInput(name,nEvent);
233 //_____________________________________________________________________________
234 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
238 // Opens the AliROOT file. Output and input are in different files
241 OpenInput(inname,nEvent);
248 //_____________________________________________________________________________
249 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
252 // Open the output file
255 TDirectory *savedir = NULL;
258 printf("<AliTRDclusterizer::OpenOutput> ");
259 printf("No input file defined\n");
263 if (strcmp(name,fInputFile->GetName()) != 0) {
264 savedir = gDirectory;
265 TFile *file = (TFile *) gROOT->FindObject(name);
267 printf("<AliTRDclusterizer::OpenOutput> ");
268 printf("Use same file for output: %s.\n",name);
273 printf("<AliTRDclusterizer::OpenOutput> ");
274 printf("Open the output file %s.\n",name);
275 fOutputFile = new TFile(name,"RECREATE");
276 fOutputFileCreated = kTRUE;
280 fOutputFile = fInputFile;
283 // Create a tree for the cluster
284 Char_t treeName[12]; sprintf(treeName,"TreeR%d_TRD",fEvent);
285 fClusterTree = new TTree(treeName,"TRD cluster");
286 TObjArray *ioArray = 0;
287 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
297 //_____________________________________________________________________________
298 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
301 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
304 // Connect the AliRoot file containing Geometry, Kine, and Hits
305 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
307 printf("AliTRDclusterizer::OpenInput -- ");
308 printf("Open the ALIROOT-file %s.\n",name);
309 fInputFile = new TFile(name,"UPDATE");
310 fInputFileCreated = kTRUE;
313 printf("AliTRDclusterizer::OpenInput -- ");
314 printf("%s is already open.\n",name);
317 // Get AliRun object from file
322 if (!(gAlice)) gAlice = (AliRun *) fInputFile->Get("gAlice");
324 printf("AliTRDclusterizer::OpenInput -- ");
325 printf("Could not find AliRun object.\n");
331 // Import the Trees for the event nEvent in the file
332 Int_t nparticles = gAlice->GetEvent(fEvent);
333 if (nparticles <= 0) {
334 printf("AliTRDclusterizer::OpenInput -- ");
335 printf("No entries in the trees for event %d.\n",fEvent);
339 // Get the TRD object
340 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
342 printf("AliTRDclusterizer::OpenInput -- ");
343 printf("No TRD detector object found\n");
351 //_____________________________________________________________________________
352 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
355 // Fills TRDcluster branch in the tree with the clusters
356 // found in detector = det. For det=-1 writes the tree.
359 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
360 printf("AliTRDclusterizer::WriteClusters -- ");
361 printf("Unexpected detector index %d.\n",det);
365 TDirectory *savedir = gDirectory;
371 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
373 TObjArray *ioArray = 0;
374 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
377 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
379 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
380 TObjArray *detRecPoints = new TObjArray(400);
382 for (Int_t i = 0; i < nRecPoints; i++) {
383 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
384 if (det == c->GetDetector()) {
385 detRecPoints->AddLast(c);
388 printf("AliTRDclusterizer::WriteClusters --");
389 printf("Attempt to write a cluster with unexpected detector index\n");
393 branch->SetAddress(&detRecPoints);
394 fClusterTree->Fill();
402 printf("AliTRDclusterizer::WriteClusters -- ");
403 printf("Writing the cluster tree %-18s for event %d.\n"
404 ,fClusterTree->GetName(),fEvent);
406 fClusterTree->Write();
408 AliTRDgeometry *geo = fTRD->GetGeometry();
409 if (!fOutputFile->Get("TRDgeometry")) {
410 geo->SetName("TRDgeometry");
413 if (!fOutputFile->Get("TRDparameter")) {
423 printf("AliTRDclusterizer::WriteClusters -- ");
424 printf("Unexpected detector index %d.\n",det);