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.9 2000/11/02 09:25:53 cblume
19 Change also the dictionary to AliTRDdataArray
21 Revision 1.8 2000/11/01 15:20:13 cblume
22 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
24 Revision 1.7 2000/11/01 14:53:20 cblume
25 Merge with TRD-develop
27 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
28 Get rid of global constants
30 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
33 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
36 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
37 Replace include files by forward declarations
39 Revision 1.5 2000/06/09 11:10:07 cblume
40 Compiler warnings and coding conventions, next round
42 Revision 1.4 2000/06/08 18:32:58 cblume
43 Make code compliant to coding conventions
45 Revision 1.3 2000/06/07 16:27:01 cblume
46 Try to remove compiler warnings on Sun and HP
48 Revision 1.2 2000/05/08 16:17:27 cblume
51 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
52 Add new class AliTRDdigitsManager
56 ///////////////////////////////////////////////////////////////////////////////
58 // Manages the digits and the track dictionary in the form of //
59 // AliTRDdataArray objects. //
61 ///////////////////////////////////////////////////////////////////////////////
70 #include "AliTRDdigitsManager.h"
71 #include "AliTRDsegmentArray.h"
72 #include "AliTRDdataArrayI.h"
73 #include "AliTRDdigit.h"
74 #include "AliTRDgeometry.h"
76 ClassImp(AliTRDdigitsManager)
78 //_____________________________________________________________________________
80 // Number of track dictionary arrays
81 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
83 //_____________________________________________________________________________
84 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
87 // Default constructor
92 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
94 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
95 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
96 ,AliTRDgeometry::Ndet());
101 //_____________________________________________________________________________
102 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
105 // AliTRDdigitsManager copy constructor
108 ((AliTRDdigitsManager &) m).Copy(*this);
112 //_____________________________________________________________________________
113 AliTRDdigitsManager::~AliTRDdigitsManager()
116 // AliTRDdigitsManager destructor
124 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
125 fDictionary[iDict]->Delete();
126 delete fDictionary[iDict];
131 //_____________________________________________________________________________
132 void AliTRDdigitsManager::Copy(TObject &m)
138 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
144 //_____________________________________________________________________________
145 void AliTRDdigitsManager::SetRaw()
150 fDigits->SetBit(AliTRDdigit::RawDigit());
154 //_____________________________________________________________________________
155 Bool_t AliTRDdigitsManager::MakeBranch(char *file)
158 // Creates the branches for the digits and the dictionary in the digits tree
161 Int_t buffersize = 64000;
163 Bool_t status = kTRUE;
165 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("TRD.Digits.root");
167 if (gAlice->TreeD()) {
169 // Make the branch for the digits
171 const AliTRDdataArray *kDigits =
172 (AliTRDdataArray *) fDigits->At(0);
174 gAlice->MakeBranchInTree(gAlice->TreeD(),
175 "TRDdigits", kDigits->IsA()->GetName(),
176 &kDigits,buffersize, 1,file) ;
177 printf("AliTRDdigitsManager::MakeBranch -- ");
178 printf("Making branch TRDdigits\n");
188 // Make the branches for the dictionaries
189 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
190 Char_t branchname[15];
191 sprintf(branchname,"TRDdictionary%d",iDict);
192 if (fDictionary[iDict]) {
193 const AliTRDdataArray *kDictionary =
194 (AliTRDdataArray *) fDictionary[iDict]->At(0);
196 gAlice->MakeBranchInTree(gAlice->TreeD(),
197 branchname,kDictionary->IsA()->GetName(),
198 &kDictionary,buffersize, 1,file) ;
199 printf("AliTRDdigitsManager::MakeBranch -- ");
200 printf("Making branch %s\n",branchname);
220 //_____________________________________________________________________________
221 Bool_t AliTRDdigitsManager::ReadDigits()
224 // Reads the digit information from the input file
227 Bool_t status = kTRUE;
229 status = fDigits->LoadArray("TRDdigits");
231 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
232 Char_t branchname[15];
233 sprintf(branchname,"TRDdictionary%d",iDict);
234 status = fDictionary[iDict]->LoadArray(branchname);
237 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
248 //_____________________________________________________________________________
249 Bool_t AliTRDdigitsManager::WriteDigits()
252 // Writes out the TRD-digits and the dictionaries
255 // Create the branches
256 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
257 if (!MakeBranch()) return kFALSE;
260 // Store the contents of the segment array in the tree
261 if (!fDigits->StoreArray("TRDdigits")) {
262 printf("AliTRDdigitsManager::WriteDigits -- ");
263 printf("Error while storing digits in branch TRDdigits\n");
266 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
267 Char_t branchname[15];
268 sprintf(branchname,"TRDdictionary%d",iDict);
269 if (!fDictionary[iDict]->StoreArray(branchname)) {
270 printf("AliTRDdigitsManager::WriteDigits -- ");
271 printf("Error while storing dictionary in branch %s\n",branchname);
280 //_____________________________________________________________________________
281 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
282 , Int_t time, Int_t det) const
285 // Creates a single digit object
296 amp[0] = GetDigits(det)->GetData(row,col,time);
298 return (new AliTRDdigit(fIsRaw,digits,amp));
302 //_____________________________________________________________________________
303 Int_t AliTRDdigitsManager::GetTrack(Int_t track
304 , Int_t row, Int_t col, Int_t time
308 // Returns the MC-track numbers from the dictionary.
311 if ((track < 0) || (track >= kNDict)) {
312 TObject::Error("GetTracks"
313 ,"track %d out of bounds (size: %d, this: 0x%08x)"
318 // Array contains index+1 to allow data compression
319 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
323 //_____________________________________________________________________________
324 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
327 // Returns the digits array for one detector
330 return (AliTRDdataArrayI *) fDigits->At(det);
334 //_____________________________________________________________________________
335 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
338 // Returns the dictionary for one detector
341 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
345 //_____________________________________________________________________________
346 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
349 // Returns the MC-track numbers from the dictionary for a given digit
352 Int_t row = Digit->GetRow();
353 Int_t col = Digit->GetCol();
354 Int_t time = Digit->GetTime();
355 Int_t det = Digit->GetDetector();
357 return GetTrack(track,row,col,time,det);
361 //_____________________________________________________________________________
362 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
365 // Assignment operator
368 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);