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.7 2001/03/30 14:40:14 cblume
19 Update of the digitization parameter
21 Revision 1.6 2000/11/01 14:53:20 cblume
22 Merge with TRD-develop
25 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
28 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
31 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
32 Replace include files by forward declarations
34 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
35 Adapted to tracking code
37 Revision 1.5 2000/10/02 21:28:19 fca
38 Removal of useless dependecies via forward declarations
40 Revision 1.4 2000/06/09 11:10:07 cblume
41 Compiler warnings and coding conventions, next round
43 Revision 1.3 2000/06/08 18:32:58 cblume
44 Make code compliant to coding conventions
46 Revision 1.2 2000/05/08 16:17:27 cblume
49 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
50 Remove the class AliTRDcluster
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.1 2000/02/28 18:57:58 cblume
69 ///////////////////////////////////////////////////////////////////////////////
71 // TRD cluster finder base class //
73 ///////////////////////////////////////////////////////////////////////////////
81 #include "AliTRDclusterizer.h"
82 #include "AliTRDcluster.h"
83 #include "AliTRDrecPoint.h"
84 #include "AliTRDgeometry.h"
86 ClassImp(AliTRDclusterizer)
88 //_____________________________________________________________________________
89 AliTRDclusterizer::AliTRDclusterizer():TNamed()
92 // AliTRDclusterizer default constructor
103 //_____________________________________________________________________________
104 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
108 // AliTRDclusterizer default constructor
119 //_____________________________________________________________________________
120 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
123 // AliTRDclusterizer copy constructor
126 ((AliTRDclusterizer &) c).Copy(*this);
130 //_____________________________________________________________________________
131 AliTRDclusterizer::~AliTRDclusterizer()
134 // AliTRDclusterizer destructor
143 fOutputFile->Close();
153 //_____________________________________________________________________________
154 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
157 // Assignment operator
160 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
165 //_____________________________________________________________________________
166 void AliTRDclusterizer::Copy(TObject &c)
172 ((AliTRDclusterizer &) c).fInputFile = NULL;
173 ((AliTRDclusterizer &) c).fOutputFile = NULL;
174 ((AliTRDclusterizer &) c).fClusterTree = NULL;
175 ((AliTRDclusterizer &) c).fEvent = 0;
176 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
180 //_____________________________________________________________________________
181 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
184 // Opens the AliROOT file. Output and input are in the same file
187 OpenInput(name,nEvent);
194 //_____________________________________________________________________________
195 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
199 // Opens the AliROOT file. Output and input are in different files
202 OpenInput(inname,nEvent);
209 //_____________________________________________________________________________
210 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
213 // Open the output file
216 TDirectory *savedir = NULL;
218 if (!fInputFile) return kFALSE;
220 if (strcmp(name,fInputFile->GetName()) != 0) {
221 savedir = gDirectory;
222 printf("AliTRDclusterizer::OpenOutput -- ");
223 printf("Open the output file %s.\n",name);
224 fOutputFile = new TFile(name,"RECREATE");
227 // Create a tree for the cluster
228 fClusterTree = new TTree("ClusterTree","Tree with TRDcluster");
229 TObjArray *ioArray = 0;
230 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
240 //_____________________________________________________________________________
241 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
244 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
247 // Connect the AliRoot file containing Geometry, Kine, and Hits
248 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
250 printf("AliTRDclusterizer::OpenInput -- ");
251 printf("Open the ALIROOT-file %s.\n",name);
252 fInputFile = new TFile(name,"UPDATE");
255 printf("AliTRDclusterizer::OpenInput -- ");
256 printf("%s is already open.\n",name);
259 // Get AliRun object from file
260 gAlice = (AliRun *) fInputFile->Get("gAlice");
262 printf("AliTRDclusterizer::OpenInput -- ");
263 printf("Could not find AliRun object.\n");
269 // Import the Trees for the event nEvent in the file
270 Int_t nparticles = gAlice->GetEvent(fEvent);
271 if (nparticles <= 0) {
272 printf("AliTRDclusterizer::OpenInput -- ");
273 printf("No entries in the trees for event %d.\n",fEvent);
277 // Get the TRD object
278 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
280 printf("AliTRDclusterizer::OpenInput -- ");
281 printf("No TRD detector object found\n");
289 //_____________________________________________________________________________
290 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
293 // Fills TRDcluster branch in the tree with the clusters
294 // found in detector = det. For det=-1 writes the tree.
297 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
298 printf("AliTRDclusterizer::WriteClusters -- ");
299 printf("Unexpected detector index %d.\n",det);
303 TDirectory *savedir = gDirectory;
309 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
311 TObjArray *ioArray = 0;
312 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
315 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
317 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
318 TObjArray *detRecPoints = new TObjArray(400);
320 for (Int_t i = 0; i < nRecPoints; i++) {
321 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
322 if (det == c->GetDetector()) {
323 detRecPoints->AddLast(c);
326 printf("AliTRDclusterizer::WriteClusters --");
327 printf("Attempt to write a cluster with unexpected detector index\n");
331 branch->SetAddress(&detRecPoints);
332 fClusterTree->Fill();
340 printf("AliTRDclusterizer::WriteClusters -- ");
341 printf("Writing the cluster tree %-18s for event %d.\n"
342 ,fClusterTree->GetName(),fEvent);
344 fClusterTree->Write();
352 printf("AliTRDclusterizer::WriteClusters -- ");
353 printf("Unexpected detector index %d.\n",det);