]>
Commit | Line | Data |
---|---|---|
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$ | |
5443e65e | 18 | Revision 1.11 2001/11/27 08:50:33 hristov |
19 | BranchOld replaced by Branch | |
20 | ||
365d0374 | 21 | Revision 1.10 2001/11/14 10:50:45 cblume |
22 | Changes in digits IO. Add merging of summable digits | |
23 | ||
abaf1f1d | 24 | Revision 1.9 2001/10/21 18:30:02 hristov |
25 | Several pointers were set to zero in the default constructors to avoid memory management problems | |
26 | ||
2685bf00 | 27 | Revision 1.8 2001/05/07 08:06:44 cblume |
28 | Speedup of the code. Create only AliTRDcluster | |
29 | ||
3e1a3ad8 | 30 | Revision 1.7 2001/03/30 14:40:14 cblume |
31 | Update of the digitization parameter | |
32 | ||
a3c76cdc | 33 | Revision 1.6 2000/11/01 14:53:20 cblume |
34 | Merge with TRD-develop | |
35 | ||
793ff80c | 36 | |
37 | Revision 1.1.4.5 2000/10/15 23:40:01 cblume | |
38 | Remove AliTRDconst | |
39 | ||
40 | Revision 1.1.4.4 2000/10/06 16:49:46 cblume | |
41 | Made Getters const | |
42 | ||
43 | Revision 1.1.4.3 2000/10/04 16:34:58 cblume | |
44 | Replace include files by forward declarations | |
45 | ||
46 | Revision 1.1.4.2 2000/09/22 14:49:49 cblume | |
47 | Adapted to tracking code | |
48 | ||
49 | Revision 1.5 2000/10/02 21:28:19 fca | |
50 | Removal of useless dependecies via forward declarations | |
51 | ||
52 | Revision 1.4 2000/06/09 11:10:07 cblume | |
53 | Compiler warnings and coding conventions, next round | |
54 | ||
55 | Revision 1.3 2000/06/08 18:32:58 cblume | |
56 | Make code compliant to coding conventions | |
57 | ||
58 | Revision 1.2 2000/05/08 16:17:27 cblume | |
59 | Merge TRD-develop | |
60 | ||
61 | Revision 1.1.4.1 2000/05/08 15:08:03 cblume | |
62 | Remove the class AliTRDcluster | |
63 | ||
94de3818 | 64 | Revision 1.4 2000/06/09 11:10:07 cblume |
65 | Compiler warnings and coding conventions, next round | |
66 | ||
dd9a6ee3 | 67 | Revision 1.3 2000/06/08 18:32:58 cblume |
68 | Make code compliant to coding conventions | |
69 | ||
8230f242 | 70 | Revision 1.2 2000/05/08 16:17:27 cblume |
71 | Merge TRD-develop | |
72 | ||
6f1e466d | 73 | Revision 1.1.4.1 2000/05/08 15:08:03 cblume |
74 | Remove the class AliTRDcluster | |
75 | ||
76 | Revision 1.1 2000/02/28 18:57:58 cblume | |
77 | Add new TRD classes | |
78 | ||
f7336fa3 | 79 | */ |
80 | ||
81 | /////////////////////////////////////////////////////////////////////////////// | |
82 | // // | |
83 | // TRD cluster finder base class // | |
84 | // // | |
85 | /////////////////////////////////////////////////////////////////////////////// | |
86 | ||
94de3818 | 87 | #include <TROOT.h> |
88 | #include <TTree.h> | |
793ff80c | 89 | #include <TFile.h> |
f7336fa3 | 90 | |
94de3818 | 91 | #include "AliRun.h" |
f7336fa3 | 92 | #include "AliTRD.h" |
93 | #include "AliTRDclusterizer.h" | |
3e1a3ad8 | 94 | #include "AliTRDcluster.h" |
793ff80c | 95 | #include "AliTRDrecPoint.h" |
96 | #include "AliTRDgeometry.h" | |
5443e65e | 97 | #include "AliTRDparameter.h" |
f7336fa3 | 98 | |
99 | ClassImp(AliTRDclusterizer) | |
100 | ||
101 | //_____________________________________________________________________________ | |
102 | AliTRDclusterizer::AliTRDclusterizer():TNamed() | |
103 | { | |
104 | // | |
105 | // AliTRDclusterizer default constructor | |
106 | // | |
107 | ||
3e1a3ad8 | 108 | fInputFile = NULL; |
109 | fOutputFile = NULL; | |
110 | fClusterTree = NULL; | |
2685bf00 | 111 | fTRD = 0; |
3e1a3ad8 | 112 | fEvent = 0; |
113 | fVerbose = 0; | |
5443e65e | 114 | fPar = 0; |
f7336fa3 | 115 | |
116 | } | |
117 | ||
118 | //_____________________________________________________________________________ | |
119 | AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title) | |
120 | :TNamed(name, title) | |
121 | { | |
122 | // | |
123 | // AliTRDclusterizer default constructor | |
124 | // | |
125 | ||
3e1a3ad8 | 126 | fInputFile = NULL; |
127 | fOutputFile = NULL; | |
128 | fClusterTree = NULL; | |
129 | fEvent = 0; | |
130 | fVerbose = 0; | |
5443e65e | 131 | fPar = 0; |
f7336fa3 | 132 | |
133 | } | |
134 | ||
8230f242 | 135 | //_____________________________________________________________________________ |
dd9a6ee3 | 136 | AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c) |
8230f242 | 137 | { |
138 | // | |
139 | // AliTRDclusterizer copy constructor | |
140 | // | |
141 | ||
dd9a6ee3 | 142 | ((AliTRDclusterizer &) c).Copy(*this); |
8230f242 | 143 | |
144 | } | |
145 | ||
f7336fa3 | 146 | //_____________________________________________________________________________ |
147 | AliTRDclusterizer::~AliTRDclusterizer() | |
148 | { | |
8230f242 | 149 | // |
150 | // AliTRDclusterizer destructor | |
151 | // | |
f7336fa3 | 152 | |
153 | if (fInputFile) { | |
154 | fInputFile->Close(); | |
155 | delete fInputFile; | |
156 | } | |
157 | ||
3e1a3ad8 | 158 | if (fOutputFile) { |
159 | fOutputFile->Close(); | |
160 | delete fOutputFile; | |
161 | } | |
162 | ||
163 | if (fClusterTree) { | |
164 | delete fClusterTree; | |
165 | } | |
166 | ||
f7336fa3 | 167 | } |
168 | ||
8230f242 | 169 | //_____________________________________________________________________________ |
dd9a6ee3 | 170 | AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c) |
171 | { | |
172 | // | |
173 | // Assignment operator | |
174 | // | |
175 | ||
176 | if (this != &c) ((AliTRDclusterizer &) c).Copy(*this); | |
177 | return *this; | |
178 | ||
179 | } | |
180 | ||
181 | //_____________________________________________________________________________ | |
182 | void AliTRDclusterizer::Copy(TObject &c) | |
8230f242 | 183 | { |
184 | // | |
185 | // Copy function | |
186 | // | |
187 | ||
3e1a3ad8 | 188 | ((AliTRDclusterizer &) c).fInputFile = NULL; |
189 | ((AliTRDclusterizer &) c).fOutputFile = NULL; | |
190 | ((AliTRDclusterizer &) c).fClusterTree = NULL; | |
191 | ((AliTRDclusterizer &) c).fEvent = 0; | |
192 | ((AliTRDclusterizer &) c).fVerbose = fVerbose; | |
5443e65e | 193 | ((AliTRDclusterizer &) c).fPar = 0; |
8230f242 | 194 | |
195 | } | |
196 | ||
f7336fa3 | 197 | //_____________________________________________________________________________ |
3e1a3ad8 | 198 | Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent) |
f7336fa3 | 199 | { |
200 | // | |
3e1a3ad8 | 201 | // Opens the AliROOT file. Output and input are in the same file |
f7336fa3 | 202 | // |
203 | ||
3e1a3ad8 | 204 | OpenInput(name,nEvent); |
205 | OpenOutput(name); | |
206 | ||
207 | return kTRUE; | |
208 | ||
f7336fa3 | 209 | } |
210 | ||
211 | //_____________________________________________________________________________ | |
3e1a3ad8 | 212 | Bool_t AliTRDclusterizer::Open(const Char_t *inname, const Char_t *outname |
213 | , Int_t nEvent) | |
214 | { | |
215 | // | |
216 | // Opens the AliROOT file. Output and input are in different files | |
217 | // | |
218 | ||
219 | OpenInput(inname,nEvent); | |
220 | OpenOutput(outname); | |
221 | ||
222 | return kTRUE; | |
223 | ||
224 | } | |
225 | ||
226 | //_____________________________________________________________________________ | |
227 | Bool_t AliTRDclusterizer::OpenOutput(const Char_t *name) | |
228 | { | |
229 | // | |
230 | // Open the output file | |
231 | // | |
232 | ||
233 | TDirectory *savedir = NULL; | |
234 | ||
235 | if (!fInputFile) return kFALSE; | |
236 | ||
237 | if (strcmp(name,fInputFile->GetName()) != 0) { | |
238 | savedir = gDirectory; | |
239 | printf("AliTRDclusterizer::OpenOutput -- "); | |
240 | printf("Open the output file %s.\n",name); | |
241 | fOutputFile = new TFile(name,"RECREATE"); | |
242 | } | |
243 | ||
244 | // Create a tree for the cluster | |
abaf1f1d | 245 | Char_t treeName[12]; |
246 | sprintf(treeName,"TreeR%d_TRD",fEvent); | |
247 | fClusterTree = new TTree(treeName,"TRD cluster"); | |
3e1a3ad8 | 248 | TObjArray *ioArray = 0; |
365d0374 | 249 | fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); |
3e1a3ad8 | 250 | |
251 | if (savedir) { | |
252 | savedir->cd(); | |
253 | } | |
254 | ||
255 | return kTRUE; | |
256 | ||
257 | } | |
258 | ||
259 | //_____________________________________________________________________________ | |
260 | Bool_t AliTRDclusterizer::OpenInput(const Char_t *name, Int_t nEvent) | |
f7336fa3 | 261 | { |
262 | // | |
263 | // Opens a ROOT-file with TRD-hits and reads in the digits-tree | |
264 | // | |
265 | ||
266 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
267 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); | |
268 | if (!fInputFile) { | |
3e1a3ad8 | 269 | printf("AliTRDclusterizer::OpenInput -- "); |
f7336fa3 | 270 | printf("Open the ALIROOT-file %s.\n",name); |
271 | fInputFile = new TFile(name,"UPDATE"); | |
272 | } | |
273 | else { | |
3e1a3ad8 | 274 | printf("AliTRDclusterizer::OpenInput -- "); |
f7336fa3 | 275 | printf("%s is already open.\n",name); |
276 | } | |
277 | ||
3e1a3ad8 | 278 | // Get AliRun object from file |
279 | gAlice = (AliRun *) fInputFile->Get("gAlice"); | |
a3c76cdc | 280 | if (!(gAlice)) { |
3e1a3ad8 | 281 | printf("AliTRDclusterizer::OpenInput -- "); |
282 | printf("Could not find AliRun object.\n"); | |
283 | return kFALSE; | |
a3c76cdc | 284 | } |
f7336fa3 | 285 | |
286 | fEvent = nEvent; | |
287 | ||
288 | // Import the Trees for the event nEvent in the file | |
289 | Int_t nparticles = gAlice->GetEvent(fEvent); | |
290 | if (nparticles <= 0) { | |
3e1a3ad8 | 291 | printf("AliTRDclusterizer::OpenInput -- "); |
f7336fa3 | 292 | printf("No entries in the trees for event %d.\n",fEvent); |
293 | return kFALSE; | |
294 | } | |
295 | ||
3e1a3ad8 | 296 | // Get the TRD object |
297 | fTRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
298 | if (!fTRD) { | |
299 | printf("AliTRDclusterizer::OpenInput -- "); | |
300 | printf("No TRD detector object found\n"); | |
301 | return kFALSE; | |
302 | } | |
a3c76cdc | 303 | |
f7336fa3 | 304 | return kTRUE; |
305 | ||
306 | } | |
307 | ||
308 | //_____________________________________________________________________________ | |
793ff80c | 309 | Bool_t AliTRDclusterizer::WriteClusters(Int_t det) |
f7336fa3 | 310 | { |
311 | // | |
3e1a3ad8 | 312 | // Fills TRDcluster branch in the tree with the clusters |
793ff80c | 313 | // found in detector = det. For det=-1 writes the tree. |
a3c76cdc | 314 | // |
793ff80c | 315 | |
3e1a3ad8 | 316 | if ((det < -1) || (det >= AliTRDgeometry::Ndet())) { |
317 | printf("AliTRDclusterizer::WriteClusters -- "); | |
318 | printf("Unexpected detector index %d.\n",det); | |
319 | return kFALSE; | |
793ff80c | 320 | } |
3e1a3ad8 | 321 | |
322 | TDirectory *savedir = gDirectory; | |
f7336fa3 | 323 | |
3e1a3ad8 | 324 | if (fOutputFile) { |
325 | fOutputFile->cd(); | |
326 | } | |
f7336fa3 | 327 | |
3e1a3ad8 | 328 | TBranch *branch = fClusterTree->GetBranch("TRDcluster"); |
329 | if (!branch) { | |
793ff80c | 330 | TObjArray *ioArray = 0; |
3e1a3ad8 | 331 | branch = fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); |
793ff80c | 332 | } |
333 | ||
334 | if ((det >= 0) && (det < AliTRDgeometry::Ndet())) { | |
335 | ||
3e1a3ad8 | 336 | Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast(); |
337 | TObjArray *detRecPoints = new TObjArray(400); | |
338 | ||
339 | for (Int_t i = 0; i < nRecPoints; i++) { | |
340 | AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i); | |
341 | if (det == c->GetDetector()) { | |
342 | detRecPoints->AddLast(c); | |
343 | } | |
344 | else { | |
345 | printf("AliTRDclusterizer::WriteClusters --"); | |
346 | printf("Attempt to write a cluster with unexpected detector index\n"); | |
347 | } | |
793ff80c | 348 | } |
349 | ||
3e1a3ad8 | 350 | branch->SetAddress(&detRecPoints); |
351 | fClusterTree->Fill(); | |
352 | ||
793ff80c | 353 | return kTRUE; |
3e1a3ad8 | 354 | |
793ff80c | 355 | } |
356 | ||
357 | if (det == -1) { | |
358 | ||
3e1a3ad8 | 359 | printf("AliTRDclusterizer::WriteClusters -- "); |
793ff80c | 360 | printf("Writing the cluster tree %-18s for event %d.\n" |
3e1a3ad8 | 361 | ,fClusterTree->GetName(),fEvent); |
793ff80c | 362 | |
3e1a3ad8 | 363 | fClusterTree->Write(); |
364 | ||
793ff80c | 365 | return kTRUE; |
3e1a3ad8 | 366 | |
793ff80c | 367 | } |
368 | ||
3e1a3ad8 | 369 | savedir->cd(); |
370 | ||
371 | printf("AliTRDclusterizer::WriteClusters -- "); | |
372 | printf("Unexpected detector index %d.\n",det); | |
373 | ||
793ff80c | 374 | return kFALSE; |
f7336fa3 | 375 | |
376 | } | |
793ff80c | 377 | |
378 | ||
379 |