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)
72 // AliTRDdigitsManager copy constructor
75 ((AliTRDdigitsManager &) m).Copy(*this);
79 //_____________________________________________________________________________
80 AliTRDdigitsManager::~AliTRDdigitsManager()
83 // AliTRDdigitsManager destructor
92 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
93 fDictionary[iDict]->Delete();
94 delete fDictionary[iDict];
95 fDictionary[iDict] = NULL;
100 //_____________________________________________________________________________
101 void AliTRDdigitsManager::Copy(TObject &m)
107 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
108 ((AliTRDdigitsManager &) m).fEvent = fEvent;
109 ((AliTRDdigitsManager &) m).fDebug = fDebug;
110 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
116 //_____________________________________________________________________________
117 void AliTRDdigitsManager::CreateArrays()
120 // Create the data arrays
123 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
125 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
126 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
127 ,AliTRDgeometry::Ndet());
131 //_____________________________________________________________________________
132 void AliTRDdigitsManager::ResetArrays()
135 // Reset the data arrays
141 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
143 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
144 if (fDictionary[iDict]) {
145 delete fDictionary[iDict];
147 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
148 ,AliTRDgeometry::Ndet());
153 //_____________________________________________________________________________
154 void AliTRDdigitsManager::SetRaw()
157 // Switch on the raw digits flag
162 fDigits->SetBit(AliTRDdigit::RawDigit());
166 //_____________________________________________________________________________
167 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
171 // Returns the amplitude of a digit
174 return ((Short_t) GetDigits(det)->GetData(row,col,time));
178 //_____________________________________________________________________________
179 Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree)
182 // Creates the tree and branches for the digits and the dictionary
185 Int_t buffersize = 64000;
187 Bool_t status = kTRUE;
189 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
195 // Make the branch for the digits
197 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
199 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
200 ,&kDigits,buffersize,99);
202 printf("<AliTRDdigitsManager::MakeBranch> ");
203 printf("Making branch TRDdigits\n");
214 // Make the branches for the dictionaries
215 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
216 Char_t branchname[15];
217 sprintf(branchname,"TRDdictionary%d",iDict);
218 if (fDictionary[iDict]) {
219 const AliTRDdataArray *kDictionary =
220 (AliTRDdataArray *) fDictionary[iDict]->At(0);
222 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
223 ,&kDictionary,buffersize,99);
225 printf("<AliTRDdigitsManager::MakeBranch> ");
226 printf("Making branch %s\n",branchname);
242 //_____________________________________________________________________________
243 Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
246 // Reads the digit information from the input file
249 Bool_t status = kTRUE;
259 printf("<AliTRDdigitsManager::ReadDigits> ");
260 printf("Create the data arrays.\n");
265 status = fDigits->LoadArray("TRDdigits",fTree);
267 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
268 Char_t branchname[15];
269 sprintf(branchname,"TRDdictionary%d",iDict);
270 status = fDictionary[iDict]->LoadArray(branchname,fTree);
273 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
284 //_____________________________________________________________________________
285 Bool_t AliTRDdigitsManager::WriteDigits()
288 // Writes out the TRD-digits and the dictionaries
291 // Store the contents of the segment array in the tree
292 if (!fDigits->StoreArray("TRDdigits",fTree)) {
293 printf("<AliTRDdigitsManager::WriteDigits> ");
294 printf("Error while storing digits in branch TRDdigits\n");
297 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
298 Char_t branchname[15];
299 sprintf(branchname,"TRDdictionary%d",iDict);
300 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
301 printf("<AliTRDdigitsManager::WriteDigits> ");
302 printf("Error while storing dictionary in branch %s\n",branchname);
307 // Write the new tree to the output file
309 fTree->AutoSave(); // Modification by Jiri
315 //_____________________________________________________________________________
316 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
317 , Int_t time, Int_t det) const
320 // Creates a single digit object
331 amp[0] = GetDigits(det)->GetData(row,col,time);
333 return (new AliTRDdigit(fIsRaw,digits,amp));
337 //_____________________________________________________________________________
338 Int_t AliTRDdigitsManager::GetTrack(Int_t track
339 , Int_t row, Int_t col, Int_t time
343 // Returns the MC-track numbers from the dictionary.
346 if ((track < 0) || (track >= kNDict)) {
347 TObject::Error("GetTracks"
348 ,"track %d out of bounds (size: %d, this: 0x%08x)"
353 // Array contains index+1 to allow data compression
354 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
358 //_____________________________________________________________________________
359 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
362 // Returns the digits array for one detector
365 return (AliTRDdataArrayI *) fDigits->At(det);
369 //_____________________________________________________________________________
370 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
373 // Returns the dictionary for one detector
376 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
380 //_____________________________________________________________________________
381 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
384 // Returns the MC-track numbers from the dictionary for a given digit
387 Int_t row = Digit->GetRow();
388 Int_t col = Digit->GetCol();
389 Int_t time = Digit->GetTime();
390 Int_t det = Digit->GetDetector();
392 return GetTrack(track,row,col,time,det);
396 //_____________________________________________________________________________
397 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
400 // Assignment operator
403 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);