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.4 2000/06/08 18:32:58 cblume
19 Make code compliant to coding conventions
21 Revision 1.3 2000/06/07 16:27:01 cblume
22 Try to remove compiler warnings on Sun and HP
24 Revision 1.2 2000/05/08 16:17:27 cblume
27 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
28 Add new class AliTRDdigitsManager
32 ///////////////////////////////////////////////////////////////////////////////
34 // Manages the digits and the track dictionary in the form of //
35 // AliTRDdataArray objects. //
37 ///////////////////////////////////////////////////////////////////////////////
41 #include "AliTRDdigitsManager.h"
42 #include "AliTRDconst.h"
44 ClassImp(AliTRDdigitsManager)
46 //_____________________________________________________________________________
47 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
50 // Default constructor
55 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
57 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
58 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
63 //_____________________________________________________________________________
64 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
67 // AliTRDdigitsManager copy constructor
70 ((AliTRDdigitsManager &) m).Copy(*this);
74 //_____________________________________________________________________________
75 AliTRDdigitsManager::~AliTRDdigitsManager()
78 // AliTRDdigitsManager destructor
86 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
87 fDictionary[iDict]->Delete();
88 delete fDictionary[iDict];
93 //_____________________________________________________________________________
94 void AliTRDdigitsManager::Copy(TObject &m)
100 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
106 //_____________________________________________________________________________
107 void AliTRDdigitsManager::SetRaw()
112 fDigits->SetBit(kRawDigit);
116 //_____________________________________________________________________________
117 Bool_t AliTRDdigitsManager::MakeBranch()
120 // Creates the branches for the digits and the dictionary in the digits tree
123 Int_t buffersize = 64000;
125 Bool_t status = kTRUE;
127 if (gAlice->TreeD()) {
129 // Make the branch for the digits
131 const AliTRDdataArrayI *kDigits =
132 (AliTRDdataArrayI *) fDigits->At(0);
134 gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName()
135 ,&kDigits,buffersize,1);
136 printf("AliTRDdigitsManager::MakeBranch -- ");
137 printf("Making branch TRDdigits\n");
147 // Make the branches for the dictionaries
148 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
150 Char_t branchname[15];
151 sprintf(branchname,"TRDdictionary%d",iDict);
152 if (fDictionary[iDict]) {
153 const AliTRDdataArrayI *kDictionary =
154 (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
156 gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName()
157 ,&kDictionary,buffersize,1);
158 printf("AliTRDdigitsManager::MakeBranch -- ");
159 printf("Making branch %s\n",branchname);
179 //_____________________________________________________________________________
180 Bool_t AliTRDdigitsManager::ReadDigits()
183 // Reads the digit information from the input file
186 Bool_t status = kTRUE;
188 status = fDigits->LoadArray("TRDdigits");
190 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
191 Char_t branchname[15];
192 sprintf(branchname,"TRDdictionary%d",iDict);
193 status = fDictionary[iDict]->LoadArray(branchname);
196 if (fDigits->TestBit(kRawDigit)) {
207 //_____________________________________________________________________________
208 Bool_t AliTRDdigitsManager::WriteDigits()
211 // Writes out the TRD-digits and the dictionaries
214 // Create the branches
215 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
216 if (!MakeBranch()) return kFALSE;
219 // Store the contents of the segment array in the tree
220 if (!fDigits->StoreArray("TRDdigits")) {
221 printf("AliTRDdigitsManager::WriteDigits -- ");
222 printf("Error while storing digits in branch TRDdigits\n");
225 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
226 Char_t branchname[15];
227 sprintf(branchname,"TRDdictionary%d",iDict);
228 if (!fDictionary[iDict]->StoreArray(branchname)) {
229 printf("AliTRDdigitsManager::WriteDigits -- ");
230 printf("Error while storing dictionary in branch %s\n",branchname);
239 //_____________________________________________________________________________
240 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
241 , Int_t time, Int_t det)
244 // Creates a single digit object
255 amp[0] = GetDigits(det)->GetData(row,col,time);
257 return (new AliTRDdigit(fIsRaw,digits,amp));
261 //_____________________________________________________________________________
262 Int_t AliTRDdigitsManager::GetTrack(Int_t track
263 , Int_t row, Int_t col, Int_t time
267 // Returns the MC-track numbers from the dictionary.
270 if ((track < 0) || (track >= kNDict)) {
271 TObject::Error("GetTracks"
272 ,"track %d out of bounds (size: %d, this: 0x%08x)"
277 // Array contains index+1 to allow data compression
278 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
282 //_____________________________________________________________________________
283 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det)
286 // Returns the digits array for one detector
289 return (AliTRDdataArrayI *) fDigits->At(det);
293 //_____________________________________________________________________________
294 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i)
297 // Returns the dictionary for one detector
300 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
304 //_____________________________________________________________________________
305 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit)
308 // Returns the MC-track numbers from the dictionary for a given digit
311 Int_t row = Digit->GetRow();
312 Int_t col = Digit->GetCol();
313 Int_t time = Digit->GetTime();
314 Int_t det = Digit->GetDetector();
316 return GetTrack(track,row,col,time,det);
320 //_____________________________________________________________________________
321 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
324 // Assignment operator
327 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);