]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDdigitsManager.cxx
declaration for StepManager()
[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$
16bf9884 18Revision 1.12 2001/05/16 14:57:28 alibrary
19New files for folders and Stack
20
9e1a0ddb 21Revision 1.11 2001/03/13 09:30:35 cblume
22Update of digitization. Moved digit branch definition to AliTRD
23
6244debe 24Revision 1.10 2001/01/26 19:56:57 hristov
25Major upgrade of AliRoot code
26
2ab0c725 27Revision 1.9 2000/11/02 09:25:53 cblume
28Change also the dictionary to AliTRDdataArray
29
4d6586ef 30Revision 1.8 2000/11/01 15:20:13 cblume
31Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
32
06754153 33Revision 1.7 2000/11/01 14:53:20 cblume
34Merge with TRD-develop
35
793ff80c 36Revision 1.1.2.5 2000/10/17 02:27:34 cblume
37Get rid of global constants
38
39Revision 1.1.2.4 2000/10/15 23:40:01 cblume
40Remove AliTRDconst
41
42Revision 1.1.2.3 2000/10/06 16:49:46 cblume
43Made Getters const
44
45Revision 1.1.2.2 2000/10/04 16:34:58 cblume
46Replace include files by forward declarations
47
94de3818 48Revision 1.5 2000/06/09 11:10:07 cblume
49Compiler warnings and coding conventions, next round
50
dd9a6ee3 51Revision 1.4 2000/06/08 18:32:58 cblume
52Make code compliant to coding conventions
53
8230f242 54Revision 1.3 2000/06/07 16:27:01 cblume
55Try to remove compiler warnings on Sun and HP
56
9d0b222b 57Revision 1.2 2000/05/08 16:17:27 cblume
58Merge TRD-develop
59
6f1e466d 60Revision 1.1.2.1 2000/05/08 14:44:01 cblume
61Add new class AliTRDdigitsManager
62
63*/
64
65///////////////////////////////////////////////////////////////////////////////
66// //
67// Manages the digits and the track dictionary in the form of //
68// AliTRDdataArray objects. //
69// //
70///////////////////////////////////////////////////////////////////////////////
6244debe 71
2ab0c725 72#include <iostream.h>
793ff80c 73
2ab0c725 74#include <TROOT.h>
793ff80c 75#include <TTree.h>
2ab0c725 76#include <TFile.h>
94de3818 77
6f1e466d 78#include "AliRun.h"
79
80#include "AliTRDdigitsManager.h"
793ff80c 81#include "AliTRDsegmentArray.h"
82#include "AliTRDdataArrayI.h"
83#include "AliTRDdigit.h"
84#include "AliTRDgeometry.h"
9e1a0ddb 85#include "AliTRD.h"
6f1e466d 86
87ClassImp(AliTRDdigitsManager)
88
793ff80c 89//_____________________________________________________________________________
90
91 // Number of track dictionary arrays
92 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
93
6f1e466d 94//_____________________________________________________________________________
95AliTRDdigitsManager::AliTRDdigitsManager():TObject()
96{
97 //
98 // Default constructor
99 //
100
101 fIsRaw = kFALSE;
102
793ff80c 103 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
6f1e466d 104
105 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
793ff80c 106 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
107 ,AliTRDgeometry::Ndet());
6f1e466d 108 }
109
110}
111
8230f242 112//_____________________________________________________________________________
dd9a6ee3 113AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
8230f242 114{
115 //
116 // AliTRDdigitsManager copy constructor
117 //
118
dd9a6ee3 119 ((AliTRDdigitsManager &) m).Copy(*this);
8230f242 120
121}
122
6f1e466d 123//_____________________________________________________________________________
124AliTRDdigitsManager::~AliTRDdigitsManager()
125{
8230f242 126 //
127 // AliTRDdigitsManager destructor
128 //
6f1e466d 129
130 if (fDigits) {
131 fDigits->Delete();
132 delete fDigits;
133 }
134
135 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
136 fDictionary[iDict]->Delete();
137 delete fDictionary[iDict];
138 }
139
140}
141
8230f242 142//_____________________________________________________________________________
dd9a6ee3 143void AliTRDdigitsManager::Copy(TObject &m)
8230f242 144{
145 //
146 // Copy function
147 //
148
dd9a6ee3 149 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
8230f242 150
151 TObject::Copy(m);
152
153}
154
6f1e466d 155//_____________________________________________________________________________
156void AliTRDdigitsManager::SetRaw()
157{
158
159 fIsRaw = kTRUE;
160
793ff80c 161 fDigits->SetBit(AliTRDdigit::RawDigit());
6f1e466d 162
163}
164
16bf9884 165//_____________________________________________________________________________
166Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
167 , Int_t det) const
168{
169 //
170 // Returns the amplitude of a digit
171 //
172
173 return ((Short_t) GetDigits(det)->GetData(row,col,time));
174
175}
176
6f1e466d 177//_____________________________________________________________________________
2ab0c725 178Bool_t AliTRDdigitsManager::MakeBranch(char *file)
6f1e466d 179{
180 //
181 // Creates the branches for the digits and the dictionary in the digits tree
182 //
183
184 Int_t buffersize = 64000;
185
186 Bool_t status = kTRUE;
187
2ab0c725 188 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("TRD.Digits.root");
189
9e1a0ddb 190 AliTRD * TRD = (AliTRD *) gAlice->GetDetector("TRD") ;
191
6f1e466d 192 if (gAlice->TreeD()) {
193
194 // Make the branch for the digits
195 if (fDigits) {
06754153 196 const AliTRDdataArray *kDigits =
197 (AliTRDdataArray *) fDigits->At(0);
8230f242 198 if (kDigits) {
9e1a0ddb 199 TRD->MakeBranchInTree(gAlice->TreeD(),
200 "TRDdigits", kDigits->IsA()->GetName(),
201 &kDigits,buffersize, 1,file);
6f1e466d 202 printf("AliTRDdigitsManager::MakeBranch -- ");
203 printf("Making branch TRDdigits\n");
204 }
205 else {
206 status = kFALSE;
207 }
208 }
209 else {
210 status = kFALSE;
211 }
212
213 // Make the branches for the dictionaries
214 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
6f1e466d 215 Char_t branchname[15];
216 sprintf(branchname,"TRDdictionary%d",iDict);
217 if (fDictionary[iDict]) {
4d6586ef 218 const AliTRDdataArray *kDictionary =
219 (AliTRDdataArray *) fDictionary[iDict]->At(0);
8230f242 220 if (kDictionary) {
9e1a0ddb 221 TRD->MakeBranchInTree(gAlice->TreeD(),
222 branchname,kDictionary->IsA()->GetName(),
223 &kDictionary,buffersize, 1,file);
6f1e466d 224 printf("AliTRDdigitsManager::MakeBranch -- ");
225 printf("Making branch %s\n",branchname);
6244debe 226 }
6f1e466d 227 else {
228 status = kFALSE;
6244debe 229 }
6f1e466d 230 }
231 else {
232 status = kFALSE;
233 }
234 }
235
236 }
237 else {
238 status = kFALSE;
239 }
240
241 return status;
242
243}
244
245//_____________________________________________________________________________
246Bool_t AliTRDdigitsManager::ReadDigits()
247{
8230f242 248 //
249 // Reads the digit information from the input file
250 //
6f1e466d 251
252 Bool_t status = kTRUE;
253
254 status = fDigits->LoadArray("TRDdigits");
255
256 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
257 Char_t branchname[15];
258 sprintf(branchname,"TRDdictionary%d",iDict);
259 status = fDictionary[iDict]->LoadArray(branchname);
260 }
261
793ff80c 262 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
6f1e466d 263 fIsRaw = kTRUE;
264 }
265 else {
266 fIsRaw = kFALSE;
267 }
268
269 return kTRUE;
270
271}
272
273//_____________________________________________________________________________
274Bool_t AliTRDdigitsManager::WriteDigits()
275{
276 //
277 // Writes out the TRD-digits and the dictionaries
278 //
279
280 // Create the branches
281 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
6244debe 282 printf("AliTRDdigitsManager::WriteDigits -- ");
283 printf("Call MakeBranch\n");
6f1e466d 284 if (!MakeBranch()) return kFALSE;
285 }
286
287 // Store the contents of the segment array in the tree
288 if (!fDigits->StoreArray("TRDdigits")) {
289 printf("AliTRDdigitsManager::WriteDigits -- ");
290 printf("Error while storing digits in branch TRDdigits\n");
291 return kFALSE;
292 }
293 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
294 Char_t branchname[15];
295 sprintf(branchname,"TRDdictionary%d",iDict);
296 if (!fDictionary[iDict]->StoreArray(branchname)) {
297 printf("AliTRDdigitsManager::WriteDigits -- ");
298 printf("Error while storing dictionary in branch %s\n",branchname);
299 return kFALSE;
300 }
301 }
302
303 return kTRUE;
304
305}
9d0b222b 306
307//_____________________________________________________________________________
308AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
793ff80c 309 , Int_t time, Int_t det) const
9d0b222b 310{
311 //
312 // Creates a single digit object
313 //
314
315 Int_t digits[4];
316 Int_t amp[1];
317
318 digits[0] = det;
319 digits[1] = row;
320 digits[2] = col;
321 digits[3] = time;
322
323 amp[0] = GetDigits(det)->GetData(row,col,time);
324
325 return (new AliTRDdigit(fIsRaw,digits,amp));
326
327}
328
329//_____________________________________________________________________________
330Int_t AliTRDdigitsManager::GetTrack(Int_t track
331 , Int_t row, Int_t col, Int_t time
793ff80c 332 , Int_t det) const
9d0b222b 333{
334 //
335 // Returns the MC-track numbers from the dictionary.
336 //
337
338 if ((track < 0) || (track >= kNDict)) {
339 TObject::Error("GetTracks"
340 ,"track %d out of bounds (size: %d, this: 0x%08x)"
341 ,track,kNDict,this);
342 return -1;
343 }
344
345 // Array contains index+1 to allow data compression
346 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
347
348}
349
dd9a6ee3 350//_____________________________________________________________________________
793ff80c 351AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
dd9a6ee3 352{
353 //
354 // Returns the digits array for one detector
355 //
356
357 return (AliTRDdataArrayI *) fDigits->At(det);
358
359}
360
361//_____________________________________________________________________________
793ff80c 362AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
dd9a6ee3 363{
364 //
365 // Returns the dictionary for one detector
366 //
367
368 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
369
370}
371
372//_____________________________________________________________________________
793ff80c 373Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
dd9a6ee3 374{
375 //
376 // Returns the MC-track numbers from the dictionary for a given digit
377 //
378
379 Int_t row = Digit->GetRow();
380 Int_t col = Digit->GetCol();
381 Int_t time = Digit->GetTime();
382 Int_t det = Digit->GetDetector();
383
384 return GetTrack(track,row,col,time,det);
385
386}
387
388//_____________________________________________________________________________
389AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
390{
391 //
392 // Assignment operator
393 //
394
395 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);
396 return *this;
397
398}