]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | $Log$ | |
d91b86b7 | 18 | Revision 1.10 2001/11/02 12:43:21 jchudoba |
19 | remove fNdigits data member, it could have wrong value if fDigits is updated. Make this class non-persistent | |
20 | ||
2186f543 | 21 | Revision 1.9 2001/03/20 13:34:05 egangler |
22 | Obvious small bug | |
23 | ||
654fdb44 | 24 | Revision 1.8 2001/01/26 21:47:21 morsch |
25 | Use access functions to AliMUONDigit member data. | |
26 | ||
1939e822 | 27 | Revision 1.7 2001/01/25 11:43:48 morsch |
28 | Add a "real" default constructor. | |
29 | ||
0a5f9c41 | 30 | Revision 1.6 2000/10/06 09:05:42 morsch |
31 | Correction on upper limits for x- and y- coordinates to make code work with slat chambers. | |
32 | ||
bad7e393 | 33 | Revision 1.5 2000/10/02 21:28:09 fca |
34 | Removal of useless dependecies via forward declarations | |
35 | ||
94de3818 | 36 | Revision 1.4 2000/07/13 16:19:44 fca |
37 | Mainly coding conventions + some small bug fixes | |
38 | ||
ef42d733 | 39 | Revision 1.3 2000/07/03 11:54:57 morsch |
40 | AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER | |
41 | The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC. | |
42 | ||
a30a000f | 43 | Revision 1.2 2000/06/15 07:58:48 morsch |
44 | Code from MUON-dev joined | |
45 | ||
a9e2aefa | 46 | Revision 1.1.2.2 2000/06/12 07:58:06 morsch |
47 | include TMath.h | |
48 | ||
49 | Revision 1.1.2.1 2000/06/09 22:01:09 morsch | |
50 | Code from AliMUONHitMap.h | |
51 | Most coding rule violations corrected. | |
52 | ||
53 | */ | |
54 | ||
55 | #include "AliMUONHitMapA1.h" | |
a30a000f | 56 | #include "AliSegmentation.h" |
a9e2aefa | 57 | #include "AliMUONResponse.h" |
58 | #include "AliMUONDigit.h" | |
59 | ||
60 | #include <TObjArray.h> | |
61 | #include <TMath.h> | |
62 | ||
63 | ClassImp(AliMUONHitMapA1) | |
64 | ||
0a5f9c41 | 65 | AliMUONHitMapA1::AliMUONHitMapA1() |
66 | { | |
67 | // Default constructor | |
0a5f9c41 | 68 | fNpx = 0; |
69 | fNpy = 0; | |
70 | fMaxIndex = 0; | |
71 | ||
72 | fHitMap = 0; | |
73 | fDigits = 0; | |
0a5f9c41 | 74 | } |
a9e2aefa | 75 | |
a30a000f | 76 | AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig) |
a9e2aefa | 77 | { |
78 | // Constructor | |
2186f543 | 79 | fNpx = seg->Npx()+1; |
80 | fNpy = seg->Npy()+1; | |
a9e2aefa | 81 | fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy; |
82 | ||
83 | fHitMap = new Int_t[fMaxIndex]; | |
84 | fDigits = dig; | |
a9e2aefa | 85 | Clear(); |
86 | } | |
87 | ||
88 | AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap) | |
89 | { | |
90 | // Dummy copy constructor | |
91 | ; | |
92 | } | |
93 | ||
94 | ||
95 | AliMUONHitMapA1::~AliMUONHitMapA1() | |
96 | { | |
97 | // Destructor | |
a9e2aefa | 98 | if (fHitMap) delete[] fHitMap; |
99 | } | |
100 | ||
ef42d733 | 101 | void AliMUONHitMapA1::Clear(const char *) |
a9e2aefa | 102 | { |
103 | // Clear hitmap | |
104 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
105 | } | |
106 | ||
d91b86b7 | 107 | Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy) |
108 | { | |
109 | // | |
110 | // Check if pad coordinates are within boundaries | |
111 | // | |
112 | // printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy); | |
113 | ||
114 | return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy); | |
115 | } | |
116 | ||
94de3818 | 117 | Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const |
a9e2aefa | 118 | { |
119 | // Return checked indices ix, iy | |
120 | Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy); | |
654fdb44 | 121 | if (index >= fMaxIndex) { |
bad7e393 | 122 | printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d", |
123 | ix,iy, fMaxIndex, index, fNpx, fNpy); | |
a9e2aefa | 124 | return fMaxIndex-1; |
125 | } else { | |
126 | return index; | |
127 | } | |
128 | } | |
129 | ||
130 | ||
131 | void AliMUONHitMapA1::FillHits() | |
132 | { | |
133 | // Fill hits from digits list | |
134 | Int_t ndigits = fDigits->GetEntriesFast(); | |
135 | //printf("\n Filling hits into HitMap\n"); | |
136 | //printf("FindRawClusters -- ndigits %d \n",ndigits); | |
137 | if (!ndigits) return; | |
138 | AliMUONDigit *dig; | |
2186f543 | 139 | for (Int_t ndig=0; ndig<ndigits; ndig++) { |
a9e2aefa | 140 | dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig); |
1939e822 | 141 | SetHit(dig->PadX(),dig->PadY(),ndig); |
a9e2aefa | 142 | } |
143 | } | |
144 | ||
145 | ||
146 | void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
147 | { | |
148 | // Assign digit to hit cell ix,iy | |
149 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1; | |
150 | fHitMap[CheckedIndex(ix, iy)]=idigit+1; | |
151 | } | |
152 | ||
153 | void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
154 | { | |
155 | // Delete hit at cell ix,iy | |
156 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0; | |
157 | fHitMap[CheckedIndex(ix, iy)]=0; | |
158 | } | |
159 | ||
160 | void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
161 | { | |
162 | // Flag hit as used | |
163 | fHitMap[CheckedIndex(ix, iy)]= | |
164 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
165 | } | |
166 | ||
94de3818 | 167 | Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const |
a9e2aefa | 168 | { |
169 | // Get absolute value of contents of hit cell ix,iy | |
170 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
171 | } | |
172 | ||
94de3818 | 173 | TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const |
a9e2aefa | 174 | { |
175 | // Get pointer to object at hit cell ix, iy | |
176 | // Force crash if index does not exist ! (Manu) | |
177 | Int_t index=GetHitIndex(ix,iy); | |
178 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
179 | } | |
180 | ||
181 | FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy) | |
182 | { | |
183 | // Check if hit cell is empty, used or unused | |
184 | // | |
185 | Int_t inf=fHitMap[CheckedIndex(ix, iy)]; | |
186 | if (inf < 0) { | |
187 | return kUsed; | |
188 | } else if (inf == 0) { | |
189 | return kEmpty; | |
190 | } else { | |
191 | return kUnused; | |
192 | } | |
193 | } | |
194 | ||
195 | AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) | |
196 | { | |
197 | // Dummy assignment operator | |
198 | return *this; | |
199 | } | |
200 | ||
201 | ||
bad7e393 | 202 | |
203 | ||
204 |