]>
Commit | Line | Data |
---|---|---|
6f1e466d | 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$ | |
81eb1f59 | 18 | Revision 1.15 2002/02/11 14:27:54 cblume |
19 | Geometry and hit structure update | |
20 | ||
855bfffd | 21 | Revision 1.14 2001/11/14 10:50:46 cblume |
22 | Changes in digits IO. Add merging of summable digits | |
23 | ||
abaf1f1d | 24 | Revision 1.13 2001/11/06 17:19:41 cblume |
25 | Add detailed geometry and simple simulator | |
26 | ||
16bf9884 | 27 | Revision 1.12 2001/05/16 14:57:28 alibrary |
28 | New files for folders and Stack | |
29 | ||
9e1a0ddb | 30 | Revision 1.11 2001/03/13 09:30:35 cblume |
31 | Update of digitization. Moved digit branch definition to AliTRD | |
32 | ||
6244debe | 33 | Revision 1.10 2001/01/26 19:56:57 hristov |
34 | Major upgrade of AliRoot code | |
35 | ||
2ab0c725 | 36 | Revision 1.9 2000/11/02 09:25:53 cblume |
37 | Change also the dictionary to AliTRDdataArray | |
38 | ||
4d6586ef | 39 | Revision 1.8 2000/11/01 15:20:13 cblume |
40 | Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch() | |
41 | ||
06754153 | 42 | Revision 1.7 2000/11/01 14:53:20 cblume |
43 | Merge with TRD-develop | |
44 | ||
793ff80c | 45 | Revision 1.1.2.5 2000/10/17 02:27:34 cblume |
46 | Get rid of global constants | |
47 | ||
48 | Revision 1.1.2.4 2000/10/15 23:40:01 cblume | |
49 | Remove AliTRDconst | |
50 | ||
51 | Revision 1.1.2.3 2000/10/06 16:49:46 cblume | |
52 | Made Getters const | |
53 | ||
54 | Revision 1.1.2.2 2000/10/04 16:34:58 cblume | |
55 | Replace include files by forward declarations | |
56 | ||
94de3818 | 57 | Revision 1.5 2000/06/09 11:10:07 cblume |
58 | Compiler warnings and coding conventions, next round | |
59 | ||
dd9a6ee3 | 60 | Revision 1.4 2000/06/08 18:32:58 cblume |
61 | Make code compliant to coding conventions | |
62 | ||
8230f242 | 63 | Revision 1.3 2000/06/07 16:27:01 cblume |
64 | Try to remove compiler warnings on Sun and HP | |
65 | ||
9d0b222b | 66 | Revision 1.2 2000/05/08 16:17:27 cblume |
67 | Merge TRD-develop | |
68 | ||
6f1e466d | 69 | Revision 1.1.2.1 2000/05/08 14:44:01 cblume |
70 | Add new class AliTRDdigitsManager | |
71 | ||
72 | */ | |
73 | ||
74 | /////////////////////////////////////////////////////////////////////////////// | |
75 | // // | |
76 | // Manages the digits and the track dictionary in the form of // | |
77 | // AliTRDdataArray objects. // | |
78 | // // | |
79 | /////////////////////////////////////////////////////////////////////////////// | |
6244debe | 80 | |
2ab0c725 | 81 | #include <iostream.h> |
793ff80c | 82 | |
2ab0c725 | 83 | #include <TROOT.h> |
793ff80c | 84 | #include <TTree.h> |
2ab0c725 | 85 | #include <TFile.h> |
94de3818 | 86 | |
6f1e466d | 87 | #include "AliRun.h" |
88 | ||
89 | #include "AliTRDdigitsManager.h" | |
793ff80c | 90 | #include "AliTRDsegmentArray.h" |
91 | #include "AliTRDdataArrayI.h" | |
92 | #include "AliTRDdigit.h" | |
93 | #include "AliTRDgeometry.h" | |
9e1a0ddb | 94 | #include "AliTRD.h" |
6f1e466d | 95 | |
96 | ClassImp(AliTRDdigitsManager) | |
97 | ||
793ff80c | 98 | //_____________________________________________________________________________ |
99 | ||
100 | // Number of track dictionary arrays | |
101 | const Int_t AliTRDdigitsManager::fgkNDict = kNDict; | |
102 | ||
6f1e466d | 103 | //_____________________________________________________________________________ |
104 | AliTRDdigitsManager::AliTRDdigitsManager():TObject() | |
105 | { | |
106 | // | |
107 | // Default constructor | |
108 | // | |
109 | ||
abaf1f1d | 110 | fIsRaw = kFALSE; |
111 | fEvent = 0; | |
855bfffd | 112 | fDebug = 0; |
abaf1f1d | 113 | fSDigits = 0; |
6f1e466d | 114 | |
abaf1f1d | 115 | fFile = NULL; |
116 | fTree = NULL; | |
117 | fDigits = NULL; | |
6f1e466d | 118 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { |
abaf1f1d | 119 | fDictionary[iDict] = NULL; |
6f1e466d | 120 | } |
121 | ||
122 | } | |
123 | ||
8230f242 | 124 | //_____________________________________________________________________________ |
dd9a6ee3 | 125 | AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) |
8230f242 | 126 | { |
127 | // | |
128 | // AliTRDdigitsManager copy constructor | |
129 | // | |
130 | ||
dd9a6ee3 | 131 | ((AliTRDdigitsManager &) m).Copy(*this); |
8230f242 | 132 | |
133 | } | |
134 | ||
6f1e466d | 135 | //_____________________________________________________________________________ |
136 | AliTRDdigitsManager::~AliTRDdigitsManager() | |
137 | { | |
8230f242 | 138 | // |
139 | // AliTRDdigitsManager destructor | |
140 | // | |
6f1e466d | 141 | |
abaf1f1d | 142 | if (fFile) { |
143 | fFile->Close(); | |
144 | delete fFile; | |
145 | fFile = NULL; | |
146 | } | |
147 | ||
6f1e466d | 148 | if (fDigits) { |
149 | fDigits->Delete(); | |
150 | delete fDigits; | |
abaf1f1d | 151 | fDigits = NULL; |
6f1e466d | 152 | } |
153 | ||
154 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
155 | fDictionary[iDict]->Delete(); | |
156 | delete fDictionary[iDict]; | |
abaf1f1d | 157 | fDictionary[iDict] = NULL; |
6f1e466d | 158 | } |
159 | ||
160 | } | |
161 | ||
8230f242 | 162 | //_____________________________________________________________________________ |
dd9a6ee3 | 163 | void AliTRDdigitsManager::Copy(TObject &m) |
8230f242 | 164 | { |
165 | // | |
166 | // Copy function | |
167 | // | |
168 | ||
abaf1f1d | 169 | ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; |
170 | ((AliTRDdigitsManager &) m).fEvent = fEvent; | |
855bfffd | 171 | ((AliTRDdigitsManager &) m).fDebug = fDebug; |
abaf1f1d | 172 | ((AliTRDdigitsManager &) m).fSDigits = fSDigits; |
8230f242 | 173 | |
174 | TObject::Copy(m); | |
175 | ||
176 | } | |
177 | ||
abaf1f1d | 178 | //_____________________________________________________________________________ |
179 | void AliTRDdigitsManager::CreateArrays() | |
180 | { | |
181 | // | |
182 | // Create the data arrays | |
183 | // | |
184 | ||
185 | fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); | |
186 | ||
187 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
188 | fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" | |
189 | ,AliTRDgeometry::Ndet()); | |
190 | } | |
191 | ||
192 | } | |
193 | ||
6f1e466d | 194 | //_____________________________________________________________________________ |
195 | void AliTRDdigitsManager::SetRaw() | |
196 | { | |
197 | ||
198 | fIsRaw = kTRUE; | |
199 | ||
793ff80c | 200 | fDigits->SetBit(AliTRDdigit::RawDigit()); |
6f1e466d | 201 | |
202 | } | |
203 | ||
16bf9884 | 204 | //_____________________________________________________________________________ |
205 | Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time | |
206 | , Int_t det) const | |
207 | { | |
208 | // | |
209 | // Returns the amplitude of a digit | |
210 | // | |
211 | ||
212 | return ((Short_t) GetDigits(det)->GetData(row,col,time)); | |
213 | ||
214 | } | |
215 | ||
6f1e466d | 216 | //_____________________________________________________________________________ |
855bfffd | 217 | Bool_t AliTRDdigitsManager::Open(const Char_t *file) |
6f1e466d | 218 | { |
219 | // | |
abaf1f1d | 220 | // Opens the file for the TRD digits |
221 | // | |
222 | ||
855bfffd | 223 | fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file); |
abaf1f1d | 224 | if (!fFile) { |
855bfffd | 225 | if (fDebug > 0) { |
226 | printf("<AliTRDdigitsManager::Open> "); | |
227 | printf("Open the AliROOT-file %s.\n",file); | |
abaf1f1d | 228 | } |
855bfffd | 229 | fFile = new TFile(file,"UPDATE"); |
abaf1f1d | 230 | if (!fFile) return kFALSE; |
231 | } | |
232 | else { | |
855bfffd | 233 | if (fDebug > 0) { |
234 | printf("<AliTRDdigitsManager::Open> "); | |
235 | printf("%s is already open.\n",file); | |
abaf1f1d | 236 | } |
237 | } | |
238 | ||
239 | return kTRUE; | |
240 | ||
241 | } | |
242 | ||
243 | //_____________________________________________________________________________ | |
244 | Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file) | |
245 | { | |
246 | // | |
247 | // Creates the tree and branches for the digits and the dictionary | |
6f1e466d | 248 | // |
249 | ||
abaf1f1d | 250 | // Create the TRD digits tree |
855bfffd | 251 | TTree *tree; |
abaf1f1d | 252 | Char_t treeName[12]; |
253 | if (fSDigits) { | |
254 | sprintf(treeName,"TreeS%d_TRD",fEvent); | |
855bfffd | 255 | tree = new TTree(treeName,"TRD SDigits"); |
abaf1f1d | 256 | } |
257 | else { | |
258 | sprintf(treeName,"TreeD%d_TRD",fEvent); | |
855bfffd | 259 | tree = new TTree(treeName,"TRD Digits"); |
abaf1f1d | 260 | } |
9e1a0ddb | 261 | |
855bfffd | 262 | if (fDebug > 0) { |
263 | printf("<AliTRDdigitsManager::MakeBranch> "); | |
abaf1f1d | 264 | printf("Creating tree %s\n",treeName); |
265 | } | |
6f1e466d | 266 | |
855bfffd | 267 | return MakeBranch(tree,file); |
268 | ||
269 | } | |
270 | ||
271 | //_____________________________________________________________________________ | |
272 | Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file) | |
273 | { | |
274 | // | |
275 | // Creates the tree and branches for the digits and the dictionary | |
276 | // | |
277 | ||
278 | Int_t buffersize = 64000; | |
279 | ||
280 | Bool_t status = kTRUE; | |
281 | ||
282 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ; | |
283 | ||
284 | if (tree) { | |
285 | fTree = tree; | |
286 | } | |
287 | ||
abaf1f1d | 288 | // Make the branch for the digits |
289 | if (fDigits) { | |
290 | const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0); | |
291 | if (kDigits) { | |
292 | trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName() | |
293 | ,&kDigits,buffersize,99,file); | |
855bfffd | 294 | if (fDebug > 0) { |
295 | printf("<AliTRDdigitsManager::MakeBranch> "); | |
6f1e466d | 296 | printf("Making branch TRDdigits\n"); |
297 | } | |
6f1e466d | 298 | } |
299 | else { | |
300 | status = kFALSE; | |
301 | } | |
abaf1f1d | 302 | } |
303 | else { | |
304 | status = kFALSE; | |
305 | } | |
6f1e466d | 306 | |
abaf1f1d | 307 | // Make the branches for the dictionaries |
308 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
309 | Char_t branchname[15]; | |
310 | sprintf(branchname,"TRDdictionary%d",iDict); | |
311 | if (fDictionary[iDict]) { | |
312 | const AliTRDdataArray *kDictionary = | |
313 | (AliTRDdataArray *) fDictionary[iDict]->At(0); | |
314 | if (kDictionary) { | |
315 | trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName() | |
316 | ,&kDictionary,buffersize,99,file); | |
855bfffd | 317 | if (fDebug > 0) { |
318 | printf("<AliTRDdigitsManager::MakeBranch> "); | |
6f1e466d | 319 | printf("Making branch %s\n",branchname); |
6244debe | 320 | } |
6f1e466d | 321 | } |
322 | else { | |
323 | status = kFALSE; | |
324 | } | |
325 | } | |
abaf1f1d | 326 | else { |
327 | status = kFALSE; | |
328 | } | |
6f1e466d | 329 | } |
330 | ||
331 | return status; | |
332 | ||
333 | } | |
334 | ||
335 | //_____________________________________________________________________________ | |
855bfffd | 336 | Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree) |
6f1e466d | 337 | { |
8230f242 | 338 | // |
339 | // Reads the digit information from the input file | |
340 | // | |
6f1e466d | 341 | |
342 | Bool_t status = kTRUE; | |
343 | ||
855bfffd | 344 | if (tree) { |
345 | ||
346 | fTree = tree; | |
347 | ||
abaf1f1d | 348 | } |
349 | else { | |
855bfffd | 350 | |
351 | // Get the digits tree | |
352 | Char_t treeName[12]; | |
353 | if (fSDigits) { | |
354 | sprintf(treeName,"TreeS%d_TRD",fEvent); | |
abaf1f1d | 355 | } |
855bfffd | 356 | else { |
357 | sprintf(treeName,"TreeD%d_TRD",fEvent); | |
358 | } | |
359 | if (fFile) { | |
360 | fTree = (TTree *) fFile->Get(treeName); | |
361 | } | |
362 | else { | |
363 | fTree = (TTree *) gDirectory->Get(treeName); | |
364 | } | |
365 | ||
366 | if (!fTree) { | |
367 | if (fDebug > 0) { | |
368 | printf("<AliTRDdigitsManager::ReadDigits> "); | |
369 | printf("Could not find tree %s.\n",treeName); | |
370 | } | |
371 | return kFALSE; | |
372 | } | |
373 | ||
abaf1f1d | 374 | } |
375 | ||
376 | if (!fDigits) { | |
855bfffd | 377 | if (fDebug > 0) { |
378 | printf("<AliTRDdigitsManager::ReadDigits> "); | |
abaf1f1d | 379 | printf("Create the data arrays.\n"); |
380 | } | |
381 | CreateArrays(); | |
382 | } | |
383 | ||
384 | status = fDigits->LoadArray("TRDdigits",fTree); | |
6f1e466d | 385 | |
386 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
387 | Char_t branchname[15]; | |
388 | sprintf(branchname,"TRDdictionary%d",iDict); | |
abaf1f1d | 389 | status = fDictionary[iDict]->LoadArray(branchname,fTree); |
6f1e466d | 390 | } |
391 | ||
793ff80c | 392 | if (fDigits->TestBit(AliTRDdigit::RawDigit())) { |
6f1e466d | 393 | fIsRaw = kTRUE; |
394 | } | |
395 | else { | |
396 | fIsRaw = kFALSE; | |
397 | } | |
398 | ||
399 | return kTRUE; | |
400 | ||
401 | } | |
402 | ||
403 | //_____________________________________________________________________________ | |
404 | Bool_t AliTRDdigitsManager::WriteDigits() | |
405 | { | |
406 | // | |
407 | // Writes out the TRD-digits and the dictionaries | |
408 | // | |
409 | ||
6f1e466d | 410 | // Store the contents of the segment array in the tree |
abaf1f1d | 411 | if (!fDigits->StoreArray("TRDdigits",fTree)) { |
855bfffd | 412 | printf("<AliTRDdigitsManager::WriteDigits> "); |
6f1e466d | 413 | printf("Error while storing digits in branch TRDdigits\n"); |
414 | return kFALSE; | |
415 | } | |
416 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
417 | Char_t branchname[15]; | |
418 | sprintf(branchname,"TRDdictionary%d",iDict); | |
abaf1f1d | 419 | if (!fDictionary[iDict]->StoreArray(branchname,fTree)) { |
855bfffd | 420 | printf("<AliTRDdigitsManager::WriteDigits> "); |
6f1e466d | 421 | printf("Error while storing dictionary in branch %s\n",branchname); |
422 | return kFALSE; | |
423 | } | |
424 | } | |
425 | ||
abaf1f1d | 426 | // Write the new tree to the output file |
427 | fTree->Write(); | |
428 | ||
6f1e466d | 429 | return kTRUE; |
430 | ||
431 | } | |
9d0b222b | 432 | |
433 | //_____________________________________________________________________________ | |
434 | AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col | |
793ff80c | 435 | , Int_t time, Int_t det) const |
9d0b222b | 436 | { |
437 | // | |
438 | // Creates a single digit object | |
439 | // | |
440 | ||
441 | Int_t digits[4]; | |
442 | Int_t amp[1]; | |
443 | ||
444 | digits[0] = det; | |
445 | digits[1] = row; | |
446 | digits[2] = col; | |
447 | digits[3] = time; | |
448 | ||
449 | amp[0] = GetDigits(det)->GetData(row,col,time); | |
450 | ||
451 | return (new AliTRDdigit(fIsRaw,digits,amp)); | |
452 | ||
453 | } | |
454 | ||
455 | //_____________________________________________________________________________ | |
456 | Int_t AliTRDdigitsManager::GetTrack(Int_t track | |
457 | , Int_t row, Int_t col, Int_t time | |
793ff80c | 458 | , Int_t det) const |
9d0b222b | 459 | { |
460 | // | |
461 | // Returns the MC-track numbers from the dictionary. | |
462 | // | |
463 | ||
464 | if ((track < 0) || (track >= kNDict)) { | |
465 | TObject::Error("GetTracks" | |
466 | ,"track %d out of bounds (size: %d, this: 0x%08x)" | |
467 | ,track,kNDict,this); | |
468 | return -1; | |
469 | } | |
470 | ||
471 | // Array contains index+1 to allow data compression | |
472 | return (GetDictionary(det,track)->GetData(row,col,time) - 1); | |
473 | ||
474 | } | |
475 | ||
dd9a6ee3 | 476 | //_____________________________________________________________________________ |
793ff80c | 477 | AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const |
dd9a6ee3 | 478 | { |
479 | // | |
480 | // Returns the digits array for one detector | |
481 | // | |
482 | ||
483 | return (AliTRDdataArrayI *) fDigits->At(det); | |
484 | ||
485 | } | |
486 | ||
487 | //_____________________________________________________________________________ | |
793ff80c | 488 | AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const |
dd9a6ee3 | 489 | { |
490 | // | |
491 | // Returns the dictionary for one detector | |
492 | // | |
493 | ||
494 | return (AliTRDdataArrayI *) fDictionary[i]->At(det); | |
495 | ||
496 | } | |
497 | ||
498 | //_____________________________________________________________________________ | |
793ff80c | 499 | Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const |
dd9a6ee3 | 500 | { |
501 | // | |
502 | // Returns the MC-track numbers from the dictionary for a given digit | |
503 | // | |
504 | ||
505 | Int_t row = Digit->GetRow(); | |
506 | Int_t col = Digit->GetCol(); | |
507 | Int_t time = Digit->GetTime(); | |
508 | Int_t det = Digit->GetDetector(); | |
509 | ||
510 | return GetTrack(track,row,col,time,det); | |
511 | ||
512 | } | |
513 | ||
514 | //_____________________________________________________________________________ | |
515 | AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m) | |
516 | { | |
517 | // | |
518 | // Assignment operator | |
519 | // | |
520 | ||
521 | if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this); | |
522 | return *this; | |
523 | ||
524 | } |