]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDdigitsManager.cxx
SetMaxAdc passes integer value consistent with AliMUONResponse and AliMUONChamber
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitsManager.cxx
CommitLineData
6f1e466d 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$
dd9a6ee3 18Revision 1.4 2000/06/08 18:32:58 cblume
19Make code compliant to coding conventions
20
8230f242 21Revision 1.3 2000/06/07 16:27:01 cblume
22Try to remove compiler warnings on Sun and HP
23
9d0b222b 24Revision 1.2 2000/05/08 16:17:27 cblume
25Merge TRD-develop
26
6f1e466d 27Revision 1.1.2.1 2000/05/08 14:44:01 cblume
28Add new class AliTRDdigitsManager
29
30*/
31
32///////////////////////////////////////////////////////////////////////////////
33// //
34// Manages the digits and the track dictionary in the form of //
35// AliTRDdataArray objects. //
36// //
37///////////////////////////////////////////////////////////////////////////////
38
39#include "AliRun.h"
40
41#include "AliTRDdigitsManager.h"
42#include "AliTRDconst.h"
43
44ClassImp(AliTRDdigitsManager)
45
46//_____________________________________________________________________________
47AliTRDdigitsManager::AliTRDdigitsManager():TObject()
48{
49 //
50 // Default constructor
51 //
52
53 fIsRaw = kFALSE;
54
55 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
56
57 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
58 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI",kNdet);
59 }
60
61}
62
8230f242 63//_____________________________________________________________________________
dd9a6ee3 64AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
8230f242 65{
66 //
67 // AliTRDdigitsManager copy constructor
68 //
69
dd9a6ee3 70 ((AliTRDdigitsManager &) m).Copy(*this);
8230f242 71
72}
73
6f1e466d 74//_____________________________________________________________________________
75AliTRDdigitsManager::~AliTRDdigitsManager()
76{
8230f242 77 //
78 // AliTRDdigitsManager destructor
79 //
6f1e466d 80
81 if (fDigits) {
82 fDigits->Delete();
83 delete fDigits;
84 }
85
86 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
87 fDictionary[iDict]->Delete();
88 delete fDictionary[iDict];
89 }
90
91}
92
8230f242 93//_____________________________________________________________________________
dd9a6ee3 94void AliTRDdigitsManager::Copy(TObject &m)
8230f242 95{
96 //
97 // Copy function
98 //
99
dd9a6ee3 100 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
8230f242 101
102 TObject::Copy(m);
103
104}
105
6f1e466d 106//_____________________________________________________________________________
107void AliTRDdigitsManager::SetRaw()
108{
109
110 fIsRaw = kTRUE;
111
112 fDigits->SetBit(kRawDigit);
113
114}
115
116//_____________________________________________________________________________
117Bool_t AliTRDdigitsManager::MakeBranch()
118{
119 //
120 // Creates the branches for the digits and the dictionary in the digits tree
121 //
122
123 Int_t buffersize = 64000;
124
125 Bool_t status = kTRUE;
126
127 if (gAlice->TreeD()) {
128
129 // Make the branch for the digits
130 if (fDigits) {
8230f242 131 const AliTRDdataArrayI *kDigits =
6f1e466d 132 (AliTRDdataArrayI *) fDigits->At(0);
8230f242 133 if (kDigits) {
134 gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName()
135 ,&kDigits,buffersize,1);
6f1e466d 136 printf("AliTRDdigitsManager::MakeBranch -- ");
137 printf("Making branch TRDdigits\n");
138 }
139 else {
140 status = kFALSE;
141 }
142 }
143 else {
144 status = kFALSE;
145 }
146
147 // Make the branches for the dictionaries
148 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
149
150 Char_t branchname[15];
151 sprintf(branchname,"TRDdictionary%d",iDict);
152 if (fDictionary[iDict]) {
8230f242 153 const AliTRDdataArrayI *kDictionary =
6f1e466d 154 (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
8230f242 155 if (kDictionary) {
156 gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName()
157 ,&kDictionary,buffersize,1);
6f1e466d 158 printf("AliTRDdigitsManager::MakeBranch -- ");
159 printf("Making branch %s\n",branchname);
160 }
161 else {
162 status = kFALSE;
163 }
164 }
165 else {
166 status = kFALSE;
167 }
168 }
169
170 }
171 else {
172 status = kFALSE;
173 }
174
175 return status;
176
177}
178
179//_____________________________________________________________________________
180Bool_t AliTRDdigitsManager::ReadDigits()
181{
8230f242 182 //
183 // Reads the digit information from the input file
184 //
6f1e466d 185
186 Bool_t status = kTRUE;
187
188 status = fDigits->LoadArray("TRDdigits");
189
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);
194 }
195
196 if (fDigits->TestBit(kRawDigit)) {
197 fIsRaw = kTRUE;
198 }
199 else {
200 fIsRaw = kFALSE;
201 }
202
203 return kTRUE;
204
205}
206
207//_____________________________________________________________________________
208Bool_t AliTRDdigitsManager::WriteDigits()
209{
210 //
211 // Writes out the TRD-digits and the dictionaries
212 //
213
214 // Create the branches
215 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
216 if (!MakeBranch()) return kFALSE;
217 }
218
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");
223 return kFALSE;
224 }
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);
231 return kFALSE;
232 }
233 }
234
235 return kTRUE;
236
237}
9d0b222b 238
239//_____________________________________________________________________________
240AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
241 , Int_t time, Int_t det)
242{
243 //
244 // Creates a single digit object
245 //
246
247 Int_t digits[4];
248 Int_t amp[1];
249
250 digits[0] = det;
251 digits[1] = row;
252 digits[2] = col;
253 digits[3] = time;
254
255 amp[0] = GetDigits(det)->GetData(row,col,time);
256
257 return (new AliTRDdigit(fIsRaw,digits,amp));
258
259}
260
261//_____________________________________________________________________________
262Int_t AliTRDdigitsManager::GetTrack(Int_t track
263 , Int_t row, Int_t col, Int_t time
264 , Int_t det)
265{
266 //
267 // Returns the MC-track numbers from the dictionary.
268 //
269
270 if ((track < 0) || (track >= kNDict)) {
271 TObject::Error("GetTracks"
272 ,"track %d out of bounds (size: %d, this: 0x%08x)"
273 ,track,kNDict,this);
274 return -1;
275 }
276
277 // Array contains index+1 to allow data compression
278 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
279
280}
281
dd9a6ee3 282//_____________________________________________________________________________
283AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det)
284{
285 //
286 // Returns the digits array for one detector
287 //
288
289 return (AliTRDdataArrayI *) fDigits->At(det);
290
291}
292
293//_____________________________________________________________________________
294AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i)
295{
296 //
297 // Returns the dictionary for one detector
298 //
299
300 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
301
302}
303
304//_____________________________________________________________________________
305Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit)
306{
307 //
308 // Returns the MC-track numbers from the dictionary for a given digit
309 //
310
311 Int_t row = Digit->GetRow();
312 Int_t col = Digit->GetCol();
313 Int_t time = Digit->GetTime();
314 Int_t det = Digit->GetDetector();
315
316 return GetTrack(track,row,col,time,det);
317
318}
319
320//_____________________________________________________________________________
321AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
322{
323 //
324 // Assignment operator
325 //
326
327 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);
328 return *this;
329
330}