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.12 2001/05/16 14:57:28 alibrary
19 New files for folders and Stack
21 Revision 1.11 2001/03/13 09:30:35 cblume
22 Update of digitization. Moved digit branch definition to AliTRD
24 Revision 1.10 2001/01/26 19:56:57 hristov
25 Major upgrade of AliRoot code
27 Revision 1.9 2000/11/02 09:25:53 cblume
28 Change also the dictionary to AliTRDdataArray
30 Revision 1.8 2000/11/01 15:20:13 cblume
31 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
33 Revision 1.7 2000/11/01 14:53:20 cblume
34 Merge with TRD-develop
36 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
37 Get rid of global constants
39 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
42 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
45 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
46 Replace include files by forward declarations
48 Revision 1.5 2000/06/09 11:10:07 cblume
49 Compiler warnings and coding conventions, next round
51 Revision 1.4 2000/06/08 18:32:58 cblume
52 Make code compliant to coding conventions
54 Revision 1.3 2000/06/07 16:27:01 cblume
55 Try to remove compiler warnings on Sun and HP
57 Revision 1.2 2000/05/08 16:17:27 cblume
60 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
61 Add new class AliTRDdigitsManager
65 ///////////////////////////////////////////////////////////////////////////////
67 // Manages the digits and the track dictionary in the form of //
68 // AliTRDdataArray objects. //
70 ///////////////////////////////////////////////////////////////////////////////
80 #include "AliTRDdigitsManager.h"
81 #include "AliTRDsegmentArray.h"
82 #include "AliTRDdataArrayI.h"
83 #include "AliTRDdigit.h"
84 #include "AliTRDgeometry.h"
87 ClassImp(AliTRDdigitsManager)
89 //_____________________________________________________________________________
91 // Number of track dictionary arrays
92 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
94 //_____________________________________________________________________________
95 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
98 // Default constructor
103 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
105 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
106 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
107 ,AliTRDgeometry::Ndet());
112 //_____________________________________________________________________________
113 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
116 // AliTRDdigitsManager copy constructor
119 ((AliTRDdigitsManager &) m).Copy(*this);
123 //_____________________________________________________________________________
124 AliTRDdigitsManager::~AliTRDdigitsManager()
127 // AliTRDdigitsManager destructor
135 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
136 fDictionary[iDict]->Delete();
137 delete fDictionary[iDict];
142 //_____________________________________________________________________________
143 void AliTRDdigitsManager::Copy(TObject &m)
149 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
155 //_____________________________________________________________________________
156 void AliTRDdigitsManager::SetRaw()
161 fDigits->SetBit(AliTRDdigit::RawDigit());
165 //_____________________________________________________________________________
166 Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time
170 // Returns the amplitude of a digit
173 return ((Short_t) GetDigits(det)->GetData(row,col,time));
177 //_____________________________________________________________________________
178 Bool_t AliTRDdigitsManager::MakeBranch(char *file)
181 // Creates the branches for the digits and the dictionary in the digits tree
184 Int_t buffersize = 64000;
186 Bool_t status = kTRUE;
188 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("TRD.Digits.root");
190 AliTRD * TRD = (AliTRD *) gAlice->GetDetector("TRD") ;
192 if (gAlice->TreeD()) {
194 // Make the branch for the digits
196 const AliTRDdataArray *kDigits =
197 (AliTRDdataArray *) fDigits->At(0);
199 TRD->MakeBranchInTree(gAlice->TreeD(),
200 "TRDdigits", kDigits->IsA()->GetName(),
201 &kDigits,buffersize, 1,file);
202 printf("AliTRDdigitsManager::MakeBranch -- ");
203 printf("Making branch TRDdigits\n");
213 // Make the branches for the dictionaries
214 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
215 Char_t branchname[15];
216 sprintf(branchname,"TRDdictionary%d",iDict);
217 if (fDictionary[iDict]) {
218 const AliTRDdataArray *kDictionary =
219 (AliTRDdataArray *) fDictionary[iDict]->At(0);
221 TRD->MakeBranchInTree(gAlice->TreeD(),
222 branchname,kDictionary->IsA()->GetName(),
223 &kDictionary,buffersize, 1,file);
224 printf("AliTRDdigitsManager::MakeBranch -- ");
225 printf("Making branch %s\n",branchname);
245 //_____________________________________________________________________________
246 Bool_t AliTRDdigitsManager::ReadDigits()
249 // Reads the digit information from the input file
252 Bool_t status = kTRUE;
254 status = fDigits->LoadArray("TRDdigits");
256 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
257 Char_t branchname[15];
258 sprintf(branchname,"TRDdictionary%d",iDict);
259 status = fDictionary[iDict]->LoadArray(branchname);
262 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
273 //_____________________________________________________________________________
274 Bool_t AliTRDdigitsManager::WriteDigits()
277 // Writes out the TRD-digits and the dictionaries
280 // Create the branches
281 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
282 printf("AliTRDdigitsManager::WriteDigits -- ");
283 printf("Call MakeBranch\n");
284 if (!MakeBranch()) return kFALSE;
287 // Store the contents of the segment array in the tree
288 if (!fDigits->StoreArray("TRDdigits")) {
289 printf("AliTRDdigitsManager::WriteDigits -- ");
290 printf("Error while storing digits in branch TRDdigits\n");
293 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
294 Char_t branchname[15];
295 sprintf(branchname,"TRDdictionary%d",iDict);
296 if (!fDictionary[iDict]->StoreArray(branchname)) {
297 printf("AliTRDdigitsManager::WriteDigits -- ");
298 printf("Error while storing dictionary in branch %s\n",branchname);
307 //_____________________________________________________________________________
308 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
309 , Int_t time, Int_t det) const
312 // Creates a single digit object
323 amp[0] = GetDigits(det)->GetData(row,col,time);
325 return (new AliTRDdigit(fIsRaw,digits,amp));
329 //_____________________________________________________________________________
330 Int_t AliTRDdigitsManager::GetTrack(Int_t track
331 , Int_t row, Int_t col, Int_t time
335 // Returns the MC-track numbers from the dictionary.
338 if ((track < 0) || (track >= kNDict)) {
339 TObject::Error("GetTracks"
340 ,"track %d out of bounds (size: %d, this: 0x%08x)"
345 // Array contains index+1 to allow data compression
346 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
350 //_____________________________________________________________________________
351 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
354 // Returns the digits array for one detector
357 return (AliTRDdataArrayI *) fDigits->At(det);
361 //_____________________________________________________________________________
362 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
365 // Returns the dictionary for one detector
368 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
372 //_____________________________________________________________________________
373 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
376 // Returns the MC-track numbers from the dictionary for a given digit
379 Int_t row = Digit->GetRow();
380 Int_t col = Digit->GetCol();
381 Int_t time = Digit->GetTime();
382 Int_t det = Digit->GetDetector();
384 return GetTrack(track,row,col,time,det);
388 //_____________________________________________________________________________
389 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
392 // Assignment operator
395 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);