]>
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$ | |
94de3818 | 18 | Revision 1.4 2000/07/13 16:19:44 fca |
19 | Mainly coding conventions + some small bug fixes | |
20 | ||
ef42d733 | 21 | Revision 1.3 2000/07/03 11:54:57 morsch |
22 | AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER | |
23 | The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC. | |
24 | ||
a30a000f | 25 | Revision 1.2 2000/06/15 07:58:48 morsch |
26 | Code from MUON-dev joined | |
27 | ||
a9e2aefa | 28 | Revision 1.1.2.2 2000/06/12 07:58:06 morsch |
29 | include TMath.h | |
30 | ||
31 | Revision 1.1.2.1 2000/06/09 22:01:09 morsch | |
32 | Code from AliMUONHitMap.h | |
33 | Most coding rule violations corrected. | |
34 | ||
35 | */ | |
36 | ||
37 | #include "AliMUONHitMapA1.h" | |
a30a000f | 38 | #include "AliSegmentation.h" |
a9e2aefa | 39 | #include "AliMUONResponse.h" |
40 | #include "AliMUONDigit.h" | |
41 | ||
42 | #include <TObjArray.h> | |
43 | #include <TMath.h> | |
44 | ||
45 | ClassImp(AliMUONHitMapA1) | |
46 | ||
47 | ||
a30a000f | 48 | AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig) |
a9e2aefa | 49 | { |
50 | // Constructor | |
51 | fSegmentation = seg; | |
52 | fNpx = fSegmentation->Npx(); | |
53 | fNpy = fSegmentation->Npy(); | |
54 | fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy; | |
55 | ||
56 | fHitMap = new Int_t[fMaxIndex]; | |
57 | fDigits = dig; | |
58 | fNdigits = fDigits->GetEntriesFast(); | |
59 | Clear(); | |
60 | } | |
61 | ||
62 | AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap) | |
63 | { | |
64 | // Dummy copy constructor | |
65 | ; | |
66 | } | |
67 | ||
68 | ||
69 | AliMUONHitMapA1::~AliMUONHitMapA1() | |
70 | { | |
71 | // Destructor | |
72 | // if (fDigits) delete fDigits; | |
73 | if (fHitMap) delete[] fHitMap; | |
74 | } | |
75 | ||
ef42d733 | 76 | void AliMUONHitMapA1::Clear(const char *) |
a9e2aefa | 77 | { |
78 | // Clear hitmap | |
79 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
80 | } | |
81 | ||
94de3818 | 82 | Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const |
a9e2aefa | 83 | { |
84 | // Return checked indices ix, iy | |
85 | Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy); | |
86 | if (index > fMaxIndex) { | |
87 | printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy); | |
88 | return fMaxIndex-1; | |
89 | } else { | |
90 | return index; | |
91 | } | |
92 | } | |
93 | ||
94 | ||
95 | void AliMUONHitMapA1::FillHits() | |
96 | { | |
97 | // Fill hits from digits list | |
98 | Int_t ndigits = fDigits->GetEntriesFast(); | |
99 | //printf("\n Filling hits into HitMap\n"); | |
100 | //printf("FindRawClusters -- ndigits %d \n",ndigits); | |
101 | if (!ndigits) return; | |
102 | AliMUONDigit *dig; | |
103 | for (Int_t ndig=0; ndig<fNdigits; ndig++) { | |
104 | dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig); | |
105 | SetHit(dig->fPadX,dig->fPadY,ndig); | |
106 | } | |
107 | } | |
108 | ||
109 | ||
110 | void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
111 | { | |
112 | // Assign digit to hit cell ix,iy | |
113 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1; | |
114 | fHitMap[CheckedIndex(ix, iy)]=idigit+1; | |
115 | } | |
116 | ||
117 | void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
118 | { | |
119 | // Delete hit at cell ix,iy | |
120 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0; | |
121 | fHitMap[CheckedIndex(ix, iy)]=0; | |
122 | } | |
123 | ||
124 | void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
125 | { | |
126 | // Flag hit as used | |
127 | fHitMap[CheckedIndex(ix, iy)]= | |
128 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
129 | } | |
130 | ||
94de3818 | 131 | Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const |
a9e2aefa | 132 | { |
133 | // Get absolute value of contents of hit cell ix,iy | |
134 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
135 | } | |
136 | ||
94de3818 | 137 | TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const |
a9e2aefa | 138 | { |
139 | // Get pointer to object at hit cell ix, iy | |
140 | // Force crash if index does not exist ! (Manu) | |
141 | Int_t index=GetHitIndex(ix,iy); | |
142 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
143 | } | |
144 | ||
145 | FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy) | |
146 | { | |
147 | // Check if hit cell is empty, used or unused | |
148 | // | |
149 | Int_t inf=fHitMap[CheckedIndex(ix, iy)]; | |
150 | if (inf < 0) { | |
151 | return kUsed; | |
152 | } else if (inf == 0) { | |
153 | return kEmpty; | |
154 | } else { | |
155 | return kUnused; | |
156 | } | |
157 | } | |
158 | ||
159 | AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) | |
160 | { | |
161 | // Dummy assignment operator | |
162 | return *this; | |
163 | } | |
164 | ||
165 |