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