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