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.11 2001/03/13 09:30:35 cblume
19 Update of digitization. Moved digit branch definition to AliTRD
21 Revision 1.10 2001/01/26 19:56:57 hristov
22 Major upgrade of AliRoot code
24 Revision 1.9 2000/11/02 09:25:53 cblume
25 Change also the dictionary to AliTRDdataArray
27 Revision 1.8 2000/11/01 15:20:13 cblume
28 Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
30 Revision 1.7 2000/11/01 14:53:20 cblume
31 Merge with TRD-develop
33 Revision 1.1.2.5 2000/10/17 02:27:34 cblume
34 Get rid of global constants
36 Revision 1.1.2.4 2000/10/15 23:40:01 cblume
39 Revision 1.1.2.3 2000/10/06 16:49:46 cblume
42 Revision 1.1.2.2 2000/10/04 16:34:58 cblume
43 Replace include files by forward declarations
45 Revision 1.5 2000/06/09 11:10:07 cblume
46 Compiler warnings and coding conventions, next round
48 Revision 1.4 2000/06/08 18:32:58 cblume
49 Make code compliant to coding conventions
51 Revision 1.3 2000/06/07 16:27:01 cblume
52 Try to remove compiler warnings on Sun and HP
54 Revision 1.2 2000/05/08 16:17:27 cblume
57 Revision 1.1.2.1 2000/05/08 14:44:01 cblume
58 Add new class AliTRDdigitsManager
62 ///////////////////////////////////////////////////////////////////////////////
64 // Manages the digits and the track dictionary in the form of //
65 // AliTRDdataArray objects. //
67 ///////////////////////////////////////////////////////////////////////////////
77 #include "AliTRDdigitsManager.h"
78 #include "AliTRDsegmentArray.h"
79 #include "AliTRDdataArrayI.h"
80 #include "AliTRDdigit.h"
81 #include "AliTRDgeometry.h"
84 ClassImp(AliTRDdigitsManager)
86 //_____________________________________________________________________________
88 // Number of track dictionary arrays
89 const Int_t AliTRDdigitsManager::fgkNDict = kNDict;
91 //_____________________________________________________________________________
92 AliTRDdigitsManager::AliTRDdigitsManager():TObject()
95 // Default constructor
100 fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
102 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
103 fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
104 ,AliTRDgeometry::Ndet());
109 //_____________________________________________________________________________
110 AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m)
113 // AliTRDdigitsManager copy constructor
116 ((AliTRDdigitsManager &) m).Copy(*this);
120 //_____________________________________________________________________________
121 AliTRDdigitsManager::~AliTRDdigitsManager()
124 // AliTRDdigitsManager destructor
132 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
133 fDictionary[iDict]->Delete();
134 delete fDictionary[iDict];
139 //_____________________________________________________________________________
140 void AliTRDdigitsManager::Copy(TObject &m)
146 ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw;
152 //_____________________________________________________________________________
153 void AliTRDdigitsManager::SetRaw()
158 fDigits->SetBit(AliTRDdigit::RawDigit());
162 //_____________________________________________________________________________
163 Bool_t AliTRDdigitsManager::MakeBranch(char *file)
166 // Creates the branches for the digits and the dictionary in the digits tree
169 Int_t buffersize = 64000;
171 Bool_t status = kTRUE;
173 //TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("TRD.Digits.root");
175 AliTRD * TRD = (AliTRD *) gAlice->GetDetector("TRD") ;
177 if (gAlice->TreeD()) {
179 // Make the branch for the digits
181 const AliTRDdataArray *kDigits =
182 (AliTRDdataArray *) fDigits->At(0);
184 TRD->MakeBranchInTree(gAlice->TreeD(),
185 "TRDdigits", kDigits->IsA()->GetName(),
186 &kDigits,buffersize, 1,file);
187 printf("AliTRDdigitsManager::MakeBranch -- ");
188 printf("Making branch TRDdigits\n");
198 // Make the branches for the dictionaries
199 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
200 Char_t branchname[15];
201 sprintf(branchname,"TRDdictionary%d",iDict);
202 if (fDictionary[iDict]) {
203 const AliTRDdataArray *kDictionary =
204 (AliTRDdataArray *) fDictionary[iDict]->At(0);
206 TRD->MakeBranchInTree(gAlice->TreeD(),
207 branchname,kDictionary->IsA()->GetName(),
208 &kDictionary,buffersize, 1,file);
209 printf("AliTRDdigitsManager::MakeBranch -- ");
210 printf("Making branch %s\n",branchname);
230 //_____________________________________________________________________________
231 Bool_t AliTRDdigitsManager::ReadDigits()
234 // Reads the digit information from the input file
237 Bool_t status = kTRUE;
239 status = fDigits->LoadArray("TRDdigits");
241 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
242 Char_t branchname[15];
243 sprintf(branchname,"TRDdictionary%d",iDict);
244 status = fDictionary[iDict]->LoadArray(branchname);
247 if (fDigits->TestBit(AliTRDdigit::RawDigit())) {
258 //_____________________________________________________________________________
259 Bool_t AliTRDdigitsManager::WriteDigits()
262 // Writes out the TRD-digits and the dictionaries
265 // Create the branches
266 if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) {
267 printf("AliTRDdigitsManager::WriteDigits -- ");
268 printf("Call MakeBranch\n");
269 if (!MakeBranch()) return kFALSE;
272 // Store the contents of the segment array in the tree
273 if (!fDigits->StoreArray("TRDdigits")) {
274 printf("AliTRDdigitsManager::WriteDigits -- ");
275 printf("Error while storing digits in branch TRDdigits\n");
278 for (Int_t iDict = 0; iDict < kNDict; iDict++) {
279 Char_t branchname[15];
280 sprintf(branchname,"TRDdictionary%d",iDict);
281 if (!fDictionary[iDict]->StoreArray(branchname)) {
282 printf("AliTRDdigitsManager::WriteDigits -- ");
283 printf("Error while storing dictionary in branch %s\n",branchname);
292 //_____________________________________________________________________________
293 AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col
294 , Int_t time, Int_t det) const
297 // Creates a single digit object
308 amp[0] = GetDigits(det)->GetData(row,col,time);
310 return (new AliTRDdigit(fIsRaw,digits,amp));
314 //_____________________________________________________________________________
315 Int_t AliTRDdigitsManager::GetTrack(Int_t track
316 , Int_t row, Int_t col, Int_t time
320 // Returns the MC-track numbers from the dictionary.
323 if ((track < 0) || (track >= kNDict)) {
324 TObject::Error("GetTracks"
325 ,"track %d out of bounds (size: %d, this: 0x%08x)"
330 // Array contains index+1 to allow data compression
331 return (GetDictionary(det,track)->GetData(row,col,time) - 1);
335 //_____________________________________________________________________________
336 AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const
339 // Returns the digits array for one detector
342 return (AliTRDdataArrayI *) fDigits->At(det);
346 //_____________________________________________________________________________
347 AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const
350 // Returns the dictionary for one detector
353 return (AliTRDdataArrayI *) fDictionary[i]->At(det);
357 //_____________________________________________________________________________
358 Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const
361 // Returns the MC-track numbers from the dictionary for a given digit
364 Int_t row = Digit->GetRow();
365 Int_t col = Digit->GetCol();
366 Int_t time = Digit->GetTime();
367 Int_t det = Digit->GetDetector();
369 return GetTrack(track,row,col,time,det);
373 //_____________________________________________________________________________
374 AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m)
377 // Assignment operator
380 if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this);