reveng tag added
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitsManager.cxx
... / ...
CommitLineData
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$
18Revision 1.3 2000/06/07 16:27:01 cblume
19Try to remove compiler warnings on Sun and HP
20
21Revision 1.2 2000/05/08 16:17:27 cblume
22Merge TRD-develop
23
24Revision 1.1.2.1 2000/05/08 14:44:01 cblume
25Add new class AliTRDdigitsManager
26
27*/
28
29///////////////////////////////////////////////////////////////////////////////
30// //
31// Manages the digits and the track dictionary in the form of //
32// AliTRDdataArray objects. //
33// //
34///////////////////////////////////////////////////////////////////////////////
35
36#include "AliRun.h"
37
38#include "AliTRDdigitsManager.h"
39#include "AliTRDconst.h"
40
41ClassImp(AliTRDdigitsManager)
42
43//_____________________________________________________________________________
44AliTRDdigitsManager::AliTRDdigitsManager():TObject()
45{
46 //
47 // Default constructor
48 //
49
50 fIsRaw = kFALSE;
51
52 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
53
54 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
55 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
56 }
57
58}
59
60//_____________________________________________________________________________
61AliTRDdigitsManager::AliTRDdigitsManager(AliTRDdigitsManager &m)
62{
63 //
64 // AliTRDdigitsManager copy constructor
65 //
66
67 m.Copy(*this);
68
69}
70
71//_____________________________________________________________________________
72AliTRDdigitsManager::~AliTRDdigitsManager()
73{
74 //
75 // AliTRDdigitsManager destructor
76 //
77
78 if (fDigits) {
79 fDigits->Delete();
80 delete fDigits;
81 }
82
83 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
84 fDictionary[iDict]->Delete();
85 delete fDictionary[iDict];
86 }
87
88}
89
90//_____________________________________________________________________________
91void AliTRDdigitsManager::Copy(AliTRDdigitsManager &m)
92{
93 //
94 // Copy function
95 //
96
97 m.fIsRaw = fIsRaw;
98
99 TObject::Copy(m);
100
101}
102
103//_____________________________________________________________________________
104void AliTRDdigitsManager::SetRaw()
105{
106
107 fIsRaw = kTRUE;
108
109 fDigits->SetBit(kRawDigit);
110
111}
112
113//_____________________________________________________________________________
114Bool_t AliTRDdigitsManager::MakeBranch()
115{
116 //
117 // Creates the branches for the digits and the dictionary in the digits tree
118 //
119
120 Int_t buffersize = 64000;
121
122 Bool_t status = kTRUE;
123
124 if (gAlice->TreeD()) {
125
126 // Make the branch for the digits
127 if (fDigits) {
128 const AliTRDdataArrayI *kDigits =
129 (AliTRDdataArrayI *) fDigits->At(0);
130 if (kDigits) {
131 gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName()
132 ,&kDigits,buffersize,1);
133 printf("AliTRDdigitsManager::MakeBranch -- ");
134 printf("Making branch TRDdigits\n");
135 }
136 else {
137 status = kFALSE;
138 }
139 }
140 else {
141 status = kFALSE;
142 }
143
144 // Make the branches for the dictionaries
145 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
146
147 Char_t branchname[15];
148 sprintf(branchname,"TRDdictionary%d",iDict);
149 if (fDictionary[iDict]) {
150 const AliTRDdataArrayI *kDictionary =
151 (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
152 if (kDictionary) {
153 gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName()
154 ,&kDictionary,buffersize,1);
155 printf("AliTRDdigitsManager::MakeBranch -- ");
156 printf("Making branch %s\n",branchname);
157 }
158 else {
159 status = kFALSE;
160 }
161 }
162 else {
163 status = kFALSE;
164 }
165 }
166
167 }
168 else {
169 status = kFALSE;
170 }
171
172 return status;
173
174}
175
176//_____________________________________________________________________________
177Bool_t AliTRDdigitsManager::ReadDigits()
178{
179 //
180 // Reads the digit information from the input file
181 //
182
183 Bool_t status = kTRUE;
184
185 status = fDigits->LoadArray("TRDdigits");
186
187 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
188 Char_t branchname[15];
189 sprintf(branchname,"TRDdictionary%d",iDict);
190 status = fDictionary[iDict]->LoadArray(branchname);
191 }
192
193 if (fDigits->TestBit(kRawDigit)) {
194 fIsRaw = kTRUE;
195 }
196 else {
197 fIsRaw = kFALSE;
198 }
199
200 return kTRUE;
201
202}
203
204//_____________________________________________________________________________
205Bool_t AliTRDdigitsManager::WriteDigits()
206{
207 //
208 // Writes out the TRD-digits and the dictionaries
209 //
210
211 // Create the branches
212 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
213 if (!MakeBranch()) return kFALSE;
214 }
215
216 // Store the contents of the segment array in the tree
217 if (!fDigits->StoreArray("TRDdigits")) {
218 printf("AliTRDdigitsManager::WriteDigits -- ");
219 printf("Error while storing digits in branch TRDdigits\n");
220 return kFALSE;
221 }
222 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
223 Char_t branchname[15];
224 sprintf(branchname,"TRDdictionary%d",iDict);
225 if (!fDictionary[iDict]->StoreArray(branchname)) {
226 printf("AliTRDdigitsManager::WriteDigits -- ");
227 printf("Error while storing dictionary in branch %s\n",branchname);
228 return kFALSE;
229 }
230 }
231
232 return kTRUE;
233
234}
235
236//_____________________________________________________________________________
237AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
238 , Int_t time, Int_t det)
239{
240 //
241 // Creates a single digit object
242 //
243
244 Int_t digits[4];
245 Int_t amp[1];
246
247 digits[0] = det;
248 digits[1] = row;
249 digits[2] = col;
250 digits[3] = time;
251
252 amp[0] = GetDigits(det)->GetData(row,col,time);
253
254 return (new AliTRDdigit(fIsRaw,digits,amp));
255
256}
257
258//_____________________________________________________________________________
259Int_t AliTRDdigitsManager::GetTrack(Int_t track
260 , Int_t row, Int_t col, Int_t time
261 , Int_t det)
262{
263 //
264 // Returns the MC-track numbers from the dictionary.
265 //
266
267 if ((track < 0) || (track >= kNDict)) {
268 TObject::Error("GetTracks"
269 ,"track %d out of bounds (size: %d, this: 0x%08x)"
270 ,track,kNDict,this);
271 return -1;
272 }
273
274 // Array contains index+1 to allow data compression
275 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
276
277}
278