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.16 2002/02/12 11:42:08 cblume
19 Remove fTree from destructor
21 Revision 1.15 2002/02/11 14:27:54 cblume
22 Geometry and hit structure update
24 Revision 1.14 2001/11/14 10:50:46 cblume
25 Changes in digits IO. Add merging of summable digits
27 Revision 1.13 2001/11/06 17:19:41 cblume
28 Add detailed geometry and simple simulator
30 Revision 1.12 2001/05/16 14:57:28 alibrary
31 New files for folders and Stack
33 Revision 1.11 2001/03/13 09:30:35 cblume
34 Update of digitization. Moved digit branch definition to AliTRD
36 Revision 1.10 2001/01/26 19:56:57 hristov
37 Major upgrade of AliRoot code
39 Revision 1.9 2000/11/02 09:25:53 cblume
40 Change also the dictionary to AliTRDdataArray
42 Revision 1.8 2000/11/01 15:20:13 cblume
43 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
45 Revision 1.7 2000/11/01 14:53:20 cblume
46 Merge with TRD-develop
48 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
49 Get rid of global constants
51 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
54 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
57 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
58 Replace include files by forward declarations
60 Revision 1.5 2000/06/09 11:10:07 cblume
61 Compiler warnings and coding conventions, next round
63 Revision 1.4 2000/06/08 18:32:58 cblume
64 Make code compliant to coding conventions
66 Revision 1.3 2000/06/07 16:27:01 cblume
67 Try to remove compiler warnings on Sun and HP
69 Revision 1.2 2000/05/08 16:17:27 cblume
72 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
73 Add new class AliTRDdigitsManager
77 ///////////////////////////////////////////////////////////////////////////////
79 // Manages the digits and the track dictionary in the form of //
80 // AliTRDdataArray objects. //
82 ///////////////////////////////////////////////////////////////////////////////
92 #include "AliTRDdigitsManager.h"
93 #include "AliTRDsegmentArray.h"
94 #include "AliTRDdataArrayI.h"
95 #include "AliTRDdigit.h"
96 #include "AliTRDgeometry.h"
99 ClassImp(AliTRDdigitsManager)
101 //_____________________________________________________________________________
103 // Number of track dictionary arrays
104 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
106 //_____________________________________________________________________________
107 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
110 // Default constructor
121 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
122 fDictionary[iDict] = NULL;
127 //_____________________________________________________________________________
128 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
131 // AliTRDdigitsManager copy constructor
134 ((AliTRDdigitsManager &) m).Copy(*this);
138 //_____________________________________________________________________________
139 AliTRDdigitsManager::~AliTRDdigitsManager()
142 // AliTRDdigitsManager destructor
157 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
158 fDictionary[iDict]->Delete();
159 delete fDictionary[iDict];
160 fDictionary[iDict] = NULL;
165 //_____________________________________________________________________________
166 void AliTRDdigitsManager::Copy(TObject &m)
172 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
173 ((AliTRDdigitsManager &) m).fEvent = fEvent;
174 ((AliTRDdigitsManager &) m).fDebug = fDebug;
175 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
181 //_____________________________________________________________________________
182 void AliTRDdigitsManager::CreateArrays()
185 // Create the data arrays
188 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
190 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
191 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
192 ,AliTRDgeometry::Ndet());
197 //_____________________________________________________________________________
198 void AliTRDdigitsManager::SetRaw()
201 // Switch on the raw digits flag
206 fDigits->SetBit(AliTRDdigit::RawDigit());
210 //_____________________________________________________________________________
211 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
215 // Returns the amplitude of a digit
218 return ((Short_t) GetDigits(det)->GetData(row,col,time));
222 //_____________________________________________________________________________
223 Bool_t AliTRDdigitsManager::Open(const Char_t *file)
226 // Opens the file for the TRD digits
229 fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file);
232 printf("<AliTRDdigitsManager::Open> ");
233 printf("Open the AliROOT-file %s.\n",file);
235 fFile = new TFile(file,"UPDATE");
236 if (!fFile) return kFALSE;
240 printf("<AliTRDdigitsManager::Open> ");
241 printf("%s is already open.\n",file);
249 //_____________________________________________________________________________
250 Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
253 // Creates the tree and branches for the digits and the dictionary
256 // Create the TRD digits tree
260 sprintf(treeName,"TreeS%d_TRD",fEvent);
261 tree = new TTree(treeName,"TRD SDigits");
264 sprintf(treeName,"TreeD%d_TRD",fEvent);
265 tree = new TTree(treeName,"TRD Digits");
269 printf("<AliTRDdigitsManager::MakeBranch> ");
270 printf("Creating tree %s\n",treeName);
273 return MakeBranch(tree,file);
277 //_____________________________________________________________________________
278 Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
281 // Creates the tree and branches for the digits and the dictionary
284 Int_t buffersize = 64000;
286 Bool_t status = kTRUE;
288 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
294 // Make the branch for the digits
296 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
298 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
299 ,&kDigits,buffersize,99,file);
301 printf("<AliTRDdigitsManager::MakeBranch> ");
302 printf("Making branch TRDdigits\n");
313 // Make the branches for the dictionaries
314 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
315 Char_t branchname[15];
316 sprintf(branchname,"TRDdictionary%d",iDict);
317 if (fDictionary[iDict]) {
318 const AliTRDdataArray *kDictionary =
319 (AliTRDdataArray *) fDictionary[iDict]->At(0);
321 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
322 ,&kDictionary,buffersize,99,file);
324 printf("<AliTRDdigitsManager::MakeBranch> ");
325 printf("Making branch %s\n",branchname);
341 //_____________________________________________________________________________
342 Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
345 // Reads the digit information from the input file
348 Bool_t status = kTRUE;
357 // Get the digits tree
360 sprintf(treeName,"TreeS%d_TRD",fEvent);
363 sprintf(treeName,"TreeD%d_TRD",fEvent);
366 fTree = (TTree *) fFile->Get(treeName);
369 fTree = (TTree *) gDirectory->Get(treeName);
374 printf("<AliTRDdigitsManager::ReadDigits> ");
375 printf("Could not find tree %s.\n",treeName);
384 printf("<AliTRDdigitsManager::ReadDigits> ");
385 printf("Create the data arrays.\n");
390 status = fDigits->LoadArray("TRDdigits",fTree);
392 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
393 Char_t branchname[15];
394 sprintf(branchname,"TRDdictionary%d",iDict);
395 status = fDictionary[iDict]->LoadArray(branchname,fTree);
398 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
409 //_____________________________________________________________________________
410 Bool_t AliTRDdigitsManager::WriteDigits()
413 // Writes out the TRD-digits and the dictionaries
416 // Store the contents of the segment array in the tree
417 if (!fDigits->StoreArray("TRDdigits",fTree)) {
418 printf("<AliTRDdigitsManager::WriteDigits> ");
419 printf("Error while storing digits in branch TRDdigits\n");
422 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
423 Char_t branchname[15];
424 sprintf(branchname,"TRDdictionary%d",iDict);
425 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
426 printf("<AliTRDdigitsManager::WriteDigits> ");
427 printf("Error while storing dictionary in branch %s\n",branchname);
432 // Write the new tree to the output file
439 //_____________________________________________________________________________
440 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
441 , Int_t time, Int_t det) const
444 // Creates a single digit object
455 amp[0] = GetDigits(det)->GetData(row,col,time);
457 return (new AliTRDdigit(fIsRaw,digits,amp));
461 //_____________________________________________________________________________
462 Int_t AliTRDdigitsManager::GetTrack(Int_t track
463 , Int_t row, Int_t col, Int_t time
467 // Returns the MC-track numbers from the dictionary.
470 if ((track < 0) || (track >= kNDict)) {
471 TObject::Error("GetTracks"
472 ,"track %d out of bounds (size: %d, this: 0x%08x)"
477 // Array contains index+1 to allow data compression
478 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
482 //_____________________________________________________________________________
483 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
486 // Returns the digits array for one detector
489 return (AliTRDdataArrayI *) fDigits->At(det);
493 //_____________________________________________________________________________
494 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
497 // Returns the dictionary for one detector
500 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
504 //_____________________________________________________________________________
505 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
508 // Returns the MC-track numbers from the dictionary for a given digit
511 Int_t row = Digit->GetRow();
512 Int_t col = Digit->GetCol();
513 Int_t time = Digit->GetTime();
514 Int_t det = Digit->GetDetector();
516 return GetTrack(track,row,col,time,det);
520 //_____________________________________________________________________________
521 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
524 // Assignment operator
527 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);