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.8 2000/11/01 15:20:13 cblume
19 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
21 Revision 1.7 2000/11/01 14:53:20 cblume
22 Merge with TRD-develop
24 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
25 Get rid of global constants
27 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
30 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
33 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
34 Replace include files by forward declarations
36 Revision 1.5 2000/06/09 11:10:07 cblume
37 Compiler warnings and coding conventions, next round
39 Revision 1.4 2000/06/08 18:32:58 cblume
40 Make code compliant to coding conventions
42 Revision 1.3 2000/06/07 16:27:01 cblume
43 Try to remove compiler warnings on Sun and HP
45 Revision 1.2 2000/05/08 16:17:27 cblume
48 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
49 Add new class AliTRDdigitsManager
53 ///////////////////////////////////////////////////////////////////////////////
55 // Manages the digits and the track dictionary in the form of //
56 // AliTRDdataArray objects. //
58 ///////////////////////////////////////////////////////////////////////////////
64 #include "AliTRDdigitsManager.h"
65 #include "AliTRDsegmentArray.h"
66 #include "AliTRDdataArrayI.h"
67 #include "AliTRDdigit.h"
68 #include "AliTRDgeometry.h"
70 ClassImp(AliTRDdigitsManager)
72 //_____________________________________________________________________________
74 // Number of track dictionary arrays
75 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
77 //_____________________________________________________________________________
78 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
81 // Default constructor
86 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
88 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
89 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
90 ,AliTRDgeometry::Ndet());
95 //_____________________________________________________________________________
96 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
99 // AliTRDdigitsManager copy constructor
102 ((AliTRDdigitsManager &) m).Copy(*this);
106 //_____________________________________________________________________________
107 AliTRDdigitsManager::~AliTRDdigitsManager()
110 // AliTRDdigitsManager destructor
118 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
119 fDictionary[iDict]->Delete();
120 delete fDictionary[iDict];
125 //_____________________________________________________________________________
126 void AliTRDdigitsManager::Copy(TObject &m)
132 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
138 //_____________________________________________________________________________
139 void AliTRDdigitsManager::SetRaw()
144 fDigits->SetBit(AliTRDdigit::RawDigit());
148 //_____________________________________________________________________________
149 Bool_t AliTRDdigitsManager::MakeBranch()
152 // Creates the branches for the digits and the dictionary in the digits tree
155 Int_t buffersize = 64000;
157 Bool_t status = kTRUE;
159 if (gAlice->TreeD()) {
161 // Make the branch for the digits
163 //const AliTRDdataArrayI *kDigits =
164 // (AliTRDdataArrayI *) fDigits->At(0);
165 const AliTRDdataArray *kDigits =
166 (AliTRDdataArray *) fDigits->At(0);
168 gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName()
169 ,&kDigits,buffersize,1);
170 printf("AliTRDdigitsManager::MakeBranch -- ");
171 printf("Making branch TRDdigits\n");
181 // Make the branches for the dictionaries
182 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
183 Char_t branchname[15];
184 sprintf(branchname,"TRDdictionary%d",iDict);
185 if (fDictionary[iDict]) {
186 //const AliTRDdataArrayI *kDictionary =
187 // (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
188 const AliTRDdataArray *kDictionary =
189 (AliTRDdataArray *) fDictionary[iDict]->At(0);
191 gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName()
192 ,&kDictionary,buffersize,1);
193 printf("AliTRDdigitsManager::MakeBranch -- ");
194 printf("Making branch %s\n",branchname);
214 //_____________________________________________________________________________
215 Bool_t AliTRDdigitsManager::ReadDigits()
218 // Reads the digit information from the input file
221 Bool_t status = kTRUE;
223 status = fDigits->LoadArray("TRDdigits");
225 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
226 Char_t branchname[15];
227 sprintf(branchname,"TRDdictionary%d",iDict);
228 status = fDictionary[iDict]->LoadArray(branchname);
231 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
242 //_____________________________________________________________________________
243 Bool_t AliTRDdigitsManager::WriteDigits()
246 // Writes out the TRD-digits and the dictionaries
249 // Create the branches
250 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
251 if (!MakeBranch()) return kFALSE;
254 // Store the contents of the segment array in the tree
255 if (!fDigits->StoreArray("TRDdigits")) {
256 printf("AliTRDdigitsManager::WriteDigits -- ");
257 printf("Error while storing digits in branch TRDdigits\n");
260 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
261 Char_t branchname[15];
262 sprintf(branchname,"TRDdictionary%d",iDict);
263 if (!fDictionary[iDict]->StoreArray(branchname)) {
264 printf("AliTRDdigitsManager::WriteDigits -- ");
265 printf("Error while storing dictionary in branch %s\n",branchname);
274 //_____________________________________________________________________________
275 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
276 , Int_t time, Int_t det) const
279 // Creates a single digit object
290 amp[0] = GetDigits(det)->GetData(row,col,time);
292 return (new AliTRDdigit(fIsRaw,digits,amp));
296 //_____________________________________________________________________________
297 Int_t AliTRDdigitsManager::GetTrack(Int_t track
298 , Int_t row, Int_t col, Int_t time
302 // Returns the MC-track numbers from the dictionary.
305 if ((track < 0) || (track >= kNDict)) {
306 TObject::Error("GetTracks"
307 ,"track %d out of bounds (size: %d, this: 0x%08x)"
312 // Array contains index+1 to allow data compression
313 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
317 //_____________________________________________________________________________
318 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
321 // Returns the digits array for one detector
324 return (AliTRDdataArrayI *) fDigits->At(det);
328 //_____________________________________________________________________________
329 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
332 // Returns the dictionary for one detector
335 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
339 //_____________________________________________________________________________
340 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
343 // Returns the MC-track numbers from the dictionary for a given digit
346 Int_t row = Digit->GetRow();
347 Int_t col = Digit->GetCol();
348 Int_t time = Digit->GetTime();
349 Int_t det = Digit->GetDetector();
351 return GetTrack(track,row,col,time,det);
355 //_____________________________________________________________________________
356 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
359 // Assignment operator
362 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);