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