]>
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 | ||
88cb7938 | 16 | /* $Id$ */ |
6f1e466d | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Manages the digits and the track dictionary in the form of // | |
b65e5048 | 21 | // TObjArray objects // |
6f1e466d | 22 | // // |
23 | /////////////////////////////////////////////////////////////////////////////// | |
6244debe | 24 | |
b65e5048 | 25 | #include <Riostream.h> |
2ab0c725 | 26 | #include <TROOT.h> |
793ff80c | 27 | #include <TTree.h> |
2ab0c725 | 28 | #include <TFile.h> |
6f1e466d | 29 | #include "AliRun.h" |
2745a409 | 30 | #include "AliLog.h" |
6f1e466d | 31 | #include "AliTRDdigitsManager.h" |
b65e5048 | 32 | #include "AliTRDarrayDictionary.h" |
33 | #include "AliTRDarrayADC.h" | |
34 | #include "AliTRDarraySignal.h" | |
793ff80c | 35 | #include "AliTRDdigit.h" |
36 | #include "AliTRDgeometry.h" | |
ca21baaa | 37 | #include "AliTRDSignalIndex.h" |
38 | ||
6f1e466d | 39 | ClassImp(AliTRDdigitsManager) |
40 | ||
793ff80c | 41 | //_____________________________________________________________________________ |
42 | ||
43 | // Number of track dictionary arrays | |
44 | const Int_t AliTRDdigitsManager::fgkNDict = kNDict; | |
45 | ||
6f1e466d | 46 | //_____________________________________________________________________________ |
2745a409 | 47 | AliTRDdigitsManager::AliTRDdigitsManager() |
48 | :TObject() | |
49 | ,fEvent(0) | |
50 | ,fTree(0) | |
b65e5048 | 51 | ,fDigits(0) |
625f5260 | 52 | ,fHasSDigits(0) |
ca21baaa | 53 | ,fSignalIndexes(NULL) |
001be664 | 54 | ,fUseDictionaries(kTRUE) |
b65e5048 | 55 | ,fTreeD(0) |
56 | ,fBranch(0) | |
6f1e466d | 57 | { |
58 | // | |
59 | // Default constructor | |
60 | // | |
61 | ||
b65e5048 | 62 | for (Int_t iDict = 0; iDict < kNDict; iDict++) |
63 | { | |
64 | fDict[iDict] = NULL; | |
65 | } | |
ca21baaa | 66 | |
ca21baaa | 67 | fSignalIndexes = new TObjArray(AliTRDgeometry::Ndet()); |
68 | ||
6f1e466d | 69 | } |
70 | ||
8230f242 | 71 | //_____________________________________________________________________________ |
dd9a6ee3 | 72 | AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) |
2745a409 | 73 | :TObject(m) |
74 | ,fEvent(m.fEvent) | |
75 | ,fTree(0) | |
b65e5048 | 76 | ,fDigits(0) |
625f5260 | 77 | ,fHasSDigits(m.fHasSDigits) |
ca21baaa | 78 | ,fSignalIndexes(NULL) |
001be664 | 79 | ,fUseDictionaries(kTRUE) |
b65e5048 | 80 | ,fTreeD(m.fTree) |
81 | ,fBranch(m.fBranch) | |
8230f242 | 82 | { |
83 | // | |
84 | // AliTRDdigitsManager copy constructor | |
85 | // | |
86 | ||
8230f242 | 87 | } |
88 | ||
6f1e466d | 89 | //_____________________________________________________________________________ |
90 | AliTRDdigitsManager::~AliTRDdigitsManager() | |
91 | { | |
8230f242 | 92 | // |
93 | // AliTRDdigitsManager destructor | |
94 | // | |
6f1e466d | 95 | |
b65e5048 | 96 | if (fDigits) |
97 | { | |
98 | fDigits->Delete(); | |
99 | delete fDigits; | |
100 | fDigits = NULL; | |
101 | } | |
6f1e466d | 102 | |
b65e5048 | 103 | for (Int_t iDict = 0; iDict < kNDict; iDict++) |
104 | { | |
105 | fDict[iDict]->Delete(); | |
106 | delete fDict[iDict]; | |
107 | fDict[iDict] = NULL; | |
108 | } | |
6f1e466d | 109 | |
b65e5048 | 110 | if (fSignalIndexes) |
111 | { | |
112 | fSignalIndexes->Delete(); | |
113 | delete fSignalIndexes; | |
114 | fSignalIndexes = NULL; | |
115 | } | |
ca21baaa | 116 | |
6f1e466d | 117 | } |
118 | ||
2745a409 | 119 | //_____________________________________________________________________________ |
120 | AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m) | |
121 | { | |
122 | // | |
123 | // Assignment operator | |
124 | // | |
125 | ||
b65e5048 | 126 | if (this != &m) |
127 | { | |
128 | ((AliTRDdigitsManager &) m).Copy(*this); | |
129 | } | |
625f5260 | 130 | |
2745a409 | 131 | return *this; |
132 | ||
133 | } | |
134 | ||
8230f242 | 135 | //_____________________________________________________________________________ |
e0d47c25 | 136 | void AliTRDdigitsManager::Copy(TObject &m) const |
8230f242 | 137 | { |
138 | // | |
139 | // Copy function | |
140 | // | |
141 | ||
625f5260 | 142 | ((AliTRDdigitsManager &) m).fEvent = fEvent; |
143 | ((AliTRDdigitsManager &) m).fHasSDigits = fHasSDigits; | |
b65e5048 | 144 | ((AliTRDdigitsManager &) m).fDigits = fDigits; |
145 | for(Int_t i=0; i<kNDict; i++) | |
146 | { | |
147 | ((AliTRDdigitsManager &) m).fDict[i] = fDict[i]; | |
148 | } | |
625f5260 | 149 | ((AliTRDdigitsManager &) m).fSignalIndexes = fSignalIndexes; |
001be664 | 150 | ((AliTRDdigitsManager &) m).fUseDictionaries = fUseDictionaries; |
151 | ||
8230f242 | 152 | TObject::Copy(m); |
153 | ||
154 | } | |
155 | ||
abaf1f1d | 156 | //_____________________________________________________________________________ |
157 | void AliTRDdigitsManager::CreateArrays() | |
158 | { | |
159 | // | |
160 | // Create the data arrays | |
161 | // | |
162 | ||
b65e5048 | 163 | if (fHasSDigits) |
164 | { | |
165 | if(fDigits) | |
166 | { | |
167 | fDigits->Delete(); | |
168 | delete fDigits; | |
169 | } | |
170 | fDigits = new TObjArray(AliTRDgeometry::Ndet()); | |
171 | for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) | |
172 | { | |
173 | AliTRDarraySignal *chamber= new AliTRDarraySignal(); | |
174 | chamber->SetNdet(index); | |
175 | fDigits->AddAt(chamber,index); | |
176 | } | |
177 | } | |
178 | else | |
179 | { | |
180 | if(fDigits) | |
181 | { | |
182 | fDigits->Delete(); | |
183 | delete fDigits; | |
184 | } | |
185 | fDigits = new TObjArray(AliTRDgeometry::Ndet()); | |
186 | for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) | |
187 | { | |
188 | AliTRDarrayADC *chamber= new AliTRDarrayADC(); | |
189 | chamber->SetNdet(index); | |
190 | fDigits->AddAt(chamber,index); | |
191 | } | |
192 | } | |
193 | ||
194 | if (fUseDictionaries) | |
195 | { | |
196 | for(Int_t iDict = 0; iDict < kNDict; iDict++) | |
197 | if(fDict[iDict]) | |
198 | { | |
199 | fDict[iDict]->Delete(); | |
200 | delete fDict[iDict]; | |
201 | } | |
202 | for(Int_t iDict = 0; iDict < kNDict; iDict++) | |
203 | { | |
204 | fDict[iDict] = new TObjArray(AliTRDgeometry::Ndet()); | |
205 | } | |
abaf1f1d | 206 | |
b65e5048 | 207 | for (Int_t iDict = 0; iDict < kNDict; iDict++) |
208 | { | |
209 | for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) | |
210 | { | |
211 | AliTRDarrayDictionary *dictio= new AliTRDarrayDictionary(); | |
212 | dictio->SetNdet(index); | |
213 | fDict[iDict]->AddAt(dictio,index); | |
214 | } | |
215 | } | |
001be664 | 216 | } |
625f5260 | 217 | |
b65e5048 | 218 | for (Int_t i = 0; i < AliTRDgeometry::Ndet(); i++) |
219 | { | |
220 | fSignalIndexes->AddLast(new AliTRDSignalIndex()); | |
221 | } | |
abaf1f1d | 222 | |
17eee78a | 223 | } |
625f5260 | 224 | |
17eee78a | 225 | //_____________________________________________________________________________ |
226 | void AliTRDdigitsManager::ResetArrays() | |
227 | { | |
228 | // | |
229 | // Reset the data arrays | |
230 | // | |
231 | ||
b65e5048 | 232 | if (fDigits) |
233 | { | |
234 | fDigits->Delete(); | |
235 | delete fDigits; | |
236 | } | |
237 | ||
238 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
239 | { | |
240 | if (fDict[iDict]) | |
241 | { | |
242 | fDict[iDict]->Delete(); | |
243 | delete fDict[iDict]; | |
244 | } | |
245 | } | |
246 | ||
247 | if (fHasSDigits) | |
248 | { | |
249 | fDigits = new TObjArray(AliTRDgeometry::Ndet()); | |
250 | for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) | |
251 | { | |
252 | AliTRDarraySignal *chamber= new AliTRDarraySignal(); | |
253 | chamber->SetNdet(index); | |
254 | fDigits->AddAt(chamber,index); | |
255 | } | |
256 | } | |
257 | else | |
258 | { | |
259 | fDigits = new TObjArray(AliTRDgeometry::Ndet()); | |
260 | for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) | |
261 | { | |
262 | AliTRDarrayADC *chamber= new AliTRDarrayADC(); | |
263 | chamber->SetNdet(index); | |
264 | fDigits->AddAt(chamber,index); | |
265 | } | |
266 | } | |
267 | ||
268 | if (fUseDictionaries) | |
269 | { | |
270 | for(Int_t iDict = 0; iDict < kNDict; iDict++) | |
271 | { | |
272 | fDict[iDict] = new TObjArray(AliTRDgeometry::Ndet()); | |
273 | } | |
274 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
275 | { | |
276 | for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) | |
277 | { | |
278 | AliTRDarrayDictionary *dictio= new AliTRDarrayDictionary(); | |
279 | dictio->SetNdet(index); | |
280 | fDict[iDict]->AddAt(dictio,index); | |
281 | } | |
282 | } | |
283 | } | |
284 | ||
285 | for (Int_t i = 0; i < AliTRDgeometry::Ndet(); i++) | |
286 | { | |
287 | AliTRDSignalIndex *idx = (AliTRDSignalIndex *) fSignalIndexes->At(i); | |
288 | if (idx) idx->Reset(); | |
289 | } | |
6f1e466d | 290 | |
6f1e466d | 291 | } |
292 | ||
16bf9884 | 293 | //_____________________________________________________________________________ |
b65e5048 | 294 | Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time, Int_t det) const |
16bf9884 | 295 | { |
296 | // | |
297 | // Returns the amplitude of a digit | |
298 | // | |
299 | ||
b65e5048 | 300 | if (!GetDigits(det)) |
301 | { | |
302 | return 0; | |
303 | } | |
304 | ||
305 | return ((Short_t) ((AliTRDarrayADC *) GetDigits(det))->GetDataB(row,col,time)); | |
16bf9884 | 306 | |
307 | } | |
b65e5048 | 308 | |
d739fd4e | 309 | //_____________________________________________________________________________ |
b65e5048 | 310 | UChar_t AliTRDdigitsManager::GetPadStatus(Int_t row, Int_t col, Int_t time, Int_t det) const |
d739fd4e | 311 | { |
c10bf383 | 312 | // |
313 | // Returns the pad status for the requested pad | |
314 | // | |
d739fd4e | 315 | |
b65e5048 | 316 | if (!GetDigits(det)) |
317 | { | |
318 | return 0; | |
319 | } | |
d739fd4e | 320 | |
b65e5048 | 321 | return ((UChar_t) ((AliTRDarrayADC *) GetDigits(det))->GetPadStatus(row,col,time)); |
322 | ||
d739fd4e | 323 | } |
324 | ||
6f1e466d | 325 | //_____________________________________________________________________________ |
b65e5048 | 326 | Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree) |
855bfffd | 327 | { |
328 | // | |
329 | // Creates the tree and branches for the digits and the dictionary | |
330 | // | |
331 | ||
b65e5048 | 332 | Int_t buffersize = 64000; |
333 | Bool_t status = kTRUE; | |
855bfffd | 334 | |
b65e5048 | 335 | if (tree) |
336 | { | |
337 | fTree = tree; | |
338 | } | |
855bfffd | 339 | |
abaf1f1d | 340 | // Make the branch for the digits |
b65e5048 | 341 | if (fDigits) |
342 | { | |
343 | if(fHasSDigits) | |
344 | { | |
345 | const AliTRDarraySignal *kDigits = (AliTRDarraySignal *) fDigits->At(0); | |
346 | if (kDigits) | |
347 | { | |
348 | if (!fTree) return kFALSE; | |
349 | AliDebug(1,"Making branch for SDigits!\n"); | |
350 | TBranch* branch = fTree->GetBranch("TRDdigits"); | |
351 | if (!branch) fTree->Branch("TRDdigits","AliTRDarraySignal",&kDigits,buffersize,99); | |
352 | AliDebug(1,"Making branch TRDdigits\n"); | |
353 | } | |
354 | else | |
355 | { | |
356 | status = kFALSE; | |
357 | } | |
358 | } | |
359 | ||
360 | if(!fHasSDigits) | |
361 | { | |
362 | const AliTRDarrayADC *kDigits = (AliTRDarrayADC *) fDigits->At(0); | |
363 | if (kDigits) | |
364 | { | |
365 | if (!fTree) return kFALSE; | |
366 | AliDebug(1,"Making branch for Digits!\n"); | |
367 | TBranch* branch = fTree->GetBranch("TRDdigits"); | |
368 | if (!branch) fTree->Branch("TRDdigits","AliTRDarrayADC",&kDigits,buffersize,99); | |
369 | AliDebug(1,"Making branch TRDdigits\n"); | |
370 | } | |
371 | else | |
372 | { | |
373 | status = kFALSE; | |
374 | } | |
375 | } | |
376 | ||
377 | } | |
378 | else | |
379 | { | |
6f1e466d | 380 | status = kFALSE; |
381 | } | |
b65e5048 | 382 | |
383 | if (fUseDictionaries) | |
384 | { | |
385 | // Make the branches for the dictionaries | |
386 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
387 | { | |
388 | Char_t branchname[15]; | |
389 | sprintf(branchname,"TRDdictionary%d",iDict); | |
390 | if (fDict[iDict]) | |
391 | { | |
392 | const AliTRDarrayDictionary *kDictionary = (AliTRDarrayDictionary *) fDict[iDict]->At(0); | |
393 | if (kDictionary) | |
394 | { | |
395 | if (!fTree) return kFALSE; | |
396 | AliDebug(2,"Making branch for dictionary!\n"); | |
397 | TBranch* branch = fTree->GetBranch(branchname); | |
398 | if (!branch) fTree->Branch(branchname,"AliTRDarrayDictionary",&kDictionary,buffersize,99); | |
399 | AliDebug(1,Form("Making branch %s\n",branchname)); | |
400 | } | |
401 | else | |
402 | { | |
403 | status = kFALSE; | |
404 | } | |
405 | } | |
406 | else | |
407 | { | |
408 | status = kFALSE; | |
409 | } | |
001be664 | 410 | } |
abaf1f1d | 411 | } |
b65e5048 | 412 | |
6f1e466d | 413 | return status; |
414 | ||
415 | } | |
416 | ||
417 | //_____________________________________________________________________________ | |
855bfffd | 418 | Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree) |
6f1e466d | 419 | { |
8230f242 | 420 | // |
421 | // Reads the digit information from the input file | |
422 | // | |
6f1e466d | 423 | |
424 | Bool_t status = kTRUE; | |
425 | ||
b65e5048 | 426 | if (tree) |
427 | { | |
428 | fTree = tree; | |
429 | } | |
430 | ||
431 | if (!fDigits) | |
432 | { | |
433 | AliDebug(1,"Create the data arrays.\n"); | |
434 | CreateArrays(); | |
435 | } | |
436 | ||
437 | status = LoadArray(fDigits,"TRDdigits",fTree); | |
438 | ||
439 | if (fUseDictionaries) | |
440 | { | |
441 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
442 | { | |
443 | Char_t branchname[15]; | |
444 | sprintf(branchname,"TRDdictionary%d",iDict); | |
445 | status = LoadArrayDict(fDict[iDict],branchname,fTree); | |
446 | if (status == kFALSE) | |
447 | { | |
448 | fUseDictionaries = kFALSE; | |
449 | AliWarning("Unable to load dict arrays. Will not use them.\n"); | |
450 | break; | |
451 | } | |
452 | } | |
453 | } | |
6f1e466d | 454 | |
455 | return kTRUE; | |
456 | ||
457 | } | |
458 | ||
459 | //_____________________________________________________________________________ | |
460 | Bool_t AliTRDdigitsManager::WriteDigits() | |
461 | { | |
462 | // | |
463 | // Writes out the TRD-digits and the dictionaries | |
464 | // | |
465 | ||
b65e5048 | 466 | // Store the contents of the detector array in the tree |
001be664 | 467 | |
b65e5048 | 468 | if (!StoreArray(fDigits,"TRDdigits",fTree)) |
469 | { | |
470 | AliError("Error while storing digits in branch TRDdigits\n"); | |
471 | return kFALSE; | |
6f1e466d | 472 | } |
6f1e466d | 473 | |
b65e5048 | 474 | if (fUseDictionaries) |
475 | { | |
476 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
477 | { | |
478 | Char_t branchname[15]; | |
479 | sprintf(branchname,"TRDdictionary%d",iDict); | |
480 | if (!StoreArrayDict(fDict[iDict],branchname,fTree)) | |
481 | { | |
482 | AliError(Form("Error while storing dictionary in branch %s\n",branchname)); | |
483 | return kFALSE; | |
484 | } | |
485 | } | |
486 | } | |
487 | ||
abaf1f1d | 488 | // Write the new tree to the output file |
b65e5048 | 489 | fTree->AutoSave(); |
abaf1f1d | 490 | |
6f1e466d | 491 | return kTRUE; |
492 | ||
493 | } | |
9d0b222b | 494 | |
495 | //_____________________________________________________________________________ | |
b65e5048 | 496 | AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row |
497 | , Int_t col | |
498 | , Int_t time | |
499 | , Int_t det) const | |
9d0b222b | 500 | { |
501 | // | |
502 | // Creates a single digit object | |
503 | // | |
504 | ||
b65e5048 | 505 | Int_t digits[4]; |
9d0b222b | 506 | Int_t amp[1]; |
507 | ||
508 | digits[0] = det; | |
509 | digits[1] = row; | |
510 | digits[2] = col; | |
511 | digits[3] = time; | |
512 | ||
b65e5048 | 513 | amp[0] = ((AliTRDarrayADC *) GetDigits(det))->GetData(row,col,time); |
9d0b222b | 514 | |
625f5260 | 515 | return (new AliTRDdigit(digits,amp)); |
9d0b222b | 516 | |
517 | } | |
518 | ||
519 | //_____________________________________________________________________________ | |
520 | Int_t AliTRDdigitsManager::GetTrack(Int_t track | |
b65e5048 | 521 | , Int_t row |
522 | , Int_t col | |
523 | , Int_t time | |
793ff80c | 524 | , Int_t det) const |
9d0b222b | 525 | { |
526 | // | |
527 | // Returns the MC-track numbers from the dictionary. | |
528 | // | |
529 | ||
b65e5048 | 530 | if ((track < 0) || (track >= kNDict)) |
531 | { | |
532 | AliError(Form("track %d out of bounds (size: %d, this: 0x%08x)",track,kNDict,this)); | |
533 | return -1; | |
534 | } | |
9d0b222b | 535 | |
b65e5048 | 536 | if (fUseDictionaries == kFALSE) |
537 | { | |
538 | return -1; | |
539 | } | |
625f5260 | 540 | |
b65e5048 | 541 | // Array contains index+1 to allow data compression--->Changed |
542 | return (((AliTRDarrayDictionary *) GetDictionary(det,track))->GetData(row,col,time) ); | |
9d0b222b | 543 | |
544 | } | |
545 | ||
b65e5048 | 546 | //________________________________________________________________________________ |
547 | AliTRDarrayADC *AliTRDdigitsManager::GetDigits(Int_t det) const | |
dd9a6ee3 | 548 | { |
549 | // | |
550 | // Returns the digits array for one detector | |
551 | // | |
552 | ||
b65e5048 | 553 | if (!fDigits) |
554 | { | |
555 | return 0x0; | |
556 | } | |
625f5260 | 557 | |
b65e5048 | 558 | if (!fHasSDigits) |
559 | { | |
560 | return (AliTRDarrayADC *) fDigits->At(det); | |
561 | } | |
562 | else | |
563 | { | |
564 | AliDebug(2,"ERROR IN DATA TYPE!!!!"); | |
565 | return 0x0; | |
566 | } | |
dd9a6ee3 | 567 | |
568 | } | |
569 | ||
570 | //_____________________________________________________________________________ | |
b65e5048 | 571 | AliTRDarraySignal *AliTRDdigitsManager::GetSDigits(Int_t det) const |
dd9a6ee3 | 572 | { |
573 | // | |
b65e5048 | 574 | // Returns the sdigits array for one detector |
dd9a6ee3 | 575 | // |
576 | ||
b65e5048 | 577 | if (!fDigits) |
578 | { | |
579 | // AliDebug(1,"NO FDIGITS!"); | |
580 | return 0x0; | |
581 | } | |
582 | ||
583 | if (fHasSDigits) | |
584 | { | |
585 | return (AliTRDarraySignal *) fDigits->At(det); | |
586 | } | |
587 | else | |
588 | { | |
589 | AliDebug(2,"ERROR IN DATA TYPE!!!!"); | |
590 | return 0x0; | |
591 | } | |
592 | ||
593 | } | |
594 | ||
595 | //_____________________________________________________________________________ | |
596 | AliTRDarrayDictionary *AliTRDdigitsManager::GetDictionary(Int_t det | |
597 | , Int_t i) const | |
598 | { | |
599 | // | |
600 | // Returns the dictionary for one detector | |
601 | // | |
625f5260 | 602 | |
b65e5048 | 603 | if (fUseDictionaries == kFALSE) |
604 | { | |
605 | return 0x0; | |
606 | } | |
dd9a6ee3 | 607 | |
b65e5048 | 608 | return (AliTRDarrayDictionary *) fDict[i]->At(det); |
609 | ||
dd9a6ee3 | 610 | } |
611 | ||
612 | //_____________________________________________________________________________ | |
b65e5048 | 613 | Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *digit) const |
dd9a6ee3 | 614 | { |
615 | // | |
616 | // Returns the MC-track numbers from the dictionary for a given digit | |
617 | // | |
618 | ||
b65e5048 | 619 | Int_t row = digit->GetRow(); |
620 | Int_t col = digit->GetCol(); | |
621 | Int_t time = digit->GetTime(); | |
622 | Int_t det = digit->GetDetector(); | |
dd9a6ee3 | 623 | |
624 | return GetTrack(track,row,col,time,det); | |
625 | ||
626 | } | |
ca21baaa | 627 | |
628 | //_____________________________________________________________________________ | |
629 | AliTRDSignalIndex *AliTRDdigitsManager::GetIndexes(Int_t det) | |
630 | { | |
631 | // | |
632 | // Returns indexes of active pads | |
633 | // | |
634 | ||
625f5260 | 635 | return (AliTRDSignalIndex *) fSignalIndexes->At(det); |
ca21baaa | 636 | |
637 | } | |
638 | ||
639 | //_____________________________________________________________________________ | |
640 | void AliTRDdigitsManager::RemoveDigits(Int_t det) | |
641 | { | |
b65e5048 | 642 | // |
643 | // Clear memory at det for Digits | |
644 | // | |
ca21baaa | 645 | |
b65e5048 | 646 | if (fDigits->At(det)) |
647 | { | |
648 | fDigits->RemoveAt(det); | |
649 | } | |
ca21baaa | 650 | |
651 | } | |
652 | ||
653 | //_____________________________________________________________________________ | |
654 | void AliTRDdigitsManager::RemoveDictionaries(Int_t det) | |
655 | { | |
656 | // | |
657 | // Clear memory | |
658 | // | |
625f5260 | 659 | |
b65e5048 | 660 | if (fUseDictionaries == kFALSE) |
661 | { | |
662 | return; | |
663 | } | |
ca21baaa | 664 | |
b65e5048 | 665 | for (Int_t i = 0; i < kNDict; i++) |
666 | { | |
667 | if (fDict[i]->At(det)) | |
668 | { | |
669 | fDict[i]->RemoveAt(det); | |
670 | } | |
671 | } | |
ca21baaa | 672 | |
673 | } | |
674 | ||
675 | //_____________________________________________________________________________ | |
676 | void AliTRDdigitsManager::ClearIndexes(Int_t det) | |
677 | { | |
678 | // | |
679 | // Clear memory | |
680 | // | |
625f5260 | 681 | |
c10bf383 | 682 | ((AliTRDSignalIndex *) fSignalIndexes->At(det))->ClearAll(); |
ca21baaa | 683 | |
625f5260 | 684 | } |
ca21baaa | 685 | |
686 | //_____________________________________________________________________________ | |
687 | Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det) | |
688 | { | |
689 | // | |
690 | // Build the list of indices | |
691 | // | |
692 | ||
b65e5048 | 693 | Int_t nRows = 0; |
694 | Int_t nCols = 0; | |
ca21baaa | 695 | Int_t nTbins = 0; |
696 | ||
b65e5048 | 697 | AliTRDgeometry geom; |
698 | AliTRDarrayADC *digits = 0x0; | |
625f5260 | 699 | |
b65e5048 | 700 | if (fHasSDigits) |
701 | { | |
702 | return kFALSE; | |
703 | } | |
704 | else | |
705 | { | |
706 | digits = (AliTRDarrayADC *) GetDigits(det); | |
707 | } | |
625f5260 | 708 | |
ca21baaa | 709 | //digits should be expanded by now!!! |
b65e5048 | 710 | if (digits->GetNtime() > 0) |
711 | { | |
712 | digits->Expand(); | |
713 | nRows = digits->GetNrow(); | |
714 | nCols = digits->GetNcol(); | |
715 | nTbins = digits->GetNtime(); | |
716 | ||
717 | AliTRDSignalIndex *indexes = GetIndexes(det); | |
718 | indexes->SetSM(geom.GetSector(det)); | |
719 | indexes->SetStack(geom.GetStack(det)); | |
720 | indexes->SetLayer(geom.GetLayer(det)); | |
721 | indexes->SetDetNumber(det); | |
722 | ||
723 | if (indexes->IsAllocated() == kFALSE) | |
724 | { | |
725 | indexes->Allocate(nRows,nCols,nTbins); | |
726 | } | |
625f5260 | 727 | |
b65e5048 | 728 | for (Int_t ir = 0; ir < nRows; ir++) |
729 | { | |
730 | for (Int_t ic = 0; ic < nCols; ic++) | |
731 | { | |
732 | for (Int_t it = 0; it < nTbins; it++) | |
733 | { | |
734 | Int_t isig = digits->GetDataB(ir,ic,it); | |
735 | if (isig > 0) | |
736 | { | |
737 | indexes->AddIndexTBin(ir,ic,it); | |
738 | } | |
739 | } // tbins | |
740 | } // cols | |
741 | } // rows | |
742 | ||
743 | } // if GetNtime | |
744 | else | |
745 | { | |
746 | return kFALSE; | |
747 | } | |
748 | ||
749 | return kTRUE; | |
625f5260 | 750 | |
b65e5048 | 751 | } |
625f5260 | 752 | |
b65e5048 | 753 | //_____________________________________________________________________________ |
754 | Bool_t AliTRDdigitsManager::LoadArray(TObjArray *object | |
755 | , const Char_t *branchname | |
756 | , TTree *tree) | |
757 | { | |
758 | // | |
759 | // Loads all detectors of the array from the branch <branchname> of | |
760 | // the digits tree <tree> | |
761 | // Adapted from code of the class AliTRDsegmentArray | |
762 | // | |
763 | ||
764 | fTreeD = tree; | |
765 | ||
766 | if (!fTreeD) | |
767 | { | |
768 | AliError("Digits tree is not defined\n"); | |
769 | return kFALSE; | |
ca21baaa | 770 | } |
625f5260 | 771 | |
b65e5048 | 772 | // Get the branch |
773 | fBranch = fTreeD->GetBranch(branchname); | |
774 | if (!fBranch) | |
775 | { | |
776 | AliError(Form("Branch %s is not defined\n",branchname)); | |
777 | return kFALSE; | |
778 | } | |
625f5260 | 779 | |
b65e5048 | 780 | // Loop through all detectors and read them from the tree |
781 | Bool_t status = kTRUE; | |
782 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) | |
783 | { | |
784 | if(fHasSDigits) | |
785 | { | |
786 | AliTRDarraySignal *dataArray = (AliTRDarraySignal *) object->At(iDet); | |
787 | if (!dataArray) | |
788 | { | |
789 | status = kFALSE; | |
790 | break; | |
791 | } | |
792 | ||
793 | fBranch->SetAddress(&dataArray); | |
794 | fBranch->GetEntry(iDet); | |
795 | } | |
796 | else | |
797 | { | |
798 | AliTRDarrayADC *dataArray = (AliTRDarrayADC *) object->At(iDet); | |
799 | if (!dataArray) | |
800 | { | |
801 | status = kFALSE; | |
802 | break; | |
803 | } | |
804 | fBranch->SetAddress(&dataArray); | |
805 | fBranch->GetEntry(iDet); | |
806 | } | |
807 | } | |
625f5260 | 808 | |
b65e5048 | 809 | return status; |
810 | ||
811 | } | |
812 | ||
813 | //________________________________________________________________________________________________ | |
814 | Bool_t AliTRDdigitsManager::LoadArrayDict(TObjArray *object | |
815 | , const Char_t *branchname | |
816 | , TTree *tree) | |
817 | { | |
818 | // | |
819 | // Loads all detectors of the array from the branch <branchname> of | |
820 | // the dictionary tree <tree> | |
821 | // Adapted from code of the class AliTRDsegmentArray | |
822 | // | |
823 | ||
824 | fTreeD = tree; | |
825 | ||
826 | if (!fTreeD) | |
827 | { | |
828 | AliError("Digits tree is not defined\n"); | |
829 | return kFALSE; | |
830 | } | |
831 | ||
832 | // Get the branch | |
833 | fBranch = fTreeD->GetBranch(branchname); | |
834 | if (!fBranch) | |
835 | { | |
836 | AliError(Form("Branch %s is not defined\n",branchname)); | |
837 | return kFALSE; | |
838 | } | |
839 | ||
840 | // Loop through all detectors and read them from the tree | |
841 | Bool_t status = kTRUE; | |
842 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) | |
843 | { | |
844 | AliTRDarrayDictionary *dataArray = (AliTRDarrayDictionary *) object->At(iDet); | |
845 | if (!dataArray) | |
846 | { | |
847 | status = kFALSE; | |
848 | break; | |
849 | } | |
850 | fBranch->SetAddress(&dataArray); | |
851 | fBranch->GetEntry(iDet); | |
852 | } | |
853 | ||
854 | return status; | |
855 | ||
856 | } | |
857 | ||
858 | //_____________________________________________________________________________ | |
859 | Bool_t AliTRDdigitsManager::StoreArray(TObjArray *array1 | |
860 | , const Char_t *branchname | |
861 | , TTree *tree) | |
862 | { | |
863 | // | |
864 | // Stores all the detectors of the array in the branch <branchname> of | |
865 | // the digits tree <tree> | |
866 | // Adapted from code of the class AliTRDsegmentArray | |
867 | // | |
868 | ||
869 | fTree = tree; | |
870 | ||
871 | if (!fTree) | |
872 | { | |
873 | AliError("Digits tree is not defined\n"); | |
874 | return kFALSE; | |
875 | } | |
876 | ||
877 | // Get the branch | |
878 | fBranch = fTree->GetBranch(branchname); | |
879 | if (!fBranch) | |
880 | { | |
881 | AliError(Form("Branch %s is not defined\n",branchname)); | |
882 | return kFALSE; | |
883 | } | |
884 | ||
885 | // Loop through all detectors and fill them into the tree | |
886 | Bool_t status = kTRUE; | |
887 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) | |
888 | { | |
889 | if (fHasSDigits) | |
890 | { | |
891 | const AliTRDarraySignal *kDataArray = (AliTRDarraySignal *) array1->At(iDet); | |
892 | if (!kDataArray) | |
893 | { | |
894 | status = kFALSE; | |
895 | break; | |
896 | } | |
897 | fBranch->SetAddress(&kDataArray); | |
898 | fBranch->Fill(); | |
899 | } | |
900 | else | |
901 | { | |
902 | const AliTRDarrayADC *kDataArray = (AliTRDarrayADC *) array1->At(iDet); | |
903 | if (!kDataArray) | |
904 | { | |
905 | status = kFALSE; | |
906 | break; | |
907 | } | |
908 | fBranch->SetAddress(&kDataArray); | |
909 | fBranch->Fill(); | |
910 | } | |
911 | } | |
912 | ||
913 | return status; | |
914 | ||
915 | } | |
916 | ||
917 | //_____________________________________________________________________________ | |
918 | Bool_t AliTRDdigitsManager::StoreArrayDict(TObjArray *array3 | |
919 | , const Char_t *branchname | |
920 | , TTree *tree) | |
921 | { | |
922 | // | |
923 | // Stores all the dictionary arrays of the detectors of the array in the branch <branchname> of | |
924 | // the dictionary tree <tree> | |
925 | // Adapted from code of the class AliTRDsegmentArray | |
926 | // | |
927 | ||
928 | // AliDebug(1,"Storing Arrays of Dictionary"); | |
929 | fTree = tree; | |
930 | ||
931 | if (!fTree) | |
932 | { | |
933 | AliError("Digits tree is not defined\n"); | |
934 | return kFALSE; | |
935 | } | |
936 | ||
937 | // Get the branch | |
938 | fBranch = fTree->GetBranch(branchname); | |
939 | if (!fBranch) | |
940 | { | |
941 | AliError(Form("Branch %s is not defined\n",branchname)); | |
942 | return kFALSE; | |
943 | } | |
944 | ||
945 | // Loop through all detectors and fill them into the tree | |
946 | Bool_t status = kTRUE; | |
947 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) | |
948 | { | |
949 | const AliTRDarrayDictionary *kDataArray = (AliTRDarrayDictionary *) array3->At(iDet); | |
950 | if (!kDataArray) | |
951 | { | |
952 | status = kFALSE; | |
953 | break; | |
954 | } | |
955 | fBranch->SetAddress(&kDataArray); | |
956 | fBranch->Fill(); | |
957 | } | |
958 | ||
959 | return status; | |
ca21baaa | 960 | |
961 | } |