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.14 2002/10/14 14:57:43 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.11.6.2 2002/10/11 07:26:37 hristov
22 Updating VirtualMC to v3-09-02
24 Revision 1.13 2002/09/18 09:20:53 cblume
25 Write the parameter class into the cluster file
27 Revision 1.12 2002/06/12 09:54:35 cblume
28 Update of tracking code provided by Sergei
30 Revision 1.11 2001/11/27 08:50:33 hristov
31 BranchOld replaced by Branch
33 Revision 1.10 2001/11/14 10:50:45 cblume
34 Changes in digits IO. Add merging of summable digits
36 Revision 1.9 2001/10/21 18:30:02 hristov
37 Several pointers were set to zero in the default constructors to avoid memory management problems
39 Revision 1.8 2001/05/07 08:06:44 cblume
40 Speedup of the code. Create only AliTRDcluster
42 Revision 1.7 2001/03/30 14:40:14 cblume
43 Update of the digitization parameter
45 Revision 1.6 2000/11/01 14:53:20 cblume
46 Merge with TRD-develop
49 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
52 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
55 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
56 Replace include files by forward declarations
58 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
59 Adapted to tracking code
61 Revision 1.5 2000/10/02 21:28:19 fca
62 Removal of useless dependecies via forward declarations
64 Revision 1.4 2000/06/09 11:10:07 cblume
65 Compiler warnings and coding conventions, next round
67 Revision 1.3 2000/06/08 18:32:58 cblume
68 Make code compliant to coding conventions
70 Revision 1.2 2000/05/08 16:17:27 cblume
73 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
74 Remove the class AliTRDcluster
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.1 2000/02/28 18:57:58 cblume
93 ///////////////////////////////////////////////////////////////////////////////
95 // TRD cluster finder base class //
97 ///////////////////////////////////////////////////////////////////////////////
105 #include "AliTRDclusterizer.h"
106 #include "AliTRDcluster.h"
107 #include "AliTRDrecPoint.h"
108 #include "AliTRDgeometry.h"
109 #include "AliTRDparameter.h"
111 ClassImp(AliTRDclusterizer)
113 //_____________________________________________________________________________
114 AliTRDclusterizer::AliTRDclusterizer():TNamed()
117 // AliTRDclusterizer default constructor
130 //_____________________________________________________________________________
131 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
135 // AliTRDclusterizer default constructor
147 //_____________________________________________________________________________
148 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
151 // AliTRDclusterizer copy constructor
154 ((AliTRDclusterizer &) c).Copy(*this);
158 //_____________________________________________________________________________
159 AliTRDclusterizer::~AliTRDclusterizer()
162 // AliTRDclusterizer destructor
171 fOutputFile->Close();
181 //_____________________________________________________________________________
182 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
185 // Assignment operator
188 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
193 //_____________________________________________________________________________
194 void AliTRDclusterizer::Copy(TObject &c)
200 ((AliTRDclusterizer &) c).fInputFile = NULL;
201 ((AliTRDclusterizer &) c).fOutputFile = NULL;
202 ((AliTRDclusterizer &) c).fClusterTree = NULL;
203 ((AliTRDclusterizer &) c).fEvent = 0;
204 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
205 ((AliTRDclusterizer &) c).fPar = 0;
209 //_____________________________________________________________________________
210 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
213 // Opens the AliROOT file. Output and input are in the same file
216 OpenInput(name,nEvent);
223 //_____________________________________________________________________________
224 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
228 // Opens the AliROOT file. Output and input are in different files
231 OpenInput(inname,nEvent);
238 //_____________________________________________________________________________
239 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
242 // Open the output file
245 TDirectory *savedir = NULL;
247 if (!fInputFile) return kFALSE;
249 if (strcmp(name,fInputFile->GetName()) != 0) {
250 savedir = gDirectory;
251 printf("AliTRDclusterizer::OpenOutput -- ");
252 printf("Open the output file %s.\n",name);
253 fOutputFile = new TFile(name,"RECREATE");
256 // Create a tree for the cluster
258 sprintf(treeName,"TreeR%d_TRD",fEvent);
259 fClusterTree = new TTree(treeName,"TRD cluster");
260 TObjArray *ioArray = 0;
261 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
271 //_____________________________________________________________________________
272 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
275 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
278 // Connect the AliRoot file containing Geometry, Kine, and Hits
279 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
281 printf("AliTRDclusterizer::OpenInput -- ");
282 printf("Open the ALIROOT-file %s.\n",name);
283 fInputFile = new TFile(name,"UPDATE");
286 printf("AliTRDclusterizer::OpenInput -- ");
287 printf("%s is already open.\n",name);
290 // Get AliRun object from file
291 gAlice = (AliRun *) fInputFile->Get("gAlice");
293 printf("AliTRDclusterizer::OpenInput -- ");
294 printf("Could not find AliRun object.\n");
300 // Import the Trees for the event nEvent in the file
301 Int_t nparticles = gAlice->GetEvent(fEvent);
302 if (nparticles <= 0) {
303 printf("AliTRDclusterizer::OpenInput -- ");
304 printf("No entries in the trees for event %d.\n",fEvent);
308 // Get the TRD object
309 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
311 printf("AliTRDclusterizer::OpenInput -- ");
312 printf("No TRD detector object found\n");
320 //_____________________________________________________________________________
321 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
324 // Fills TRDcluster branch in the tree with the clusters
325 // found in detector = det. For det=-1 writes the tree.
328 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
329 printf("AliTRDclusterizer::WriteClusters -- ");
330 printf("Unexpected detector index %d.\n",det);
334 TDirectory *savedir = gDirectory;
340 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
342 TObjArray *ioArray = 0;
343 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
346 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
348 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
349 TObjArray *detRecPoints = new TObjArray(400);
351 for (Int_t i = 0; i < nRecPoints; i++) {
352 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
353 if (det == c->GetDetector()) {
354 detRecPoints->AddLast(c);
357 printf("AliTRDclusterizer::WriteClusters --");
358 printf("Attempt to write a cluster with unexpected detector index\n");
362 branch->SetAddress(&detRecPoints);
363 fClusterTree->Fill();
371 printf("AliTRDclusterizer::WriteClusters -- ");
372 printf("Writing the cluster tree %-18s for event %d.\n"
373 ,fClusterTree->GetName(),fEvent);
375 fClusterTree->Write();
377 AliTRDgeometry *geo = fTRD->GetGeometry();
378 geo->SetName("TRDgeometry");
388 printf("AliTRDclusterizer::WriteClusters -- ");
389 printf("Unexpected detector index %d.\n",det);