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.10 2001/11/14 10:50:45 cblume
19 Changes in digits IO. Add merging of summable digits
21 Revision 1.9 2001/10/21 18:30:02 hristov
22 Several pointers were set to zero in the default constructors to avoid memory management problems
24 Revision 1.8 2001/05/07 08:06:44 cblume
25 Speedup of the code. Create only AliTRDcluster
27 Revision 1.7 2001/03/30 14:40:14 cblume
28 Update of the digitization parameter
30 Revision 1.6 2000/11/01 14:53:20 cblume
31 Merge with TRD-develop
34 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
37 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
40 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
41 Replace include files by forward declarations
43 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
44 Adapted to tracking code
46 Revision 1.5 2000/10/02 21:28:19 fca
47 Removal of useless dependecies via forward declarations
49 Revision 1.4 2000/06/09 11:10:07 cblume
50 Compiler warnings and coding conventions, next round
52 Revision 1.3 2000/06/08 18:32:58 cblume
53 Make code compliant to coding conventions
55 Revision 1.2 2000/05/08 16:17:27 cblume
58 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
59 Remove the class AliTRDcluster
61 Revision 1.4 2000/06/09 11:10:07 cblume
62 Compiler warnings and coding conventions, next round
64 Revision 1.3 2000/06/08 18:32:58 cblume
65 Make code compliant to coding conventions
67 Revision 1.2 2000/05/08 16:17:27 cblume
70 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
71 Remove the class AliTRDcluster
73 Revision 1.1 2000/02/28 18:57:58 cblume
78 ///////////////////////////////////////////////////////////////////////////////
80 // TRD cluster finder base class //
82 ///////////////////////////////////////////////////////////////////////////////
90 #include "AliTRDclusterizer.h"
91 #include "AliTRDcluster.h"
92 #include "AliTRDrecPoint.h"
93 #include "AliTRDgeometry.h"
95 ClassImp(AliTRDclusterizer)
97 //_____________________________________________________________________________
98 AliTRDclusterizer::AliTRDclusterizer():TNamed()
101 // AliTRDclusterizer default constructor
113 //_____________________________________________________________________________
114 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
118 // AliTRDclusterizer default constructor
129 //_____________________________________________________________________________
130 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
133 // AliTRDclusterizer copy constructor
136 ((AliTRDclusterizer &) c).Copy(*this);
140 //_____________________________________________________________________________
141 AliTRDclusterizer::~AliTRDclusterizer()
144 // AliTRDclusterizer destructor
153 fOutputFile->Close();
163 //_____________________________________________________________________________
164 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
167 // Assignment operator
170 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
175 //_____________________________________________________________________________
176 void AliTRDclusterizer::Copy(TObject &c)
182 ((AliTRDclusterizer &) c).fInputFile = NULL;
183 ((AliTRDclusterizer &) c).fOutputFile = NULL;
184 ((AliTRDclusterizer &) c).fClusterTree = NULL;
185 ((AliTRDclusterizer &) c).fEvent = 0;
186 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
190 //_____________________________________________________________________________
191 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
194 // Opens the AliROOT file. Output and input are in the same file
197 OpenInput(name,nEvent);
204 //_____________________________________________________________________________
205 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
209 // Opens the AliROOT file. Output and input are in different files
212 OpenInput(inname,nEvent);
219 //_____________________________________________________________________________
220 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
223 // Open the output file
226 TDirectory *savedir = NULL;
228 if (!fInputFile) return kFALSE;
230 if (strcmp(name,fInputFile->GetName()) != 0) {
231 savedir = gDirectory;
232 printf("AliTRDclusterizer::OpenOutput -- ");
233 printf("Open the output file %s.\n",name);
234 fOutputFile = new TFile(name,"RECREATE");
237 // Create a tree for the cluster
239 sprintf(treeName,"TreeR%d_TRD",fEvent);
240 fClusterTree = new TTree(treeName,"TRD cluster");
241 TObjArray *ioArray = 0;
242 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
252 //_____________________________________________________________________________
253 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
256 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
259 // Connect the AliRoot file containing Geometry, Kine, and Hits
260 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
262 printf("AliTRDclusterizer::OpenInput -- ");
263 printf("Open the ALIROOT-file %s.\n",name);
264 fInputFile = new TFile(name,"UPDATE");
267 printf("AliTRDclusterizer::OpenInput -- ");
268 printf("%s is already open.\n",name);
271 // Get AliRun object from file
272 gAlice = (AliRun *) fInputFile->Get("gAlice");
274 printf("AliTRDclusterizer::OpenInput -- ");
275 printf("Could not find AliRun object.\n");
281 // Import the Trees for the event nEvent in the file
282 Int_t nparticles = gAlice->GetEvent(fEvent);
283 if (nparticles <= 0) {
284 printf("AliTRDclusterizer::OpenInput -- ");
285 printf("No entries in the trees for event %d.\n",fEvent);
289 // Get the TRD object
290 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
292 printf("AliTRDclusterizer::OpenInput -- ");
293 printf("No TRD detector object found\n");
301 //_____________________________________________________________________________
302 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
305 // Fills TRDcluster branch in the tree with the clusters
306 // found in detector = det. For det=-1 writes the tree.
309 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
310 printf("AliTRDclusterizer::WriteClusters -- ");
311 printf("Unexpected detector index %d.\n",det);
315 TDirectory *savedir = gDirectory;
321 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
323 TObjArray *ioArray = 0;
324 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
327 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
329 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
330 TObjArray *detRecPoints = new TObjArray(400);
332 for (Int_t i = 0; i < nRecPoints; i++) {
333 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
334 if (det == c->GetDetector()) {
335 detRecPoints->AddLast(c);
338 printf("AliTRDclusterizer::WriteClusters --");
339 printf("Attempt to write a cluster with unexpected detector index\n");
343 branch->SetAddress(&detRecPoints);
344 fClusterTree->Fill();
352 printf("AliTRDclusterizer::WriteClusters -- ");
353 printf("Writing the cluster tree %-18s for event %d.\n"
354 ,fClusterTree->GetName(),fEvent);
356 fClusterTree->Write();
364 printf("AliTRDclusterizer::WriteClusters -- ");
365 printf("Unexpected detector index %d.\n",det);