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.5 2000/06/09 11:10:07 cblume
19 Compiler warnings and coding conventions, next round
21 Revision 1.4 2000/06/08 18:32:58 cblume
22 Make code compliant to coding conventions
24 Revision 1.3 2000/06/07 16:27:01 cblume
25 Try to remove compiler warnings on Sun and HP
27 Revision 1.2 2000/05/08 16:17:27 cblume
30 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
31 Add new class AliTRDdigitsManager
35 ///////////////////////////////////////////////////////////////////////////////
37 // Manages the digits and the track dictionary in the form of //
38 // AliTRDdataArray objects. //
40 ///////////////////////////////////////////////////////////////////////////////
46 #include "AliTRDdigitsManager.h"
47 #include "AliTRDconst.h"
49 ClassImp(AliTRDdigitsManager)
51 //_____________________________________________________________________________
52 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
55 // Default constructor
60 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
62 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
63 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
68 //_____________________________________________________________________________
69 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
72 // AliTRDdigitsManager copy constructor
75 ((AliTRDdigitsManager &) m).Copy(*this);
79 //_____________________________________________________________________________
80 AliTRDdigitsManager::~AliTRDdigitsManager()
83 // AliTRDdigitsManager destructor
91 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
92 fDictionary[iDict]->Delete();
93 delete fDictionary[iDict];
98 //_____________________________________________________________________________
99 void AliTRDdigitsManager::Copy(TObject &m)
105 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
111 //_____________________________________________________________________________
112 void AliTRDdigitsManager::SetRaw()
117 fDigits->SetBit(kRawDigit);
121 //_____________________________________________________________________________
122 Bool_t AliTRDdigitsManager::MakeBranch()
125 // Creates the branches for the digits and the dictionary in the digits tree
128 Int_t buffersize = 64000;
130 Bool_t status = kTRUE;
132 if (gAlice->TreeD()) {
134 // Make the branch for the digits
136 const AliTRDdataArrayI *kDigits =
137 (AliTRDdataArrayI *) fDigits->At(0);
139 gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName()
140 ,&kDigits,buffersize,1);
141 printf("AliTRDdigitsManager::MakeBranch -- ");
142 printf("Making branch TRDdigits\n");
152 // Make the branches for the dictionaries
153 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
155 Char_t branchname[15];
156 sprintf(branchname,"TRDdictionary%d",iDict);
157 if (fDictionary[iDict]) {
158 const AliTRDdataArrayI *kDictionary =
159 (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
161 gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName()
162 ,&kDictionary,buffersize,1);
163 printf("AliTRDdigitsManager::MakeBranch -- ");
164 printf("Making branch %s\n",branchname);
184 //_____________________________________________________________________________
185 Bool_t AliTRDdigitsManager::ReadDigits()
188 // Reads the digit information from the input file
191 Bool_t status = kTRUE;
193 status = fDigits->LoadArray("TRDdigits");
195 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
196 Char_t branchname[15];
197 sprintf(branchname,"TRDdictionary%d",iDict);
198 status = fDictionary[iDict]->LoadArray(branchname);
201 if (fDigits->TestBit(kRawDigit)) {
212 //_____________________________________________________________________________
213 Bool_t AliTRDdigitsManager::WriteDigits()
216 // Writes out the TRD-digits and the dictionaries
219 // Create the branches
220 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
221 if (!MakeBranch()) return kFALSE;
224 // Store the contents of the segment array in the tree
225 if (!fDigits->StoreArray("TRDdigits")) {
226 printf("AliTRDdigitsManager::WriteDigits -- ");
227 printf("Error while storing digits in branch TRDdigits\n");
230 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
231 Char_t branchname[15];
232 sprintf(branchname,"TRDdictionary%d",iDict);
233 if (!fDictionary[iDict]->StoreArray(branchname)) {
234 printf("AliTRDdigitsManager::WriteDigits -- ");
235 printf("Error while storing dictionary in branch %s\n",branchname);
244 //_____________________________________________________________________________
245 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
246 , Int_t time, Int_t det)
249 // Creates a single digit object
260 amp[0] = GetDigits(det)->GetData(row,col,time);
262 return (new AliTRDdigit(fIsRaw,digits,amp));
266 //_____________________________________________________________________________
267 Int_t AliTRDdigitsManager::GetTrack(Int_t track
268 , Int_t row, Int_t col, Int_t time
272 // Returns the MC-track numbers from the dictionary.
275 if ((track < 0) || (track >= kNDict)) {
276 TObject::Error("GetTracks"
277 ,"track %d out of bounds (size: %d, this: 0x%08x)"
282 // Array contains index+1 to allow data compression
283 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
287 //_____________________________________________________________________________
288 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det)
291 // Returns the digits array for one detector
294 return (AliTRDdataArrayI *) fDigits->At(det);
298 //_____________________________________________________________________________
299 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i)
302 // Returns the dictionary for one detector
305 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
309 //_____________________________________________________________________________
310 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit)
313 // Returns the MC-track numbers from the dictionary for a given digit
316 Int_t row = Digit->GetRow();
317 Int_t col = Digit->GetCol();
318 Int_t time = Digit->GetTime();
319 Int_t det = Digit->GetDetector();
321 return GetTrack(track,row,col,time,det);
325 //_____________________________________________________________________________
326 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
329 // Assignment operator
332 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);