]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDdigitsManager.cxx
Try to remove compiler warnings on Sun and HP
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitsManager.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.2  2000/05/08 16:17:27  cblume
19 Merge TRD-develop
20
21 Revision 1.1.2.1  2000/05/08 14:44:01  cblume
22 Add new class AliTRDdigitsManager
23
24 */
25
26 ///////////////////////////////////////////////////////////////////////////////
27 //                                                                           //
28 //  Manages the digits and the track dictionary in the form of               //
29 //  AliTRDdataArray objects.                                                 //
30 //                                                                           //
31 ///////////////////////////////////////////////////////////////////////////////
32
33 #include "AliRun.h"
34
35 #include "AliTRDdigitsManager.h"
36 #include "AliTRDconst.h"
37
38 ClassImp(AliTRDdigitsManager)
39
40 //_____________________________________________________________________________
41 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
42 {
43   //
44   // Default constructor
45   //
46
47   fIsRaw = kFALSE;
48
49   fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
50
51   for (Int_t iDict = 0; iDict < kNDict; iDict++) {
52     fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
53   }
54
55 }
56
57 //_____________________________________________________________________________
58 AliTRDdigitsManager::~AliTRDdigitsManager()
59 {
60
61   if (fDigits) {
62     fDigits->Delete();
63     delete fDigits;
64   }
65
66   for (Int_t iDict = 0; iDict < kNDict; iDict++) {
67     fDictionary[iDict]->Delete();
68     delete fDictionary[iDict];
69   }
70
71 }
72
73 //_____________________________________________________________________________
74 void AliTRDdigitsManager::SetRaw()
75 {
76
77   fIsRaw = kTRUE;
78
79   fDigits->SetBit(kRawDigit);
80   
81 }
82
83 //_____________________________________________________________________________
84 Bool_t AliTRDdigitsManager::MakeBranch()
85 {
86   //
87   // Creates the branches for the digits and the dictionary in the digits tree
88   //
89
90   Int_t buffersize = 64000;
91
92   Bool_t status = kTRUE;
93
94   if (gAlice->TreeD()) {
95
96     // Make the branch for the digits
97     if (fDigits) {
98       const AliTRDdataArrayI *Digits = 
99            (AliTRDdataArrayI *) fDigits->At(0);
100       if (Digits) {
101         gAlice->TreeD()->Branch("TRDdigits",Digits->IsA()->GetName()
102                                            ,&Digits,buffersize,1);
103         printf("AliTRDdigitsManager::MakeBranch -- ");
104         printf("Making branch TRDdigits\n");
105       }
106       else {
107         status = kFALSE;
108       }
109     }
110     else {
111       status = kFALSE;
112     }
113
114     // Make the branches for the dictionaries
115     for (Int_t iDict = 0; iDict < kNDict; iDict++) {
116
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);
122         if (Dictionary) {
123           gAlice->TreeD()->Branch(branchname,Dictionary->IsA()->GetName()
124                                             ,&Dictionary,buffersize,1);
125           printf("AliTRDdigitsManager::MakeBranch -- ");
126           printf("Making branch %s\n",branchname);
127         }
128         else {
129           status = kFALSE;
130         }
131       }
132       else {
133         status = kFALSE;
134       }
135     }
136
137   }
138   else {
139     status = kFALSE;
140   }
141
142   return status;
143
144 }
145
146 //_____________________________________________________________________________
147 Bool_t AliTRDdigitsManager::ReadDigits()
148 {
149
150   Bool_t status = kTRUE;
151
152   status = fDigits->LoadArray("TRDdigits");
153
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);
158   }  
159
160   if (fDigits->TestBit(kRawDigit)) {
161     fIsRaw = kTRUE;
162   }
163   else {
164     fIsRaw = kFALSE;
165   }
166
167   return kTRUE;
168
169 }
170
171 //_____________________________________________________________________________
172 Bool_t AliTRDdigitsManager::WriteDigits()
173 {
174   //
175   // Writes out the TRD-digits and the dictionaries
176   //
177
178   // Create the branches
179   if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) { 
180     if (!MakeBranch()) return kFALSE;
181   }
182
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");
187     return kFALSE;
188   }
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);
195       return kFALSE;
196     }
197   }
198
199   return kTRUE;
200
201 }
202
203 //_____________________________________________________________________________
204 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
205                                          , Int_t time, Int_t det)
206 {
207   // 
208   // Creates a single digit object 
209   //
210
211   Int_t digits[4];
212   Int_t amp[1];
213
214   digits[0] = det;
215   digits[1] = row;
216   digits[2] = col;
217   digits[3] = time;
218
219   amp[0]    = GetDigits(det)->GetData(row,col,time);
220   
221   return (new AliTRDdigit(fIsRaw,digits,amp));
222
223 }
224
225 //_____________________________________________________________________________
226 Int_t AliTRDdigitsManager::GetTrack(Int_t track
227                                   , Int_t row, Int_t col, Int_t time
228                                   , Int_t det)
229 {
230   // 
231   // Returns the MC-track numbers from the dictionary.
232   //
233
234   if ((track < 0) || (track >= kNDict)) {
235     TObject::Error("GetTracks"
236                   ,"track %d out of bounds (size: %d, this: 0x%08x)"
237                   ,track,kNDict,this);
238     return -1;
239   }
240
241   // Array contains index+1 to allow data compression
242   return (GetDictionary(det,track)->GetData(row,col,time) - 1);
243
244 }
245