]>
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 | ||
88cb7938 | 16 | /* $Id$ */ |
a9e2aefa | 17 | |
30178c30 | 18 | #include <TObjArray.h> |
19 | #include <TMath.h> | |
20 | ||
a9e2aefa | 21 | #include "AliMUONHitMapA1.h" |
a30a000f | 22 | #include "AliSegmentation.h" |
a9e2aefa | 23 | #include "AliMUONDigit.h" |
24 | ||
a9e2aefa | 25 | ClassImp(AliMUONHitMapA1) |
26 | ||
30178c30 | 27 | AliMUONHitMapA1::AliMUONHitMapA1() |
28 | : AliHitMap() | |
0a5f9c41 | 29 | { |
30 | // Default constructor | |
0a5f9c41 | 31 | fNpx = 0; |
32 | fNpy = 0; | |
33 | fMaxIndex = 0; | |
34 | ||
35 | fHitMap = 0; | |
36 | fDigits = 0; | |
0a5f9c41 | 37 | } |
a9e2aefa | 38 | |
a30a000f | 39 | AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig) |
30178c30 | 40 | : AliHitMap() |
a9e2aefa | 41 | { |
42 | // Constructor | |
2186f543 | 43 | fNpx = seg->Npx()+1; |
44 | fNpy = seg->Npy()+1; | |
a9e2aefa | 45 | fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy; |
46 | ||
47 | fHitMap = new Int_t[fMaxIndex]; | |
48 | fDigits = dig; | |
a9e2aefa | 49 | Clear(); |
50 | } | |
51 | ||
30178c30 | 52 | AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap) |
53 | : AliHitMap(hitMap) | |
a9e2aefa | 54 | { |
30178c30 | 55 | // Protected copy constructor |
56 | ||
57 | Fatal("AliMUONHitMapA1", "Not implemented."); | |
a9e2aefa | 58 | } |
59 | ||
60 | ||
61 | AliMUONHitMapA1::~AliMUONHitMapA1() | |
62 | { | |
63 | // Destructor | |
a9e2aefa | 64 | if (fHitMap) delete[] fHitMap; |
65 | } | |
66 | ||
ef42d733 | 67 | void AliMUONHitMapA1::Clear(const char *) |
a9e2aefa | 68 | { |
69 | // Clear hitmap | |
70 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
71 | } | |
72 | ||
d91b86b7 | 73 | Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy) |
74 | { | |
75 | // | |
76 | // Check if pad coordinates are within boundaries | |
77 | // | |
78 | // printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy); | |
79 | ||
80 | return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy); | |
81 | } | |
82 | ||
94de3818 | 83 | Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const |
a9e2aefa | 84 | { |
85 | // Return checked indices ix, iy | |
86 | Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy); | |
654fdb44 | 87 | if (index >= fMaxIndex) { |
bad7e393 | 88 | printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d", |
89 | ix,iy, fMaxIndex, index, fNpx, fNpy); | |
a9e2aefa | 90 | return fMaxIndex-1; |
91 | } else { | |
92 | return index; | |
93 | } | |
94 | } | |
95 | ||
96 | ||
97 | void AliMUONHitMapA1::FillHits() | |
98 | { | |
99 | // Fill hits from digits list | |
100 | Int_t ndigits = fDigits->GetEntriesFast(); | |
101 | //printf("\n Filling hits into HitMap\n"); | |
102 | //printf("FindRawClusters -- ndigits %d \n",ndigits); | |
103 | if (!ndigits) return; | |
104 | AliMUONDigit *dig; | |
2186f543 | 105 | for (Int_t ndig=0; ndig<ndigits; ndig++) { |
a9e2aefa | 106 | dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig); |
1939e822 | 107 | SetHit(dig->PadX(),dig->PadY(),ndig); |
a9e2aefa | 108 | } |
109 | } | |
110 | ||
111 | ||
112 | void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
113 | { | |
114 | // Assign digit to hit cell ix,iy | |
115 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1; | |
116 | fHitMap[CheckedIndex(ix, iy)]=idigit+1; | |
117 | } | |
118 | ||
119 | void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
120 | { | |
121 | // Delete hit at cell ix,iy | |
122 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0; | |
123 | fHitMap[CheckedIndex(ix, iy)]=0; | |
124 | } | |
125 | ||
126 | void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
127 | { | |
128 | // Flag hit as used | |
129 | fHitMap[CheckedIndex(ix, iy)]= | |
130 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
131 | } | |
132 | ||
94de3818 | 133 | Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const |
a9e2aefa | 134 | { |
135 | // Get absolute value of contents of hit cell ix,iy | |
136 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
137 | } | |
138 | ||
94de3818 | 139 | TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const |
a9e2aefa | 140 | { |
141 | // Get pointer to object at hit cell ix, iy | |
142 | // Force crash if index does not exist ! (Manu) | |
143 | Int_t index=GetHitIndex(ix,iy); | |
144 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
145 | } | |
146 | ||
147 | FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy) | |
148 | { | |
149 | // Check if hit cell is empty, used or unused | |
150 | // | |
151 | Int_t inf=fHitMap[CheckedIndex(ix, iy)]; | |
152 | if (inf < 0) { | |
153 | return kUsed; | |
154 | } else if (inf == 0) { | |
155 | return kEmpty; | |
156 | } else { | |
157 | return kUnused; | |
158 | } | |
159 | } | |
160 | ||
30178c30 | 161 | AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) |
a9e2aefa | 162 | { |
30178c30 | 163 | // Protected assignement operator |
164 | ||
165 | if (this == &rhs) return *this; | |
166 | ||
167 | Fatal("operator=", "Not implemented."); | |
168 | ||
169 | return *this; | |
a9e2aefa | 170 | } |
171 | ||
172 | ||
bad7e393 | 173 | |
174 | ||
175 |