]>
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 | **************************************************************************/ | |
70479d0e | 15 | |
88cb7938 | 16 | /* $Id$ */ |
a9e2aefa | 17 | |
18 | #include "AliMUONClusterFinderVS.h" | |
19 | #include "AliMUONDigit.h" | |
20 | #include "AliMUONRawCluster.h" | |
a30a000f | 21 | #include "AliSegmentation.h" |
a9e2aefa | 22 | #include "AliMUONResponse.h" |
c1a185bf | 23 | #include "AliMUONClusterInput.h" |
a9e2aefa | 24 | #include "AliMUONHitMapA1.h" |
25 | #include "AliRun.h" | |
26 | #include "AliMUON.h" | |
27 | ||
28 | #include <TTree.h> | |
29 | #include <TCanvas.h> | |
30 | #include <TH1.h> | |
31 | #include <TPad.h> | |
32 | #include <TGraph.h> | |
33 | #include <TPostScript.h> | |
34 | #include <TMinuit.h> | |
ecfa008b | 35 | #include <TF1.h> |
36 | ||
a9e2aefa | 37 | #include <stdio.h> |
70479d0e | 38 | #include <Riostream.h> |
a9e2aefa | 39 | |
40 | //_____________________________________________________________________ | |
a9e2aefa | 41 | // This function is minimized in the double-Mathieson fit |
42 | void fcnS2(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); | |
43 | void fcnS1(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); | |
44 | void fcnCombiS1(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); | |
45 | void fcnCombiS2(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); | |
46 | ||
47 | ClassImp(AliMUONClusterFinderVS) | |
48 | ||
a9e2aefa | 49 | AliMUONClusterFinderVS::AliMUONClusterFinderVS() |
a9e2aefa | 50 | { |
51 | // Default constructor | |
30aaba74 | 52 | fInput=AliMUONClusterInput::Instance(); |
53 | fHitMap[0] = 0; | |
54 | fHitMap[1] = 0; | |
a9e2aefa | 55 | fTrack[0]=fTrack[1]=-1; |
07cfabcf | 56 | fDebugLevel = 0; // make silent default |
57 | fGhostChi2Cut = 1e6; // nothing done by default | |
3f5cf0b3 | 58 | fSeg[0] = 0; |
59 | fSeg[1] = 0; | |
60 | for(Int_t i=0; i<100; i++) { | |
61 | for (Int_t j=0; j<2; j++) { | |
62 | fDig[i][j] = 0; | |
63 | } | |
64 | } | |
a9e2aefa | 65 | } |
66 | ||
e3cba86e | 67 | AliMUONClusterFinderVS::AliMUONClusterFinderVS(const AliMUONClusterFinderVS & clusterFinder):TObject(clusterFinder) |
a9e2aefa | 68 | { |
69 | // Dummy copy Constructor | |
70 | ; | |
71 | } | |
72 | ||
a9e2aefa | 73 | void AliMUONClusterFinderVS::Decluster(AliMUONRawCluster *cluster) |
74 | { | |
75 | // Decluster by local maxima | |
76 | SplitByLocalMaxima(cluster); | |
77 | } | |
78 | ||
79 | void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c) | |
80 | { | |
81 | // Split complex cluster by local maxima | |
a9e2aefa | 82 | Int_t cath, i; |
9825400f | 83 | |
30aaba74 | 84 | fInput->SetCluster(c); |
9825400f | 85 | |
a9e2aefa | 86 | fMul[0]=c->fMultiplicity[0]; |
87 | fMul[1]=c->fMultiplicity[1]; | |
88 | ||
89 | // | |
90 | // dump digit information into arrays | |
91 | // | |
9825400f | 92 | |
f0d86bc4 | 93 | Float_t qtot; |
a9e2aefa | 94 | |
95 | for (cath=0; cath<2; cath++) { | |
96 | qtot=0; | |
97 | for (i=0; i<fMul[cath]; i++) | |
98 | { | |
99 | // pointer to digit | |
30aaba74 | 100 | fDig[i][cath]=fInput->Digit(cath, c->fIndexMap[i][cath]); |
a9e2aefa | 101 | // pad coordinates |
08a636a8 | 102 | fIx[i][cath]= fDig[i][cath]->PadX(); |
103 | fIy[i][cath]= fDig[i][cath]->PadY(); | |
a9e2aefa | 104 | // pad charge |
08a636a8 | 105 | fQ[i][cath] = fDig[i][cath]->Signal(); |
a9e2aefa | 106 | // pad centre coordinates |
f0d86bc4 | 107 | fSeg[cath]-> |
108 | GetPadC(fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]); | |
a9e2aefa | 109 | } // loop over cluster digits |
a9e2aefa | 110 | } // loop over cathodes |
111 | ||
112 | ||
113 | FindLocalMaxima(c); | |
114 | ||
115 | // | |
116 | // Initialise and perform mathieson fits | |
117 | Float_t chi2, oldchi2; | |
118 | // ++++++++++++++++++*************+++++++++++++++++++++ | |
119 | // (1) No more than one local maximum per cathode plane | |
120 | // +++++++++++++++++++++++++++++++*************++++++++ | |
121 | if ((fNLocal[0]==1 && (fNLocal[1]==0 || fNLocal[1]==1)) || | |
122 | (fNLocal[0]==0 && fNLocal[1]==1)) { | |
a9e2aefa | 123 | // Perform combined single Mathieson fit |
124 | // Initial values for coordinates (x,y) | |
125 | ||
126 | // One local maximum on cathodes 1 and 2 (X->cathode 2, Y->cathode 1) | |
127 | if (fNLocal[0]==1 && fNLocal[1]==1) { | |
128 | fXInit[0]=c->fX[1]; | |
129 | fYInit[0]=c->fY[0]; | |
130 | // One local maximum on cathode 1 (X,Y->cathode 1) | |
131 | } else if (fNLocal[0]==1) { | |
132 | fXInit[0]=c->fX[0]; | |
133 | fYInit[0]=c->fY[0]; | |
134 | // One local maximum on cathode 2 (X,Y->cathode 2) | |
135 | } else { | |
136 | fXInit[0]=c->fX[1]; | |
137 | fYInit[0]=c->fY[1]; | |
138 | } | |
07cfabcf | 139 | if (fDebugLevel) |
140 | fprintf(stderr,"\n cas (1) CombiSingleMathiesonFit(c)\n"); | |
a9e2aefa | 141 | chi2=CombiSingleMathiesonFit(c); |
142 | // Int_t ndf = fgNbins[0]+fgNbins[1]-2; | |
143 | // Float_t prob = TMath::Prob(Double_t(chi2),ndf); | |
144 | // prob1->Fill(prob); | |
145 | // chi2_1->Fill(chi2); | |
146 | oldchi2=chi2; | |
07cfabcf | 147 | if (fDebugLevel) |
148 | fprintf(stderr," chi2 %f ",chi2); | |
a9e2aefa | 149 | |
150 | c->fX[0]=fXFit[0]; | |
151 | c->fY[0]=fYFit[0]; | |
152 | ||
153 | c->fX[1]=fXFit[0]; | |
154 | c->fY[1]=fYFit[0]; | |
155 | c->fChi2[0]=chi2; | |
156 | c->fChi2[1]=chi2; | |
07cfabcf | 157 | // Force on anod |
f0d86bc4 | 158 | c->fX[0]=fSeg[0]->GetAnod(c->fX[0]); |
159 | c->fX[1]=fSeg[1]->GetAnod(c->fX[1]); | |
a9e2aefa | 160 | |
161 | // If reasonable chi^2 add result to the list of rawclusters | |
a9e2aefa | 162 | if (chi2 < 0.3) { |
163 | AddRawCluster(*c); | |
164 | // If not try combined double Mathieson Fit | |
165 | } else { | |
19dd5b2f | 166 | if (fDebugLevel) |
a9e2aefa | 167 | fprintf(stderr," MAUVAIS CHI2 !!!\n"); |
168 | if (fNLocal[0]==1 && fNLocal[1]==1) { | |
169 | fXInit[0]=fX[fIndLocal[0][1]][1]; | |
170 | fYInit[0]=fY[fIndLocal[0][0]][0]; | |
171 | fXInit[1]=fX[fIndLocal[0][1]][1]; | |
172 | fYInit[1]=fY[fIndLocal[0][0]][0]; | |
173 | } else if (fNLocal[0]==1) { | |
174 | fXInit[0]=fX[fIndLocal[0][0]][0]; | |
175 | fYInit[0]=fY[fIndLocal[0][0]][0]; | |
176 | fXInit[1]=fX[fIndLocal[0][0]][0]; | |
177 | fYInit[1]=fY[fIndLocal[0][0]][0]; | |
178 | } else { | |
179 | fXInit[0]=fX[fIndLocal[0][1]][1]; | |
180 | fYInit[0]=fY[fIndLocal[0][1]][1]; | |
181 | fXInit[1]=fX[fIndLocal[0][1]][1]; | |
182 | fYInit[1]=fY[fIndLocal[0][1]][1]; | |
183 | } | |
184 | ||
185 | // Initial value for charge ratios | |
186 | fQrInit[0]=0.5; | |
187 | fQrInit[1]=0.5; | |
07cfabcf | 188 | if (fDebugLevel) |
a9e2aefa | 189 | fprintf(stderr,"\n cas (1) CombiDoubleMathiesonFit(c)\n"); |
190 | chi2=CombiDoubleMathiesonFit(c); | |
191 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
192 | // Float_t prob = TMath::Prob(chi2,ndf); | |
193 | // prob2->Fill(prob); | |
194 | // chi2_2->Fill(chi2); | |
195 | ||
196 | // Was this any better ?? | |
19dd5b2f | 197 | if (fDebugLevel) |
198 | fprintf(stderr," Old and new chi2 %f %f ", oldchi2, chi2); | |
a9e2aefa | 199 | if (fFitStat!=0 && chi2>0 && (2.*chi2 < oldchi2)) { |
19dd5b2f | 200 | if (fDebugLevel) |
a9e2aefa | 201 | fprintf(stderr," Split\n"); |
202 | // Split cluster into two according to fit result | |
203 | Split(c); | |
204 | } else { | |
19dd5b2f | 205 | if (fDebugLevel) |
a9e2aefa | 206 | fprintf(stderr," Don't Split\n"); |
207 | // Don't split | |
208 | AddRawCluster(*c); | |
209 | } | |
210 | } | |
211 | ||
212 | // +++++++++++++++++++++++++++++++++++++++ | |
213 | // (2) Two local maxima per cathode plane | |
214 | // +++++++++++++++++++++++++++++++++++++++ | |
215 | } else if (fNLocal[0]==2 && fNLocal[1]==2) { | |
216 | // | |
217 | // Let's look for ghosts first | |
05c39730 | 218 | |
a9e2aefa | 219 | Float_t xm[4][2], ym[4][2]; |
220 | Float_t dpx, dpy, dx, dy; | |
221 | Int_t ixm[4][2], iym[4][2]; | |
222 | Int_t isec, im1, im2, ico; | |
223 | // | |
224 | // Form the 2x2 combinations | |
225 | // 0-0, 0-1, 1-0, 1-1 | |
226 | ico=0; | |
227 | for (im1=0; im1<2; im1++) { | |
228 | for (im2=0; im2<2; im2++) { | |
229 | xm[ico][0]=fX[fIndLocal[im1][0]][0]; | |
230 | ym[ico][0]=fY[fIndLocal[im1][0]][0]; | |
231 | xm[ico][1]=fX[fIndLocal[im2][1]][1]; | |
232 | ym[ico][1]=fY[fIndLocal[im2][1]][1]; | |
233 | ||
234 | ixm[ico][0]=fIx[fIndLocal[im1][0]][0]; | |
235 | iym[ico][0]=fIy[fIndLocal[im1][0]][0]; | |
236 | ixm[ico][1]=fIx[fIndLocal[im2][1]][1]; | |
237 | iym[ico][1]=fIy[fIndLocal[im2][1]][1]; | |
238 | ico++; | |
239 | } | |
240 | } | |
241 | // ico = 0 : first local maximum on cathodes 1 and 2 | |
242 | // ico = 1 : fisrt local maximum on cathode 1 and second on cathode 2 | |
243 | // ico = 2 : second local maximum on cathode 1 and first on cathode 1 | |
244 | // ico = 3 : second local maximum on cathodes 1 and 2 | |
245 | ||
246 | // Analyse the combinations and keep those that are possible ! | |
247 | // For each combination check consistency in x and y | |
05c39730 | 248 | Int_t iacc; |
249 | Bool_t accepted[4]; | |
250 | Float_t dr[4] = {1.e4, 1.e4, 1.e4, 1.e4}; | |
a9e2aefa | 251 | iacc=0; |
05c39730 | 252 | |
253 | // In case of staggering maxima are displaced by exactly half the pad-size in y. | |
254 | // We have to take into account the numerical precision in the consistency check; | |
255 | Float_t eps = 1.e-5; | |
256 | // | |
a9e2aefa | 257 | for (ico=0; ico<4; ico++) { |
258 | accepted[ico]=kFALSE; | |
259 | // cathode one: x-coordinate | |
f0d86bc4 | 260 | isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]); |
261 | dpx=fSeg[0]->Dpx(isec)/2.; | |
a9e2aefa | 262 | dx=TMath::Abs(xm[ico][0]-xm[ico][1]); |
263 | // cathode two: y-coordinate | |
f0d86bc4 | 264 | isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]); |
265 | dpy=fSeg[1]->Dpy(isec)/2.; | |
a9e2aefa | 266 | dy=TMath::Abs(ym[ico][0]-ym[ico][1]); |
05c39730 | 267 | if (fDebugLevel>1) |
268 | printf("\n %i %f %f %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy, dx, dpx ); | |
269 | if ((dx <= dpx) && (dy <= dpy+eps)) { | |
a9e2aefa | 270 | // consistent |
271 | accepted[ico]=kTRUE; | |
05c39730 | 272 | dr[ico] = TMath::Sqrt(dx*dx+dy*dy); |
a9e2aefa | 273 | iacc++; |
274 | } else { | |
275 | // reject | |
276 | accepted[ico]=kFALSE; | |
277 | } | |
278 | } | |
19dd5b2f | 279 | if (fDebugLevel) |
280 | printf("\n iacc= %d:\n", iacc); | |
05c39730 | 281 | if (iacc == 3) { |
282 | if (accepted[0] && accepted[1]) { | |
283 | if (dr[0] >= dr[1]) { | |
284 | accepted[0]=kFALSE; | |
285 | } else { | |
286 | accepted[1]=kFALSE; | |
287 | } | |
288 | } | |
a9e2aefa | 289 | |
05c39730 | 290 | if (accepted[2] && accepted[3]) { |
291 | if (dr[2] >= dr[3]) { | |
292 | accepted[2]=kFALSE; | |
293 | } else { | |
294 | accepted[3]=kFALSE; | |
295 | } | |
296 | } | |
297 | /* | |
298 | // eliminate one candidate | |
299 | Float_t drmax = 0; | |
300 | Int_t icobad = -1; | |
301 | ||
302 | for (ico=0; ico<4; ico++) { | |
303 | if (accepted[ico] && dr[ico] > drmax) { | |
304 | icobad = ico; | |
305 | drmax = dr[ico]; | |
306 | } | |
307 | } | |
308 | ||
309 | accepted[icobad] = kFALSE; | |
310 | */ | |
311 | iacc = 2; | |
312 | } | |
313 | ||
314 | ||
07cfabcf | 315 | if (fDebugLevel) { |
19dd5b2f | 316 | printf("\n iacc= %d:\n", iacc); |
07cfabcf | 317 | if (iacc==2) { |
318 | fprintf(stderr,"\n iacc=2: No problem ! \n"); | |
319 | } else if (iacc==4) { | |
320 | fprintf(stderr,"\n iacc=4: Ok, but ghost problem !!! \n"); | |
321 | } else if (iacc==0) { | |
322 | fprintf(stderr,"\n iacc=0: I don't know what to do with this !!!!!!!!! \n"); | |
323 | } | |
a9e2aefa | 324 | } |
325 | ||
326 | // Initial value for charge ratios | |
327 | fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/ | |
328 | Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]); | |
329 | fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/ | |
330 | Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]); | |
331 | ||
332 | // ******* iacc = 0 ******* | |
333 | // No combinations found between the 2 cathodes | |
334 | // We keep the center of gravity of the cluster | |
335 | if (iacc==0) { | |
336 | AddRawCluster(*c); | |
337 | } | |
338 | ||
339 | // ******* iacc = 1 ******* | |
340 | // Only one combination found between the 2 cathodes | |
341 | if (iacc==1) { | |
a9e2aefa | 342 | // Initial values for the 2 maxima (x,y) |
343 | ||
344 | // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1) | |
345 | // 1 maximum is initialised with the other maximum of the first cathode | |
346 | if (accepted[0]){ | |
347 | fprintf(stderr,"ico=0\n"); | |
348 | fXInit[0]=xm[0][1]; | |
349 | fYInit[0]=ym[0][0]; | |
350 | fXInit[1]=xm[3][0]; | |
351 | fYInit[1]=ym[3][0]; | |
352 | } else if (accepted[1]){ | |
353 | fprintf(stderr,"ico=1\n"); | |
354 | fXInit[0]=xm[1][1]; | |
355 | fYInit[0]=ym[1][0]; | |
356 | fXInit[1]=xm[2][0]; | |
357 | fYInit[1]=ym[2][0]; | |
358 | } else if (accepted[2]){ | |
359 | fprintf(stderr,"ico=2\n"); | |
360 | fXInit[0]=xm[2][1]; | |
361 | fYInit[0]=ym[2][0]; | |
362 | fXInit[1]=xm[1][0]; | |
363 | fYInit[1]=ym[1][0]; | |
364 | } else if (accepted[3]){ | |
365 | fprintf(stderr,"ico=3\n"); | |
366 | fXInit[0]=xm[3][1]; | |
367 | fYInit[0]=ym[3][0]; | |
368 | fXInit[1]=xm[0][0]; | |
369 | fYInit[1]=ym[0][0]; | |
370 | } | |
07cfabcf | 371 | if (fDebugLevel) |
372 | fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n"); | |
a9e2aefa | 373 | chi2=CombiDoubleMathiesonFit(c); |
374 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
375 | // Float_t prob = TMath::Prob(chi2,ndf); | |
376 | // prob2->Fill(prob); | |
377 | // chi2_2->Fill(chi2); | |
07cfabcf | 378 | if (fDebugLevel) |
379 | fprintf(stderr," chi2 %f\n",chi2); | |
a9e2aefa | 380 | |
381 | // If reasonable chi^2 add result to the list of rawclusters | |
382 | if (chi2<10) { | |
383 | Split(c); | |
384 | ||
385 | } else { | |
386 | // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1) | |
387 | // 1 maximum is initialised with the other maximum of the second cathode | |
388 | if (accepted[0]){ | |
389 | fprintf(stderr,"ico=0\n"); | |
390 | fXInit[0]=xm[0][1]; | |
391 | fYInit[0]=ym[0][0]; | |
392 | fXInit[1]=xm[3][1]; | |
393 | fYInit[1]=ym[3][1]; | |
394 | } else if (accepted[1]){ | |
395 | fprintf(stderr,"ico=1\n"); | |
396 | fXInit[0]=xm[1][1]; | |
397 | fYInit[0]=ym[1][0]; | |
398 | fXInit[1]=xm[2][1]; | |
399 | fYInit[1]=ym[2][1]; | |
400 | } else if (accepted[2]){ | |
401 | fprintf(stderr,"ico=2\n"); | |
402 | fXInit[0]=xm[2][1]; | |
403 | fYInit[0]=ym[2][0]; | |
404 | fXInit[1]=xm[1][1]; | |
405 | fYInit[1]=ym[1][1]; | |
406 | } else if (accepted[3]){ | |
407 | fprintf(stderr,"ico=3\n"); | |
408 | fXInit[0]=xm[3][1]; | |
409 | fYInit[0]=ym[3][0]; | |
410 | fXInit[1]=xm[0][1]; | |
411 | fYInit[1]=ym[0][1]; | |
412 | } | |
07cfabcf | 413 | if (fDebugLevel) |
414 | fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n"); | |
a9e2aefa | 415 | chi2=CombiDoubleMathiesonFit(c); |
416 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
417 | // Float_t prob = TMath::Prob(chi2,ndf); | |
418 | // prob2->Fill(prob); | |
419 | // chi2_2->Fill(chi2); | |
07cfabcf | 420 | if (fDebugLevel) |
421 | fprintf(stderr," chi2 %f\n",chi2); | |
a9e2aefa | 422 | |
423 | // If reasonable chi^2 add result to the list of rawclusters | |
424 | if (chi2<10) { | |
425 | Split(c); | |
426 | } else { | |
427 | //We keep only the combination found (X->cathode 2, Y->cathode 1) | |
428 | for (Int_t ico=0; ico<2; ico++) { | |
429 | if (accepted[ico]) { | |
430 | AliMUONRawCluster cnew; | |
431 | Int_t cath; | |
432 | for (cath=0; cath<2; cath++) { | |
9825400f | 433 | cnew.fX[cath]=Float_t(xm[ico][1]); |
434 | cnew.fY[cath]=Float_t(ym[ico][0]); | |
aadda617 | 435 | cnew.fZ[cath]=fZPlane; |
436 | ||
9825400f | 437 | cnew.fMultiplicity[cath]=c->fMultiplicity[cath]; |
a9e2aefa | 438 | for (i=0; i<fMul[cath]; i++) { |
9825400f | 439 | cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath]; |
f0d86bc4 | 440 | fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]); |
a9e2aefa | 441 | } |
9825400f | 442 | fprintf(stderr,"\nRawCluster %d cath %d\n",ico,cath); |
443 | fprintf(stderr,"mult_av %d\n",c->fMultiplicity[cath]); | |
444 | FillCluster(&cnew,cath); | |
a9e2aefa | 445 | } |
446 | cnew.fClusterType=cnew.PhysicsContribution(); | |
447 | AddRawCluster(cnew); | |
448 | fNPeaks++; | |
449 | } | |
450 | } | |
451 | } | |
452 | } | |
453 | } | |
9825400f | 454 | |
a9e2aefa | 455 | // ******* iacc = 2 ******* |
456 | // Two combinations found between the 2 cathodes | |
457 | if (iacc==2) { | |
a9e2aefa | 458 | // Was the same maximum taken twice |
9825400f | 459 | if ((accepted[0]&&accepted[1]) || (accepted[2]&&accepted[3])) { |
460 | fprintf(stderr,"\n Maximum taken twice !!!\n"); | |
a9e2aefa | 461 | |
05c39730 | 462 | // Have a try !! with that |
9825400f | 463 | if (accepted[0]&&accepted[3]) { |
464 | fXInit[0]=xm[0][1]; | |
465 | fYInit[0]=ym[0][0]; | |
466 | fXInit[1]=xm[1][1]; | |
467 | fYInit[1]=ym[1][0]; | |
468 | } else { | |
469 | fXInit[0]=xm[2][1]; | |
470 | fYInit[0]=ym[2][0]; | |
471 | fXInit[1]=xm[3][1]; | |
472 | fYInit[1]=ym[3][0]; | |
473 | } | |
07cfabcf | 474 | if (fDebugLevel) |
475 | fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n"); | |
9825400f | 476 | chi2=CombiDoubleMathiesonFit(c); |
a9e2aefa | 477 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; |
478 | // Float_t prob = TMath::Prob(chi2,ndf); | |
479 | // prob2->Fill(prob); | |
480 | // chi2_2->Fill(chi2); | |
9825400f | 481 | Split(c); |
482 | ||
483 | } else { | |
a9e2aefa | 484 | // No ghosts ! No Problems ! - Perform one fit only ! |
9825400f | 485 | if (accepted[0]&&accepted[3]) { |
486 | fXInit[0]=xm[0][1]; | |
487 | fYInit[0]=ym[0][0]; | |
488 | fXInit[1]=xm[3][1]; | |
489 | fYInit[1]=ym[3][0]; | |
490 | } else { | |
491 | fXInit[0]=xm[1][1]; | |
492 | fYInit[0]=ym[1][0]; | |
493 | fXInit[1]=xm[2][1]; | |
494 | fYInit[1]=ym[2][0]; | |
495 | } | |
07cfabcf | 496 | if (fDebugLevel) |
497 | fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n"); | |
9825400f | 498 | chi2=CombiDoubleMathiesonFit(c); |
a9e2aefa | 499 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; |
500 | // Float_t prob = TMath::Prob(chi2,ndf); | |
501 | // prob2->Fill(prob); | |
502 | // chi2_2->Fill(chi2); | |
07cfabcf | 503 | if (fDebugLevel) |
504 | fprintf(stderr," chi2 %f\n",chi2); | |
9825400f | 505 | Split(c); |
506 | } | |
507 | ||
a9e2aefa | 508 | // ******* iacc = 4 ******* |
509 | // Four combinations found between the 2 cathodes | |
510 | // Ghost !! | |
9825400f | 511 | } else if (iacc==4) { |
a9e2aefa | 512 | // Perform fits for the two possibilities !! |
07cfabcf | 513 | // Accept if charges are compatible on both cathodes |
514 | // If none are compatible, keep everything | |
9825400f | 515 | fXInit[0]=xm[0][1]; |
516 | fYInit[0]=ym[0][0]; | |
517 | fXInit[1]=xm[3][1]; | |
518 | fYInit[1]=ym[3][0]; | |
07cfabcf | 519 | if (fDebugLevel) |
520 | fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n"); | |
9825400f | 521 | chi2=CombiDoubleMathiesonFit(c); |
a9e2aefa | 522 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; |
523 | // Float_t prob = TMath::Prob(chi2,ndf); | |
524 | // prob2->Fill(prob); | |
525 | // chi2_2->Fill(chi2); | |
07cfabcf | 526 | if (fDebugLevel) |
527 | fprintf(stderr," chi2 %f\n",chi2); | |
528 | // store results of fit and postpone decision | |
529 | Double_t sXFit[2],sYFit[2],sQrFit[2]; | |
530 | Float_t sChi2[2]; | |
531 | for (Int_t i=0;i<2;i++) { | |
532 | sXFit[i]=fXFit[i]; | |
533 | sYFit[i]=fYFit[i]; | |
534 | sQrFit[i]=fQrFit[i]; | |
535 | sChi2[i]=fChi2[i]; | |
536 | } | |
9825400f | 537 | fXInit[0]=xm[1][1]; |
538 | fYInit[0]=ym[1][0]; | |
539 | fXInit[1]=xm[2][1]; | |
540 | fYInit[1]=ym[2][0]; | |
07cfabcf | 541 | if (fDebugLevel) |
542 | fprintf(stderr,"\n cas (2) CombiDoubleMathiesonFit(c)\n"); | |
9825400f | 543 | chi2=CombiDoubleMathiesonFit(c); |
a9e2aefa | 544 | // ndf = fgNbins[0]+fgNbins[1]-6; |
545 | // prob = TMath::Prob(chi2,ndf); | |
546 | // prob2->Fill(prob); | |
547 | // chi2_2->Fill(chi2); | |
07cfabcf | 548 | if (fDebugLevel) |
549 | fprintf(stderr," chi2 %f\n",chi2); | |
550 | // We have all informations to perform the decision | |
551 | // Compute the chi2 for the 2 possibilities | |
552 | Float_t chi2fi,chi2si,chi2f,chi2s; | |
553 | ||
554 | chi2f = (TMath::Log(fInput->TotalCharge(0)*fQrFit[0] | |
555 | / (fInput->TotalCharge(1)*fQrFit[1]) ) | |
556 | / fInput->Response()->ChargeCorrel() ); | |
557 | chi2f *=chi2f; | |
558 | chi2fi = (TMath::Log(fInput->TotalCharge(0)*(1-fQrFit[0]) | |
559 | / (fInput->TotalCharge(1)*(1-fQrFit[1])) ) | |
560 | / fInput->Response()->ChargeCorrel() ); | |
561 | chi2f += chi2fi*chi2fi; | |
562 | ||
563 | chi2s = (TMath::Log(fInput->TotalCharge(0)*sQrFit[0] | |
564 | / (fInput->TotalCharge(1)*sQrFit[1]) ) | |
565 | / fInput->Response()->ChargeCorrel() ); | |
566 | chi2s *=chi2s; | |
567 | chi2si = (TMath::Log(fInput->TotalCharge(0)*(1-sQrFit[0]) | |
568 | / (fInput->TotalCharge(1)*(1-sQrFit[1])) ) | |
569 | / fInput->Response()->ChargeCorrel() ); | |
570 | chi2s += chi2si*chi2si; | |
571 | ||
572 | // usefull to store the charge matching chi2 in the cluster | |
573 | // fChi2[0]=sChi2[1]=chi2f; | |
574 | // fChi2[1]=sChi2[0]=chi2s; | |
575 | ||
576 | if (chi2f<=fGhostChi2Cut && chi2s<=fGhostChi2Cut) | |
577 | c->fGhost=1; | |
578 | if (chi2f>fGhostChi2Cut && chi2s>fGhostChi2Cut) { | |
579 | // we keep the ghost | |
580 | c->fGhost=2; | |
581 | chi2s=-1; | |
582 | chi2f=-1; | |
583 | } | |
584 | if (chi2f<=fGhostChi2Cut) | |
585 | Split(c); | |
586 | if (chi2s<=fGhostChi2Cut) { | |
587 | // retreive saved values | |
588 | for (Int_t i=0;i<2;i++) { | |
589 | fXFit[i]=sXFit[i]; | |
590 | fYFit[i]=sYFit[i]; | |
591 | fQrFit[i]=sQrFit[i]; | |
592 | fChi2[i]=sChi2[i]; | |
593 | } | |
594 | Split(c); | |
595 | } | |
596 | c->fGhost=0; | |
9825400f | 597 | } |
a9e2aefa | 598 | |
9825400f | 599 | } else if (fNLocal[0]==2 && fNLocal[1]==1) { |
a9e2aefa | 600 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
601 | // (3) Two local maxima on cathode 1 and one maximum on cathode 2 | |
602 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
603 | // | |
604 | Float_t xm[4][2], ym[4][2]; | |
605 | Float_t dpx, dpy, dx, dy; | |
606 | Int_t ixm[4][2], iym[4][2]; | |
607 | Int_t isec, im1, ico; | |
608 | // | |
609 | // Form the 2x2 combinations | |
610 | // 0-0, 0-1, 1-0, 1-1 | |
611 | ico=0; | |
612 | for (im1=0; im1<2; im1++) { | |
9825400f | 613 | xm[ico][0]=fX[fIndLocal[im1][0]][0]; |
614 | ym[ico][0]=fY[fIndLocal[im1][0]][0]; | |
615 | xm[ico][1]=fX[fIndLocal[0][1]][1]; | |
616 | ym[ico][1]=fY[fIndLocal[0][1]][1]; | |
617 | ||
618 | ixm[ico][0]=fIx[fIndLocal[im1][0]][0]; | |
619 | iym[ico][0]=fIy[fIndLocal[im1][0]][0]; | |
620 | ixm[ico][1]=fIx[fIndLocal[0][1]][1]; | |
621 | iym[ico][1]=fIy[fIndLocal[0][1]][1]; | |
622 | ico++; | |
a9e2aefa | 623 | } |
624 | // ico = 0 : first local maximum on cathodes 1 and 2 | |
625 | // ico = 1 : second local maximum on cathode 1 and first on cathode 2 | |
626 | ||
627 | // Analyse the combinations and keep those that are possible ! | |
628 | // For each combination check consistency in x and y | |
629 | Int_t iacc; | |
630 | Bool_t accepted[4]; | |
631 | iacc=0; | |
05c39730 | 632 | // In case of staggering maxima are displaced by exactly half the pad-size in y. |
375c469b | 633 | // We have to take into account the numerical precision in the consistency check; |
634 | ||
05c39730 | 635 | Float_t eps = 1.e-5; |
636 | ||
a9e2aefa | 637 | for (ico=0; ico<2; ico++) { |
638 | accepted[ico]=kFALSE; | |
f0d86bc4 | 639 | isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]); |
640 | dpx=fSeg[0]->Dpx(isec)/2.; | |
a9e2aefa | 641 | dx=TMath::Abs(xm[ico][0]-xm[ico][1]); |
f0d86bc4 | 642 | isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]); |
643 | dpy=fSeg[1]->Dpy(isec)/2.; | |
a9e2aefa | 644 | dy=TMath::Abs(ym[ico][0]-ym[ico][1]); |
05c39730 | 645 | if (fDebugLevel>1) |
07cfabcf | 646 | printf("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ); |
05c39730 | 647 | if ((dx <= dpx) && (dy <= dpy+eps)) { |
a9e2aefa | 648 | // consistent |
649 | accepted[ico]=kTRUE; | |
650 | iacc++; | |
651 | } else { | |
652 | // reject | |
653 | accepted[ico]=kFALSE; | |
654 | } | |
655 | } | |
9825400f | 656 | |
a9e2aefa | 657 | Float_t chi21 = 100; |
658 | Float_t chi22 = 100; | |
05c39730 | 659 | Float_t chi23 = 100; |
660 | ||
661 | // Initial value for charge ratios | |
662 | fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/ | |
663 | Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]); | |
664 | fQrInit[1]=fQrInit[0]; | |
9825400f | 665 | |
05c39730 | 666 | if (accepted[0] && accepted[1]) { |
667 | ||
668 | fXInit[0]=0.5*(xm[0][1]+xm[0][0]); | |
669 | fYInit[0]=ym[0][0]; | |
670 | fXInit[1]=0.5*(xm[0][1]+xm[1][0]); | |
671 | fYInit[1]=ym[1][0]; | |
672 | fQrInit[0]=0.5; | |
673 | fQrInit[1]=0.5; | |
674 | chi23=CombiDoubleMathiesonFit(c); | |
675 | if (chi23<10) { | |
676 | Split(c); | |
677 | Float_t yst; | |
678 | yst = fYFit[0]; | |
679 | fYFit[0] = fYFit[1]; | |
680 | fYFit[1] = yst; | |
681 | Split(c); | |
682 | } | |
683 | } else if (accepted[0]) { | |
a9e2aefa | 684 | fXInit[0]=xm[0][1]; |
685 | fYInit[0]=ym[0][0]; | |
686 | fXInit[1]=xm[1][0]; | |
687 | fYInit[1]=ym[1][0]; | |
688 | chi21=CombiDoubleMathiesonFit(c); | |
689 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
690 | // Float_t prob = TMath::Prob(chi2,ndf); | |
691 | // prob2->Fill(prob); | |
692 | // chi2_2->Fill(chi21); | |
07cfabcf | 693 | if (fDebugLevel) |
694 | fprintf(stderr," chi2 %f\n",chi21); | |
a9e2aefa | 695 | if (chi21<10) Split(c); |
696 | } else if (accepted[1]) { | |
697 | fXInit[0]=xm[1][1]; | |
698 | fYInit[0]=ym[1][0]; | |
699 | fXInit[1]=xm[0][0]; | |
700 | fYInit[1]=ym[0][0]; | |
701 | chi22=CombiDoubleMathiesonFit(c); | |
702 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
703 | // Float_t prob = TMath::Prob(chi2,ndf); | |
704 | // prob2->Fill(prob); | |
705 | // chi2_2->Fill(chi22); | |
07cfabcf | 706 | if (fDebugLevel) |
707 | fprintf(stderr," chi2 %f\n",chi22); | |
a9e2aefa | 708 | if (chi22<10) Split(c); |
709 | } | |
710 | ||
375c469b | 711 | if (chi21 > 10 && chi22 > 10 && chi23 > 10) { |
a9e2aefa | 712 | // We keep only the combination found (X->cathode 2, Y->cathode 1) |
713 | for (Int_t ico=0; ico<2; ico++) { | |
714 | if (accepted[ico]) { | |
715 | AliMUONRawCluster cnew; | |
716 | Int_t cath; | |
717 | for (cath=0; cath<2; cath++) { | |
718 | cnew.fX[cath]=Float_t(xm[ico][1]); | |
719 | cnew.fY[cath]=Float_t(ym[ico][0]); | |
aadda617 | 720 | cnew.fZ[cath]=fZPlane; |
a9e2aefa | 721 | cnew.fMultiplicity[cath]=c->fMultiplicity[cath]; |
722 | for (i=0; i<fMul[cath]; i++) { | |
9825400f | 723 | cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath]; |
f0d86bc4 | 724 | fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]); |
a9e2aefa | 725 | } |
726 | fprintf(stderr,"\nRawCluster %d cath %d\n",ico,cath); | |
727 | fprintf(stderr,"mult_av %d\n",c->fMultiplicity[cath]); | |
728 | FillCluster(&cnew,cath); | |
729 | } | |
730 | cnew.fClusterType=cnew.PhysicsContribution(); | |
731 | AddRawCluster(cnew); | |
732 | fNPeaks++; | |
733 | } | |
734 | } | |
735 | } | |
9825400f | 736 | |
a9e2aefa | 737 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
738 | // (3') One local maximum on cathode 1 and two maxima on cathode 2 | |
739 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
740 | } else if (fNLocal[0]==1 && fNLocal[1]==2) { | |
a9e2aefa | 741 | Float_t xm[4][2], ym[4][2]; |
742 | Float_t dpx, dpy, dx, dy; | |
743 | Int_t ixm[4][2], iym[4][2]; | |
744 | Int_t isec, im1, ico; | |
745 | // | |
746 | // Form the 2x2 combinations | |
747 | // 0-0, 0-1, 1-0, 1-1 | |
748 | ico=0; | |
749 | for (im1=0; im1<2; im1++) { | |
9825400f | 750 | xm[ico][0]=fX[fIndLocal[0][0]][0]; |
751 | ym[ico][0]=fY[fIndLocal[0][0]][0]; | |
752 | xm[ico][1]=fX[fIndLocal[im1][1]][1]; | |
753 | ym[ico][1]=fY[fIndLocal[im1][1]][1]; | |
754 | ||
755 | ixm[ico][0]=fIx[fIndLocal[0][0]][0]; | |
756 | iym[ico][0]=fIy[fIndLocal[0][0]][0]; | |
757 | ixm[ico][1]=fIx[fIndLocal[im1][1]][1]; | |
758 | iym[ico][1]=fIy[fIndLocal[im1][1]][1]; | |
759 | ico++; | |
a9e2aefa | 760 | } |
761 | // ico = 0 : first local maximum on cathodes 1 and 2 | |
762 | // ico = 1 : first local maximum on cathode 1 and second on cathode 2 | |
763 | ||
764 | // Analyse the combinations and keep those that are possible ! | |
765 | // For each combination check consistency in x and y | |
766 | Int_t iacc; | |
767 | Bool_t accepted[4]; | |
768 | iacc=0; | |
05c39730 | 769 | // In case of staggering maxima are displaced by exactly half the pad-size in y. |
770 | // We have to take into account the numerical precision in the consistency check; | |
771 | Float_t eps = 1.e-5; | |
772 | ||
a9e2aefa | 773 | |
774 | for (ico=0; ico<2; ico++) { | |
775 | accepted[ico]=kFALSE; | |
f0d86bc4 | 776 | isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]); |
777 | dpx=fSeg[0]->Dpx(isec)/2.; | |
a9e2aefa | 778 | dx=TMath::Abs(xm[ico][0]-xm[ico][1]); |
f0d86bc4 | 779 | isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]); |
780 | dpy=fSeg[1]->Dpy(isec)/2.; | |
a9e2aefa | 781 | dy=TMath::Abs(ym[ico][0]-ym[ico][1]); |
05c39730 | 782 | if (fDebugLevel>0) |
07cfabcf | 783 | printf("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ); |
05c39730 | 784 | if ((dx <= dpx) && (dy <= dpy+eps)) { |
a9e2aefa | 785 | // consistent |
786 | accepted[ico]=kTRUE; | |
787 | fprintf(stderr,"ico %d\n",ico); | |
788 | iacc++; | |
789 | } else { | |
790 | // reject | |
791 | accepted[ico]=kFALSE; | |
792 | } | |
793 | } | |
794 | ||
795 | Float_t chi21 = 100; | |
796 | Float_t chi22 = 100; | |
05c39730 | 797 | Float_t chi23 = 100; |
798 | ||
799 | fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/ | |
800 | Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]); | |
801 | ||
802 | fQrInit[0]=fQrInit[1]; | |
a9e2aefa | 803 | |
05c39730 | 804 | |
805 | if (accepted[0] && accepted[1]) { | |
806 | fXInit[0]=xm[0][1]; | |
807 | fYInit[0]=0.5*(ym[0][0]+ym[0][1]); | |
808 | fXInit[1]=xm[1][1]; | |
809 | fYInit[1]=0.5*(ym[0][0]+ym[1][1]); | |
810 | fQrInit[0]=0.5; | |
811 | fQrInit[1]=0.5; | |
812 | chi23=CombiDoubleMathiesonFit(c); | |
813 | if (chi23<10) { | |
814 | Split(c); | |
815 | Float_t yst; | |
816 | yst = fYFit[0]; | |
817 | fYFit[0] = fYFit[1]; | |
818 | fYFit[1] = yst; | |
819 | Split(c); | |
820 | } | |
821 | } else if (accepted[0]) { | |
a9e2aefa | 822 | fXInit[0]=xm[0][0]; |
823 | fYInit[0]=ym[0][1]; | |
824 | fXInit[1]=xm[1][1]; | |
825 | fYInit[1]=ym[1][1]; | |
826 | chi21=CombiDoubleMathiesonFit(c); | |
827 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
828 | // Float_t prob = TMath::Prob(chi2,ndf); | |
829 | // prob2->Fill(prob); | |
830 | // chi2_2->Fill(chi21); | |
07cfabcf | 831 | if (fDebugLevel) |
832 | fprintf(stderr," chi2 %f\n",chi21); | |
a9e2aefa | 833 | if (chi21<10) Split(c); |
834 | } else if (accepted[1]) { | |
835 | fXInit[0]=xm[1][0]; | |
836 | fYInit[0]=ym[1][1]; | |
837 | fXInit[1]=xm[0][1]; | |
838 | fYInit[1]=ym[0][1]; | |
839 | chi22=CombiDoubleMathiesonFit(c); | |
840 | // Int_t ndf = fgNbins[0]+fgNbins[1]-6; | |
841 | // Float_t prob = TMath::Prob(chi2,ndf); | |
842 | // prob2->Fill(prob); | |
843 | // chi2_2->Fill(chi22); | |
07cfabcf | 844 | if (fDebugLevel) |
845 | fprintf(stderr," chi2 %f\n",chi22); | |
a9e2aefa | 846 | if (chi22<10) Split(c); |
847 | } | |
848 | ||
05c39730 | 849 | if (chi21 > 10 && chi22 > 10 && chi23 > 10) { |
a9e2aefa | 850 | //We keep only the combination found (X->cathode 2, Y->cathode 1) |
851 | for (Int_t ico=0; ico<2; ico++) { | |
852 | if (accepted[ico]) { | |
853 | AliMUONRawCluster cnew; | |
854 | Int_t cath; | |
855 | for (cath=0; cath<2; cath++) { | |
856 | cnew.fX[cath]=Float_t(xm[ico][1]); | |
857 | cnew.fY[cath]=Float_t(ym[ico][0]); | |
aadda617 | 858 | cnew.fZ[cath]=fZPlane; |
a9e2aefa | 859 | cnew.fMultiplicity[cath]=c->fMultiplicity[cath]; |
860 | for (i=0; i<fMul[cath]; i++) { | |
9825400f | 861 | cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath]; |
f0d86bc4 | 862 | fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]); |
a9e2aefa | 863 | } |
864 | fprintf(stderr,"\nRawCluster %d cath %d\n",ico,cath); | |
865 | fprintf(stderr,"mult_av %d\n",c->fMultiplicity[cath]); | |
866 | FillCluster(&cnew,cath); | |
867 | } | |
868 | cnew.fClusterType=cnew.PhysicsContribution(); | |
869 | AddRawCluster(cnew); | |
870 | fNPeaks++; | |
871 | } | |
872 | } | |
873 | } | |
874 | ||
875 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
876 | // (4) At least three local maxima on cathode 1 or on cathode 2 | |
877 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
878 | } else if (fNLocal[0]>2 || fNLocal[1]>2) { | |
a9e2aefa | 879 | Int_t param = fNLocal[0]*fNLocal[1]; |
f8ffca81 | 880 | Int_t ii; |
9825400f | 881 | |
39e6d319 | 882 | Float_t ** xm = new Float_t * [param]; |
883 | for (ii=0; ii<param; ii++) xm[ii]=new Float_t [2]; | |
884 | Float_t ** ym = new Float_t * [param]; | |
885 | for (ii=0; ii<param; ii++) ym[ii]=new Float_t [2]; | |
886 | Int_t ** ixm = new Int_t * [param]; | |
887 | for (ii=0; ii<param; ii++) ixm[ii]=new Int_t [2]; | |
888 | Int_t ** iym = new Int_t * [param]; | |
889 | for (ii=0; ii<param; ii++) iym[ii]=new Int_t [2]; | |
f8ffca81 | 890 | |
a9e2aefa | 891 | Int_t isec, ico; |
892 | Float_t dpx, dpy, dx, dy; | |
893 | ||
894 | ico=0; | |
895 | for (Int_t im1=0; im1<fNLocal[0]; im1++) { | |
896 | for (Int_t im2=0; im2<fNLocal[1]; im2++) { | |
897 | xm[ico][0]=fX[fIndLocal[im1][0]][0]; | |
898 | ym[ico][0]=fY[fIndLocal[im1][0]][0]; | |
899 | xm[ico][1]=fX[fIndLocal[im2][1]][1]; | |
900 | ym[ico][1]=fY[fIndLocal[im2][1]][1]; | |
901 | ||
902 | ixm[ico][0]=fIx[fIndLocal[im1][0]][0]; | |
903 | iym[ico][0]=fIy[fIndLocal[im1][0]][0]; | |
904 | ixm[ico][1]=fIx[fIndLocal[im2][1]][1]; | |
905 | iym[ico][1]=fIy[fIndLocal[im2][1]][1]; | |
906 | ico++; | |
907 | } | |
908 | } | |
9825400f | 909 | |
a9e2aefa | 910 | Int_t nIco = ico; |
07cfabcf | 911 | if (fDebugLevel) |
912 | fprintf(stderr,"nIco %d\n",nIco); | |
a9e2aefa | 913 | for (ico=0; ico<nIco; ico++) { |
07cfabcf | 914 | if (fDebugLevel) |
915 | fprintf(stderr,"ico = %d\n",ico); | |
f0d86bc4 | 916 | isec=fSeg[0]->Sector(ixm[ico][0], iym[ico][0]); |
917 | dpx=fSeg[0]->Dpx(isec)/2.; | |
a9e2aefa | 918 | dx=TMath::Abs(xm[ico][0]-xm[ico][1]); |
f0d86bc4 | 919 | isec=fSeg[1]->Sector(ixm[ico][1], iym[ico][1]); |
920 | dpy=fSeg[1]->Dpy(isec)/2.; | |
a9e2aefa | 921 | dy=TMath::Abs(ym[ico][0]-ym[ico][1]); |
07cfabcf | 922 | if (fDebugLevel) { |
923 | fprintf(stderr,"dx %f dpx %f dy %f dpy %f\n",dx,dpx,dy,dpy); | |
924 | fprintf(stderr," X %f Y %f\n",xm[ico][1],ym[ico][0]); | |
925 | } | |
a9e2aefa | 926 | if ((dx <= dpx) && (dy <= dpy)) { |
07cfabcf | 927 | if (fDebugLevel) |
928 | fprintf(stderr,"ok\n"); | |
a9e2aefa | 929 | Int_t cath; |
930 | AliMUONRawCluster cnew; | |
931 | for (cath=0; cath<2; cath++) { | |
932 | cnew.fX[cath]=Float_t(xm[ico][1]); | |
933 | cnew.fY[cath]=Float_t(ym[ico][0]); | |
aadda617 | 934 | cnew.fZ[cath]=fZPlane; |
a9e2aefa | 935 | cnew.fMultiplicity[cath]=c->fMultiplicity[cath]; |
936 | for (i=0; i<fMul[cath]; i++) { | |
9825400f | 937 | cnew.fIndexMap[i][cath]=c->fIndexMap[i][cath]; |
f0d86bc4 | 938 | fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]); |
a9e2aefa | 939 | } |
940 | FillCluster(&cnew,cath); | |
941 | } | |
942 | cnew.fClusterType=cnew.PhysicsContribution(); | |
943 | AddRawCluster(cnew); | |
944 | fNPeaks++; | |
945 | } | |
946 | } | |
f8ffca81 | 947 | delete [] xm; |
948 | delete [] ym; | |
949 | delete [] ixm; | |
950 | delete [] iym; | |
a9e2aefa | 951 | } |
952 | } | |
953 | ||
e3cba86e | 954 | void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/) |
a9e2aefa | 955 | { |
956 | // Find all local maxima of a cluster | |
07cfabcf | 957 | if (fDebugLevel) |
958 | printf("\n Find Local maxima !"); | |
f0d86bc4 | 959 | |
a9e2aefa | 960 | AliMUONDigit* digt; |
961 | ||
962 | Int_t cath, cath1; // loops over cathodes | |
963 | Int_t i; // loops over digits | |
964 | Int_t j; // loops over cathodes | |
965 | // | |
966 | // Find local maxima | |
967 | // | |
968 | // counters for number of local maxima | |
969 | fNLocal[0]=fNLocal[1]=0; | |
970 | // flags digits as local maximum | |
971 | Bool_t isLocal[100][2]; | |
972 | for (i=0; i<100;i++) { | |
973 | isLocal[i][0]=isLocal[i][1]=kFALSE; | |
974 | } | |
975 | // number of next neighbours and arrays to store them | |
976 | Int_t nn; | |
30aaba74 | 977 | Int_t x[10], y[10]; |
a9e2aefa | 978 | // loop over cathodes |
979 | for (cath=0; cath<2; cath++) { | |
980 | // loop over cluster digits | |
981 | for (i=0; i<fMul[cath]; i++) { | |
982 | // get neighbours for that digit and assume that it is local maximum | |
f0d86bc4 | 983 | fSeg[cath]->Neighbours(fIx[i][cath], fIy[i][cath], &nn, x, y); |
a9e2aefa | 984 | isLocal[i][cath]=kTRUE; |
f0d86bc4 | 985 | Int_t isec= fSeg[cath]->Sector(fIx[i][cath], fIy[i][cath]); |
986 | Float_t a0 = fSeg[cath]->Dpx(isec)*fSeg[cath]->Dpy(isec); | |
a9e2aefa | 987 | // loop over next neighbours, if at least one neighbour has higher charger assumption |
988 | // digit is not local maximum | |
989 | for (j=0; j<nn; j++) { | |
30aaba74 | 990 | if (fHitMap[cath]->TestHit(x[j], y[j])==kEmpty) continue; |
991 | digt=(AliMUONDigit*) fHitMap[cath]->GetHit(x[j], y[j]); | |
f0d86bc4 | 992 | isec=fSeg[cath]->Sector(x[j], y[j]); |
993 | Float_t a1 = fSeg[cath]->Dpx(isec)*fSeg[cath]->Dpy(isec); | |
08a636a8 | 994 | if (digt->Signal()/a1 > fQ[i][cath]/a0) { |
a9e2aefa | 995 | isLocal[i][cath]=kFALSE; |
996 | break; | |
997 | // | |
998 | // handle special case of neighbouring pads with equal signal | |
08a636a8 | 999 | } else if (digt->Signal() == fQ[i][cath]) { |
a9e2aefa | 1000 | if (fNLocal[cath]>0) { |
1001 | for (Int_t k=0; k<fNLocal[cath]; k++) { | |
1002 | if (x[j]==fIx[fIndLocal[k][cath]][cath] | |
1003 | && y[j]==fIy[fIndLocal[k][cath]][cath]) | |
1004 | { | |
1005 | isLocal[i][cath]=kFALSE; | |
1006 | } | |
1007 | } // loop over local maxima | |
1008 | } // are there already local maxima | |
1009 | } // same charge ? | |
1010 | } // loop over next neighbours | |
1011 | if (isLocal[i][cath]) { | |
1012 | fIndLocal[fNLocal[cath]][cath]=i; | |
1013 | fNLocal[cath]++; | |
1014 | } | |
1015 | } // loop over all digits | |
1016 | } // loop over cathodes | |
07cfabcf | 1017 | |
1018 | if (fDebugLevel) { | |
1019 | printf("\n Found %d %d %d %d local Maxima\n", | |
1020 | fNLocal[0], fNLocal[1], fMul[0], fMul[1]); | |
1021 | fprintf(stderr,"\n Cathode 1 local Maxima %d Multiplicite %d\n",fNLocal[0], fMul[0]); | |
1022 | fprintf(stderr," Cathode 2 local Maxima %d Multiplicite %d\n",fNLocal[1], fMul[1]); | |
1023 | } | |
a9e2aefa | 1024 | Int_t ix, iy, isec; |
1025 | Float_t dpx, dpy; | |
1026 | ||
1027 | ||
1028 | if (fNLocal[1]==2 && (fNLocal[0]==1 || fNLocal[0]==0)) { | |
1029 | Int_t iback=fNLocal[0]; | |
1030 | ||
1031 | // Two local maxima on cathode 2 and one maximum on cathode 1 | |
1032 | // Look for local maxima considering up and down neighbours on the 1st cathode only | |
1033 | // | |
1034 | // Loop over cluster digits | |
1035 | cath=0; | |
1036 | cath1=1; | |
1037 | ||
1038 | for (i=0; i<fMul[cath]; i++) { | |
f0d86bc4 | 1039 | isec=fSeg[cath]->Sector(fIx[i][cath],fIy[i][cath]); |
1040 | dpy=fSeg[cath]->Dpy(isec); | |
1041 | dpx=fSeg[cath]->Dpx(isec); | |
a9e2aefa | 1042 | if (isLocal[i][cath]) continue; |
1043 | // Pad position should be consistent with position of local maxima on the opposite cathode | |
1044 | if ((TMath::Abs(fX[i][cath]-fX[fIndLocal[0][cath1]][cath1]) > dpx/2.) && | |
1045 | (TMath::Abs(fX[i][cath]-fX[fIndLocal[1][cath1]][cath1]) > dpx/2.)) | |
1046 | continue; | |
1047 | ||
1048 | // get neighbours for that digit and assume that it is local maximum | |
1049 | isLocal[i][cath]=kTRUE; | |
1050 | // compare signal to that on the two neighbours on the left and on the right | |
a9e2aefa | 1051 | // iNN counts the number of neighbours with signal, it should be 1 or 2 |
1052 | Int_t iNN=0; | |
f0d86bc4 | 1053 | |
1054 | for (fSeg[cath] | |
1055 | ->FirstPad(fX[i][cath], fY[i][cath], fZPlane, 0., dpy); | |
1056 | fSeg[cath] | |
1057 | ->MorePads(); | |
1058 | fSeg[cath] | |
1059 | ->NextPad()) | |
1060 | { | |
1061 | ix = fSeg[cath]->Ix(); | |
1062 | iy = fSeg[cath]->Iy(); | |
1063 | // skip the current pad | |
1064 | if (iy == fIy[i][cath]) continue; | |
1065 | ||
1066 | if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) { | |
1067 | iNN++; | |
1068 | digt=(AliMUONDigit*) fHitMap[cath]->GetHit(ix,iy); | |
08a636a8 | 1069 | if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE; |
f0d86bc4 | 1070 | } |
1071 | } // Loop over pad neighbours in y | |
a9e2aefa | 1072 | if (isLocal[i][cath] && iNN>0) { |
1073 | fIndLocal[fNLocal[cath]][cath]=i; | |
1074 | fNLocal[cath]++; | |
1075 | } | |
1076 | } // loop over all digits | |
1077 | // if one additional maximum has been found we are happy | |
1078 | // if more maxima have been found restore the previous situation | |
07cfabcf | 1079 | if (fDebugLevel) { |
1080 | fprintf(stderr, | |
1081 | "\n New search gives %d local maxima for cathode 1 \n", | |
1082 | fNLocal[0]); | |
1083 | fprintf(stderr, | |
1084 | " %d local maxima for cathode 2 \n", | |
1085 | fNLocal[1]); | |
1086 | } | |
a9e2aefa | 1087 | if (fNLocal[cath]>2) { |
1088 | fNLocal[cath]=iback; | |
1089 | } | |
1090 | ||
1091 | } // 1,2 local maxima | |
1092 | ||
1093 | if (fNLocal[0]==2 && (fNLocal[1]==1 || fNLocal[1]==0)) { | |
1094 | Int_t iback=fNLocal[1]; | |
1095 | ||
1096 | // Two local maxima on cathode 1 and one maximum on cathode 2 | |
1097 | // Look for local maxima considering left and right neighbours on the 2nd cathode only | |
1098 | cath=1; | |
05c39730 | 1099 | Int_t cath1 = 0; |
1100 | Float_t eps = 1.e-5; | |
1101 | ||
a9e2aefa | 1102 | // |
1103 | // Loop over cluster digits | |
1104 | for (i=0; i<fMul[cath]; i++) { | |
f0d86bc4 | 1105 | isec=fSeg[cath]->Sector(fIx[i][cath],fIy[i][cath]); |
1106 | dpx=fSeg[cath]->Dpx(isec); | |
1107 | dpy=fSeg[cath]->Dpy(isec); | |
a9e2aefa | 1108 | if (isLocal[i][cath]) continue; |
1109 | // Pad position should be consistent with position of local maxima on the opposite cathode | |
05c39730 | 1110 | if ((TMath::Abs(fY[i][cath]-fY[fIndLocal[0][cath1]][cath1]) > dpy/2.+eps) && |
1111 | (TMath::Abs(fY[i][cath]-fY[fIndLocal[1][cath1]][cath1]) > dpy/2.+eps)) | |
a9e2aefa | 1112 | continue; |
05c39730 | 1113 | |
a9e2aefa | 1114 | // |
1115 | // get neighbours for that digit and assume that it is local maximum | |
1116 | isLocal[i][cath]=kTRUE; | |
1117 | // compare signal to that on the two neighbours on the left and on the right | |
f0d86bc4 | 1118 | |
a9e2aefa | 1119 | // iNN counts the number of neighbours with signal, it should be 1 or 2 |
1120 | Int_t iNN=0; | |
f0d86bc4 | 1121 | for (fSeg[cath] |
05c39730 | 1122 | ->FirstPad(fX[i][cath], fY[i][cath], fZPlane, dpx, 0.); |
f0d86bc4 | 1123 | fSeg[cath] |
1124 | ->MorePads(); | |
1125 | fSeg[cath] | |
1126 | ->NextPad()) | |
1127 | { | |
05c39730 | 1128 | |
f0d86bc4 | 1129 | ix = fSeg[cath]->Ix(); |
1130 | iy = fSeg[cath]->Iy(); | |
05c39730 | 1131 | |
f0d86bc4 | 1132 | // skip the current pad |
1133 | if (ix == fIx[i][cath]) continue; | |
1134 | ||
1135 | if (fHitMap[cath]->TestHit(ix, iy)!=kEmpty) { | |
1136 | iNN++; | |
1137 | digt=(AliMUONDigit*) fHitMap[cath]->GetHit(ix,iy); | |
08a636a8 | 1138 | if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE; |
f0d86bc4 | 1139 | } |
1140 | } // Loop over pad neighbours in x | |
a9e2aefa | 1141 | if (isLocal[i][cath] && iNN>0) { |
1142 | fIndLocal[fNLocal[cath]][cath]=i; | |
1143 | fNLocal[cath]++; | |
1144 | } | |
1145 | } // loop over all digits | |
1146 | // if one additional maximum has been found we are happy | |
1147 | // if more maxima have been found restore the previous situation | |
07cfabcf | 1148 | if (fDebugLevel) { |
1149 | fprintf(stderr,"\n New search gives %d local maxima for cathode 1 \n",fNLocal[0]); | |
1150 | fprintf(stderr,"\n %d local maxima for cathode 2 \n",fNLocal[1]); | |
1151 | printf("\n New search gives %d %d \n",fNLocal[0],fNLocal[1]); | |
1152 | } | |
a9e2aefa | 1153 | if (fNLocal[cath]>2) { |
1154 | fNLocal[cath]=iback; | |
1155 | } | |
a9e2aefa | 1156 | } // 2,1 local maxima |
1157 | } | |
1158 | ||
1159 | ||
1160 | void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t flag, Int_t cath) | |
1161 | { | |
1162 | // | |
1163 | // Completes cluster information starting from list of digits | |
1164 | // | |
1165 | AliMUONDigit* dig; | |
802a864d | 1166 | Float_t x, y, z; |
a9e2aefa | 1167 | Int_t ix, iy; |
1168 | ||
1169 | if (cath==1) { | |
1170 | c->fPeakSignal[cath]=c->fPeakSignal[0]; | |
1171 | } else { | |
1172 | c->fPeakSignal[cath]=0; | |
1173 | } | |
1174 | ||
1175 | ||
1176 | if (flag) { | |
1177 | c->fX[cath]=0; | |
1178 | c->fY[cath]=0; | |
1179 | c->fQ[cath]=0; | |
1180 | } | |
1181 | ||
07cfabcf | 1182 | if (fDebugLevel) |
1183 | fprintf(stderr,"\n fPeakSignal %d\n",c->fPeakSignal[cath]); | |
a9e2aefa | 1184 | for (Int_t i=0; i<c->fMultiplicity[cath]; i++) |
1185 | { | |
30aaba74 | 1186 | dig= fInput->Digit(cath,c->fIndexMap[i][cath]); |
08a636a8 | 1187 | ix=dig->PadX()+c->fOffsetMap[i][cath]; |
1188 | iy=dig->PadY(); | |
1189 | Int_t q=dig->Signal(); | |
a9e2aefa | 1190 | if (!flag) q=Int_t(q*c->fContMap[i][cath]); |
1191 | // fprintf(stderr,"q %d c->fPeakSignal[ %d ] %d\n",q,cath,c->fPeakSignal[cath]); | |
08a636a8 | 1192 | if (dig->Physics() >= dig->Signal()) { |
a9e2aefa | 1193 | c->fPhysicsMap[i]=2; |
08a636a8 | 1194 | } else if (dig->Physics() == 0) { |
a9e2aefa | 1195 | c->fPhysicsMap[i]=0; |
1196 | } else c->fPhysicsMap[i]=1; | |
1197 | // | |
1198 | // | |
05c39730 | 1199 | if (fDebugLevel>1) |
07cfabcf | 1200 | fprintf(stderr,"q %d c->fPeakSignal[cath] %d\n",q,c->fPeakSignal[cath]); |
a9e2aefa | 1201 | // peak signal and track list |
1202 | if (q>c->fPeakSignal[cath]) { | |
1203 | c->fPeakSignal[cath]=q; | |
08a636a8 | 1204 | c->fTracks[0]=dig->Hit(); |
1205 | c->fTracks[1]=dig->Track(0); | |
1206 | c->fTracks[2]=dig->Track(1); | |
a9e2aefa | 1207 | // fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->fHit,dig->fTracks[0]); |
1208 | } | |
1209 | // | |
1210 | if (flag) { | |
f0d86bc4 | 1211 | fSeg[cath]->GetPadC(ix, iy, x, y, z); |
a9e2aefa | 1212 | c->fX[cath] += q*x; |
1213 | c->fY[cath] += q*y; | |
1214 | c->fQ[cath] += q; | |
1215 | } | |
1216 | } // loop over digits | |
07cfabcf | 1217 | if (fDebugLevel) |
1218 | fprintf(stderr," fin du cluster c\n"); | |
a9e2aefa | 1219 | |
1220 | ||
1221 | if (flag) { | |
1222 | c->fX[cath]/=c->fQ[cath]; | |
07cfabcf | 1223 | // Force on anod |
f0d86bc4 | 1224 | c->fX[cath]=fSeg[cath]->GetAnod(c->fX[cath]); |
a9e2aefa | 1225 | c->fY[cath]/=c->fQ[cath]; |
1226 | // | |
1227 | // apply correction to the coordinate along the anode wire | |
1228 | // | |
1229 | x=c->fX[cath]; | |
1230 | y=c->fY[cath]; | |
f0d86bc4 | 1231 | fSeg[cath]->GetPadI(x, y, fZPlane, ix, iy); |
1232 | fSeg[cath]->GetPadC(ix, iy, x, y, z); | |
1233 | Int_t isec=fSeg[cath]->Sector(ix,iy); | |
1234 | TF1* cogCorr = fSeg[cath]->CorrFunc(isec-1); | |
a9e2aefa | 1235 | |
1236 | if (cogCorr) { | |
f0d86bc4 | 1237 | Float_t yOnPad=(c->fY[cath]-y)/fSeg[cath]->Dpy(isec); |
a9e2aefa | 1238 | c->fY[cath]=c->fY[cath]-cogCorr->Eval(yOnPad, 0, 0); |
1239 | } | |
1240 | } | |
1241 | } | |
1242 | ||
1243 | void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t cath) | |
1244 | { | |
1245 | // | |
1246 | // Completes cluster information starting from list of digits | |
1247 | // | |
1248 | static Float_t dr0; | |
1249 | ||
1250 | AliMUONDigit* dig; | |
1251 | ||
1252 | if (cath==0) { | |
1253 | dr0 = 10000; | |
1254 | } | |
1255 | ||
802a864d | 1256 | Float_t xpad, ypad, zpad; |
a9e2aefa | 1257 | Float_t dx, dy, dr; |
1258 | ||
1259 | for (Int_t i=0; i<c->fMultiplicity[cath]; i++) | |
1260 | { | |
30aaba74 | 1261 | dig = fInput->Digit(cath,c->fIndexMap[i][cath]); |
f0d86bc4 | 1262 | fSeg[cath]-> |
08a636a8 | 1263 | GetPadC(dig->PadX(),dig->PadY(),xpad,ypad, zpad); |
07cfabcf | 1264 | if (fDebugLevel) |
1265 | fprintf(stderr,"x %f y %f cx %f cy %f\n",xpad,ypad,c->fX[0],c->fY[0]); | |
a9e2aefa | 1266 | dx = xpad - c->fX[0]; |
1267 | dy = ypad - c->fY[0]; | |
1268 | dr = TMath::Sqrt(dx*dx+dy*dy); | |
1269 | ||
1270 | if (dr < dr0) { | |
1271 | dr0 = dr; | |
07cfabcf | 1272 | if (fDebugLevel) |
1273 | fprintf(stderr," dr %f\n",dr); | |
08a636a8 | 1274 | Int_t q=dig->Signal(); |
1275 | if (dig->Physics() >= dig->Signal()) { | |
a9e2aefa | 1276 | c->fPhysicsMap[i]=2; |
08a636a8 | 1277 | } else if (dig->Physics() == 0) { |
a9e2aefa | 1278 | c->fPhysicsMap[i]=0; |
1279 | } else c->fPhysicsMap[i]=1; | |
1280 | c->fPeakSignal[cath]=q; | |
08a636a8 | 1281 | c->fTracks[0]=dig->Hit(); |
1282 | c->fTracks[1]=dig->Track(0); | |
1283 | c->fTracks[2]=dig->Track(1); | |
07cfabcf | 1284 | if (fDebugLevel) |
1285 | fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->Hit(), | |
08a636a8 | 1286 | dig->Track(0)); |
a9e2aefa | 1287 | } |
1288 | // | |
1289 | } // loop over digits | |
1290 | ||
1291 | // apply correction to the coordinate along the anode wire | |
07cfabcf | 1292 | // Force on anod |
f0d86bc4 | 1293 | c->fX[cath]=fSeg[cath]->GetAnod(c->fX[cath]); |
a9e2aefa | 1294 | } |
1295 | ||
1296 | void AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONRawCluster &c){ | |
f0d86bc4 | 1297 | |
1298 | ||
a9e2aefa | 1299 | // |
f0d86bc4 | 1300 | // Find a super cluster on both cathodes |
a9e2aefa | 1301 | // |
1302 | // | |
1303 | // Add i,j as element of the cluster | |
1304 | // | |
f0d86bc4 | 1305 | |
30aaba74 | 1306 | Int_t idx = fHitMap[cath]->GetHitIndex(i,j); |
1307 | AliMUONDigit* dig = (AliMUONDigit*) fHitMap[cath]->GetHit(i,j); | |
08a636a8 | 1308 | Int_t q=dig->Signal(); |
1309 | Int_t theX=dig->PadX(); | |
1310 | Int_t theY=dig->PadY(); | |
f0d86bc4 | 1311 | |
a9e2aefa | 1312 | if (q > TMath::Abs(c.fPeakSignal[0]) && q > TMath::Abs(c.fPeakSignal[1])) { |
1313 | c.fPeakSignal[cath]=q; | |
08a636a8 | 1314 | c.fTracks[0]=dig->Hit(); |
1315 | c.fTracks[1]=dig->Track(0); | |
1316 | c.fTracks[2]=dig->Track(1); | |
a9e2aefa | 1317 | } |
1318 | ||
1319 | // | |
1320 | // Make sure that list of digits is ordered | |
1321 | // | |
1322 | Int_t mu=c.fMultiplicity[cath]; | |
1323 | c.fIndexMap[mu][cath]=idx; | |
1324 | ||
08a636a8 | 1325 | if (dig->Physics() >= dig->Signal()) { |
a9e2aefa | 1326 | c.fPhysicsMap[mu]=2; |
08a636a8 | 1327 | } else if (dig->Physics() == 0) { |
a9e2aefa | 1328 | c.fPhysicsMap[mu]=0; |
1329 | } else c.fPhysicsMap[mu]=1; | |
f0d86bc4 | 1330 | |
1331 | ||
a9e2aefa | 1332 | if (mu > 0) { |
f0d86bc4 | 1333 | for (Int_t ind = mu-1; ind >= 0; ind--) { |
a9e2aefa | 1334 | Int_t ist=(c.fIndexMap)[ind][cath]; |
08a636a8 | 1335 | Int_t ql=fInput->Digit(cath, ist)->Signal(); |
1336 | Int_t ix=fInput->Digit(cath, ist)->PadX(); | |
1337 | Int_t iy=fInput->Digit(cath, ist)->PadY(); | |
f0d86bc4 | 1338 | |
a9e2aefa | 1339 | if (q>ql || (q==ql && theX > ix && theY < iy)) { |
1340 | c.fIndexMap[ind][cath]=idx; | |
1341 | c.fIndexMap[ind+1][cath]=ist; | |
1342 | } else { | |
f0d86bc4 | 1343 | |
a9e2aefa | 1344 | break; |
1345 | } | |
1346 | } | |
1347 | } | |
f0d86bc4 | 1348 | |
a9e2aefa | 1349 | c.fMultiplicity[cath]++; |
1350 | if (c.fMultiplicity[cath] >= 50 ) { | |
1351 | printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity[0]); | |
1352 | c.fMultiplicity[cath]=49; | |
1353 | } | |
1354 | ||
1355 | // Prepare center of gravity calculation | |
802a864d | 1356 | Float_t x, y, z; |
f0d86bc4 | 1357 | fSeg[cath]->GetPadC(i, j, x, y, z); |
1358 | ||
a9e2aefa | 1359 | c.fX[cath] += q*x; |
1360 | c.fY[cath] += q*y; | |
1361 | c.fQ[cath] += q; | |
f0d86bc4 | 1362 | // |
1363 | // Flag hit as "taken" | |
30aaba74 | 1364 | fHitMap[cath]->FlagHit(i,j); |
a9e2aefa | 1365 | // |
1366 | // Now look recursively for all neighbours and pad hit on opposite cathode | |
1367 | // | |
1368 | // Loop over neighbours | |
1369 | Int_t ix,iy; | |
f0d86bc4 | 1370 | ix=iy=0; |
a9e2aefa | 1371 | Int_t nn; |
30aaba74 | 1372 | Int_t xList[10], yList[10]; |
f0d86bc4 | 1373 | fSeg[cath]->Neighbours(i,j,&nn,xList,yList); |
a9e2aefa | 1374 | for (Int_t in=0; in<nn; in++) { |
1375 | ix=xList[in]; | |
1376 | iy=yList[in]; | |
f0d86bc4 | 1377 | |
1378 | if (fHitMap[cath]->TestHit(ix,iy)==kUnused) { | |
05c39730 | 1379 | if (fDebugLevel>1) |
07cfabcf | 1380 | printf("\n Neighbours %d %d %d", cath, ix, iy); |
f0d86bc4 | 1381 | FindCluster(ix, iy, cath, c); |
1382 | } | |
1383 | ||
1384 | } | |
1385 | Int_t nOpp=0; | |
1386 | Int_t iXopp[50], iYopp[50]; | |
1387 | ||
a9e2aefa | 1388 | // Neighbours on opposite cathode |
1389 | // Take into account that several pads can overlap with the present pad | |
f0d86bc4 | 1390 | Int_t isec=fSeg[cath]->Sector(i,j); |
a9e2aefa | 1391 | Int_t iop; |
f0d86bc4 | 1392 | Float_t dx, dy; |
1393 | ||
a9e2aefa | 1394 | if (cath==0) { |
f0d86bc4 | 1395 | iop = 1; |
1396 | dx = (fSeg[cath]->Dpx(isec))/2.; | |
1397 | dy = 0.; | |
a9e2aefa | 1398 | } else { |
f0d86bc4 | 1399 | iop = 0; |
1400 | dx = 0.; | |
1401 | dy = (fSeg[cath]->Dpy(isec))/2; | |
1402 | } | |
1403 | // loop over pad neighbours on opposite cathode | |
1404 | for (fSeg[iop]->FirstPad(x, y, fZPlane, dx, dy); | |
1405 | fSeg[iop]->MorePads(); | |
1406 | fSeg[iop]->NextPad()) | |
1407 | { | |
1408 | ||
1409 | ix = fSeg[iop]->Ix(); iy = fSeg[iop]->Iy(); | |
05c39730 | 1410 | if (fDebugLevel > 1) |
07cfabcf | 1411 | printf("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector); |
f0d86bc4 | 1412 | if (fHitMap[iop]->TestHit(ix,iy)==kUnused){ |
1413 | iXopp[nOpp]=ix; | |
1414 | iYopp[nOpp++]=iy; | |
05c39730 | 1415 | if (fDebugLevel > 1) |
07cfabcf | 1416 | printf("\n Opposite %d %d %d", iop, ix, iy); |
a9e2aefa | 1417 | } |
f0d86bc4 | 1418 | |
1419 | } // Loop over pad neighbours | |
1420 | // This had to go outside the loop since recursive calls inside the iterator are not possible | |
1421 | // | |
1422 | Int_t jopp; | |
1423 | for (jopp=0; jopp<nOpp; jopp++) { | |
1424 | if (fHitMap[iop]->TestHit(iXopp[jopp],iYopp[jopp]) == kUnused) | |
1425 | FindCluster(iXopp[jopp], iYopp[jopp], iop, c); | |
a9e2aefa | 1426 | } |
1427 | } | |
1428 | ||
1429 | //_____________________________________________________________________________ | |
1430 | ||
1431 | void AliMUONClusterFinderVS::FindRawClusters() | |
1432 | { | |
1433 | // | |
1434 | // MUON cluster finder from digits -- finds neighbours on both cathodes and | |
1435 | // fills the tree with raw clusters | |
1436 | // | |
1437 | ||
f0d86bc4 | 1438 | // Return if no input datad available |
30aaba74 | 1439 | if (!fInput->NDigits(0) && !fInput->NDigits(1)) return; |
a9e2aefa | 1440 | |
f0d86bc4 | 1441 | fSeg[0] = fInput->Segmentation(0); |
1442 | fSeg[1] = fInput->Segmentation(1); | |
1443 | ||
1444 | fHitMap[0] = new AliMUONHitMapA1(fSeg[0], fInput->Digits(0)); | |
1445 | fHitMap[1] = new AliMUONHitMapA1(fSeg[1], fInput->Digits(1)); | |
a9e2aefa | 1446 | |
f0d86bc4 | 1447 | |
a9e2aefa | 1448 | AliMUONDigit *dig; |
1449 | ||
1450 | Int_t ndig, cath; | |
1451 | Int_t nskip=0; | |
1452 | Int_t ncls=0; | |
30aaba74 | 1453 | fHitMap[0]->FillHits(); |
1454 | fHitMap[1]->FillHits(); | |
a9e2aefa | 1455 | // |
1456 | // Outer Loop over Cathodes | |
1457 | for (cath=0; cath<2; cath++) { | |
30aaba74 | 1458 | for (ndig=0; ndig<fInput->NDigits(cath); ndig++) { |
1459 | dig = fInput->Digit(cath, ndig); | |
08a636a8 | 1460 | Int_t i=dig->PadX(); |
1461 | Int_t j=dig->PadY(); | |
30aaba74 | 1462 | if (fHitMap[cath]->TestHit(i,j)==kUsed ||fHitMap[0]->TestHit(i,j)==kEmpty) { |
a9e2aefa | 1463 | nskip++; |
1464 | continue; | |
1465 | } | |
07cfabcf | 1466 | if (fDebugLevel) |
1467 | fprintf(stderr,"\n CATHODE %d CLUSTER %d\n",cath,ncls); | |
a9e2aefa | 1468 | AliMUONRawCluster c; |
1469 | c.fMultiplicity[0]=0; | |
1470 | c.fMultiplicity[1]=0; | |
08a636a8 | 1471 | c.fPeakSignal[cath]=dig->Signal(); |
1472 | c.fTracks[0]=dig->Hit(); | |
1473 | c.fTracks[1]=dig->Track(0); | |
1474 | c.fTracks[2]=dig->Track(1); | |
a9e2aefa | 1475 | // tag the beginning of cluster list in a raw cluster |
1476 | c.fNcluster[0]=-1; | |
f0d86bc4 | 1477 | Float_t xcu, ycu; |
1478 | fSeg[cath]->GetPadC(i,j,xcu, ycu, fZPlane); | |
1479 | fSector= fSeg[cath]->Sector(i,j)/100; | |
07cfabcf | 1480 | if (fDebugLevel) |
1481 | printf("\n New Seed %d %d ", i,j); | |
f36a6c8b | 1482 | |
1483 | ||
a9e2aefa | 1484 | FindCluster(i,j,cath,c); |
f0d86bc4 | 1485 | // ^^^^^^^^^^^^^^^^^^^^^^^^ |
a9e2aefa | 1486 | // center of gravity |
f36a6c8b | 1487 | if (c.fX[0]!=0.) c.fX[0] /= c.fQ[0]; |
07cfabcf | 1488 | // Force on anod |
f0d86bc4 | 1489 | c.fX[0]=fSeg[0]->GetAnod(c.fX[0]); |
f36a6c8b | 1490 | if (c.fY[0]!=0.) c.fY[0] /= c.fQ[0]; |
1491 | ||
1492 | if(c.fQ[1]!=0.) c.fX[1] /= c.fQ[1]; | |
1493 | ||
1494 | // Force on anod | |
f0d86bc4 | 1495 | c.fX[1]=fSeg[0]->GetAnod(c.fX[1]); |
f36a6c8b | 1496 | if(c.fQ[1]!=0.) c.fY[1] /= c.fQ[1]; |
3e1872ed | 1497 | |
1498 | c.fZ[0] = fZPlane; | |
1499 | c.fZ[1] = fZPlane; | |
1500 | ||
07cfabcf | 1501 | if (fDebugLevel) { |
1502 | fprintf(stderr,"\n Cathode 1 multiplicite %d X(CG) %f Y(CG) %f\n", | |
1503 | c.fMultiplicity[0],c.fX[0],c.fY[0]); | |
1504 | fprintf(stderr," Cathode 2 multiplicite %d X(CG) %f Y(CG) %f\n", | |
1505 | c.fMultiplicity[1],c.fX[1],c.fY[1]); | |
1506 | } | |
a9e2aefa | 1507 | // Analyse cluster and decluster if necessary |
1508 | // | |
1509 | ncls++; | |
1510 | c.fNcluster[1]=fNRawClusters; | |
1511 | c.fClusterType=c.PhysicsContribution(); | |
1512 | ||
1513 | fNPeaks=0; | |
1514 | // | |
1515 | // | |
1516 | Decluster(&c); | |
a9e2aefa | 1517 | // |
1518 | // reset Cluster object | |
f8ffca81 | 1519 | { // begin local scope |
1520 | for (int k=0;k<c.fMultiplicity[0];k++) c.fIndexMap[k][0]=0; | |
1521 | } // end local scope | |
a9e2aefa | 1522 | |
f8ffca81 | 1523 | { // begin local scope |
1524 | for (int k=0;k<c.fMultiplicity[1];k++) c.fIndexMap[k][1]=0; | |
1525 | } // end local scope | |
1526 | ||
a9e2aefa | 1527 | c.fMultiplicity[0]=c.fMultiplicity[0]=0; |
1528 | ||
1529 | ||
1530 | } // end loop ndig | |
1531 | } // end loop cathodes | |
30aaba74 | 1532 | delete fHitMap[0]; |
1533 | delete fHitMap[1]; | |
a9e2aefa | 1534 | } |
1535 | ||
1536 | Float_t AliMUONClusterFinderVS::SingleMathiesonFit(AliMUONRawCluster *c, Int_t cath) | |
1537 | { | |
f0d86bc4 | 1538 | // Performs a single Mathieson fit on one cathode |
1539 | // | |
19dd5b2f | 1540 | Double_t arglist[20]; |
1541 | Int_t ierflag=0; | |
9825400f | 1542 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
a9e2aefa | 1543 | |
9825400f | 1544 | clusterInput.Fitter()->SetFCN(fcnS1); |
1545 | clusterInput.Fitter()->mninit(2,10,7); | |
19dd5b2f | 1546 | clusterInput.Fitter()->SetPrintLevel(-1+fDebugLevel); |
1547 | arglist[0]=-1; | |
1548 | clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag); | |
a9e2aefa | 1549 | // Set starting values |
1550 | static Double_t vstart[2]; | |
1551 | vstart[0]=c->fX[1]; | |
1552 | vstart[1]=c->fY[0]; | |
1553 | ||
1554 | ||
1555 | // lower and upper limits | |
1556 | static Double_t lower[2], upper[2]; | |
1557 | Int_t ix,iy; | |
f0d86bc4 | 1558 | fSeg[cath]->GetPadI(c->fX[cath], c->fY[cath], fZPlane, ix, iy); |
1559 | Int_t isec=fSeg[cath]->Sector(ix, iy); | |
1560 | lower[0]=vstart[0]-fSeg[cath]->Dpx(isec)/2; | |
1561 | lower[1]=vstart[1]-fSeg[cath]->Dpy(isec)/2; | |
a9e2aefa | 1562 | |
f0d86bc4 | 1563 | upper[0]=lower[0]+fSeg[cath]->Dpx(isec); |
1564 | upper[1]=lower[1]+fSeg[cath]->Dpy(isec); | |
a9e2aefa | 1565 | |
1566 | // step sizes | |
1567 | static Double_t step[2]={0.0005, 0.0005}; | |
1568 | ||
9825400f | 1569 | clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag); |
1570 | clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag); | |
a9e2aefa | 1571 | // ready for minimisation |
a9e2aefa | 1572 | arglist[0]= -1; |
1573 | arglist[1]= 0; | |
1574 | ||
9825400f | 1575 | clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag); |
1576 | clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag); | |
1577 | clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag); | |
a9e2aefa | 1578 | Double_t fmin, fedm, errdef; |
1579 | Int_t npari, nparx, istat; | |
1580 | ||
9825400f | 1581 | clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat); |
a9e2aefa | 1582 | fFitStat=istat; |
1583 | ||
1584 | // Print results | |
1585 | // Get fitted parameters | |
1586 | Double_t xrec, yrec; | |
1587 | TString chname; | |
1588 | Double_t epxz, b1, b2; | |
1589 | Int_t ierflg; | |
9825400f | 1590 | clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg); |
1591 | clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg); | |
a9e2aefa | 1592 | fXFit[cath]=xrec; |
1593 | fYFit[cath]=yrec; | |
1594 | return fmin; | |
1595 | } | |
1596 | ||
e3cba86e | 1597 | Float_t AliMUONClusterFinderVS::CombiSingleMathiesonFit(AliMUONRawCluster * /*c*/) |
a9e2aefa | 1598 | { |
1599 | // Perform combined Mathieson fit on both cathode planes | |
1600 | // | |
19dd5b2f | 1601 | Double_t arglist[20]; |
1602 | Int_t ierflag=0; | |
9825400f | 1603 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
1604 | clusterInput.Fitter()->SetFCN(fcnCombiS1); | |
1605 | clusterInput.Fitter()->mninit(2,10,7); | |
19dd5b2f | 1606 | clusterInput.Fitter()->SetPrintLevel(-1+fDebugLevel); |
1607 | arglist[0]=-1; | |
1608 | clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag); | |
a9e2aefa | 1609 | static Double_t vstart[2]; |
1610 | vstart[0]=fXInit[0]; | |
1611 | vstart[1]=fYInit[0]; | |
1612 | ||
1613 | ||
1614 | // lower and upper limits | |
f0d86bc4 | 1615 | static Float_t lower[2], upper[2]; |
a9e2aefa | 1616 | Int_t ix,iy,isec; |
f0d86bc4 | 1617 | fSeg[0]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy); |
1618 | isec=fSeg[0]->Sector(ix, iy); | |
1619 | Float_t dpy=fSeg[0]->Dpy(isec); | |
1620 | fSeg[1]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy); | |
1621 | isec=fSeg[1]->Sector(ix, iy); | |
1622 | Float_t dpx=fSeg[1]->Dpx(isec); | |
a9e2aefa | 1623 | |
f0d86bc4 | 1624 | Int_t icount; |
1625 | Float_t xdum, ydum, zdum; | |
a9e2aefa | 1626 | |
f0d86bc4 | 1627 | // Find save upper and lower limits |
a9e2aefa | 1628 | |
f0d86bc4 | 1629 | icount = 0; |
a9e2aefa | 1630 | |
f0d86bc4 | 1631 | for (fSeg[1]->FirstPad(fXInit[0], fYInit[0], fZPlane, dpx, 0.); |
1632 | fSeg[1]->MorePads(); fSeg[1]->NextPad()) | |
1633 | { | |
1634 | ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy(); | |
1635 | fSeg[1]->GetPadC(ix,iy, upper[0], ydum, zdum); | |
1636 | if (icount ==0) lower[0]=upper[0]; | |
1637 | icount++; | |
1638 | } | |
1639 | ||
1640 | if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;} | |
1641 | ||
1642 | icount=0; | |
07cfabcf | 1643 | if (fDebugLevel) |
1644 | printf("\n single y %f %f", fXInit[0], fYInit[0]); | |
f0d86bc4 | 1645 | |
1646 | for (fSeg[0]->FirstPad(fXInit[0], fYInit[0], fZPlane, 0., dpy); | |
1647 | fSeg[0]->MorePads(); fSeg[0]->NextPad()) | |
1648 | { | |
1649 | ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy(); | |
1650 | fSeg[0]->GetPadC(ix,iy,xdum,upper[1],zdum); | |
1651 | if (icount ==0) lower[1]=upper[1]; | |
1652 | icount++; | |
07cfabcf | 1653 | if (fDebugLevel) |
1654 | printf("\n upper lower %d %f %f", icount, upper[1], lower[1]); | |
f0d86bc4 | 1655 | } |
1656 | ||
1657 | if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;} | |
1658 | ||
a9e2aefa | 1659 | // step sizes |
1660 | static Double_t step[2]={0.00001, 0.0001}; | |
1661 | ||
9825400f | 1662 | clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag); |
1663 | clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag); | |
a9e2aefa | 1664 | // ready for minimisation |
a9e2aefa | 1665 | arglist[0]= -1; |
1666 | arglist[1]= 0; | |
1667 | ||
9825400f | 1668 | clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag); |
1669 | clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag); | |
1670 | clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag); | |
a9e2aefa | 1671 | Double_t fmin, fedm, errdef; |
1672 | Int_t npari, nparx, istat; | |
1673 | ||
9825400f | 1674 | clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat); |
a9e2aefa | 1675 | fFitStat=istat; |
1676 | ||
1677 | // Print results | |
1678 | // Get fitted parameters | |
1679 | Double_t xrec, yrec; | |
1680 | TString chname; | |
1681 | Double_t epxz, b1, b2; | |
1682 | Int_t ierflg; | |
9825400f | 1683 | clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg); |
1684 | clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg); | |
a9e2aefa | 1685 | fXFit[0]=xrec; |
1686 | fYFit[0]=yrec; | |
1687 | return fmin; | |
1688 | } | |
1689 | ||
e3cba86e | 1690 | Bool_t AliMUONClusterFinderVS::DoubleMathiesonFit(AliMUONRawCluster * /*c*/, Int_t cath) |
a9e2aefa | 1691 | { |
f0d86bc4 | 1692 | // Performs a double Mathieson fit on one cathode |
1693 | // | |
1694 | ||
a9e2aefa | 1695 | // |
1696 | // Initialise global variables for fit | |
19dd5b2f | 1697 | Double_t arglist[20]; |
1698 | Int_t ierflag=0; | |
9825400f | 1699 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
1700 | clusterInput.Fitter()->SetFCN(fcnS2); | |
1701 | clusterInput.Fitter()->mninit(5,10,7); | |
19dd5b2f | 1702 | clusterInput.Fitter()->SetPrintLevel(-1+fDebugLevel); |
1703 | arglist[0]=-1; | |
1704 | clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag); | |
a9e2aefa | 1705 | // Set starting values |
1706 | static Double_t vstart[5]; | |
1707 | vstart[0]=fX[fIndLocal[0][cath]][cath]; | |
1708 | vstart[1]=fY[fIndLocal[0][cath]][cath]; | |
1709 | vstart[2]=fX[fIndLocal[1][cath]][cath]; | |
1710 | vstart[3]=fY[fIndLocal[1][cath]][cath]; | |
1711 | vstart[4]=Float_t(fQ[fIndLocal[0][cath]][cath])/ | |
1712 | Float_t(fQ[fIndLocal[0][cath]][cath]+fQ[fIndLocal[1][cath]][cath]); | |
1713 | // lower and upper limits | |
f0d86bc4 | 1714 | static Float_t lower[5], upper[5]; |
1715 | Int_t isec=fSeg[cath]->Sector(fIx[fIndLocal[0][cath]][cath], fIy[fIndLocal[0][cath]][cath]); | |
1716 | lower[0]=vstart[0]-fSeg[cath]->Dpx(isec); | |
1717 | lower[1]=vstart[1]-fSeg[cath]->Dpy(isec); | |
a9e2aefa | 1718 | |
f0d86bc4 | 1719 | upper[0]=lower[0]+2.*fSeg[cath]->Dpx(isec); |
1720 | upper[1]=lower[1]+2.*fSeg[cath]->Dpy(isec); | |
a9e2aefa | 1721 | |
f0d86bc4 | 1722 | isec=fSeg[cath]->Sector(fIx[fIndLocal[1][cath]][cath], fIy[fIndLocal[1][cath]][cath]); |
1723 | lower[2]=vstart[2]-fSeg[cath]->Dpx(isec)/2; | |
1724 | lower[3]=vstart[3]-fSeg[cath]->Dpy(isec)/2; | |
a9e2aefa | 1725 | |
f0d86bc4 | 1726 | upper[2]=lower[2]+fSeg[cath]->Dpx(isec); |
1727 | upper[3]=lower[3]+fSeg[cath]->Dpy(isec); | |
a9e2aefa | 1728 | |
1729 | lower[4]=0.; | |
1730 | upper[4]=1.; | |
1731 | // step sizes | |
1732 | static Double_t step[5]={0.0005, 0.0005, 0.0005, 0.0005, 0.0001}; | |
1733 | ||
9825400f | 1734 | clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag); |
1735 | clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag); | |
1736 | clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag); | |
1737 | clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag); | |
1738 | clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag); | |
a9e2aefa | 1739 | // ready for minimisation |
a9e2aefa | 1740 | arglist[0]= -1; |
1741 | arglist[1]= 0; | |
1742 | ||
9825400f | 1743 | clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag); |
1744 | clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag); | |
1745 | clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag); | |
a9e2aefa | 1746 | // Get fitted parameters |
1747 | Double_t xrec[2], yrec[2], qfrac; | |
1748 | TString chname; | |
1749 | Double_t epxz, b1, b2; | |
1750 | Int_t ierflg; | |
9825400f | 1751 | clusterInput.Fitter()->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg); |
1752 | clusterInput.Fitter()->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg); | |
1753 | clusterInput.Fitter()->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg); | |
1754 | clusterInput.Fitter()->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg); | |
1755 | clusterInput.Fitter()->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg); | |
a9e2aefa | 1756 | |
1757 | Double_t fmin, fedm, errdef; | |
1758 | Int_t npari, nparx, istat; | |
1759 | ||
9825400f | 1760 | clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat); |
a9e2aefa | 1761 | fFitStat=istat; |
a9e2aefa | 1762 | return kTRUE; |
1763 | } | |
1764 | ||
e3cba86e | 1765 | Float_t AliMUONClusterFinderVS::CombiDoubleMathiesonFit(AliMUONRawCluster * /*c*/) |
a9e2aefa | 1766 | { |
1767 | // | |
1768 | // Perform combined double Mathieson fit on both cathode planes | |
1769 | // | |
19dd5b2f | 1770 | Double_t arglist[20]; |
1771 | Int_t ierflag=0; | |
9825400f | 1772 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
1773 | clusterInput.Fitter()->SetFCN(fcnCombiS2); | |
1774 | clusterInput.Fitter()->mninit(6,10,7); | |
19dd5b2f | 1775 | clusterInput.Fitter()->SetPrintLevel(-1+fDebugLevel); |
1776 | arglist[0]=-1; | |
1777 | clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag); | |
a9e2aefa | 1778 | // Set starting values |
1779 | static Double_t vstart[6]; | |
1780 | vstart[0]=fXInit[0]; | |
1781 | vstart[1]=fYInit[0]; | |
1782 | vstart[2]=fXInit[1]; | |
1783 | vstart[3]=fYInit[1]; | |
1784 | vstart[4]=fQrInit[0]; | |
1785 | vstart[5]=fQrInit[1]; | |
1786 | // lower and upper limits | |
f0d86bc4 | 1787 | static Float_t lower[6], upper[6]; |
a9e2aefa | 1788 | Int_t ix,iy,isec; |
1789 | Float_t dpx, dpy; | |
1790 | ||
f0d86bc4 | 1791 | fSeg[1]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy); |
1792 | isec=fSeg[1]->Sector(ix, iy); | |
1793 | dpx=fSeg[1]->Dpx(isec); | |
a9e2aefa | 1794 | |
f0d86bc4 | 1795 | fSeg[0]->GetPadI(fXInit[0], fYInit[0], fZPlane, ix, iy); |
1796 | isec=fSeg[0]->Sector(ix, iy); | |
1797 | dpy=fSeg[0]->Dpy(isec); | |
a9e2aefa | 1798 | |
a9e2aefa | 1799 | |
f0d86bc4 | 1800 | Int_t icount; |
1801 | Float_t xdum, ydum, zdum; | |
07cfabcf | 1802 | if (fDebugLevel) |
1803 | printf("\n Cluster Finder: %f %f %f %f ", fXInit[0], fXInit[1],fYInit[0], fYInit[1] ); | |
f0d86bc4 | 1804 | |
1805 | // Find save upper and lower limits | |
1806 | icount = 0; | |
1807 | ||
1808 | for (fSeg[1]->FirstPad(fXInit[0], fYInit[0], fZPlane, dpx, 0.); | |
1809 | fSeg[1]->MorePads(); fSeg[1]->NextPad()) | |
1810 | { | |
1811 | ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy(); | |
05c39730 | 1812 | // if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue; |
f0d86bc4 | 1813 | fSeg[1]->GetPadC(ix,iy,upper[0],ydum,zdum); |
1814 | if (icount ==0) lower[0]=upper[0]; | |
1815 | icount++; | |
1816 | } | |
1817 | if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;} | |
05c39730 | 1818 | // vstart[0] = 0.5*(lower[0]+upper[0]); |
1819 | ||
1820 | ||
f0d86bc4 | 1821 | icount=0; |
1822 | ||
1823 | for (fSeg[0]->FirstPad(fXInit[0], fYInit[0], fZPlane, 0., dpy); | |
1824 | fSeg[0]->MorePads(); fSeg[0]->NextPad()) | |
1825 | { | |
1826 | ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy(); | |
05c39730 | 1827 | // if (fHitMap[0]->TestHit(ix, iy) == kEmpty) continue; |
f0d86bc4 | 1828 | fSeg[0]->GetPadC(ix,iy,xdum,upper[1],zdum); |
1829 | if (icount ==0) lower[1]=upper[1]; | |
1830 | icount++; | |
1831 | } | |
05c39730 | 1832 | |
f0d86bc4 | 1833 | if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;} |
05c39730 | 1834 | // vstart[1] = 0.5*(lower[1]+upper[1]); |
1835 | ||
a9e2aefa | 1836 | |
f0d86bc4 | 1837 | fSeg[1]->GetPadI(fXInit[1], fYInit[1], fZPlane, ix, iy); |
1838 | isec=fSeg[1]->Sector(ix, iy); | |
1839 | dpx=fSeg[1]->Dpx(isec); | |
1840 | fSeg[0]->GetPadI(fXInit[1], fYInit[1], fZPlane, ix, iy); | |
1841 | isec=fSeg[0]->Sector(ix, iy); | |
1842 | dpy=fSeg[0]->Dpy(isec); | |
a9e2aefa | 1843 | |
a9e2aefa | 1844 | |
f0d86bc4 | 1845 | // Find save upper and lower limits |
1846 | ||
1847 | icount=0; | |
1848 | ||
1849 | for (fSeg[1]->FirstPad(fXInit[1], fYInit[1], fZPlane, dpx, 0); | |
1850 | fSeg[1]->MorePads(); fSeg[1]->NextPad()) | |
1851 | { | |
1852 | ix=fSeg[1]->Ix(); iy=fSeg[1]->Iy(); | |
05c39730 | 1853 | // if (fHitMap[1]->TestHit(ix, iy) == kEmpty) continue; |
f0d86bc4 | 1854 | fSeg[1]->GetPadC(ix,iy,upper[2],ydum,zdum); |
1855 | if (icount ==0) lower[2]=upper[2]; | |
1856 | icount++; | |
1857 | } | |
1858 | if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;} | |
05c39730 | 1859 | // vstart[2] = 0.5*(lower[2]+upper[2]); |
f0d86bc4 | 1860 | |
1861 | icount=0; | |
1862 | ||
1863 | for (fSeg[0]->FirstPad(fXInit[1], fYInit[1], fZPlane, 0, dpy); | |
1864 | fSeg[0]-> MorePads(); fSeg[0]->NextPad()) | |
1865 | { | |
1866 | ix=fSeg[0]->Ix(); iy=fSeg[0]->Iy(); | |
05c39730 | 1867 | // if (fHitMap[0]->TestHit(ix, iy) != kEmpty) continue; |
1868 | ||
f0d86bc4 | 1869 | fSeg[0]->GetPadC(ix,iy,xdum,upper[3],zdum); |
1870 | if (icount ==0) lower[3]=upper[3]; | |
1871 | icount++; | |
05c39730 | 1872 | |
f0d86bc4 | 1873 | } |
1874 | if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;} | |
05c39730 | 1875 | |
1876 | // vstart[3] = 0.5*(lower[3]+upper[3]); | |
1877 | ||
a9e2aefa | 1878 | lower[4]=0.; |
1879 | upper[4]=1.; | |
1880 | lower[5]=0.; | |
1881 | upper[5]=1.; | |
1882 | ||
1883 | // step sizes | |
1884 | static Double_t step[6]={0.0005, 0.0005, 0.0005, 0.0005, 0.001, 0.001}; | |
9825400f | 1885 | clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag); |
1886 | clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag); | |
1887 | clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag); | |
1888 | clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag); | |
1889 | clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag); | |
1890 | clusterInput.Fitter()->mnparm(5,"a1",vstart[5],step[5],lower[5],upper[5],ierflag); | |
a9e2aefa | 1891 | // ready for minimisation |
a9e2aefa | 1892 | arglist[0]= -1; |
1893 | arglist[1]= 0; | |
1894 | ||
9825400f | 1895 | clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag); |
1896 | clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag); | |
1897 | clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag); | |
a9e2aefa | 1898 | // Get fitted parameters |
1899 | TString chname; | |
1900 | Double_t epxz, b1, b2; | |
1901 | Int_t ierflg; | |
9825400f | 1902 | clusterInput.Fitter()->mnpout(0, chname, fXFit[0], epxz, b1, b2, ierflg); |
1903 | clusterInput.Fitter()->mnpout(1, chname, fYFit[0], epxz, b1, b2, ierflg); | |
1904 | clusterInput.Fitter()->mnpout(2, chname, fXFit[1], epxz, b1, b2, ierflg); | |
1905 | clusterInput.Fitter()->mnpout(3, chname, fYFit[1], epxz, b1, b2, ierflg); | |
1906 | clusterInput.Fitter()->mnpout(4, chname, fQrFit[0], epxz, b1, b2, ierflg); | |
1907 | clusterInput.Fitter()->mnpout(5, chname, fQrFit[1], epxz, b1, b2, ierflg); | |
a9e2aefa | 1908 | |
1909 | Double_t fmin, fedm, errdef; | |
1910 | Int_t npari, nparx, istat; | |
1911 | ||
9825400f | 1912 | clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat); |
a9e2aefa | 1913 | fFitStat=istat; |
1914 | ||
1915 | fChi2[0]=fmin; | |
1916 | fChi2[1]=fmin; | |
1917 | return fmin; | |
1918 | } | |
1919 | ||
1920 | void AliMUONClusterFinderVS::Split(AliMUONRawCluster* c) | |
1921 | { | |
1922 | // | |
1923 | // One cluster for each maximum | |
1924 | // | |
1925 | Int_t i, j, cath; | |
9825400f | 1926 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
a9e2aefa | 1927 | for (j=0; j<2; j++) { |
1928 | AliMUONRawCluster cnew; | |
07cfabcf | 1929 | cnew.fGhost=c->fGhost; |
a9e2aefa | 1930 | for (cath=0; cath<2; cath++) { |
1931 | cnew.fChi2[cath]=fChi2[0]; | |
07cfabcf | 1932 | // ?? why not cnew.fChi2[cath]=fChi2[cath]; |
a9e2aefa | 1933 | |
1934 | if (fNPeaks == 0) { | |
1935 | cnew.fNcluster[0]=-1; | |
1936 | cnew.fNcluster[1]=fNRawClusters; | |
1937 | } else { | |
1938 | cnew.fNcluster[0]=fNPeaks; | |
1939 | cnew.fNcluster[1]=0; | |
1940 | } | |
1941 | cnew.fMultiplicity[cath]=0; | |
1942 | cnew.fX[cath]=Float_t(fXFit[j]); | |
1943 | cnew.fY[cath]=Float_t(fYFit[j]); | |
7382d3a4 | 1944 | cnew.fZ[cath]=fZPlane; |
a9e2aefa | 1945 | if (j==0) { |
9825400f | 1946 | cnew.fQ[cath]=Int_t(clusterInput.TotalCharge(cath)*fQrFit[cath]); |
a9e2aefa | 1947 | } else { |
9825400f | 1948 | cnew.fQ[cath]=Int_t(clusterInput.TotalCharge(cath)*(1-fQrFit[cath])); |
a9e2aefa | 1949 | } |
f0d86bc4 | 1950 | fSeg[cath]->SetHit(fXFit[j],fYFit[j],fZPlane); |
a9e2aefa | 1951 | for (i=0; i<fMul[cath]; i++) { |
1952 | cnew.fIndexMap[cnew.fMultiplicity[cath]][cath]= | |
1953 | c->fIndexMap[i][cath]; | |
f0d86bc4 | 1954 | fSeg[cath]->SetPad(fIx[i][cath], fIy[i][cath]); |
1955 | Float_t q1=fInput->Response()->IntXY(fSeg[cath]); | |
a9e2aefa | 1956 | cnew.fContMap[i][cath] |
1957 | =(q1*Float_t(cnew.fQ[cath]))/Float_t(fQ[i][cath]); | |
1958 | cnew.fMultiplicity[cath]++; | |
a9e2aefa | 1959 | } |
1960 | FillCluster(&cnew,0,cath); | |
1961 | } // cathode loop | |
1962 | ||
1963 | cnew.fClusterType=cnew.PhysicsContribution(); | |
1964 | if (cnew.fQ[0]>0 && cnew.fQ[1]>0) AddRawCluster(cnew); | |
1965 | fNPeaks++; | |
1966 | } | |
1967 | } | |
1968 | ||
1969 | ||
a9e2aefa | 1970 | // |
1971 | // Minimisation functions | |
1972 | // Single Mathieson | |
e3cba86e | 1973 | void fcnS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/) |
a9e2aefa | 1974 | { |
9825400f | 1975 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
a9e2aefa | 1976 | Int_t i; |
1977 | Float_t delta; | |
1978 | Float_t chisq=0; | |
1979 | Float_t qcont=0; | |
1980 | Float_t qtot=0; | |
9825400f | 1981 | |
1982 | for (i=0; i<clusterInput.Nmul(0); i++) { | |
1983 | Float_t q0=clusterInput.Charge(i,0); | |
1984 | Float_t q1=clusterInput.DiscrChargeS1(i,par); | |
a9e2aefa | 1985 | delta=(q0-q1)/q0; |
1986 | chisq+=delta*delta; | |
1987 | qcont+=q1; | |
1988 | qtot+=q0; | |
1989 | } | |
1990 | f=chisq; | |
1991 | } | |
1992 | ||
e3cba86e | 1993 | void fcnCombiS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/) |
a9e2aefa | 1994 | { |
9825400f | 1995 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
a9e2aefa | 1996 | Int_t i, cath; |
1997 | Float_t delta; | |
1998 | Float_t chisq=0; | |
1999 | Float_t qcont=0; | |
2000 | Float_t qtot=0; | |
a9e2aefa | 2001 | |
2002 | for (cath=0; cath<2; cath++) { | |
9825400f | 2003 | for (i=0; i<clusterInput.Nmul(cath); i++) { |
2004 | Float_t q0=clusterInput.Charge(i,cath); | |
2005 | Float_t q1=clusterInput.DiscrChargeCombiS1(i,par,cath); | |
a9e2aefa | 2006 | delta=(q0-q1)/q0; |
2007 | chisq+=delta*delta; | |
2008 | qcont+=q1; | |
2009 | qtot+=q0; | |
2010 | } | |
a9e2aefa | 2011 | } |
a9e2aefa | 2012 | f=chisq; |
2013 | } | |
2014 | ||
2015 | // Double Mathieson | |
e3cba86e | 2016 | void fcnS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/) |
a9e2aefa | 2017 | { |
9825400f | 2018 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
a9e2aefa | 2019 | Int_t i; |
2020 | Float_t delta; | |
2021 | Float_t chisq=0; | |
2022 | Float_t qcont=0; | |
2023 | Float_t qtot=0; | |
2024 | ||
9825400f | 2025 | for (i=0; i<clusterInput.Nmul(0); i++) { |
a9e2aefa | 2026 | |
9825400f | 2027 | Float_t q0=clusterInput.Charge(i,0); |
2028 | Float_t q1=clusterInput.DiscrChargeS2(i,par); | |
a9e2aefa | 2029 | delta=(q0-q1)/q0; |
2030 | chisq+=delta*delta; | |
2031 | qcont+=q1; | |
2032 | qtot+=q0; | |
2033 | } | |
a9e2aefa | 2034 | f=chisq; |
2035 | } | |
2036 | ||
2037 | // Double Mathieson | |
e3cba86e | 2038 | void fcnCombiS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/) |
a9e2aefa | 2039 | { |
9825400f | 2040 | AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance()); |
a9e2aefa | 2041 | Int_t i, cath; |
2042 | Float_t delta; | |
2043 | Float_t chisq=0; | |
2044 | Float_t qcont=0; | |
2045 | Float_t qtot=0; | |
a9e2aefa | 2046 | for (cath=0; cath<2; cath++) { |
9825400f | 2047 | for (i=0; i<clusterInput.Nmul(cath); i++) { |
2048 | Float_t q0=clusterInput.Charge(i,cath); | |
2049 | Float_t q1=clusterInput.DiscrChargeCombiS2(i,par,cath); | |
a9e2aefa | 2050 | delta=(q0-q1)/q0; |
2051 | chisq+=delta*delta; | |
2052 | qcont+=q1; | |
2053 | qtot+=q0; | |
2054 | } | |
a9e2aefa | 2055 | } |
a9e2aefa | 2056 | f=chisq; |
2057 | } | |
2058 | ||
67aef06e | 2059 | void AliMUONClusterFinderVS::AddRawCluster(const AliMUONRawCluster c) |
a9e2aefa | 2060 | { |
2061 | // | |
2062 | // Add a raw cluster copy to the list | |
2063 | // | |
2064 | AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON"); | |
ce3f5e87 | 2065 | pMUON->GetMUONData()->AddRawCluster(fInput->Chamber(),c); |
a9e2aefa | 2066 | fNRawClusters++; |
19dd5b2f | 2067 | if (fDebugLevel) |
07cfabcf | 2068 | fprintf(stderr,"\nfNRawClusters %d\n",fNRawClusters); |
a9e2aefa | 2069 | } |
2070 | ||
30aaba74 | 2071 | Bool_t AliMUONClusterFinderVS::TestTrack(Int_t t) { |
6a9bc541 | 2072 | // Test if track was user selected |
30aaba74 | 2073 | if (fTrack[0]==-1 || fTrack[1]==-1) { |
2074 | return kTRUE; | |
2075 | } else if (t==fTrack[0] || t==fTrack[1]) { | |
2076 | return kTRUE; | |
2077 | } else { | |
2078 | return kFALSE; | |
2079 | } | |
2080 | } | |
a9e2aefa | 2081 | |
2082 | AliMUONClusterFinderVS& AliMUONClusterFinderVS | |
e3cba86e | 2083 | ::operator = (const AliMUONClusterFinderVS& /*rhs*/) |
a9e2aefa | 2084 | { |
2085 | // Dummy assignment operator | |
2086 | return *this; | |
2087 | } | |
2088 | ||
2089 | ||
2090 | ||
2091 | ||
2092 | ||
2093 | ||
2094 | ||
2095 | ||
2096 |