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.15 2002/11/07 15:52:09 cblume
19 Update of tracking code for tilted pads
21 Revision 1.14 2002/10/14 14:57:43 hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
24 Revision 1.11.6.2 2002/10/11 07:26:37 hristov
25 Updating VirtualMC to v3-09-02
27 Revision 1.13 2002/09/18 09:20:53 cblume
28 Write the parameter class into the cluster file
30 Revision 1.12 2002/06/12 09:54:35 cblume
31 Update of tracking code provided by Sergei
33 Revision 1.11 2001/11/27 08:50:33 hristov
34 BranchOld replaced by Branch
36 Revision 1.10 2001/11/14 10:50:45 cblume
37 Changes in digits IO. Add merging of summable digits
39 Revision 1.9 2001/10/21 18:30:02 hristov
40 Several pointers were set to zero in the default constructors to avoid memory management problems
42 Revision 1.8 2001/05/07 08:06:44 cblume
43 Speedup of the code. Create only AliTRDcluster
45 Revision 1.7 2001/03/30 14:40:14 cblume
46 Update of the digitization parameter
48 Revision 1.6 2000/11/01 14:53:20 cblume
49 Merge with TRD-develop
52 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
55 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
58 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
59 Replace include files by forward declarations
61 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
62 Adapted to tracking code
64 Revision 1.5 2000/10/02 21:28:19 fca
65 Removal of useless dependecies via forward declarations
67 Revision 1.4 2000/06/09 11:10:07 cblume
68 Compiler warnings and coding conventions, next round
70 Revision 1.3 2000/06/08 18:32:58 cblume
71 Make code compliant to coding conventions
73 Revision 1.2 2000/05/08 16:17:27 cblume
76 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
77 Remove the class AliTRDcluster
79 Revision 1.4 2000/06/09 11:10:07 cblume
80 Compiler warnings and coding conventions, next round
82 Revision 1.3 2000/06/08 18:32:58 cblume
83 Make code compliant to coding conventions
85 Revision 1.2 2000/05/08 16:17:27 cblume
88 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
89 Remove the class AliTRDcluster
91 Revision 1.1 2000/02/28 18:57:58 cblume
96 ///////////////////////////////////////////////////////////////////////////////
98 // TRD cluster finder base class //
100 ///////////////////////////////////////////////////////////////////////////////
108 #include "AliTRDclusterizer.h"
109 #include "AliTRDcluster.h"
110 #include "AliTRDrecPoint.h"
111 #include "AliTRDgeometry.h"
112 #include "AliTRDparameter.h"
114 ClassImp(AliTRDclusterizer)
116 //_____________________________________________________________________________
117 AliTRDclusterizer::AliTRDclusterizer():TNamed()
120 // AliTRDclusterizer default constructor
133 //_____________________________________________________________________________
134 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
138 // AliTRDclusterizer default constructor
150 //_____________________________________________________________________________
151 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
154 // AliTRDclusterizer copy constructor
157 ((AliTRDclusterizer &) c).Copy(*this);
161 //_____________________________________________________________________________
162 AliTRDclusterizer::~AliTRDclusterizer()
165 // AliTRDclusterizer destructor
174 fOutputFile->Close();
184 //_____________________________________________________________________________
185 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
188 // Assignment operator
191 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
196 //_____________________________________________________________________________
197 void AliTRDclusterizer::Copy(TObject &c)
203 ((AliTRDclusterizer &) c).fInputFile = NULL;
204 ((AliTRDclusterizer &) c).fOutputFile = NULL;
205 ((AliTRDclusterizer &) c).fClusterTree = NULL;
206 ((AliTRDclusterizer &) c).fEvent = 0;
207 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
208 ((AliTRDclusterizer &) c).fPar = 0;
212 //_____________________________________________________________________________
213 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
216 // Opens the AliROOT file. Output and input are in the same file
219 OpenInput(name,nEvent);
226 //_____________________________________________________________________________
227 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
231 // Opens the AliROOT file. Output and input are in different files
234 OpenInput(inname,nEvent);
241 //_____________________________________________________________________________
242 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
245 // Open the output file
248 TDirectory *savedir = NULL;
250 if (!fInputFile) return kFALSE;
252 if (strcmp(name,fInputFile->GetName()) != 0) {
253 savedir = gDirectory;
254 if (fOutputFile->IsOpen()) {
258 printf("AliTRDclusterizer::OpenOutput -- ");
259 printf("Open the output file %s.\n",name);
260 fOutputFile = new TFile(name,"RECREATE");
264 // Create a tree for the cluster
266 sprintf(treeName,"TreeR%d_TRD",fEvent);
267 fClusterTree = new TTree(treeName,"TRD cluster");
268 TObjArray *ioArray = 0;
269 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
279 //_____________________________________________________________________________
280 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
283 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
286 // Connect the AliRoot file containing Geometry, Kine, and Hits
287 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
289 printf("AliTRDclusterizer::OpenInput -- ");
290 printf("Open the ALIROOT-file %s.\n",name);
291 fInputFile = new TFile(name,"UPDATE");
294 printf("AliTRDclusterizer::OpenInput -- ");
295 printf("%s is already open.\n",name);
298 // Get AliRun object from file
299 gAlice = (AliRun *) fInputFile->Get("gAlice");
301 printf("AliTRDclusterizer::OpenInput -- ");
302 printf("Could not find AliRun object.\n");
308 // Import the Trees for the event nEvent in the file
309 Int_t nparticles = gAlice->GetEvent(fEvent);
310 if (nparticles <= 0) {
311 printf("AliTRDclusterizer::OpenInput -- ");
312 printf("No entries in the trees for event %d.\n",fEvent);
316 // Get the TRD object
317 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
319 printf("AliTRDclusterizer::OpenInput -- ");
320 printf("No TRD detector object found\n");
328 //_____________________________________________________________________________
329 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
332 // Fills TRDcluster branch in the tree with the clusters
333 // found in detector = det. For det=-1 writes the tree.
336 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
337 printf("AliTRDclusterizer::WriteClusters -- ");
338 printf("Unexpected detector index %d.\n",det);
342 TDirectory *savedir = gDirectory;
348 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
350 TObjArray *ioArray = 0;
351 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
354 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
356 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
357 TObjArray *detRecPoints = new TObjArray(400);
359 for (Int_t i = 0; i < nRecPoints; i++) {
360 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
361 if (det == c->GetDetector()) {
362 detRecPoints->AddLast(c);
365 printf("AliTRDclusterizer::WriteClusters --");
366 printf("Attempt to write a cluster with unexpected detector index\n");
370 branch->SetAddress(&detRecPoints);
371 fClusterTree->Fill();
379 printf("AliTRDclusterizer::WriteClusters -- ");
380 printf("Writing the cluster tree %-18s for event %d.\n"
381 ,fClusterTree->GetName(),fEvent);
383 fClusterTree->Write();
385 AliTRDgeometry *geo = fTRD->GetGeometry();
386 geo->SetName("TRDgeometry");
396 printf("AliTRDclusterizer::WriteClusters -- ");
397 printf("Unexpected detector index %d.\n",det);