1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.14 2001/11/14 10:50:46 cblume
19 Changes in digits IO. Add merging of summable digits
21 Revision 1.13 2001/11/06 17:19:41 cblume
22 Add detailed geometry and simple simulator
24 Revision 1.12 2001/05/16 14:57:28 alibrary
25 New files for folders and Stack
27 Revision 1.11 2001/03/13 09:30:35 cblume
28 Update of digitization. Moved digit branch definition to AliTRD
30 Revision 1.10 2001/01/26 19:56:57 hristov
31 Major upgrade of AliRoot code
33 Revision 1.9 2000/11/02 09:25:53 cblume
34 Change also the dictionary to AliTRDdataArray
36 Revision 1.8 2000/11/01 15:20:13 cblume
37 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
39 Revision 1.7 2000/11/01 14:53:20 cblume
40 Merge with TRD-develop
42 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
43 Get rid of global constants
45 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
48 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
51 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
52 Replace include files by forward declarations
54 Revision 1.5 2000/06/09 11:10:07 cblume
55 Compiler warnings and coding conventions, next round
57 Revision 1.4 2000/06/08 18:32:58 cblume
58 Make code compliant to coding conventions
60 Revision 1.3 2000/06/07 16:27:01 cblume
61 Try to remove compiler warnings on Sun and HP
63 Revision 1.2 2000/05/08 16:17:27 cblume
66 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
67 Add new class AliTRDdigitsManager
71 ///////////////////////////////////////////////////////////////////////////////
73 // Manages the digits and the track dictionary in the form of //
74 // AliTRDdataArray objects. //
76 ///////////////////////////////////////////////////////////////////////////////
86 #include "AliTRDdigitsManager.h"
87 #include "AliTRDsegmentArray.h"
88 #include "AliTRDdataArrayI.h"
89 #include "AliTRDdigit.h"
90 #include "AliTRDgeometry.h"
93 ClassImp(AliTRDdigitsManager)
95 //_____________________________________________________________________________
97 // Number of track dictionary arrays
98 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
100 //_____________________________________________________________________________
101 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
104 // Default constructor
115 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
116 fDictionary[iDict] = NULL;
121 //_____________________________________________________________________________
122 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
125 // AliTRDdigitsManager copy constructor
128 ((AliTRDdigitsManager &) m).Copy(*this);
132 //_____________________________________________________________________________
133 AliTRDdigitsManager::~AliTRDdigitsManager()
136 // AliTRDdigitsManager destructor
156 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
157 fDictionary[iDict]->Delete();
158 delete fDictionary[iDict];
159 fDictionary[iDict] = NULL;
164 //_____________________________________________________________________________
165 void AliTRDdigitsManager::Copy(TObject &m)
171 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
172 ((AliTRDdigitsManager &) m).fEvent = fEvent;
173 ((AliTRDdigitsManager &) m).fDebug = fDebug;
174 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
180 //_____________________________________________________________________________
181 void AliTRDdigitsManager::CreateArrays()
184 // Create the data arrays
187 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
189 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
190 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
191 ,AliTRDgeometry::Ndet());
196 //_____________________________________________________________________________
197 void AliTRDdigitsManager::SetRaw()
202 fDigits->SetBit(AliTRDdigit::RawDigit());
206 //_____________________________________________________________________________
207 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
211 // Returns the amplitude of a digit
214 return ((Short_t) GetDigits(det)->GetData(row,col,time));
218 //_____________________________________________________________________________
219 Bool_t AliTRDdigitsManager::Open(const Char_t *file)
222 // Opens the file for the TRD digits
225 fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file);
228 printf("<AliTRDdigitsManager::Open> ");
229 printf("Open the AliROOT-file %s.\n",file);
231 fFile = new TFile(file,"UPDATE");
232 if (!fFile) return kFALSE;
236 printf("<AliTRDdigitsManager::Open> ");
237 printf("%s is already open.\n",file);
245 //_____________________________________________________________________________
246 Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
249 // Creates the tree and branches for the digits and the dictionary
252 // Create the TRD digits tree
256 sprintf(treeName,"TreeS%d_TRD",fEvent);
257 tree = new TTree(treeName,"TRD SDigits");
260 sprintf(treeName,"TreeD%d_TRD",fEvent);
261 tree = new TTree(treeName,"TRD Digits");
265 printf("<AliTRDdigitsManager::MakeBranch> ");
266 printf("Creating tree %s\n",treeName);
269 return MakeBranch(tree,file);
273 //_____________________________________________________________________________
274 Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
277 // Creates the tree and branches for the digits and the dictionary
280 Int_t buffersize = 64000;
282 Bool_t status = kTRUE;
284 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
290 // Make the branch for the digits
292 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
294 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
295 ,&kDigits,buffersize,99,file);
297 printf("<AliTRDdigitsManager::MakeBranch> ");
298 printf("Making branch TRDdigits\n");
309 // Make the branches for the dictionaries
310 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
311 Char_t branchname[15];
312 sprintf(branchname,"TRDdictionary%d",iDict);
313 if (fDictionary[iDict]) {
314 const AliTRDdataArray *kDictionary =
315 (AliTRDdataArray *) fDictionary[iDict]->At(0);
317 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
318 ,&kDictionary,buffersize,99,file);
320 printf("<AliTRDdigitsManager::MakeBranch> ");
321 printf("Making branch %s\n",branchname);
337 //_____________________________________________________________________________
338 Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
341 // Reads the digit information from the input file
344 Bool_t status = kTRUE;
353 // Get the digits tree
356 sprintf(treeName,"TreeS%d_TRD",fEvent);
359 sprintf(treeName,"TreeD%d_TRD",fEvent);
362 fTree = (TTree *) fFile->Get(treeName);
365 fTree = (TTree *) gDirectory->Get(treeName);
370 printf("<AliTRDdigitsManager::ReadDigits> ");
371 printf("Could not find tree %s.\n",treeName);
380 printf("<AliTRDdigitsManager::ReadDigits> ");
381 printf("Create the data arrays.\n");
386 status = fDigits->LoadArray("TRDdigits",fTree);
388 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
389 Char_t branchname[15];
390 sprintf(branchname,"TRDdictionary%d",iDict);
391 status = fDictionary[iDict]->LoadArray(branchname,fTree);
394 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
405 //_____________________________________________________________________________
406 Bool_t AliTRDdigitsManager::WriteDigits()
409 // Writes out the TRD-digits and the dictionaries
412 // Store the contents of the segment array in the tree
413 if (!fDigits->StoreArray("TRDdigits",fTree)) {
414 printf("<AliTRDdigitsManager::WriteDigits> ");
415 printf("Error while storing digits in branch TRDdigits\n");
418 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
419 Char_t branchname[15];
420 sprintf(branchname,"TRDdictionary%d",iDict);
421 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
422 printf("<AliTRDdigitsManager::WriteDigits> ");
423 printf("Error while storing dictionary in branch %s\n",branchname);
428 // Write the new tree to the output file
435 //_____________________________________________________________________________
436 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
437 , Int_t time, Int_t det) const
440 // Creates a single digit object
451 amp[0] = GetDigits(det)->GetData(row,col,time);
453 return (new AliTRDdigit(fIsRaw,digits,amp));
457 //_____________________________________________________________________________
458 Int_t AliTRDdigitsManager::GetTrack(Int_t track
459 , Int_t row, Int_t col, Int_t time
463 // Returns the MC-track numbers from the dictionary.
466 if ((track < 0) || (track >= kNDict)) {
467 TObject::Error("GetTracks"
468 ,"track %d out of bounds (size: %d, this: 0x%08x)"
473 // Array contains index+1 to allow data compression
474 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
478 //_____________________________________________________________________________
479 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
482 // Returns the digits array for one detector
485 return (AliTRDdataArrayI *) fDigits->At(det);
489 //_____________________________________________________________________________
490 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
493 // Returns the dictionary for one detector
496 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
500 //_____________________________________________________________________________
501 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
504 // Returns the MC-track numbers from the dictionary for a given digit
507 Int_t row = Digit->GetRow();
508 Int_t col = Digit->GetCol();
509 Int_t time = Digit->GetTime();
510 Int_t det = Digit->GetDetector();
512 return GetTrack(track,row,col,time,det);
516 //_____________________________________________________________________________
517 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
520 // Assignment operator
523 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);