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.10 2001/01/26 19:56:57 hristov
19 Major upgrade of AliRoot code
21 Revision 1.9 2000/11/02 09:25:53 cblume
22 Change also the dictionary to AliTRDdataArray
24 Revision 1.8 2000/11/01 15:20:13 cblume
25 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
27 Revision 1.7 2000/11/01 14:53:20 cblume
28 Merge with TRD-develop
30 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
31 Get rid of global constants
33 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
36 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
39 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
40 Replace include files by forward declarations
42 Revision 1.5 2000/06/09 11:10:07 cblume
43 Compiler warnings and coding conventions, next round
45 Revision 1.4 2000/06/08 18:32:58 cblume
46 Make code compliant to coding conventions
48 Revision 1.3 2000/06/07 16:27:01 cblume
49 Try to remove compiler warnings on Sun and HP
51 Revision 1.2 2000/05/08 16:17:27 cblume
54 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
55 Add new class AliTRDdigitsManager
59 ///////////////////////////////////////////////////////////////////////////////
61 // Manages the digits and the track dictionary in the form of //
62 // AliTRDdataArray objects. //
64 ///////////////////////////////////////////////////////////////////////////////
74 #include "AliTRDdigitsManager.h"
75 #include "AliTRDsegmentArray.h"
76 #include "AliTRDdataArrayI.h"
77 #include "AliTRDdigit.h"
78 #include "AliTRDgeometry.h"
80 ClassImp(AliTRDdigitsManager)
82 //_____________________________________________________________________________
84 // Number of track dictionary arrays
85 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
87 //_____________________________________________________________________________
88 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
91 // Default constructor
96 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
98 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
99 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
100 ,AliTRDgeometry::Ndet());
105 //_____________________________________________________________________________
106 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
109 // AliTRDdigitsManager copy constructor
112 ((AliTRDdigitsManager &) m).Copy(*this);
116 //_____________________________________________________________________________
117 AliTRDdigitsManager::~AliTRDdigitsManager()
120 // AliTRDdigitsManager destructor
128 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
129 fDictionary[iDict]->Delete();
130 delete fDictionary[iDict];
135 //_____________________________________________________________________________
136 void AliTRDdigitsManager::Copy(TObject &m)
142 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
148 //_____________________________________________________________________________
149 void AliTRDdigitsManager::SetRaw()
154 fDigits->SetBit(AliTRDdigit::RawDigit());
158 //_____________________________________________________________________________
159 Bool_t AliTRDdigitsManager::MakeBranch(char *file)
162 // Creates the branches for the digits and the dictionary in the digits tree
165 Int_t buffersize = 64000;
167 Bool_t status = kTRUE;
169 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("TRD.Digits.root");
171 if (gAlice->TreeD()) {
173 // Make the branch for the digits
175 const AliTRDdataArray *kDigits =
176 (AliTRDdataArray *) fDigits->At(0);
178 gAlice->MakeBranchInTree(gAlice->TreeD(),
179 "TRDdigits", kDigits->IsA()->GetName(),
180 &kDigits,buffersize, 1,file) ;
181 printf("AliTRDdigitsManager::MakeBranch -- ");
182 printf("Making branch TRDdigits\n");
192 // Make the branches for the dictionaries
193 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
194 Char_t branchname[15];
195 sprintf(branchname,"TRDdictionary%d",iDict);
196 if (fDictionary[iDict]) {
197 const AliTRDdataArray *kDictionary =
198 (AliTRDdataArray *) fDictionary[iDict]->At(0);
200 gAlice->MakeBranchInTree(gAlice->TreeD(),
201 branchname,kDictionary->IsA()->GetName(),
202 &kDictionary,buffersize, 1,file) ;
203 printf("AliTRDdigitsManager::MakeBranch -- ");
204 printf("Making branch %s\n",branchname);
224 //_____________________________________________________________________________
225 Bool_t AliTRDdigitsManager::ReadDigits()
228 // Reads the digit information from the input file
231 Bool_t status = kTRUE;
233 status = fDigits->LoadArray("TRDdigits");
235 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
236 Char_t branchname[15];
237 sprintf(branchname,"TRDdictionary%d",iDict);
238 status = fDictionary[iDict]->LoadArray(branchname);
241 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
252 //_____________________________________________________________________________
253 Bool_t AliTRDdigitsManager::WriteDigits()
256 // Writes out the TRD-digits and the dictionaries
259 // Create the branches
260 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
261 printf("AliTRDdigitsManager::WriteDigits -- ");
262 printf("Call MakeBranch\n");
263 if (!MakeBranch()) return kFALSE;
266 // Store the contents of the segment array in the tree
267 if (!fDigits->StoreArray("TRDdigits")) {
268 printf("AliTRDdigitsManager::WriteDigits -- ");
269 printf("Error while storing digits in branch TRDdigits\n");
272 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
273 Char_t branchname[15];
274 sprintf(branchname,"TRDdictionary%d",iDict);
275 if (!fDictionary[iDict]->StoreArray(branchname)) {
276 printf("AliTRDdigitsManager::WriteDigits -- ");
277 printf("Error while storing dictionary in branch %s\n",branchname);
286 //_____________________________________________________________________________
287 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
288 , Int_t time, Int_t det) const
291 // Creates a single digit object
302 amp[0] = GetDigits(det)->GetData(row,col,time);
304 return (new AliTRDdigit(fIsRaw,digits,amp));
308 //_____________________________________________________________________________
309 Int_t AliTRDdigitsManager::GetTrack(Int_t track
310 , Int_t row, Int_t col, Int_t time
314 // Returns the MC-track numbers from the dictionary.
317 if ((track < 0) || (track >= kNDict)) {
318 TObject::Error("GetTracks"
319 ,"track %d out of bounds (size: %d, this: 0x%08x)"
324 // Array contains index+1 to allow data compression
325 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
329 //_____________________________________________________________________________
330 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
333 // Returns the digits array for one detector
336 return (AliTRDdataArrayI *) fDigits->At(det);
340 //_____________________________________________________________________________
341 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
344 // Returns the dictionary for one detector
347 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
351 //_____________________________________________________________________________
352 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
355 // Returns the MC-track numbers from the dictionary for a given digit
358 Int_t row = Digit->GetRow();
359 Int_t col = Digit->GetCol();
360 Int_t time = Digit->GetTime();
361 Int_t det = Digit->GetDetector();
363 return GetTrack(track,row,col,time,det);
367 //_____________________________________________________________________________
368 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
371 // Assignment operator
374 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);