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.15 2002/02/11 14:27:54 cblume
19 Geometry and hit structure update
21 Revision 1.14 2001/11/14 10:50:46 cblume
22 Changes in digits IO. Add merging of summable digits
24 Revision 1.13 2001/11/06 17:19:41 cblume
25 Add detailed geometry and simple simulator
27 Revision 1.12 2001/05/16 14:57:28 alibrary
28 New files for folders and Stack
30 Revision 1.11 2001/03/13 09:30:35 cblume
31 Update of digitization. Moved digit branch definition to AliTRD
33 Revision 1.10 2001/01/26 19:56:57 hristov
34 Major upgrade of AliRoot code
36 Revision 1.9 2000/11/02 09:25:53 cblume
37 Change also the dictionary to AliTRDdataArray
39 Revision 1.8 2000/11/01 15:20:13 cblume
40 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
42 Revision 1.7 2000/11/01 14:53:20 cblume
43 Merge with TRD-develop
45 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
46 Get rid of global constants
48 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
51 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
54 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
55 Replace include files by forward declarations
57 Revision 1.5 2000/06/09 11:10:07 cblume
58 Compiler warnings and coding conventions, next round
60 Revision 1.4 2000/06/08 18:32:58 cblume
61 Make code compliant to coding conventions
63 Revision 1.3 2000/06/07 16:27:01 cblume
64 Try to remove compiler warnings on Sun and HP
66 Revision 1.2 2000/05/08 16:17:27 cblume
69 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
70 Add new class AliTRDdigitsManager
74 ///////////////////////////////////////////////////////////////////////////////
76 // Manages the digits and the track dictionary in the form of //
77 // AliTRDdataArray objects. //
79 ///////////////////////////////////////////////////////////////////////////////
89 #include "AliTRDdigitsManager.h"
90 #include "AliTRDsegmentArray.h"
91 #include "AliTRDdataArrayI.h"
92 #include "AliTRDdigit.h"
93 #include "AliTRDgeometry.h"
96 ClassImp(AliTRDdigitsManager)
98 //_____________________________________________________________________________
100 // Number of track dictionary arrays
101 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
103 //_____________________________________________________________________________
104 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
107 // Default constructor
118 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
119 fDictionary[iDict] = NULL;
124 //_____________________________________________________________________________
125 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
128 // AliTRDdigitsManager copy constructor
131 ((AliTRDdigitsManager &) m).Copy(*this);
135 //_____________________________________________________________________________
136 AliTRDdigitsManager::~AliTRDdigitsManager()
139 // AliTRDdigitsManager destructor
154 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
155 fDictionary[iDict]->Delete();
156 delete fDictionary[iDict];
157 fDictionary[iDict] = NULL;
162 //_____________________________________________________________________________
163 void AliTRDdigitsManager::Copy(TObject &m)
169 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
170 ((AliTRDdigitsManager &) m).fEvent = fEvent;
171 ((AliTRDdigitsManager &) m).fDebug = fDebug;
172 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
178 //_____________________________________________________________________________
179 void AliTRDdigitsManager::CreateArrays()
182 // Create the data arrays
185 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
187 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
188 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
189 ,AliTRDgeometry::Ndet());
194 //_____________________________________________________________________________
195 void AliTRDdigitsManager::SetRaw()
200 fDigits->SetBit(AliTRDdigit::RawDigit());
204 //_____________________________________________________________________________
205 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
209 // Returns the amplitude of a digit
212 return ((Short_t) GetDigits(det)->GetData(row,col,time));
216 //_____________________________________________________________________________
217 Bool_t AliTRDdigitsManager::Open(const Char_t *file)
220 // Opens the file for the TRD digits
223 fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file);
226 printf("<AliTRDdigitsManager::Open> ");
227 printf("Open the AliROOT-file %s.\n",file);
229 fFile = new TFile(file,"UPDATE");
230 if (!fFile) return kFALSE;
234 printf("<AliTRDdigitsManager::Open> ");
235 printf("%s is already open.\n",file);
243 //_____________________________________________________________________________
244 Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
247 // Creates the tree and branches for the digits and the dictionary
250 // Create the TRD digits tree
254 sprintf(treeName,"TreeS%d_TRD",fEvent);
255 tree = new TTree(treeName,"TRD SDigits");
258 sprintf(treeName,"TreeD%d_TRD",fEvent);
259 tree = new TTree(treeName,"TRD Digits");
263 printf("<AliTRDdigitsManager::MakeBranch> ");
264 printf("Creating tree %s\n",treeName);
267 return MakeBranch(tree,file);
271 //_____________________________________________________________________________
272 Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree, const Char_t *file)
275 // Creates the tree and branches for the digits and the dictionary
278 Int_t buffersize = 64000;
280 Bool_t status = kTRUE;
282 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
288 // Make the branch for the digits
290 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
292 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
293 ,&kDigits,buffersize,99,file);
295 printf("<AliTRDdigitsManager::MakeBranch> ");
296 printf("Making branch TRDdigits\n");
307 // Make the branches for the dictionaries
308 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
309 Char_t branchname[15];
310 sprintf(branchname,"TRDdictionary%d",iDict);
311 if (fDictionary[iDict]) {
312 const AliTRDdataArray *kDictionary =
313 (AliTRDdataArray *) fDictionary[iDict]->At(0);
315 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
316 ,&kDictionary,buffersize,99,file);
318 printf("<AliTRDdigitsManager::MakeBranch> ");
319 printf("Making branch %s\n",branchname);
335 //_____________________________________________________________________________
336 Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree)
339 // Reads the digit information from the input file
342 Bool_t status = kTRUE;
351 // Get the digits tree
354 sprintf(treeName,"TreeS%d_TRD",fEvent);
357 sprintf(treeName,"TreeD%d_TRD",fEvent);
360 fTree = (TTree *) fFile->Get(treeName);
363 fTree = (TTree *) gDirectory->Get(treeName);
368 printf("<AliTRDdigitsManager::ReadDigits> ");
369 printf("Could not find tree %s.\n",treeName);
378 printf("<AliTRDdigitsManager::ReadDigits> ");
379 printf("Create the data arrays.\n");
384 status = fDigits->LoadArray("TRDdigits",fTree);
386 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
387 Char_t branchname[15];
388 sprintf(branchname,"TRDdictionary%d",iDict);
389 status = fDictionary[iDict]->LoadArray(branchname,fTree);
392 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
403 //_____________________________________________________________________________
404 Bool_t AliTRDdigitsManager::WriteDigits()
407 // Writes out the TRD-digits and the dictionaries
410 // Store the contents of the segment array in the tree
411 if (!fDigits->StoreArray("TRDdigits",fTree)) {
412 printf("<AliTRDdigitsManager::WriteDigits> ");
413 printf("Error while storing digits in branch TRDdigits\n");
416 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
417 Char_t branchname[15];
418 sprintf(branchname,"TRDdictionary%d",iDict);
419 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
420 printf("<AliTRDdigitsManager::WriteDigits> ");
421 printf("Error while storing dictionary in branch %s\n",branchname);
426 // Write the new tree to the output file
433 //_____________________________________________________________________________
434 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
435 , Int_t time, Int_t det) const
438 // Creates a single digit object
449 amp[0] = GetDigits(det)->GetData(row,col,time);
451 return (new AliTRDdigit(fIsRaw,digits,amp));
455 //_____________________________________________________________________________
456 Int_t AliTRDdigitsManager::GetTrack(Int_t track
457 , Int_t row, Int_t col, Int_t time
461 // Returns the MC-track numbers from the dictionary.
464 if ((track < 0) || (track >= kNDict)) {
465 TObject::Error("GetTracks"
466 ,"track %d out of bounds (size: %d, this: 0x%08x)"
471 // Array contains index+1 to allow data compression
472 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
476 //_____________________________________________________________________________
477 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
480 // Returns the digits array for one detector
483 return (AliTRDdataArrayI *) fDigits->At(det);
487 //_____________________________________________________________________________
488 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
491 // Returns the dictionary for one detector
494 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
498 //_____________________________________________________________________________
499 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
502 // Returns the MC-track numbers from the dictionary for a given digit
505 Int_t row = Digit->GetRow();
506 Int_t col = Digit->GetCol();
507 Int_t time = Digit->GetTime();
508 Int_t det = Digit->GetDetector();
510 return GetTrack(track,row,col,time,det);
514 //_____________________________________________________________________________
515 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
518 // Assignment operator
521 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);