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.13 2001/11/06 17:19:41 cblume
19 Add detailed geometry and simple simulator
21 Revision 1.12 2001/05/16 14:57:28 alibrary
22 New files for folders and Stack
24 Revision 1.11 2001/03/13 09:30:35 cblume
25 Update of digitization. Moved digit branch definition to AliTRD
27 Revision 1.10 2001/01/26 19:56:57 hristov
28 Major upgrade of AliRoot code
30 Revision 1.9 2000/11/02 09:25:53 cblume
31 Change also the dictionary to AliTRDdataArray
33 Revision 1.8 2000/11/01 15:20:13 cblume
34 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
36 Revision 1.7 2000/11/01 14:53:20 cblume
37 Merge with TRD-develop
39 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
40 Get rid of global constants
42 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
45 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
48 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
49 Replace include files by forward declarations
51 Revision 1.5 2000/06/09 11:10:07 cblume
52 Compiler warnings and coding conventions, next round
54 Revision 1.4 2000/06/08 18:32:58 cblume
55 Make code compliant to coding conventions
57 Revision 1.3 2000/06/07 16:27:01 cblume
58 Try to remove compiler warnings on Sun and HP
60 Revision 1.2 2000/05/08 16:17:27 cblume
63 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
64 Add new class AliTRDdigitsManager
68 ///////////////////////////////////////////////////////////////////////////////
70 // Manages the digits and the track dictionary in the form of //
71 // AliTRDdataArray objects. //
73 ///////////////////////////////////////////////////////////////////////////////
83 #include "AliTRDdigitsManager.h"
84 #include "AliTRDsegmentArray.h"
85 #include "AliTRDdataArrayI.h"
86 #include "AliTRDdigit.h"
87 #include "AliTRDgeometry.h"
90 ClassImp(AliTRDdigitsManager)
92 //_____________________________________________________________________________
94 // Number of track dictionary arrays
95 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
97 //_____________________________________________________________________________
98 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
101 // Default constructor
112 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
113 fDictionary[iDict] = NULL;
118 //_____________________________________________________________________________
119 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
122 // AliTRDdigitsManager copy constructor
125 ((AliTRDdigitsManager &) m).Copy(*this);
129 //_____________________________________________________________________________
130 AliTRDdigitsManager::~AliTRDdigitsManager()
133 // AliTRDdigitsManager destructor
153 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
154 fDictionary[iDict]->Delete();
155 delete fDictionary[iDict];
156 fDictionary[iDict] = NULL;
161 //_____________________________________________________________________________
162 void AliTRDdigitsManager::Copy(TObject &m)
168 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
169 ((AliTRDdigitsManager &) m).fEvent = fEvent;
170 ((AliTRDdigitsManager &) m).fVerbose = fVerbose;
171 ((AliTRDdigitsManager &) m).fSDigits = fSDigits;
177 //_____________________________________________________________________________
178 void AliTRDdigitsManager::CreateArrays()
181 // Create the data arrays
184 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
186 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
187 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
188 ,AliTRDgeometry::Ndet());
193 //_____________________________________________________________________________
194 void AliTRDdigitsManager::SetRaw()
199 fDigits->SetBit(AliTRDdigit::RawDigit());
203 //_____________________________________________________________________________
204 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
208 // Returns the amplitude of a digit
211 return ((Short_t) GetDigits(det)->GetData(row,col,time));
215 //_____________________________________________________________________________
216 Bool_t AliTRDdigitsManager::Open(const Char_t *name)
219 // Opens the file for the TRD digits
222 fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name);
225 printf("AliTRDdigitsManager::Open -- ");
226 printf("Open the AliROOT-file %s.\n",name);
228 fFile = new TFile(name,"UPDATE");
229 if (!fFile) return kFALSE;
233 printf("AliTRDdigitsManager::Open -- ");
234 printf("%s is already open.\n",name);
242 //_____________________________________________________________________________
243 Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
246 // Creates the tree and branches for the digits and the dictionary
249 Int_t buffersize = 64000;
251 Bool_t status = kTRUE;
253 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ;
255 // Create the TRD digits tree
258 sprintf(treeName,"TreeS%d_TRD",fEvent);
259 fTree = new TTree(treeName,"TRD SDigits");
262 sprintf(treeName,"TreeD%d_TRD",fEvent);
263 fTree = new TTree(treeName,"TRD Digits");
267 printf("AliTRDdigitsManager::MakeBranch -- ");
268 printf("Creating tree %s\n",treeName);
271 // Make the branch for the digits
273 const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0);
275 trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName()
276 ,&kDigits,buffersize,99,file);
278 printf("AliTRDdigitsManager::MakeBranch -- ");
279 printf("Making branch TRDdigits\n");
290 // Make the branches for the dictionaries
291 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
292 Char_t branchname[15];
293 sprintf(branchname,"TRDdictionary%d",iDict);
294 if (fDictionary[iDict]) {
295 const AliTRDdataArray *kDictionary =
296 (AliTRDdataArray *) fDictionary[iDict]->At(0);
298 trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName()
299 ,&kDictionary,buffersize,99,file);
301 printf("AliTRDdigitsManager::MakeBranch -- ");
302 printf("Making branch %s\n",branchname);
318 //_____________________________________________________________________________
319 Bool_t AliTRDdigitsManager::ReadDigits()
322 // Reads the digit information from the input file
325 Bool_t status = kTRUE;
327 // Get the digits tree
330 sprintf(treeName,"TreeS%d_TRD",fEvent);
333 sprintf(treeName,"TreeD%d_TRD",fEvent);
336 fTree = (TTree *) fFile->Get(treeName);
339 fTree = (TTree *) gDirectory->Get(treeName);
343 printf("AliTRDdigitsManager::ReadDigits -- ");
344 printf("Could not find tree %s.\n",treeName);
351 printf("AliTRDdigitsManager::ReadDigits -- ");
352 printf("Create the data arrays.\n");
357 status = fDigits->LoadArray("TRDdigits",fTree);
359 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
360 Char_t branchname[15];
361 sprintf(branchname,"TRDdictionary%d",iDict);
362 status = fDictionary[iDict]->LoadArray(branchname,fTree);
365 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
376 //_____________________________________________________________________________
377 Bool_t AliTRDdigitsManager::WriteDigits()
380 // Writes out the TRD-digits and the dictionaries
383 // Store the contents of the segment array in the tree
384 if (!fDigits->StoreArray("TRDdigits",fTree)) {
385 printf("AliTRDdigitsManager::WriteDigits -- ");
386 printf("Error while storing digits in branch TRDdigits\n");
389 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
390 Char_t branchname[15];
391 sprintf(branchname,"TRDdictionary%d",iDict);
392 if (!fDictionary[iDict]->StoreArray(branchname,fTree)) {
393 printf("AliTRDdigitsManager::WriteDigits -- ");
394 printf("Error while storing dictionary in branch %s\n",branchname);
399 // Write the new tree to the output file
406 //_____________________________________________________________________________
407 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
408 , Int_t time, Int_t det) const
411 // Creates a single digit object
422 amp[0] = GetDigits(det)->GetData(row,col,time);
424 return (new AliTRDdigit(fIsRaw,digits,amp));
428 //_____________________________________________________________________________
429 Int_t AliTRDdigitsManager::GetTrack(Int_t track
430 , Int_t row, Int_t col, Int_t time
434 // Returns the MC-track numbers from the dictionary.
437 if ((track < 0) || (track >= kNDict)) {
438 TObject::Error("GetTracks"
439 ,"track %d out of bounds (size: %d, this: 0x%08x)"
444 // Array contains index+1 to allow data compression
445 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
449 //_____________________________________________________________________________
450 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
453 // Returns the digits array for one detector
456 return (AliTRDdataArrayI *) fDigits->At(det);
460 //_____________________________________________________________________________
461 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
464 // Returns the dictionary for one detector
467 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
471 //_____________________________________________________________________________
472 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
475 // Returns the MC-track numbers from the dictionary for a given digit
478 Int_t row = Digit->GetRow();
479 Int_t col = Digit->GetCol();
480 Int_t time = Digit->GetTime();
481 Int_t det = Digit->GetDetector();
483 return GetTrack(track,row,col,time,det);
487 //_____________________________________________________________________________
488 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
491 // Assignment operator
494 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);