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