]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFDigitMap.cxx
TOF raw data format: updated version
[u/mrichter/AliRoot.git] / TOF / AliTOFDigitMap.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16
17 ////////////////////////////////////////////////////////////////////////
18 //
19 // AliTOFDigitMap class
20 //
21 // digitmap enables fast check if the pad was already digit.
22
23 // The index of a AliTOFdigit is saved in the each digitmap "cell"
24 // (there is an offset +1, because the index can be zero and zero
25 // means empty cell).
26 // In TOF, number of strips varies according plate type, the highest
27 // number is in plate C. For all plates is used this number, so the
28 // size of the digitmap is a little bit greater than necessary, but it
29 // simplifies the access algorithm.
30 // 
31 //
32 // Author: F. Pierella based on AliTOFHitMap
33 //
34 // Modified by A. De Caro
35 //
36 ///////////////////////////////////////////////////////////////////////
37
38 #include "AliLog.h"
39
40 #include "AliTOFDigitMap.h"
41 #include "AliTOFGeometry.h"
42
43 ClassImp(AliTOFDigitMap)
44
45 AliTOFDigitMap::AliTOFDigitMap()
46 {
47 //
48 // Default ctor
49 //
50   fDigitMap = 0;
51
52   fTOFGeometry = new AliTOFGeometry();
53
54   fNSector = AliTOFGeometry::NSectors();
55   fNplate = AliTOFGeometry::NPlates();
56   fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip();
57   fNpx  = AliTOFGeometry::NpadX();
58   fNpz  = AliTOFGeometry::NpadZ();
59   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
60
61   fDigitMap = new Int_t*[fMaxIndex];
62   for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
63   Clear();
64 }
65
66 ////////////////////////////////////////////////////////////////////////
67 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/)
68 :TObject()
69 {
70 //
71 // Dummy copy constructor
72 //
73   ;
74
75 }
76
77  
78 ////////////////////////////////////////////////////////////////////////
79 AliTOFDigitMap::~AliTOFDigitMap()
80 {
81 //
82 // Destructor
83 //
84   if (fDigitMap) {
85     for (Int_t i=0; i<fMaxIndex; i++)  delete[] fDigitMap[i];
86   }
87
88   fTOFGeometry = 0;
89
90 }
91
92 ////////////////////////////////////////////////////////////////////////
93 void AliTOFDigitMap::Clear(const Option_t*)
94 {
95   //
96   // Clear digitmap
97   //
98
99   for(Int_t ii=0; ii<fMaxIndex; ii++) {
100     for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
101       fDigitMap[ii][jj] = 0;
102     }
103   }
104  
105 }
106
107 ////////////////////////////////////////////////////////////////////////
108 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
109 {
110   //
111   // Return checked index for vol
112   //
113
114   Int_t index =
115     vol[0]*fNplate*fNstrip*fNpx*fNpz+             // sector
116     vol[1]*fNstrip*fNpx*fNpz+                     // plate
117     vol[2]*fNpx*fNpz+                             // strip
118     vol[3]*fNpz+                                  // padx
119     vol[4];                                       // padz
120
121     if (index >= fMaxIndex || index < 0) {
122       AliError("CheckedIndex - input outside bounds");
123       return -1;
124     } else {
125       return index;
126     }
127 }
128
129 ////////////////////////////////////////////////////////////////////////
130 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
131 {
132   //
133   // Assign digit to pad vol
134   //
135   // 0 means empty pad, we need to shift indeces by 1
136
137   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
138
139     if (fDigitMap[CheckedIndex(vol)][slot]==0) {
140       fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
141       break;
142     }
143     //else continue;
144
145   }
146 }
147
148 ////////////////////////////////////////////////////////////////////////
149 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
150 {
151   //
152   // Get all contents (digitLabels) of pad volume (vol)
153   //
154
155   // 0 means empty pad, we need to shift indeces by 1
156
157   Int_t dummy;
158     for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
159       dummy = GetDigitIndex(vol,j);
160       if (dummy>=0) digitLabels[j] = dummy;
161       else break;
162     }
163 }
164
165 ////////////////////////////////////////////////////////////////////////
166 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
167 {
168   //
169   // Get one of the contents (label) of pad volume (vol)
170   //
171
172   // 0 means empty pad, we need to shift indeces by 1
173
174   if (!(label<kMaxDigitsPerPad)) {
175     AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
176     return -1;
177   }
178
179   if (CheckedIndex(vol)==-1) return -1;
180   
181   Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
182   
183   if (dummy>0) return dummy-1;
184   else return -1;
185
186 }
187
188 ////////////////////////////////////////////////////////////////////////
189 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
190 {
191 //
192 // Check if hit cell is empty, used or unused
193 //
194   Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
195     if (inf > 0) {
196         return kUsed;
197     } else if (inf == 0) {
198         return kEmpty;
199     } else {
200         return kUnused;
201     }
202 }
203
204 ////////////////////////////////////////////////////////////////////////
205 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) 
206 {
207 // Dummy assignment operator
208     return *this;
209 }