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.16 2003/02/07 09:45:24 cblume
19 Modification in OpenOutput() for many events in single file
21 Revision 1.15 2002/11/07 15:52:09 cblume
22 Update of tracking code for tilted pads
24 Revision 1.14 2002/10/14 14:57:43 hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
27 Revision 1.11.6.2 2002/10/11 07:26:37 hristov
28 Updating VirtualMC to v3-09-02
30 Revision 1.13 2002/09/18 09:20:53 cblume
31 Write the parameter class into the cluster file
33 Revision 1.12 2002/06/12 09:54:35 cblume
34 Update of tracking code provided by Sergei
36 Revision 1.11 2001/11/27 08:50:33 hristov
37 BranchOld replaced by Branch
39 Revision 1.10 2001/11/14 10:50:45 cblume
40 Changes in digits IO. Add merging of summable digits
42 Revision 1.9 2001/10/21 18:30:02 hristov
43 Several pointers were set to zero in the default constructors to avoid memory management problems
45 Revision 1.8 2001/05/07 08:06:44 cblume
46 Speedup of the code. Create only AliTRDcluster
48 Revision 1.7 2001/03/30 14:40:14 cblume
49 Update of the digitization parameter
51 Revision 1.6 2000/11/01 14:53:20 cblume
52 Merge with TRD-develop
55 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
58 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
61 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
62 Replace include files by forward declarations
64 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
65 Adapted to tracking code
67 Revision 1.5 2000/10/02 21:28:19 fca
68 Removal of useless dependecies via forward declarations
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.4 2000/06/09 11:10:07 cblume
83 Compiler warnings and coding conventions, next round
85 Revision 1.3 2000/06/08 18:32:58 cblume
86 Make code compliant to coding conventions
88 Revision 1.2 2000/05/08 16:17:27 cblume
91 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
92 Remove the class AliTRDcluster
94 Revision 1.1 2000/02/28 18:57:58 cblume
99 ///////////////////////////////////////////////////////////////////////////////
101 // TRD cluster finder base class //
103 ///////////////////////////////////////////////////////////////////////////////
111 #include "AliTRDclusterizer.h"
112 #include "AliTRDcluster.h"
113 #include "AliTRDrecPoint.h"
114 #include "AliTRDgeometry.h"
115 #include "AliTRDparameter.h"
117 ClassImp(AliTRDclusterizer)
119 //_____________________________________________________________________________
120 AliTRDclusterizer::AliTRDclusterizer():TNamed()
123 // AliTRDclusterizer default constructor
136 //_____________________________________________________________________________
137 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
141 // AliTRDclusterizer default constructor
153 //_____________________________________________________________________________
154 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
157 // AliTRDclusterizer copy constructor
160 ((AliTRDclusterizer &) c).Copy(*this);
164 //_____________________________________________________________________________
165 AliTRDclusterizer::~AliTRDclusterizer()
168 // AliTRDclusterizer destructor
177 fOutputFile->Close();
187 //_____________________________________________________________________________
188 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
191 // Assignment operator
194 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
199 //_____________________________________________________________________________
200 void AliTRDclusterizer::Copy(TObject &c)
206 ((AliTRDclusterizer &) c).fInputFile = NULL;
207 ((AliTRDclusterizer &) c).fOutputFile = NULL;
208 ((AliTRDclusterizer &) c).fClusterTree = NULL;
209 ((AliTRDclusterizer &) c).fEvent = 0;
210 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
211 ((AliTRDclusterizer &) c).fPar = 0;
215 //_____________________________________________________________________________
216 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
219 // Opens the AliROOT file. Output and input are in the same file
222 OpenInput(name,nEvent);
229 //_____________________________________________________________________________
230 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
234 // Opens the AliROOT file. Output and input are in different files
237 OpenInput(inname,nEvent);
244 //_____________________________________________________________________________
245 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
248 // Open the output file
251 TDirectory *savedir = NULL;
253 if (!fInputFile) return kFALSE;
255 if (strcmp(name,fInputFile->GetName()) != 0) {
256 savedir = gDirectory;
257 TFile *file = (TFile *) gROOT->FindObject(name);
263 printf("AliTRDclusterizer::OpenOutput -- ");
264 printf("Open the output file %s.\n",name);
265 fOutputFile = new TFile(name,"RECREATE");
269 // Create a tree for the cluster
271 sprintf(treeName,"TreeR%d_TRD",fEvent);
272 fClusterTree = new TTree(treeName,"TRD cluster");
273 TObjArray *ioArray = 0;
274 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
284 //_____________________________________________________________________________
285 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
288 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
291 // Connect the AliRoot file containing Geometry, Kine, and Hits
292 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
294 printf("AliTRDclusterizer::OpenInput -- ");
295 printf("Open the ALIROOT-file %s.\n",name);
296 fInputFile = new TFile(name,"UPDATE");
299 printf("AliTRDclusterizer::OpenInput -- ");
300 printf("%s is already open.\n",name);
303 // Get AliRun object from file
304 gAlice = (AliRun *) fInputFile->Get("gAlice");
306 printf("AliTRDclusterizer::OpenInput -- ");
307 printf("Could not find AliRun object.\n");
313 // Import the Trees for the event nEvent in the file
314 Int_t nparticles = gAlice->GetEvent(fEvent);
315 if (nparticles <= 0) {
316 printf("AliTRDclusterizer::OpenInput -- ");
317 printf("No entries in the trees for event %d.\n",fEvent);
321 // Get the TRD object
322 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
324 printf("AliTRDclusterizer::OpenInput -- ");
325 printf("No TRD detector object found\n");
333 //_____________________________________________________________________________
334 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
337 // Fills TRDcluster branch in the tree with the clusters
338 // found in detector = det. For det=-1 writes the tree.
341 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
342 printf("AliTRDclusterizer::WriteClusters -- ");
343 printf("Unexpected detector index %d.\n",det);
347 TDirectory *savedir = gDirectory;
353 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
355 TObjArray *ioArray = 0;
356 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
359 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
361 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
362 TObjArray *detRecPoints = new TObjArray(400);
364 for (Int_t i = 0; i < nRecPoints; i++) {
365 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
366 if (det == c->GetDetector()) {
367 detRecPoints->AddLast(c);
370 printf("AliTRDclusterizer::WriteClusters --");
371 printf("Attempt to write a cluster with unexpected detector index\n");
375 branch->SetAddress(&detRecPoints);
376 fClusterTree->Fill();
384 printf("AliTRDclusterizer::WriteClusters -- ");
385 printf("Writing the cluster tree %-18s for event %d.\n"
386 ,fClusterTree->GetName(),fEvent);
388 fClusterTree->Write();
390 AliTRDgeometry *geo = fTRD->GetGeometry();
391 if (!fOutputFile->Get("TRDgeometry")) {
392 geo->SetName("TRDgeometry");
395 if (!fOutputFile->Get("TRDparameter")) {
405 printf("AliTRDclusterizer::WriteClusters -- ");
406 printf("Unexpected detector index %d.\n",det);