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.1.2.5 2000/10/17 02:27:34 cblume
19 Get rid of global constants
21 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
24 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
27 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
28 Replace include files by forward declarations
30 Revision 1.5 2000/06/09 11:10:07 cblume
31 Compiler warnings and coding conventions, next round
33 Revision 1.4 2000/06/08 18:32:58 cblume
34 Make code compliant to coding conventions
36 Revision 1.3 2000/06/07 16:27:01 cblume
37 Try to remove compiler warnings on Sun and HP
39 Revision 1.2 2000/05/08 16:17:27 cblume
42 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
43 Add new class AliTRDdigitsManager
47 ///////////////////////////////////////////////////////////////////////////////
49 // Manages the digits and the track dictionary in the form of //
50 // AliTRDdataArray objects. //
52 ///////////////////////////////////////////////////////////////////////////////
58 #include "AliTRDdigitsManager.h"
59 #include "AliTRDsegmentArray.h"
60 #include "AliTRDdataArrayI.h"
61 #include "AliTRDdigit.h"
62 #include "AliTRDgeometry.h"
64 ClassImp(AliTRDdigitsManager)
66 //_____________________________________________________________________________
68 // Number of track dictionary arrays
69 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
71 //_____________________________________________________________________________
72 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
75 // Default constructor
80 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
82 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
83 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
84 ,AliTRDgeometry::Ndet());
89 //_____________________________________________________________________________
90 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
93 // AliTRDdigitsManager copy constructor
96 ((AliTRDdigitsManager &) m).Copy(*this);
100 //_____________________________________________________________________________
101 AliTRDdigitsManager::~AliTRDdigitsManager()
104 // AliTRDdigitsManager destructor
112 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
113 fDictionary[iDict]->Delete();
114 delete fDictionary[iDict];
119 //_____________________________________________________________________________
120 void AliTRDdigitsManager::Copy(TObject &m)
126 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
132 //_____________________________________________________________________________
133 void AliTRDdigitsManager::SetRaw()
138 fDigits->SetBit(AliTRDdigit::RawDigit());
142 //_____________________________________________________________________________
143 Bool_t AliTRDdigitsManager::MakeBranch()
146 // Creates the branches for the digits and the dictionary in the digits tree
149 Int_t buffersize = 64000;
151 Bool_t status = kTRUE;
153 if (gAlice->TreeD()) {
155 // Make the branch for the digits
157 const AliTRDdataArrayI *kDigits =
158 (AliTRDdataArrayI *) fDigits->At(0);
160 gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName()
161 ,&kDigits,buffersize,1);
162 printf("AliTRDdigitsManager::MakeBranch -- ");
163 printf("Making branch TRDdigits\n");
173 // Make the branches for the dictionaries
174 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
176 Char_t branchname[15];
177 sprintf(branchname,"TRDdictionary%d",iDict);
178 if (fDictionary[iDict]) {
179 const AliTRDdataArrayI *kDictionary =
180 (AliTRDdataArrayI *) fDictionary[iDict]->At(0);
182 gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName()
183 ,&kDictionary,buffersize,1);
184 printf("AliTRDdigitsManager::MakeBranch -- ");
185 printf("Making branch %s\n",branchname);
205 //_____________________________________________________________________________
206 Bool_t AliTRDdigitsManager::ReadDigits()
209 // Reads the digit information from the input file
212 Bool_t status = kTRUE;
214 status = fDigits->LoadArray("TRDdigits");
216 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
217 Char_t branchname[15];
218 sprintf(branchname,"TRDdictionary%d",iDict);
219 status = fDictionary[iDict]->LoadArray(branchname);
222 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
233 //_____________________________________________________________________________
234 Bool_t AliTRDdigitsManager::WriteDigits()
237 // Writes out the TRD-digits and the dictionaries
240 // Create the branches
241 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
242 if (!MakeBranch()) return kFALSE;
245 // Store the contents of the segment array in the tree
246 if (!fDigits->StoreArray("TRDdigits")) {
247 printf("AliTRDdigitsManager::WriteDigits -- ");
248 printf("Error while storing digits in branch TRDdigits\n");
251 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
252 Char_t branchname[15];
253 sprintf(branchname,"TRDdictionary%d",iDict);
254 if (!fDictionary[iDict]->StoreArray(branchname)) {
255 printf("AliTRDdigitsManager::WriteDigits -- ");
256 printf("Error while storing dictionary in branch %s\n",branchname);
265 //_____________________________________________________________________________
266 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
267 , Int_t time, Int_t det) const
270 // Creates a single digit object
281 amp[0] = GetDigits(det)->GetData(row,col,time);
283 return (new AliTRDdigit(fIsRaw,digits,amp));
287 //_____________________________________________________________________________
288 Int_t AliTRDdigitsManager::GetTrack(Int_t track
289 , Int_t row, Int_t col, Int_t time
293 // Returns the MC-track numbers from the dictionary.
296 if ((track < 0) || (track >= kNDict)) {
297 TObject::Error("GetTracks"
298 ,"track %d out of bounds (size: %d, this: 0x%08x)"
303 // Array contains index+1 to allow data compression
304 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
308 //_____________________________________________________________________________
309 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
312 // Returns the digits array for one detector
315 return (AliTRDdataArrayI *) fDigits->At(det);
319 //_____________________________________________________________________________
320 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
323 // Returns the dictionary for one detector
326 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
330 //_____________________________________________________________________________
331 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
334 // Returns the MC-track numbers from the dictionary for a given digit
337 Int_t row = Digit->GetRow();
338 Int_t col = Digit->GetCol();
339 Int_t time = Digit->GetTime();
340 Int_t det = Digit->GetDetector();
342 return GetTrack(track,row,col,time,det);
346 //_____________________________________________________________________________
347 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
350 // Assignment operator
353 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);