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 2001/11/27 08:50:33 hristov
19 BranchOld replaced by Branch
21 Revision 1.10 2001/11/14 10:50:45 cblume
22 Changes in digits IO. Add merging of summable digits
24 Revision 1.9 2001/10/21 18:30:02 hristov
25 Several pointers were set to zero in the default constructors to avoid memory management problems
27 Revision 1.8 2001/05/07 08:06:44 cblume
28 Speedup of the code. Create only AliTRDcluster
30 Revision 1.7 2001/03/30 14:40:14 cblume
31 Update of the digitization parameter
33 Revision 1.6 2000/11/01 14:53:20 cblume
34 Merge with TRD-develop
37 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
40 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
43 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
44 Replace include files by forward declarations
46 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
47 Adapted to tracking code
49 Revision 1.5 2000/10/02 21:28:19 fca
50 Removal of useless dependecies via forward declarations
52 Revision 1.4 2000/06/09 11:10:07 cblume
53 Compiler warnings and coding conventions, next round
55 Revision 1.3 2000/06/08 18:32:58 cblume
56 Make code compliant to coding conventions
58 Revision 1.2 2000/05/08 16:17:27 cblume
61 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
62 Remove the class AliTRDcluster
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.1 2000/02/28 18:57:58 cblume
81 ///////////////////////////////////////////////////////////////////////////////
83 // TRD cluster finder base class //
85 ///////////////////////////////////////////////////////////////////////////////
93 #include "AliTRDclusterizer.h"
94 #include "AliTRDcluster.h"
95 #include "AliTRDrecPoint.h"
96 #include "AliTRDgeometry.h"
97 #include "AliTRDparameter.h"
99 ClassImp(AliTRDclusterizer)
101 //_____________________________________________________________________________
102 AliTRDclusterizer::AliTRDclusterizer():TNamed()
105 // AliTRDclusterizer default constructor
118 //_____________________________________________________________________________
119 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
123 // AliTRDclusterizer default constructor
135 //_____________________________________________________________________________
136 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
139 // AliTRDclusterizer copy constructor
142 ((AliTRDclusterizer &) c).Copy(*this);
146 //_____________________________________________________________________________
147 AliTRDclusterizer::~AliTRDclusterizer()
150 // AliTRDclusterizer destructor
159 fOutputFile->Close();
169 //_____________________________________________________________________________
170 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
173 // Assignment operator
176 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
181 //_____________________________________________________________________________
182 void AliTRDclusterizer::Copy(TObject &c)
188 ((AliTRDclusterizer &) c).fInputFile = NULL;
189 ((AliTRDclusterizer &) c).fOutputFile = NULL;
190 ((AliTRDclusterizer &) c).fClusterTree = NULL;
191 ((AliTRDclusterizer &) c).fEvent = 0;
192 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
193 ((AliTRDclusterizer &) c).fPar = 0;
197 //_____________________________________________________________________________
198 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
201 // Opens the AliROOT file. Output and input are in the same file
204 OpenInput(name,nEvent);
211 //_____________________________________________________________________________
212 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
216 // Opens the AliROOT file. Output and input are in different files
219 OpenInput(inname,nEvent);
226 //_____________________________________________________________________________
227 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
230 // Open the output file
233 TDirectory *savedir = NULL;
235 if (!fInputFile) return kFALSE;
237 if (strcmp(name,fInputFile->GetName()) != 0) {
238 savedir = gDirectory;
239 printf("AliTRDclusterizer::OpenOutput -- ");
240 printf("Open the output file %s.\n",name);
241 fOutputFile = new TFile(name,"RECREATE");
244 // Create a tree for the cluster
246 sprintf(treeName,"TreeR%d_TRD",fEvent);
247 fClusterTree = new TTree(treeName,"TRD cluster");
248 TObjArray *ioArray = 0;
249 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
259 //_____________________________________________________________________________
260 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
263 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
266 // Connect the AliRoot file containing Geometry, Kine, and Hits
267 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
269 printf("AliTRDclusterizer::OpenInput -- ");
270 printf("Open the ALIROOT-file %s.\n",name);
271 fInputFile = new TFile(name,"UPDATE");
274 printf("AliTRDclusterizer::OpenInput -- ");
275 printf("%s is already open.\n",name);
278 // Get AliRun object from file
279 gAlice = (AliRun *) fInputFile->Get("gAlice");
281 printf("AliTRDclusterizer::OpenInput -- ");
282 printf("Could not find AliRun object.\n");
288 // Import the Trees for the event nEvent in the file
289 Int_t nparticles = gAlice->GetEvent(fEvent);
290 if (nparticles <= 0) {
291 printf("AliTRDclusterizer::OpenInput -- ");
292 printf("No entries in the trees for event %d.\n",fEvent);
296 // Get the TRD object
297 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
299 printf("AliTRDclusterizer::OpenInput -- ");
300 printf("No TRD detector object found\n");
308 //_____________________________________________________________________________
309 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
312 // Fills TRDcluster branch in the tree with the clusters
313 // found in detector = det. For det=-1 writes the tree.
316 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
317 printf("AliTRDclusterizer::WriteClusters -- ");
318 printf("Unexpected detector index %d.\n",det);
322 TDirectory *savedir = gDirectory;
328 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
330 TObjArray *ioArray = 0;
331 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
334 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
336 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
337 TObjArray *detRecPoints = new TObjArray(400);
339 for (Int_t i = 0; i < nRecPoints; i++) {
340 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
341 if (det == c->GetDetector()) {
342 detRecPoints->AddLast(c);
345 printf("AliTRDclusterizer::WriteClusters --");
346 printf("Attempt to write a cluster with unexpected detector index\n");
350 branch->SetAddress(&detRecPoints);
351 fClusterTree->Fill();
359 printf("AliTRDclusterizer::WriteClusters -- ");
360 printf("Writing the cluster tree %-18s for event %d.\n"
361 ,fClusterTree->GetName(),fEvent);
363 fClusterTree->Write();
371 printf("AliTRDclusterizer::WriteClusters -- ");
372 printf("Unexpected detector index %d.\n",det);