]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDdigitsManager.cxx
Correction connected with compiler warnings on Darwin
[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
88cb7938 16/* $Id$ */
6f1e466d 17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// Manages the digits and the track dictionary in the form of //
21// AliTRDdataArray objects. //
22// //
23///////////////////////////////////////////////////////////////////////////////
6244debe 24
a2cb5b3d 25#include <Riostream.h>
793ff80c 26
2ab0c725 27#include <TROOT.h>
793ff80c 28#include <TTree.h>
2ab0c725 29#include <TFile.h>
94de3818 30
6f1e466d 31#include "AliRun.h"
32
33#include "AliTRDdigitsManager.h"
793ff80c 34#include "AliTRDsegmentArray.h"
35#include "AliTRDdataArrayI.h"
36#include "AliTRDdigit.h"
37#include "AliTRDgeometry.h"
9e1a0ddb 38#include "AliTRD.h"
6f1e466d 39
40ClassImp(AliTRDdigitsManager)
41
793ff80c 42//_____________________________________________________________________________
43
44 // Number of track dictionary arrays
45 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
46
6f1e466d 47//_____________________________________________________________________________
48AliTRDdigitsManager::AliTRDdigitsManager():TObject()
49{
50 //
51 // Default constructor
52 //
53
abaf1f1d 54 fIsRaw = kFALSE;
55 fEvent = 0;
855bfffd 56 fDebug = 0;
abaf1f1d 57 fSDigits = 0;
6f1e466d 58
abaf1f1d 59 fTree = NULL;
60 fDigits = NULL;
6f1e466d 61 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
abaf1f1d 62 fDictionary[iDict] = NULL;
6f1e466d 63 }
64
65}
66
8230f242 67//_____________________________________________________________________________
dd9a6ee3 68AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
8230f242 69{
70 //
71 // AliTRDdigitsManager copy constructor
72 //
73
dd9a6ee3 74 ((AliTRDdigitsManager &) m).Copy(*this);
8230f242 75
76}
77
6f1e466d 78//_____________________________________________________________________________
79AliTRDdigitsManager::~AliTRDdigitsManager()
80{
8230f242 81 //
82 // AliTRDdigitsManager destructor
83 //
6f1e466d 84
85 if (fDigits) {
86 fDigits->Delete();
87 delete fDigits;
abaf1f1d 88 fDigits = NULL;
6f1e466d 89 }
90
91 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
92 fDictionary[iDict]->Delete();
93 delete fDictionary[iDict];
abaf1f1d 94 fDictionary[iDict] = NULL;
6f1e466d 95 }
96
97}
98
8230f242 99//_____________________________________________________________________________
dd9a6ee3 100void AliTRDdigitsManager::Copy(TObject &m)
8230f242 101{
102 //
103 // Copy function
104 //
105
abaf1f1d 106 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
107 ((AliTRDdigitsManager &) m).fEvent = fEvent;
855bfffd 108 ((AliTRDdigitsManager &) m).fDebug = fDebug;
abaf1f1d 109 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
8230f242 110
111 TObject::Copy(m);
112
113}
114
abaf1f1d 115//_____________________________________________________________________________
116void AliTRDdigitsManager::CreateArrays()
117{
118 //
119 // Create the data arrays
120 //
121
122 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
123
124 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
125 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
126 ,AliTRDgeometry::Ndet());
127 }
128
17eee78a 129}
130//_____________________________________________________________________________
131void AliTRDdigitsManager::ResetArrays()
132{
133 //
134 // Reset the data arrays
135 //
136
137 if (fDigits) {
138 delete fDigits;
139 }
140 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
141
142 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
143 if (fDictionary[iDict]) {
144 delete fDictionary[iDict];
145 }
146 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
147 ,AliTRDgeometry::Ndet());
148 }
149
abaf1f1d 150}
151
6f1e466d 152//_____________________________________________________________________________
153void AliTRDdigitsManager::SetRaw()
154{
0a29d0f1 155 //
156 // Switch on the raw digits flag
157 //
6f1e466d 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//_____________________________________________________________________________
88cb7938 178Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree)
855bfffd 179{
180 //
181 // Creates the tree and branches for the digits and the dictionary
182 //
183
184 Int_t buffersize = 64000;
185
186 Bool_t status = kTRUE;
187
188 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
189
190 if (tree) {
191 fTree = tree;
192 }
193
abaf1f1d 194 // Make the branch for the digits
195 if (fDigits) {
196 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
197 if (kDigits) {
198 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
88cb7938 199 ,&kDigits,buffersize,99);
855bfffd 200 if (fDebug > 0) {
201 printf("<AliTRDdigitsManager::MakeBranch> ");
6f1e466d 202 printf("Making branch TRDdigits\n");
203 }
6f1e466d 204 }
205 else {
206 status = kFALSE;
207 }
abaf1f1d 208 }
209 else {
210 status = kFALSE;
211 }
6f1e466d 212
abaf1f1d 213 // Make the branches for the dictionaries
214 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
215 Char_t branchname[15];
216 sprintf(branchname,"TRDdictionary%d",iDict);
217 if (fDictionary[iDict]) {
218 const AliTRDdataArray *kDictionary =
219 (AliTRDdataArray *) fDictionary[iDict]->At(0);
220 if (kDictionary) {
221 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
88cb7938 222 ,&kDictionary,buffersize,99);
855bfffd 223 if (fDebug > 0) {
224 printf("<AliTRDdigitsManager::MakeBranch> ");
6f1e466d 225 printf("Making branch %s\n",branchname);
6244debe 226 }
6f1e466d 227 }
228 else {
229 status = kFALSE;
230 }
231 }
abaf1f1d 232 else {
233 status = kFALSE;
234 }
6f1e466d 235 }
236
237 return status;
238
239}
240
241//_____________________________________________________________________________
855bfffd 242Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
6f1e466d 243{
8230f242 244 //
245 // Reads the digit information from the input file
246 //
6f1e466d 247
248 Bool_t status = kTRUE;
249
855bfffd 250 if (tree) {
251
252 fTree = tree;
253
abaf1f1d 254 }
255
256 if (!fDigits) {
855bfffd 257 if (fDebug > 0) {
258 printf("<AliTRDdigitsManager::ReadDigits> ");
abaf1f1d 259 printf("Create the data arrays.\n");
260 }
261 CreateArrays();
262 }
263
264 status = fDigits->LoadArray("TRDdigits",fTree);
6f1e466d 265
266 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
267 Char_t branchname[15];
268 sprintf(branchname,"TRDdictionary%d",iDict);
abaf1f1d 269 status = fDictionary[iDict]->LoadArray(branchname,fTree);
6f1e466d 270 }
271
793ff80c 272 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
6f1e466d 273 fIsRaw = kTRUE;
274 }
275 else {
276 fIsRaw = kFALSE;
277 }
278
279 return kTRUE;
280
281}
282
283//_____________________________________________________________________________
284Bool_t AliTRDdigitsManager::WriteDigits()
285{
286 //
287 // Writes out the TRD-digits and the dictionaries
288 //
289
6f1e466d 290 // Store the contents of the segment array in the tree
abaf1f1d 291 if (!fDigits->StoreArray("TRDdigits",fTree)) {
855bfffd 292 printf("<AliTRDdigitsManager::WriteDigits> ");
6f1e466d 293 printf("Error while storing digits in branch TRDdigits\n");
294 return kFALSE;
295 }
296 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
297 Char_t branchname[15];
298 sprintf(branchname,"TRDdictionary%d",iDict);
abaf1f1d 299 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
855bfffd 300 printf("<AliTRDdigitsManager::WriteDigits> ");
6f1e466d 301 printf("Error while storing dictionary in branch %s\n",branchname);
302 return kFALSE;
303 }
304 }
305
abaf1f1d 306 // Write the new tree to the output file
8e64dd77 307 //fTree->Write();
308 fTree->AutoSave(); // Modification by Jiri
abaf1f1d 309
6f1e466d 310 return kTRUE;
311
312}
9d0b222b 313
314//_____________________________________________________________________________
315AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
793ff80c 316 , Int_t time, Int_t det) const
9d0b222b 317{
318 //
319 // Creates a single digit object
320 //
321
322 Int_t digits[4];
323 Int_t amp[1];
324
325 digits[0] = det;
326 digits[1] = row;
327 digits[2] = col;
328 digits[3] = time;
329
330 amp[0] = GetDigits(det)->GetData(row,col,time);
331
332 return (new AliTRDdigit(fIsRaw,digits,amp));
333
334}
335
336//_____________________________________________________________________________
337Int_t AliTRDdigitsManager::GetTrack(Int_t track
338 , Int_t row, Int_t col, Int_t time
793ff80c 339 , Int_t det) const
9d0b222b 340{
341 //
342 // Returns the MC-track numbers from the dictionary.
343 //
344
345 if ((track < 0) || (track >= kNDict)) {
346 TObject::Error("GetTracks"
347 ,"track %d out of bounds (size: %d, this: 0x%08x)"
348 ,track,kNDict,this);
349 return -1;
350 }
351
352 // Array contains index+1 to allow data compression
353 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
354
355}
356
dd9a6ee3 357//_____________________________________________________________________________
793ff80c 358AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
dd9a6ee3 359{
360 //
361 // Returns the digits array for one detector
362 //
363
364 return (AliTRDdataArrayI *) fDigits->At(det);
365
366}
367
368//_____________________________________________________________________________
793ff80c 369AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
dd9a6ee3 370{
371 //
372 // Returns the dictionary for one detector
373 //
374
375 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
376
377}
378
379//_____________________________________________________________________________
793ff80c 380Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
dd9a6ee3 381{
382 //
383 // Returns the MC-track numbers from the dictionary for a given digit
384 //
385
386 Int_t row = Digit->GetRow();
387 Int_t col = Digit->GetCol();
388 Int_t time = Digit->GetTime();
389 Int_t det = Digit->GetDetector();
390
391 return GetTrack(track,row,col,time,det);
392
393}
394
395//_____________________________________________________________________________
396AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
397{
398 //
399 // Assignment operator
400 //
401
402 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);
403 return *this;
404
405}