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 Revision 1.2 2000/05/08 16:17:27 cblume
21 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
22 Add new class AliTRDdigitsManager
26 ///////////////////////////////////////////////////////////////////////////////
28 // Manages the digits and the track dictionary in the form of //
29 // AliTRDdataArray objects. //
31 ///////////////////////////////////////////////////////////////////////////////
35 #include "AliTRDdigitsManager.h"
36 #include "AliTRDconst.h"
38 ClassImp(AliTRDdigitsManager)
40 //_____________________________________________________________________________
41 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
44 // Default constructor
49 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
51 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
52 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
57 //_____________________________________________________________________________
58 AliTRDdigitsManager::~AliTRDdigitsManager()
66 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
67 fDictionary[iDict]->Delete();
68 delete fDictionary[iDict];
73 //_____________________________________________________________________________
74 void AliTRDdigitsManager::SetRaw()
79 fDigits->SetBit(kRawDigit);
83 //_____________________________________________________________________________
84 Bool_t AliTRDdigitsManager::MakeBranch()
87 // Creates the branches for the digits and the dictionary in the digits tree
90 Int_t buffersize = 64000;
92 Bool_t status = kTRUE;
94 if (gAlice->TreeD()) {
96 // Make the branch for the digits
98 const AliTRDdataArrayI *Digits =
99 (AliTRDdataArrayI *) fDigits->At(0);
101 gAlice->TreeD()->Branch("TRDdigits",Digits->IsA()->GetName()
102 ,&Digits,buffersize,1);
103 printf("AliTRDdigitsManager::MakeBranch -- ");
104 printf("Making branch TRDdigits\n");
114 // Make the branches for the dictionaries
115 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
117 Char_t branchname[15];
118 sprintf(branchname,"TRDdictionary%d",iDict);
119 if (fDictionary[iDict]) {
120 const AliTRDdataArrayI *Dictionary =
121 (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
123 gAlice->TreeD()->Branch(branchname,Dictionary->IsA()->GetName()
124 ,&Dictionary,buffersize,1);
125 printf("AliTRDdigitsManager::MakeBranch -- ");
126 printf("Making branch %s\n",branchname);
146 //_____________________________________________________________________________
147 Bool_t AliTRDdigitsManager::ReadDigits()
150 Bool_t status = kTRUE;
152 status = fDigits->LoadArray("TRDdigits");
154 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
155 Char_t branchname[15];
156 sprintf(branchname,"TRDdictionary%d",iDict);
157 status = fDictionary[iDict]->LoadArray(branchname);
160 if (fDigits->TestBit(kRawDigit)) {
171 //_____________________________________________________________________________
172 Bool_t AliTRDdigitsManager::WriteDigits()
175 // Writes out the TRD-digits and the dictionaries
178 // Create the branches
179 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
180 if (!MakeBranch()) return kFALSE;
183 // Store the contents of the segment array in the tree
184 if (!fDigits->StoreArray("TRDdigits")) {
185 printf("AliTRDdigitsManager::WriteDigits -- ");
186 printf("Error while storing digits in branch TRDdigits\n");
189 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
190 Char_t branchname[15];
191 sprintf(branchname,"TRDdictionary%d",iDict);
192 if (!fDictionary[iDict]->StoreArray(branchname)) {
193 printf("AliTRDdigitsManager::WriteDigits -- ");
194 printf("Error while storing dictionary in branch %s\n",branchname);
203 //_____________________________________________________________________________
204 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
205 , Int_t time, Int_t det)
208 // Creates a single digit object
219 amp[0] = GetDigits(det)->GetData(row,col,time);
221 return (new AliTRDdigit(fIsRaw,digits,amp));
225 //_____________________________________________________________________________
226 Int_t AliTRDdigitsManager::GetTrack(Int_t track
227 , Int_t row, Int_t col, Int_t time
231 // Returns the MC-track numbers from the dictionary.
234 if ((track < 0) || (track >= kNDict)) {
235 TObject::Error("GetTracks"
236 ,"track %d out of bounds (size: %d, this: 0x%08x)"
241 // Array contains index+1 to allow data compression
242 return (GetDictionary(det,track)->GetData(row,col,time) - 1);