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.11.6.2 2002/10/11 07:26:37 hristov
19 Updating VirtualMC to v3-09-02
21 Revision 1.13 2002/09/18 09:20:53 cblume
22 Write the parameter class into the cluster file
24 Revision 1.11 2001/11/27 08:50:33 hristov
25 BranchOld replaced by Branch
27 Revision 1.10 2001/11/14 10:50:45 cblume
28 Changes in digits IO. Add merging of summable digits
30 Revision 1.9 2001/10/21 18:30:02 hristov
31 Several pointers were set to zero in the default constructors to avoid memory management problems
33 Revision 1.8 2001/05/07 08:06:44 cblume
34 Speedup of the code. Create only AliTRDcluster
36 Revision 1.7 2001/03/30 14:40:14 cblume
37 Update of the digitization parameter
39 Revision 1.6 2000/11/01 14:53:20 cblume
40 Merge with TRD-develop
43 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
46 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
49 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
50 Replace include files by forward declarations
52 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
53 Adapted to tracking code
55 Revision 1.5 2000/10/02 21:28:19 fca
56 Removal of useless dependecies via forward declarations
58 Revision 1.4 2000/06/09 11:10:07 cblume
59 Compiler warnings and coding conventions, next round
61 Revision 1.3 2000/06/08 18:32:58 cblume
62 Make code compliant to coding conventions
64 Revision 1.2 2000/05/08 16:17:27 cblume
67 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
68 Remove the class AliTRDcluster
70 Revision 1.4 2000/06/09 11:10:07 cblume
71 Compiler warnings and coding conventions, next round
73 Revision 1.3 2000/06/08 18:32:58 cblume
74 Make code compliant to coding conventions
76 Revision 1.2 2000/05/08 16:17:27 cblume
79 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
80 Remove the class AliTRDcluster
82 Revision 1.1 2000/02/28 18:57:58 cblume
87 ///////////////////////////////////////////////////////////////////////////////
89 // TRD cluster finder base class //
91 ///////////////////////////////////////////////////////////////////////////////
99 #include "AliTRDclusterizer.h"
100 #include "AliTRDcluster.h"
101 #include "AliTRDrecPoint.h"
102 #include "AliTRDgeometry.h"
103 #include "AliTRDparameter.h"
105 ClassImp(AliTRDclusterizer)
107 //_____________________________________________________________________________
108 AliTRDclusterizer::AliTRDclusterizer():TNamed()
111 // AliTRDclusterizer default constructor
124 //_____________________________________________________________________________
125 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
129 // AliTRDclusterizer default constructor
141 //_____________________________________________________________________________
142 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
145 // AliTRDclusterizer copy constructor
148 ((AliTRDclusterizer &) c).Copy(*this);
152 //_____________________________________________________________________________
153 AliTRDclusterizer::~AliTRDclusterizer()
156 // AliTRDclusterizer destructor
165 fOutputFile->Close();
175 //_____________________________________________________________________________
176 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
179 // Assignment operator
182 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
187 //_____________________________________________________________________________
188 void AliTRDclusterizer::Copy(TObject &c)
194 ((AliTRDclusterizer &) c).fInputFile = NULL;
195 ((AliTRDclusterizer &) c).fOutputFile = NULL;
196 ((AliTRDclusterizer &) c).fClusterTree = NULL;
197 ((AliTRDclusterizer &) c).fEvent = 0;
198 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
199 ((AliTRDclusterizer &) c).fPar = 0;
203 //_____________________________________________________________________________
204 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
207 // Opens the AliROOT file. Output and input are in the same file
210 OpenInput(name,nEvent);
217 //_____________________________________________________________________________
218 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
222 // Opens the AliROOT file. Output and input are in different files
225 OpenInput(inname,nEvent);
232 //_____________________________________________________________________________
233 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
236 // Open the output file
239 TDirectory *savedir = NULL;
241 if (!fInputFile) return kFALSE;
243 if (strcmp(name,fInputFile->GetName()) != 0) {
244 savedir = gDirectory;
245 printf("AliTRDclusterizer::OpenOutput -- ");
246 printf("Open the output file %s.\n",name);
247 fOutputFile = new TFile(name,"RECREATE");
250 // Create a tree for the cluster
252 sprintf(treeName,"TreeR%d_TRD",fEvent);
253 fClusterTree = new TTree(treeName,"TRD cluster");
254 TObjArray *ioArray = 0;
255 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
265 //_____________________________________________________________________________
266 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
269 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
272 // Connect the AliRoot file containing Geometry, Kine, and Hits
273 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
275 printf("AliTRDclusterizer::OpenInput -- ");
276 printf("Open the ALIROOT-file %s.\n",name);
277 fInputFile = new TFile(name,"UPDATE");
280 printf("AliTRDclusterizer::OpenInput -- ");
281 printf("%s is already open.\n",name);
284 // Get AliRun object from file
285 gAlice = (AliRun *) fInputFile->Get("gAlice");
287 printf("AliTRDclusterizer::OpenInput -- ");
288 printf("Could not find AliRun object.\n");
294 // Import the Trees for the event nEvent in the file
295 Int_t nparticles = gAlice->GetEvent(fEvent);
296 if (nparticles <= 0) {
297 printf("AliTRDclusterizer::OpenInput -- ");
298 printf("No entries in the trees for event %d.\n",fEvent);
302 // Get the TRD object
303 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
305 printf("AliTRDclusterizer::OpenInput -- ");
306 printf("No TRD detector object found\n");
314 //_____________________________________________________________________________
315 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
318 // Fills TRDcluster branch in the tree with the clusters
319 // found in detector = det. For det=-1 writes the tree.
322 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
323 printf("AliTRDclusterizer::WriteClusters -- ");
324 printf("Unexpected detector index %d.\n",det);
328 TDirectory *savedir = gDirectory;
334 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
336 TObjArray *ioArray = 0;
337 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
340 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
342 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
343 TObjArray *detRecPoints = new TObjArray(400);
345 for (Int_t i = 0; i < nRecPoints; i++) {
346 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
347 if (det == c->GetDetector()) {
348 detRecPoints->AddLast(c);
351 printf("AliTRDclusterizer::WriteClusters --");
352 printf("Attempt to write a cluster with unexpected detector index\n");
356 branch->SetAddress(&detRecPoints);
357 fClusterTree->Fill();
365 printf("AliTRDclusterizer::WriteClusters -- ");
366 printf("Writing the cluster tree %-18s for event %d.\n"
367 ,fClusterTree->GetName(),fEvent);
369 fClusterTree->Write();
371 AliTRDgeometry *geo = fTRD->GetGeometry();
372 geo->SetName("TRDgeometry");
382 printf("AliTRDclusterizer::WriteClusters -- ");
383 printf("Unexpected detector index %d.\n",det);