]>
Commit | Line | Data |
---|---|---|
fe4da5cc | 1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // // | |
3 | // This class contains the points for the ALICE event display // | |
4 | // // | |
5 | //Begin_Html | |
6 | /* | |
1439f98e | 7 | <img src="picts/AliMUONpointsClass.gif"> |
fe4da5cc | 8 | */ |
9 | //End_Html | |
10 | // // | |
11 | // // | |
12 | /////////////////////////////////////////////////////////////////////////////// | |
13 | #include "AliMUONdisplay.h" | |
14 | #include "AliMUONpoints.h" | |
15 | #include "AliRun.h" | |
16 | #include "TPad.h" | |
17 | #include "TView.h" | |
18 | #include "TMath.h" | |
19 | ||
20 | const Int_t MAX_Nipx=400, MAX_Nipy=800; | |
21 | ||
22 | ClassImp(AliMUONpoints) | |
23 | ||
24 | //_____________________________________________________________________________ | |
25 | AliMUONpoints::AliMUONpoints() | |
26 | { | |
27 | // | |
28 | // Default constructor | |
29 | // | |
30 | fHitIndex = 0; | |
31 | fTrackIndex = 0; | |
32 | fDigitIndex = 0; | |
33 | } | |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliMUONpoints::AliMUONpoints(Int_t npoints) | |
37 | :AliPoints(npoints) | |
38 | { | |
39 | // | |
40 | // Standard constructor | |
41 | // | |
42 | fHitIndex = 0; | |
43 | fTrackIndex = 0; | |
44 | fDigitIndex = 0; | |
45 | } | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMUONpoints::~AliMUONpoints() | |
49 | { | |
50 | // | |
51 | // Default destructor | |
52 | // | |
53 | fHitIndex = 0; | |
54 | fTrackIndex = 0; | |
55 | fDigitIndex = 0; | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | void AliMUONpoints::DumpHit() | |
60 | { | |
61 | // | |
62 | // Dump hit corresponding to this point | |
63 | // | |
64 | AliMUONhit *hit = GetHit(); | |
65 | if (hit) hit->Dump(); | |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | void AliMUONpoints::DumpDigit() | |
70 | { | |
71 | // | |
72 | // Dump digit corresponding to this point | |
73 | // | |
74 | AliMUONdigit *digit = GetDigit(); | |
75 | if (digit) digit->Dump(); | |
76 | } | |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | void AliMUONpoints::InspectHit() | |
80 | { | |
81 | // | |
82 | // Inspect hit corresponding to this point | |
83 | // | |
84 | AliMUONhit *hit = GetHit(); | |
85 | if (hit) hit->Inspect(); | |
86 | } | |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | void AliMUONpoints::InspectDigit() | |
90 | { | |
91 | // | |
92 | // Inspect digit corresponding to this point | |
93 | // | |
94 | AliMUONdigit *digit = GetDigit(); | |
95 | if (digit) digit->Inspect(); | |
96 | } | |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | Int_t AliMUONpoints::GetTrackIndex() | |
100 | { | |
101 | // | |
102 | // Dump digit corresponding to this point | |
103 | // | |
104 | printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex); | |
105 | this->Inspect(); | |
106 | return fTrackIndex; | |
107 | } | |
108 | ||
109 | //_____________________________________________________________________________ | |
110 | AliMUONhit *AliMUONpoints::GetHit() const | |
111 | { | |
112 | // | |
113 | // Returns pointer to hit index in AliRun::fParticles | |
114 | // | |
0f439796 | 115 | AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON"); |
fe4da5cc | 116 | gAlice->TreeH()->GetEvent(fTrackIndex); |
117 | TClonesArray *MUONhits = MUON->Hits(); | |
118 | Int_t nhits = MUONhits->GetEntriesFast(); | |
119 | if (fHitIndex < 0 || fHitIndex >= nhits) return 0; | |
120 | return (AliMUONhit*)MUONhits->UncheckedAt(fHitIndex); | |
121 | } | |
122 | ||
123 | //_____________________________________________________________________________ | |
124 | AliMUONdigit *AliMUONpoints::GetDigit() const | |
125 | { | |
126 | // | |
127 | // Returns pointer to digit index in AliRun::fParticles | |
128 | // | |
129 | ||
130 | AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display(); | |
131 | Int_t chamber=display->GetChamber(); | |
132 | Int_t cathode=display->GetCathode(); | |
133 | ||
0f439796 | 134 | AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON"); |
fe4da5cc | 135 | TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1); |
136 | gAlice->TreeD()->GetEvent(cathode); | |
137 | Int_t ndigits = MUONdigits->GetEntriesFast(); | |
138 | if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0; | |
139 | return (AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex); | |
140 | } | |
141 | //_____________________________________________________________________________ | |
142 | struct Bin { | |
143 | const AliMUONdigit *dig; | |
144 | int idx; | |
145 | Bin() {dig=0; idx=-1;} | |
146 | }; | |
147 | ||
148 | struct PreCluster : public AliMUONreccluster { | |
149 | const AliMUONdigit* summit; | |
150 | int idx; | |
151 | int cut; | |
152 | int npeaks; | |
153 | PreCluster() : AliMUONreccluster() {cut=npeaks=0;} | |
154 | }; | |
155 | //_____________________________________________________________________________ | |
156 | ||
157 | static void FindCluster(AliMUONchamber *iChamber, AliMUONsegmentation *segmentation, int i, int j, Bin bins[MAX_Nipx][MAX_Nipy], PreCluster &c) | |
158 | ||
159 | { | |
160 | ||
161 | // | |
162 | // Find clusters | |
163 | // | |
164 | ||
165 | printf("I'm in FindCluster \n"); | |
166 | ||
167 | Bin& b=bins[i][j]; | |
168 | Int_t q=b.dig->fSignal; | |
169 | ||
170 | printf("FindCluster - i j q %d %d %d\n",i,j,q); | |
171 | ||
172 | if (q<0) { | |
173 | q=-q; | |
174 | c.cut=1; | |
175 | } | |
176 | if (b.idx >= 0 && b.idx != c.idx) { | |
177 | c.idx=b.idx; | |
178 | c.npeaks++; | |
179 | } | |
180 | ||
181 | if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig; | |
182 | ||
183 | Int_t npx = segmentation->Npx(); | |
184 | Int_t npy = segmentation->Npy(); | |
185 | Float_t x,y; | |
186 | segmentation->GetPadCxy(i-npx, j-npy, x,y); | |
187 | printf("FindCluster - x y %f %f \n",x,y); | |
188 | ||
189 | ||
190 | c.fX += q*x; | |
191 | c.fY += q*y; | |
192 | c.fQ += q; | |
193 | ||
194 | b.dig = 0; b.idx = c.idx; | |
195 | ||
196 | if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c); | |
197 | if (bins[i][j-1].dig) FindCluster(iChamber,segmentation,i,j-1,bins,c); | |
198 | if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c); | |
199 | if (bins[i][j+1].dig) FindCluster(iChamber,segmentation,i,j+1,bins,c); | |
200 | ||
201 | } | |
202 | ||
203 | //_____________________________________________________________________________ | |
204 | ||
205 | void AliMUONpoints::GetCenterOfGravity() | |
206 | { | |
207 | // | |
208 | // simple MUON cluster finder from digits -- finds neighbours and | |
209 | // calculates center of gravity for the cluster | |
210 | // | |
211 | const Int_t MAX_Nipx=400, MAX_Nipy=800; | |
212 | printf("\n Hallo world"); | |
213 | AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display(); | |
214 | Int_t chamber=display->GetChamber(); | |
215 | Int_t cathode=display->GetCathode(); | |
216 | ||
0f439796 | 217 | AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON"); |
fe4da5cc | 218 | AliMUONchamber *iChamber; |
219 | AliMUONsegmentation *segmentation; | |
220 | iChamber =&(MUON->Chamber(chamber-1)); | |
221 | segmentation=iChamber->GetSegmentationModel(cathode); | |
222 | Int_t npx = segmentation->Npx(); | |
223 | Int_t npy = segmentation->Npy(); | |
224 | Float_t zpos=iChamber->ZPosition(); | |
225 | ||
226 | TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1); | |
227 | gAlice->TreeD()->GetEvent(cathode); | |
228 | Int_t ndigits = MUONdigits->GetEntriesFast(); | |
229 | if (fDigitIndex < 0 || fDigitIndex >= ndigits) return; | |
230 | ||
231 | AliMUONdigit *dig; | |
232 | dig=(AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex); | |
233 | Int_t ipx=dig->fPadX; | |
234 | Int_t ipy=dig->fPadY; | |
235 | Bin bins[MAX_Nipx][MAX_Nipy]; | |
236 | bins[ipx+npx][ipy+npy].dig=dig; | |
237 | ||
238 | int ndig; | |
239 | int ncls=0; | |
240 | for (ndig=0; ndig<ndigits; ndig++) { | |
241 | dig = (AliMUONdigit*)MUONdigits->UncheckedAt(ndig); | |
242 | int i=dig->fPadX, j=dig->fPadY; | |
243 | bins[i+npx][j+npy].dig=dig; | |
244 | } | |
245 | ||
246 | PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls; | |
247 | FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c); | |
248 | if (c.npeaks>1) { | |
249 | printf("GetCenterOfGravity -- more than one peak"); | |
250 | } | |
251 | c.fX /= c.fQ; | |
252 | c.fY /= c.fQ; | |
253 | printf("GetCenterOfGravity - c.fX c.fY c.fQ %f %f %d \n",c.fX,c.fY,c.fQ); | |
254 | ||
255 | c.fTracks[0]=c.summit->fTracks[0]; | |
256 | c.fTracks[1]=c.summit->fTracks[1]; | |
257 | c.fTracks[2]=c.summit->fTracks[2]; | |
258 | ncls++; | |
259 | AliMUONpoints *points = 0; | |
260 | points = new AliMUONpoints(1); | |
261 | points->SetMarkerColor(kYellow); | |
262 | points->SetMarkerStyle(5); | |
263 | points->SetMarkerSize(1.); | |
264 | points->SetPoint(0,c.fX,c.fY,zpos); | |
265 | points->Draw(); | |
266 | ||
267 | printf("GetCenterOfGravity -- ncls %d \n",ncls); | |
268 | ||
269 | } | |
270 | ||
271 | ||
272 |