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.19 2002/10/14 14:57:43 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.16.6.2 2002/07/24 10:09:30 alibrary
24 Revision 1.16.6.1 2002/06/10 15:28:58 hristov
27 Revision 1.18 2002/04/12 12:13:23 cblume
30 Revision 1.17 2002/03/28 14:59:07 cblume
33 Revision 1.18 2002/04/12 12:13:23 cblume
36 Revision 1.17 2002/03/28 14:59:07 cblume
39 Revision 1.16 2002/02/12 11:42:08 cblume
40 Remove fTree from destructor
42 Revision 1.15 2002/02/11 14:27:54 cblume
43 Geometry and hit structure update
45 Revision 1.14 2001/11/14 10:50:46 cblume
46 Changes in digits IO. Add merging of summable digits
48 Revision 1.13 2001/11/06 17:19:41 cblume
49 Add detailed geometry and simple simulator
51 Revision 1.12 2001/05/16 14:57:28 alibrary
52 New files for folders and Stack
54 Revision 1.11 2001/03/13 09:30:35 cblume
55 Update of digitization. Moved digit branch definition to AliTRD
57 Revision 1.10 2001/01/26 19:56:57 hristov
58 Major upgrade of AliRoot code
60 Revision 1.9 2000/11/02 09:25:53 cblume
61 Change also the dictionary to AliTRDdataArray
63 Revision 1.8 2000/11/01 15:20:13 cblume
64 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
66 Revision 1.7 2000/11/01 14:53:20 cblume
67 Merge with TRD-develop
69 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
70 Get rid of global constants
72 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
75 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
78 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
79 Replace include files by forward declarations
81 Revision 1.5 2000/06/09 11:10:07 cblume
82 Compiler warnings and coding conventions, next round
84 Revision 1.4 2000/06/08 18:32:58 cblume
85 Make code compliant to coding conventions
87 Revision 1.3 2000/06/07 16:27:01 cblume
88 Try to remove compiler warnings on Sun and HP
90 Revision 1.2 2000/05/08 16:17:27 cblume
93 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
94 Add new class AliTRDdigitsManager
98 ///////////////////////////////////////////////////////////////////////////////
100 // Manages the digits and the track dictionary in the form of //
101 // AliTRDdataArray objects. //
103 ///////////////////////////////////////////////////////////////////////////////
105 #include <Riostream.h>
113 #include "AliTRDdigitsManager.h"
114 #include "AliTRDsegmentArray.h"
115 #include "AliTRDdataArrayI.h"
116 #include "AliTRDdigit.h"
117 #include "AliTRDgeometry.h"
120 ClassImp(AliTRDdigitsManager)
122 //_____________________________________________________________________________
124 // Number of track dictionary arrays
125 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
127 //_____________________________________________________________________________
128 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
131 // Default constructor
142 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
143 fDictionary[iDict] = NULL;
148 //_____________________________________________________________________________
149 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
152 // AliTRDdigitsManager copy constructor
155 ((AliTRDdigitsManager &) m).Copy(*this);
159 //_____________________________________________________________________________
160 AliTRDdigitsManager::~AliTRDdigitsManager()
163 // AliTRDdigitsManager destructor
178 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
179 fDictionary[iDict]->Delete();
180 delete fDictionary[iDict];
181 fDictionary[iDict] = NULL;
186 //_____________________________________________________________________________
187 void AliTRDdigitsManager::Copy(TObject &m)
193 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
194 ((AliTRDdigitsManager &) m).fEvent = fEvent;
195 ((AliTRDdigitsManager &) m).fDebug = fDebug;
196 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
202 //_____________________________________________________________________________
203 void AliTRDdigitsManager::CreateArrays()
206 // Create the data arrays
209 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
211 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
212 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
213 ,AliTRDgeometry::Ndet());
218 //_____________________________________________________________________________
219 void AliTRDdigitsManager::SetRaw()
222 // Switch on the raw digits flag
227 fDigits->SetBit(AliTRDdigit::RawDigit());
231 //_____________________________________________________________________________
232 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
236 // Returns the amplitude of a digit
239 return ((Short_t) GetDigits(det)->GetData(row,col,time));
243 //_____________________________________________________________________________
244 Bool_t AliTRDdigitsManager::Open(const Char_t *file)
247 // Opens the file for the TRD digits
250 fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file);
253 printf("<AliTRDdigitsManager::Open> ");
254 printf("Open the AliROOT-file %s.\n",file);
256 fFile = new TFile(file,"UPDATE");
257 if (!fFile) return kFALSE;
261 printf("<AliTRDdigitsManager::Open> ");
262 printf("%s is already open.\n",file);
270 //_____________________________________________________________________________
271 void AliTRDdigitsManager::MakeTreeAndBranches(TFile *file, Int_t iEvent)
274 // Creates tree for (s)digits in the specified file
278 TDirectory *wd = gDirectory;
285 //_____________________________________________________________________________
286 Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
289 // Creates the tree and branches for the digits and the dictionary
292 // Create the TRD digits tree
296 sprintf(treeName,"TreeS%d_TRD",fEvent);
297 tree = new TTree(treeName,"TRD SDigits");
300 sprintf(treeName,"TreeD%d_TRD",fEvent);
301 tree = new TTree(treeName,"TRD Digits");
305 printf("<AliTRDdigitsManager::MakeBranch> ");
306 printf("Creating tree %s\n",treeName);
309 return MakeBranch(tree,file);
313 //_____________________________________________________________________________
314 Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
317 // Creates the tree and branches for the digits and the dictionary
320 Int_t buffersize = 64000;
322 Bool_t status = kTRUE;
324 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
330 // Make the branch for the digits
332 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
334 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
335 ,&kDigits,buffersize,99,file);
337 printf("<AliTRDdigitsManager::MakeBranch> ");
338 printf("Making branch TRDdigits\n");
349 // Make the branches for the dictionaries
350 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
351 Char_t branchname[15];
352 sprintf(branchname,"TRDdictionary%d",iDict);
353 if (fDictionary[iDict]) {
354 const AliTRDdataArray *kDictionary =
355 (AliTRDdataArray *) fDictionary[iDict]->At(0);
357 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
358 ,&kDictionary,buffersize,99,file);
360 printf("<AliTRDdigitsManager::MakeBranch> ");
361 printf("Making branch %s\n",branchname);
377 //_____________________________________________________________________________
378 Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
381 // Reads the digit information from the input file
384 Bool_t status = kTRUE;
393 // Get the digits tree
396 sprintf(treeName,"TreeS%d_TRD",fEvent);
399 sprintf(treeName,"TreeD%d_TRD",fEvent);
402 fTree = (TTree *) fFile->Get(treeName);
405 fTree = (TTree *) gDirectory->Get(treeName);
410 printf("<AliTRDdigitsManager::ReadDigits> ");
411 printf("Could not find tree %s.\n",treeName);
420 printf("<AliTRDdigitsManager::ReadDigits> ");
421 printf("Create the data arrays.\n");
426 status = fDigits->LoadArray("TRDdigits",fTree);
428 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
429 Char_t branchname[15];
430 sprintf(branchname,"TRDdictionary%d",iDict);
431 status = fDictionary[iDict]->LoadArray(branchname,fTree);
434 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
445 //_____________________________________________________________________________
446 Bool_t AliTRDdigitsManager::WriteDigits()
449 // Writes out the TRD-digits and the dictionaries
452 // Store the contents of the segment array in the tree
453 if (!fDigits->StoreArray("TRDdigits",fTree)) {
454 printf("<AliTRDdigitsManager::WriteDigits> ");
455 printf("Error while storing digits in branch TRDdigits\n");
458 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
459 Char_t branchname[15];
460 sprintf(branchname,"TRDdictionary%d",iDict);
461 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
462 printf("<AliTRDdigitsManager::WriteDigits> ");
463 printf("Error while storing dictionary in branch %s\n",branchname);
468 // Write the new tree to the output file
470 fTree->AutoSave(); // Modification by Jiri
476 //_____________________________________________________________________________
477 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
478 , Int_t time, Int_t det) const
481 // Creates a single digit object
492 amp[0] = GetDigits(det)->GetData(row,col,time);
494 return (new AliTRDdigit(fIsRaw,digits,amp));
498 //_____________________________________________________________________________
499 Int_t AliTRDdigitsManager::GetTrack(Int_t track
500 , Int_t row, Int_t col, Int_t time
504 // Returns the MC-track numbers from the dictionary.
507 if ((track < 0) || (track >= kNDict)) {
508 TObject::Error("GetTracks"
509 ,"track %d out of bounds (size: %d, this: 0x%08x)"
514 // Array contains index+1 to allow data compression
515 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
519 //_____________________________________________________________________________
520 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
523 // Returns the digits array for one detector
526 return (AliTRDdataArrayI *) fDigits->At(det);
530 //_____________________________________________________________________________
531 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
534 // Returns the dictionary for one detector
537 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
541 //_____________________________________________________________________________
542 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
545 // Returns the MC-track numbers from the dictionary for a given digit
548 Int_t row = Digit->GetRow();
549 Int_t col = Digit->GetCol();
550 Int_t time = Digit->GetTime();
551 Int_t det = Digit->GetDetector();
553 return GetTrack(track,row,col,time,det);
557 //_____________________________________________________________________________
558 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
561 // Assignment operator
564 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);