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.8 2001/05/07 08:06:44 cblume
19 Speedup of the code. Create only AliTRDcluster
21 Revision 1.7 2001/03/30 14:40:14 cblume
22 Update of the digitization parameter
24 Revision 1.6 2000/11/01 14:53:20 cblume
25 Merge with TRD-develop
28 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
31 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
34 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
35 Replace include files by forward declarations
37 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
38 Adapted to tracking code
40 Revision 1.5 2000/10/02 21:28:19 fca
41 Removal of useless dependecies via forward declarations
43 Revision 1.4 2000/06/09 11:10:07 cblume
44 Compiler warnings and coding conventions, next round
46 Revision 1.3 2000/06/08 18:32:58 cblume
47 Make code compliant to coding conventions
49 Revision 1.2 2000/05/08 16:17:27 cblume
52 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
53 Remove the class AliTRDcluster
55 Revision 1.4 2000/06/09 11:10:07 cblume
56 Compiler warnings and coding conventions, next round
58 Revision 1.3 2000/06/08 18:32:58 cblume
59 Make code compliant to coding conventions
61 Revision 1.2 2000/05/08 16:17:27 cblume
64 Revision 1.1.4.1 2000/05/08 15:08:03 cblume
65 Remove the class AliTRDcluster
67 Revision 1.1 2000/02/28 18:57:58 cblume
72 ///////////////////////////////////////////////////////////////////////////////
74 // TRD cluster finder base class //
76 ///////////////////////////////////////////////////////////////////////////////
84 #include "AliTRDclusterizer.h"
85 #include "AliTRDcluster.h"
86 #include "AliTRDrecPoint.h"
87 #include "AliTRDgeometry.h"
89 ClassImp(AliTRDclusterizer)
91 //_____________________________________________________________________________
92 AliTRDclusterizer::AliTRDclusterizer():TNamed()
95 // AliTRDclusterizer default constructor
107 //_____________________________________________________________________________
108 AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
112 // AliTRDclusterizer default constructor
123 //_____________________________________________________________________________
124 AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
127 // AliTRDclusterizer copy constructor
130 ((AliTRDclusterizer &) c).Copy(*this);
134 //_____________________________________________________________________________
135 AliTRDclusterizer::~AliTRDclusterizer()
138 // AliTRDclusterizer destructor
147 fOutputFile->Close();
157 //_____________________________________________________________________________
158 AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
161 // Assignment operator
164 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
169 //_____________________________________________________________________________
170 void AliTRDclusterizer::Copy(TObject &c)
176 ((AliTRDclusterizer &) c).fInputFile = NULL;
177 ((AliTRDclusterizer &) c).fOutputFile = NULL;
178 ((AliTRDclusterizer &) c).fClusterTree = NULL;
179 ((AliTRDclusterizer &) c).fEvent = 0;
180 ((AliTRDclusterizer &) c).fVerbose = fVerbose;
184 //_____________________________________________________________________________
185 Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
188 // Opens the AliROOT file. Output and input are in the same file
191 OpenInput(name,nEvent);
198 //_____________________________________________________________________________
199 Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname
203 // Opens the AliROOT file. Output and input are in different files
206 OpenInput(inname,nEvent);
213 //_____________________________________________________________________________
214 Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name)
217 // Open the output file
220 TDirectory *savedir = NULL;
222 if (!fInputFile) return kFALSE;
224 if (strcmp(name,fInputFile->GetName()) != 0) {
225 savedir = gDirectory;
226 printf("AliTRDclusterizer::OpenOutput -- ");
227 printf("Open the output file %s.\n",name);
228 fOutputFile = new TFile(name,"RECREATE");
231 // Create a tree for the cluster
232 fClusterTree = new TTree("ClusterTree","Tree with TRDcluster");
233 TObjArray *ioArray = 0;
234 fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
244 //_____________________________________________________________________________
245 Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent)
248 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
251 // Connect the AliRoot file containing Geometry, Kine, and Hits
252 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
254 printf("AliTRDclusterizer::OpenInput -- ");
255 printf("Open the ALIROOT-file %s.\n",name);
256 fInputFile = new TFile(name,"UPDATE");
259 printf("AliTRDclusterizer::OpenInput -- ");
260 printf("%s is already open.\n",name);
263 // Get AliRun object from file
264 gAlice = (AliRun *) fInputFile->Get("gAlice");
266 printf("AliTRDclusterizer::OpenInput -- ");
267 printf("Could not find AliRun object.\n");
273 // Import the Trees for the event nEvent in the file
274 Int_t nparticles = gAlice->GetEvent(fEvent);
275 if (nparticles <= 0) {
276 printf("AliTRDclusterizer::OpenInput -- ");
277 printf("No entries in the trees for event %d.\n",fEvent);
281 // Get the TRD object
282 fTRD = (AliTRD*) gAlice->GetDetector("TRD");
284 printf("AliTRDclusterizer::OpenInput -- ");
285 printf("No TRD detector object found\n");
293 //_____________________________________________________________________________
294 Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
297 // Fills TRDcluster branch in the tree with the clusters
298 // found in detector = det. For det=-1 writes the tree.
301 if ((det < -1) || (det >= AliTRDgeometry::Ndet())) {
302 printf("AliTRDclusterizer::WriteClusters -- ");
303 printf("Unexpected detector index %d.\n",det);
307 TDirectory *savedir = gDirectory;
313 TBranch *branch = fClusterTree->GetBranch("TRDcluster");
315 TObjArray *ioArray = 0;
316 branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0);
319 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
321 Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast();
322 TObjArray *detRecPoints = new TObjArray(400);
324 for (Int_t i = 0; i < nRecPoints; i++) {
325 AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i);
326 if (det == c->GetDetector()) {
327 detRecPoints->AddLast(c);
330 printf("AliTRDclusterizer::WriteClusters --");
331 printf("Attempt to write a cluster with unexpected detector index\n");
335 branch->SetAddress(&detRecPoints);
336 fClusterTree->Fill();
344 printf("AliTRDclusterizer::WriteClusters -- ");
345 printf("Writing the cluster tree %-18s for event %d.\n"
346 ,fClusterTree->GetName(),fEvent);
348 fClusterTree->Write();
356 printf("AliTRDclusterizer::WriteClusters -- ");
357 printf("Unexpected detector index %d.\n",det);