1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Manages the digits and the track dictionary in the form of //
21 // AliTRDdataArray objects. //
23 ///////////////////////////////////////////////////////////////////////////////
25 #include <Riostream.h>
33 #include "AliTRDdigitsManager.h"
34 #include "AliTRDsegmentArray.h"
35 #include "AliTRDdataArrayI.h"
36 #include "AliTRDdigit.h"
37 #include "AliTRDgeometry.h"
40 ClassImp(AliTRDdigitsManager)
42 //_____________________________________________________________________________
44 // Number of track dictionary arrays
45 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
47 //_____________________________________________________________________________
48 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
51 // Default constructor
61 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
62 fDictionary[iDict] = NULL;
67 //_____________________________________________________________________________
68 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
71 // AliTRDdigitsManager copy constructor
74 ((AliTRDdigitsManager &) m).Copy(*this);
78 //_____________________________________________________________________________
79 AliTRDdigitsManager::~AliTRDdigitsManager()
82 // AliTRDdigitsManager destructor
91 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
92 fDictionary[iDict]->Delete();
93 delete fDictionary[iDict];
94 fDictionary[iDict] = NULL;
99 //_____________________________________________________________________________
100 void AliTRDdigitsManager::Copy(TObject &m)
106 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
107 ((AliTRDdigitsManager &) m).fEvent = fEvent;
108 ((AliTRDdigitsManager &) m).fDebug = fDebug;
109 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
115 //_____________________________________________________________________________
116 void AliTRDdigitsManager::CreateArrays()
119 // Create the data arrays
122 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
124 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
125 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
126 ,AliTRDgeometry::Ndet());
130 //_____________________________________________________________________________
131 void AliTRDdigitsManager::ResetArrays()
134 // Reset the data arrays
140 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
142 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
143 if (fDictionary[iDict]) {
144 delete fDictionary[iDict];
146 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
147 ,AliTRDgeometry::Ndet());
152 //_____________________________________________________________________________
153 void AliTRDdigitsManager::SetRaw()
156 // Switch on the raw digits flag
161 fDigits->SetBit(AliTRDdigit::RawDigit());
165 //_____________________________________________________________________________
166 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
170 // Returns the amplitude of a digit
173 return ((Short_t) GetDigits(det)->GetData(row,col,time));
177 //_____________________________________________________________________________
178 Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree)
181 // Creates the tree and branches for the digits and the dictionary
184 Int_t buffersize = 64000;
186 Bool_t status = kTRUE;
188 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
194 // Make the branch for the digits
196 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
198 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
199 ,&kDigits,buffersize,99);
201 printf("<AliTRDdigitsManager::MakeBranch> ");
202 printf("Making branch TRDdigits\n");
213 // Make the branches for the dictionaries
214 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
215 Char_t branchname[15];
216 sprintf(branchname,"TRDdictionary%d",iDict);
217 if (fDictionary[iDict]) {
218 const AliTRDdataArray *kDictionary =
219 (AliTRDdataArray *) fDictionary[iDict]->At(0);
221 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
222 ,&kDictionary,buffersize,99);
224 printf("<AliTRDdigitsManager::MakeBranch> ");
225 printf("Making branch %s\n",branchname);
241 //_____________________________________________________________________________
242 Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
245 // Reads the digit information from the input file
248 Bool_t status = kTRUE;
258 printf("<AliTRDdigitsManager::ReadDigits> ");
259 printf("Create the data arrays.\n");
264 status = fDigits->LoadArray("TRDdigits",fTree);
266 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
267 Char_t branchname[15];
268 sprintf(branchname,"TRDdictionary%d",iDict);
269 status = fDictionary[iDict]->LoadArray(branchname,fTree);
272 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
283 //_____________________________________________________________________________
284 Bool_t AliTRDdigitsManager::WriteDigits()
287 // Writes out the TRD-digits and the dictionaries
290 // Store the contents of the segment array in the tree
291 if (!fDigits->StoreArray("TRDdigits",fTree)) {
292 printf("<AliTRDdigitsManager::WriteDigits> ");
293 printf("Error while storing digits in branch TRDdigits\n");
296 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
297 Char_t branchname[15];
298 sprintf(branchname,"TRDdictionary%d",iDict);
299 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
300 printf("<AliTRDdigitsManager::WriteDigits> ");
301 printf("Error while storing dictionary in branch %s\n",branchname);
306 // Write the new tree to the output file
308 fTree->AutoSave(); // Modification by Jiri
314 //_____________________________________________________________________________
315 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
316 , Int_t time, Int_t det) const
319 // Creates a single digit object
330 amp[0] = GetDigits(det)->GetData(row,col,time);
332 return (new AliTRDdigit(fIsRaw,digits,amp));
336 //_____________________________________________________________________________
337 Int_t AliTRDdigitsManager::GetTrack(Int_t track
338 , Int_t row, Int_t col, Int_t time
342 // Returns the MC-track numbers from the dictionary.
345 if ((track < 0) || (track >= kNDict)) {
346 TObject::Error("GetTracks"
347 ,"track %d out of bounds (size: %d, this: 0x%08x)"
352 // Array contains index+1 to allow data compression
353 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
357 //_____________________________________________________________________________
358 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
361 // Returns the digits array for one detector
364 return (AliTRDdataArrayI *) fDigits->At(det);
368 //_____________________________________________________________________________
369 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
372 // Returns the dictionary for one detector
375 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
379 //_____________________________________________________________________________
380 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
383 // Returns the MC-track numbers from the dictionary for a given digit
386 Int_t row = Digit->GetRow();
387 Int_t col = Digit->GetCol();
388 Int_t time = Digit->GetTime();
389 Int_t det = Digit->GetDetector();
391 return GetTrack(track,row,col,time,det);
395 //_____________________________________________________________________________
396 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
399 // Assignment operator
402 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);