]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFDigitMap.cxx
removal of effective c++ warnings (C.Zampolli)
[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   fNSector(-1),
47   fNplate(-1),
48   fNstrip(-1),
49   fNpx(-1),
50   fNpz(-1),
51   fMaxIndex(-1),
52   fDigitMap(0x0),
53   fTOFGeometry(new AliTOFGeometry())
54 {
55 //
56 // Default ctor
57 //
58
59   fNSector = AliTOFGeometry::NSectors();
60   fNplate = AliTOFGeometry::NPlates();
61   fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip();
62   fNpx  = AliTOFGeometry::NpadX();
63   fNpz  = AliTOFGeometry::NpadZ();
64   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
65
66   fDigitMap = new Int_t*[fMaxIndex];
67   for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
68   Clear();
69 }
70
71 ////////////////////////////////////////////////////////////////////////
72 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/):
73   TObject(),
74   fNSector(-1),
75   fNplate(-1),
76   fNstrip(-1),
77   fNpx(-1),
78   fNpz(-1),
79   fMaxIndex(-1),
80   fDigitMap(0x0),
81   fTOFGeometry(new AliTOFGeometry())
82 {
83 //
84 // Dummy copy constructor
85 //
86   ;
87
88 }
89
90  
91 ////////////////////////////////////////////////////////////////////////
92 AliTOFDigitMap::~AliTOFDigitMap()
93 {
94 //
95 // Destructor
96 //
97   if (fDigitMap) {
98     for (Int_t i=0; i<fMaxIndex; i++)  delete[] fDigitMap[i];
99   }
100
101   fTOFGeometry = 0;
102
103 }
104
105 ////////////////////////////////////////////////////////////////////////
106 void AliTOFDigitMap::Clear(const Option_t*)
107 {
108   //
109   // Clear digitmap
110   //
111
112   for(Int_t ii=0; ii<fMaxIndex; ii++) {
113     for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
114       fDigitMap[ii][jj] = 0;
115     }
116   }
117  
118 }
119
120 ////////////////////////////////////////////////////////////////////////
121 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
122 {
123   //
124   // Return checked index for vol
125   //
126
127   Int_t index =
128     vol[0]*fNplate*fNstrip*fNpx*fNpz+             // sector
129     vol[1]*fNstrip*fNpx*fNpz+                     // plate
130     vol[2]*fNpx*fNpz+                             // strip
131     vol[3]*fNpz+                                  // padx
132     vol[4];                                       // padz
133
134     if (index >= fMaxIndex || index < 0) {
135       AliError("CheckedIndex - input outside bounds");
136       return -1;
137     } else {
138       return index;
139     }
140 }
141
142 ////////////////////////////////////////////////////////////////////////
143 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
144 {
145   //
146   // Assign digit to pad vol
147   //
148   // 0 means empty pad, we need to shift indeces by 1
149
150   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
151
152     if (fDigitMap[CheckedIndex(vol)][slot]==0) {
153       fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
154       break;
155     }
156     //else continue;
157
158   }
159 }
160
161 ////////////////////////////////////////////////////////////////////////
162 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
163 {
164   //
165   // Get all contents (digitLabels) of pad volume (vol)
166   //
167
168   // 0 means empty pad, we need to shift indeces by 1
169
170   Int_t dummy;
171     for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
172       dummy = GetDigitIndex(vol,j);
173       if (dummy>=0) digitLabels[j] = dummy;
174       else break;
175     }
176 }
177
178 ////////////////////////////////////////////////////////////////////////
179 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
180 {
181   //
182   // Get one of the contents (label) of pad volume (vol)
183   //
184
185   // 0 means empty pad, we need to shift indeces by 1
186
187   if (!(label<kMaxDigitsPerPad)) {
188     AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
189     return -1;
190   }
191
192   if (CheckedIndex(vol)==-1) return -1;
193   
194   Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
195   
196   if (dummy>0) return dummy-1;
197   else return -1;
198
199 }
200
201 ////////////////////////////////////////////////////////////////////////
202 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
203 {
204 //
205 // Check if hit cell is empty, used or unused
206 //
207   Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
208     if (inf > 0) {
209         return kUsed;
210     } else if (inf == 0) {
211         return kEmpty;
212     } else {
213         return kUnused;
214     }
215 }
216
217 ////////////////////////////////////////////////////////////////////////
218 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) 
219 {
220 // Dummy assignment operator
221     return *this;
222 }