]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDclusterizer.cxx
Update of the digitization parameter
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizer.cxx
CommitLineData
f7336fa3 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
a3c76cdc 18Revision 1.6 2000/11/01 14:53:20 cblume
19Merge with TRD-develop
20
793ff80c 21
22Revision 1.1.4.5 2000/10/15 23:40:01 cblume
23Remove AliTRDconst
24
25Revision 1.1.4.4 2000/10/06 16:49:46 cblume
26Made Getters const
27
28Revision 1.1.4.3 2000/10/04 16:34:58 cblume
29Replace include files by forward declarations
30
31Revision 1.1.4.2 2000/09/22 14:49:49 cblume
32Adapted to tracking code
33
34Revision 1.5 2000/10/02 21:28:19 fca
35Removal of useless dependecies via forward declarations
36
37Revision 1.4 2000/06/09 11:10:07 cblume
38Compiler warnings and coding conventions, next round
39
40Revision 1.3 2000/06/08 18:32:58 cblume
41Make code compliant to coding conventions
42
43Revision 1.2 2000/05/08 16:17:27 cblume
44Merge TRD-develop
45
46Revision 1.1.4.1 2000/05/08 15:08:03 cblume
47Remove the class AliTRDcluster
48
94de3818 49Revision 1.4 2000/06/09 11:10:07 cblume
50Compiler warnings and coding conventions, next round
51
dd9a6ee3 52Revision 1.3 2000/06/08 18:32:58 cblume
53Make code compliant to coding conventions
54
8230f242 55Revision 1.2 2000/05/08 16:17:27 cblume
56Merge TRD-develop
57
6f1e466d 58Revision 1.1.4.1 2000/05/08 15:08:03 cblume
59Remove the class AliTRDcluster
60
61Revision 1.1 2000/02/28 18:57:58 cblume
62Add new TRD classes
63
f7336fa3 64*/
65
66///////////////////////////////////////////////////////////////////////////////
67// //
68// TRD cluster finder base class //
69// //
70///////////////////////////////////////////////////////////////////////////////
71
94de3818 72#include <TROOT.h>
73#include <TTree.h>
793ff80c 74#include <TFile.h>
f7336fa3 75
94de3818 76#include "AliRun.h"
f7336fa3 77#include "AliTRD.h"
78#include "AliTRDclusterizer.h"
793ff80c 79#include "AliTRDrecPoint.h"
80#include "AliTRDgeometry.h"
f7336fa3 81
82ClassImp(AliTRDclusterizer)
83
84//_____________________________________________________________________________
85AliTRDclusterizer::AliTRDclusterizer():TNamed()
86{
87 //
88 // AliTRDclusterizer default constructor
89 //
90
91 fInputFile = NULL;
92 fEvent = 0;
93
94}
95
96//_____________________________________________________________________________
97AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title)
98 :TNamed(name, title)
99{
100 //
101 // AliTRDclusterizer default constructor
102 //
103
104 fInputFile = NULL;
105 fEvent = 0;
106
107 Init();
108
109}
110
8230f242 111//_____________________________________________________________________________
dd9a6ee3 112AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c)
8230f242 113{
114 //
115 // AliTRDclusterizer copy constructor
116 //
117
dd9a6ee3 118 ((AliTRDclusterizer &) c).Copy(*this);
8230f242 119
120}
121
f7336fa3 122//_____________________________________________________________________________
123AliTRDclusterizer::~AliTRDclusterizer()
124{
8230f242 125 //
126 // AliTRDclusterizer destructor
127 //
f7336fa3 128
129 if (fInputFile) {
130 fInputFile->Close();
131 delete fInputFile;
132 }
133
134}
135
8230f242 136//_____________________________________________________________________________
dd9a6ee3 137AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c)
138{
139 //
140 // Assignment operator
141 //
142
143 if (this != &c) ((AliTRDclusterizer &) c).Copy(*this);
144 return *this;
145
146}
147
148//_____________________________________________________________________________
149void AliTRDclusterizer::Copy(TObject &c)
8230f242 150{
151 //
152 // Copy function
153 //
154
dd9a6ee3 155 ((AliTRDclusterizer &) c).fInputFile = NULL;
156 ((AliTRDclusterizer &) c).fEvent = 0;
8230f242 157
158}
159
f7336fa3 160//_____________________________________________________________________________
161void AliTRDclusterizer::Init()
162{
163 //
164 // Initializes the cluster finder
165 //
166
167}
168
169//_____________________________________________________________________________
170Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent)
171{
172 //
173 // Opens a ROOT-file with TRD-hits and reads in the digits-tree
174 //
175
176 // Connect the AliRoot file containing Geometry, Kine, and Hits
177 fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
178 if (!fInputFile) {
179 printf("AliTRDclusterizer::Open -- ");
180 printf("Open the ALIROOT-file %s.\n",name);
181 fInputFile = new TFile(name,"UPDATE");
182 }
183 else {
184 printf("AliTRDclusterizer::Open -- ");
185 printf("%s is already open.\n",name);
186 }
187
188 // Get AliRun object from file or create it if not on file
a3c76cdc 189 if (!(gAlice)) {
190 gAlice = (AliRun *) fInputFile->Get("gAlice");
191 if (!(gAlice)) {
f7336fa3 192 printf("AliTRDclusterizer::Open -- ");
193 printf("Could not find AliRun object.\n");
194 return kFALSE;
195 }
a3c76cdc 196 }
f7336fa3 197
198 fEvent = nEvent;
199
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);
205 return kFALSE;
206 }
207
a3c76cdc 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);
214
f7336fa3 215 return kTRUE;
216
217}
218
219//_____________________________________________________________________________
793ff80c 220Bool_t AliTRDclusterizer::WriteClusters(Int_t det)
f7336fa3 221{
222 //
793ff80c 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.
a3c76cdc 226 //
793ff80c 227
228 Char_t treeName[14];
229 sprintf(treeName,"TRDrecPoints%d", fEvent);
230
231 if (det == -2) {
232 fInputFile->Delete(treeName);
233 TTree *tree = new TTree(treeName,"Tree with TRD rec. points");
234 tree->Write();
235 return kTRUE;
236 }
f7336fa3 237
a3c76cdc 238 //TTree *tree = (TTree *) fInputFile->Get(treeName);
239 TTree *tree = (TTree *) fInputFile->Get("ClusterTree");
240 TBranch *branch = tree->GetBranch("TRDrecPoints");
f7336fa3 241
793ff80c 242 if(!branch) {
243 TObjArray *ioArray = 0;
244 branch = tree->Branch("TRDrecPoints","TObjArray",&ioArray,32000,0);
245 }
246
247 if ((det >= 0) && (det < AliTRDgeometry::Ndet())) {
248
249 AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD");
250 Int_t nRecPoints = TRD->RecPoints()->GetEntriesFast();
251 TObjArray *fDetRecPoints = new TObjArray(400);
252
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");
257 }
258
259 branch->SetAddress(&fDetRecPoints);
260 tree->Fill();
261 return kTRUE;
262 }
263
264 if (det == -1) {
265
266 printf("\rAliTRDclusterizer::WriteClusters -- ");
267 printf("Writing the cluster tree %-18s for event %d.\n"
268 ,tree->GetName(),fEvent);
269
270 tree->Write();
271 return kTRUE;
272 }
273
274 printf("\rAliTRDclusterizer::WriteClusters -- ");
275 printf("Unexpected detector index %d.\n", det);
276 return kFALSE;
f7336fa3 277
278}
793ff80c 279
280
281