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.17 2003/02/10 11:09:26 cblume
19 Further modifications in OpenOutput and WriteCluster
21 Revision 1.16 2003/02/07 09:45:24 cblume
22 Modification in OpenOutput() for many events in single file
24 Revision 1.15 2002/11/07 15:52:09 cblume
25 Update of tracking code for tilted pads
27 Revision 1.14 2002/10/14 14:57:43 hristov
28 Merging the VirtualMC branch to the main development branch (HEAD)
30 Revision 1.11.6.2 2002/10/11 07:26:37 hristov
31 Updating VirtualMC to v3-09-02
33 Revision 1.13 2002/09/18 09:20:53 cblume
34 Write the parameter class into the cluster file
36 Revision 1.12 2002/06/12 09:54:35 cblume
37 Update of tracking code provided by Sergei
39 Revision 1.11 2001/11/27 08:50:33 hristov
40 BranchOld replaced by Branch
42 Revision 1.10 2001/11/14 10:50:45 cblume
43 Changes in digits IO. Add merging of summable digits
45 Revision 1.9 2001/10/21 18:30:02 hristov
46 Several pointers were set to zero in the default constructors to avoid memory management problems
48 Revision 1.8 2001/05/07 08:06:44 cblume
49 Speedup of the code. Create only AliTRDcluster
51 Revision 1.7 2001/03/30 14:40:14 cblume
52 Update of the digitization parameter
54 Revision 1.6 2000/11/01 14:53:20 cblume
55 Merge with TRD-develop
58 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
61 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
64 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
65 Replace include files by forward declarations
67 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
68 Adapted to tracking code
70 Revision 1.5 2000/10/02 21:28:19 fca
71 Removal of useless dependecies via forward declarations
73 Revision 1.4 2000/06/09 11:10:07 cblume
74 Compiler warnings and coding conventions, next round
76 Revision 1.3 2000/06/08 18:32:58 cblume
77 Make code compliant to coding conventions
79 Revision 1.2 2000/05/08 16:17:27 cblume
82 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
83 Remove the class AliTRDcluster
85 Revision 1.4 2000/06/09 11:10:07 cblume
86 Compiler warnings and coding conventions, next round
88 Revision 1.3 2000/06/08 18:32:58 cblume
89 Make code compliant to coding conventions
91 Revision 1.2 2000/05/08 16:17:27 cblume
94 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
95 Remove the class AliTRDcluster
97 Revision 1.1 2000/02/28 18:57:58 cblume
102 ///////////////////////////////////////////////////////////////////////////////
104 // TRD cluster finder base class //
106 ///////////////////////////////////////////////////////////////////////////////
114 #include "AliTRDclusterizer.h"
115 #include "AliTRDcluster.h"
116 #include "AliTRDrecPoint.h"
117 #include "AliTRDgeometry.h"
118 #include "AliTRDparameter.h"
120 ClassImp(AliTRDclusterizer)
122 //_____________________________________________________________________________
123 AliTRDclusterizer::AliTRDclusterizer():TNamed()
126 // AliTRDclusterizer default constructor
130 fInputFileCreated = kFALSE;
132 fOutputFileCreated = kFALSE;
141 //_____________________________________________________________________________
142 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
146 // AliTRDclusterizer default constructor
158 //_____________________________________________________________________________
159 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
162 // AliTRDclusterizer copy constructor
165 ((AliTRDclusterizer &) c).Copy(*this);
169 //_____________________________________________________________________________
170 AliTRDclusterizer::~AliTRDclusterizer()
173 // AliTRDclusterizer destructor
176 if (fInputFile && fInputFileCreated) {
181 if (fOutputFile && fOutputFileCreated) {
182 fOutputFile->Close();
188 //_____________________________________________________________________________
189 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
192 // Assignment operator
195 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
200 //_____________________________________________________________________________
201 void AliTRDclusterizer::Copy(TObject &c)
207 ((AliTRDclusterizer &) c).fInputFile = NULL;
208 ((AliTRDclusterizer &) c).fOutputFile = NULL;
209 ((AliTRDclusterizer &) c).fClusterTree = NULL;
210 ((AliTRDclusterizer &) c).fEvent = 0;
211 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
212 ((AliTRDclusterizer &) c).fPar = 0;
216 //_____________________________________________________________________________
217 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
220 // Opens the AliROOT file. Output and input are in the same file
223 OpenInput(name,nEvent);
230 //_____________________________________________________________________________
231 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
235 // Opens the AliROOT file. Output and input are in different files
238 OpenInput(inname,nEvent);
245 //_____________________________________________________________________________
246 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
249 // Open the output file
252 TDirectory *savedir = NULL;
254 if (!fInputFile) return kFALSE;
256 if (strcmp(name,fInputFile->GetName()) != 0) {
257 savedir = gDirectory;
258 TFile *file = (TFile *) gROOT->FindObject(name);
264 printf("AliTRDclusterizer::OpenOutput -- ");
265 printf("Open the output file %s.\n",name);
266 fOutputFile = new TFile(name,"RECREATE");
267 fOutputFileCreated = kTRUE;
271 // Create a tree for the cluster
273 sprintf(treeName,"TreeR%d_TRD",fEvent);
274 fClusterTree = new TTree(treeName,"TRD cluster");
275 TObjArray *ioArray = 0;
276 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
286 //_____________________________________________________________________________
287 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
290 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
293 // Connect the AliRoot file containing Geometry, Kine, and Hits
294 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
296 printf("AliTRDclusterizer::OpenInput -- ");
297 printf("Open the ALIROOT-file %s.\n",name);
298 fInputFile = new TFile(name,"UPDATE");
299 fInputFileCreated = kTRUE;
302 printf("AliTRDclusterizer::OpenInput -- ");
303 printf("%s is already open.\n",name);
306 // Get AliRun object from file
307 if (!(gAlice)) gAlice = (AliRun *) fInputFile->Get("gAlice");
309 printf("AliTRDclusterizer::OpenInput -- ");
310 printf("Could not find AliRun object.\n");
316 // Import the Trees for the event nEvent in the file
317 Int_t nparticles = gAlice->GetEvent(fEvent);
318 if (nparticles <= 0) {
319 printf("AliTRDclusterizer::OpenInput -- ");
320 printf("No entries in the trees for event %d.\n",fEvent);
324 // Get the TRD object
325 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
327 printf("AliTRDclusterizer::OpenInput -- ");
328 printf("No TRD detector object found\n");
336 //_____________________________________________________________________________
337 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
340 // Fills TRDcluster branch in the tree with the clusters
341 // found in detector = det. For det=-1 writes the tree.
344 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
345 printf("AliTRDclusterizer::WriteClusters -- ");
346 printf("Unexpected detector index %d.\n",det);
350 TDirectory *savedir = gDirectory;
356 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
358 TObjArray *ioArray = 0;
359 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
362 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
364 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
365 TObjArray *detRecPoints = new TObjArray(400);
367 for (Int_t i = 0; i < nRecPoints; i++) {
368 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
369 if (det == c->GetDetector()) {
370 detRecPoints->AddLast(c);
373 printf("AliTRDclusterizer::WriteClusters --");
374 printf("Attempt to write a cluster with unexpected detector index\n");
378 branch->SetAddress(&detRecPoints);
379 fClusterTree->Fill();
387 printf("AliTRDclusterizer::WriteClusters -- ");
388 printf("Writing the cluster tree %-18s for event %d.\n"
389 ,fClusterTree->GetName(),fEvent);
391 fClusterTree->Write();
393 AliTRDgeometry *geo = fTRD->GetGeometry();
394 if (!fOutputFile->Get("TRDgeometry")) {
395 geo->SetName("TRDgeometry");
398 if (!fOutputFile->Get("TRDparameter")) {
408 printf("AliTRDclusterizer::WriteClusters -- ");
409 printf("Unexpected detector index %d.\n",det);