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.6 2000/11/01 14:53:20 cblume
19 Merge with TRD-develop
22 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
25 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
28 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
29 Replace include files by forward declarations
31 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
32 Adapted to tracking code
34 Revision 1.5 2000/10/02 21:28:19 fca
35 Removal of useless dependecies via forward declarations
37 Revision 1.4 2000/06/09 11:10:07 cblume
38 Compiler warnings and coding conventions, next round
40 Revision 1.3 2000/06/08 18:32:58 cblume
41 Make code compliant to coding conventions
43 Revision 1.2 2000/05/08 16:17:27 cblume
46 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
47 Remove the class AliTRDcluster
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.1 2000/02/28 18:57:58 cblume
66 ///////////////////////////////////////////////////////////////////////////////
68 // TRD cluster finder base class //
70 ///////////////////////////////////////////////////////////////////////////////
78 #include "AliTRDclusterizer.h"
79 #include "AliTRDrecPoint.h"
80 #include "AliTRDgeometry.h"
82 ClassImp(AliTRDclusterizer)
84 //_____________________________________________________________________________
85 AliTRDclusterizer::AliTRDclusterizer():TNamed()
88 // AliTRDclusterizer default constructor
96 //_____________________________________________________________________________
97 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
101 // AliTRDclusterizer default constructor
111 //_____________________________________________________________________________
112 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
115 // AliTRDclusterizer copy constructor
118 ((AliTRDclusterizer &) c).Copy(*this);
122 //_____________________________________________________________________________
123 AliTRDclusterizer::~AliTRDclusterizer()
126 // AliTRDclusterizer destructor
136 //_____________________________________________________________________________
137 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
140 // Assignment operator
143 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
148 //_____________________________________________________________________________
149 void AliTRDclusterizer::Copy(TObject &c)
155 ((AliTRDclusterizer &) c).fInputFile = NULL;
156 ((AliTRDclusterizer &) c).fEvent = 0;
160 //_____________________________________________________________________________
161 void AliTRDclusterizer::Init()
164 // Initializes the cluster finder
169 //_____________________________________________________________________________
170 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
173 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
176 // Connect the AliRoot file containing Geometry, Kine, and Hits
177 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
179 printf("AliTRDclusterizer::Open -- ");
180 printf("Open the ALIROOT-file %s.\n",name);
181 fInputFile = new TFile(name,"UPDATE");
184 printf("AliTRDclusterizer::Open -- ");
185 printf("%s is already open.\n",name);
188 // Get AliRun object from file or create it if not on file
190 gAlice = (AliRun *) fInputFile->Get("gAlice");
192 printf("AliTRDclusterizer::Open -- ");
193 printf("Could not find AliRun object.\n");
200 // Import the Trees for the event nEvent in the file
201 Int_t nparticles = gAlice->GetEvent(fEvent);
202 if (nparticles <= 0) {
203 printf("AliTRDclusterizer::Open -- ");
204 printf("No entries in the trees for event %d.\n",fEvent);
208 // Create a tree for the reconstructed points
209 TTree *recPointTree = new TTree("ClusterTree","Tree with clusters and rec. points");
210 TObjArray *ioArray = 0;
211 recPointTree->Branch("TRDrecPoints","TObjArray",&ioArray,32000,0);
212 // TObjArray *iopointer = 0;
213 // recPointTree->Branch("Clusters","TObjArray",&iopointer,32000,0);
219 //_____________________________________________________________________________
220 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
223 // Fills TRDrecPoints branch in TRDrecPoints## tree with rec. points
224 // found in detector = det. For det=-1 writes the tree.
225 // For det=-2 recreates the tree.
229 sprintf(treeName,"TRDrecPoints%d", fEvent);
232 fInputFile->Delete(treeName);
233 TTree *tree = new TTree(treeName,"Tree with TRD rec. points");
238 //TTree *tree = (TTree *) fInputFile->Get(treeName);
239 TTree *tree = (TTree *) fInputFile->Get("ClusterTree");
240 TBranch *branch = tree->GetBranch("TRDrecPoints");
243 TObjArray *ioArray = 0;
244 branch = tree->Branch("TRDrecPoints","TObjArray",&ioArray,32000,0);
247 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
249 AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD");
250 Int_t nRecPoints = TRD->RecPoints()->GetEntriesFast();
251 TObjArray *fDetRecPoints = new TObjArray(400);
253 for (Int_t i=0; i<nRecPoints; i++) {
254 AliTRDrecPoint *p=(AliTRDrecPoint*)TRD->RecPoints()->UncheckedAt(i);
255 if(det == p->GetDetector()) fDetRecPoints->AddLast(p);
256 else printf("attempt to write a RecPoint with unexpected detector index");
259 branch->SetAddress(&fDetRecPoints);
266 printf("\rAliTRDclusterizer::WriteClusters -- ");
267 printf("Writing the cluster tree %-18s for event %d.\n"
268 ,tree->GetName(),fEvent);
274 printf("\rAliTRDclusterizer::WriteClusters -- ");
275 printf("Unexpected detector index %d.\n", det);