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