1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // -------------------------------
19 // Class AliMUONClusterFinderVS
20 // -------------------------------
21 // Class for clustering and reconstruction of space points
22 // (Not used by default)
24 #include "AliMUONClusterFinderVS.h"
25 #include "AliMUONDigit.h"
26 #include "AliMUONRawCluster.h"
27 #include "AliMUONGeometrySegmentation.h"
28 #include "AliMUONMathieson.h"
29 #include "AliMUONClusterInput.h"
30 #include "AliMUONDigitMapA1.h"
37 #include <Riostream.h>
40 //_____________________________________________________________________
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);
48 ClassImp(AliMUONClusterFinderVS)
51 AliMUONClusterFinderVS::AliMUONClusterFinderVS()
53 fInput(AliMUONClusterInput::Instance()),
65 /// Default constructor
68 fTrack[0]=fTrack[1]=-1;
72 for(Int_t i=0; i<100; i++) {
73 for (Int_t j=0; j<2; j++) {
77 fRawClusters = new TClonesArray("AliMUONRawCluster",1000);
79 //____________________________________________________________________________
80 AliMUONClusterFinderVS::~AliMUONClusterFinderVS()
84 // Reset tracks information
87 fRawClusters->Delete();
92 //____________________________________________________________________________
93 void AliMUONClusterFinderVS::ResetRawClusters()
95 /// Reset tracks information
97 if (fRawClusters) fRawClusters->Clear();
99 //____________________________________________________________________________
100 void AliMUONClusterFinderVS::Decluster(AliMUONRawCluster *cluster)
102 /// Decluster by local maxima
103 SplitByLocalMaxima(cluster);
105 //____________________________________________________________________________
106 void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
108 /// Split complex cluster by local maxima
111 fInput->SetCluster(c);
113 fMul[0]=c->GetMultiplicity(0);
114 fMul[1]=c->GetMultiplicity(1);
117 // dump digit information into arrays
122 for (cath=0; cath<2; cath++) {
125 for (i=0; i<fMul[cath]; i++) {
127 fDig[i][cath]=fInput->Digit(cath, c->GetIndex(i, cath));
129 fIx[i][cath]= fDig[i][cath]->PadX();
130 fIy[i][cath]= fDig[i][cath]->PadY();
132 fQ[i][cath] = fDig[i][cath]->Signal();
133 // pad centre coordinates
135 GetPadC(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]);
136 } // loop over cluster digits
138 } // loop over cathodes
144 // Initialise and perform mathieson fits
145 Float_t chi2, oldchi2;
146 // ++++++++++++++++++*************+++++++++++++++++++++
147 // (1) No more than one local maximum per cathode plane
148 // +++++++++++++++++++++++++++++++*************++++++++
149 if ((fNLocal[0]==1 && (fNLocal[1]==0 || fNLocal[1]==1)) ||
150 (fNLocal[0]==0 && fNLocal[1]==1)) {
151 // Perform combined single Mathieson fit
152 // Initial values for coordinates (x,y)
154 // One local maximum on cathodes 1 and 2 (X->cathode 2, Y->cathode 1)
155 if (fNLocal[0]==1 && fNLocal[1]==1) {
156 fXInit[0]=c->GetX(1);
157 fYInit[0]=c->GetY(0);
158 // One local maximum on cathode 1 (X,Y->cathode 1)
159 } else if (fNLocal[0]==1) {
160 fXInit[0]=c->GetX(0);
161 fYInit[0]=c->GetY(0);
162 // One local maximum on cathode 2 (X,Y->cathode 2)
164 fXInit[0]=c->GetX(1);
165 fYInit[0]=c->GetY(1);
167 AliDebug(1,"cas (1) CombiSingleMathiesonFit(c)");
168 chi2=CombiSingleMathiesonFit(c);
169 // Int_t ndf = fgNbins[0]+fgNbins[1]-2;
170 // Float_t prob = TMath::Prob(Double_t(chi2),ndf);
171 // prob1->Fill(prob);
172 // chi2_1->Fill(chi2);
174 AliDebug(1,Form(" chi2 %f ",chi2));
176 c->SetX(0, fXFit[0]);
177 c->SetY(0, fYFit[0]);
185 c->SetX(0, fSeg2[0]->GetAnod(fInput->DetElemId(), c->GetX(0)));
186 c->SetX(1, fSeg2[1]->GetAnod(fInput->DetElemId(), c->GetX(1)));
188 // c->SetDetElemId(fInput->DetElemId());
189 // If reasonable chi^2 add result to the list of rawclusters
192 // If not try combined double Mathieson Fit
194 AliDebug(1," MAUVAIS CHI2 !!!\n");
195 if (fNLocal[0]==1 && fNLocal[1]==1) {
196 fXInit[0]=fX[fIndLocal[0][1]][1];
197 fYInit[0]=fY[fIndLocal[0][0]][0];
198 fXInit[1]=fX[fIndLocal[0][1]][1];
199 fYInit[1]=fY[fIndLocal[0][0]][0];
200 } else if (fNLocal[0]==1) {
201 fXInit[0]=fX[fIndLocal[0][0]][0];
202 fYInit[0]=fY[fIndLocal[0][0]][0];
203 fXInit[1]=fX[fIndLocal[0][0]][0];
204 fYInit[1]=fY[fIndLocal[0][0]][0];
206 fXInit[0]=fX[fIndLocal[0][1]][1];
207 fYInit[0]=fY[fIndLocal[0][1]][1];
208 fXInit[1]=fX[fIndLocal[0][1]][1];
209 fYInit[1]=fY[fIndLocal[0][1]][1];
212 // Initial value for charge ratios
215 AliDebug(1,"\n cas (1) CombiDoubleMathiesonFit(c)\n");
216 chi2=CombiDoubleMathiesonFit(c);
217 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
218 // Float_t prob = TMath::Prob(chi2,ndf);
219 // prob2->Fill(prob);
220 // chi2_2->Fill(chi2);
222 // Was this any better ??
223 AliDebug(1,Form(" Old and new chi2 %f %f ", oldchi2, chi2));
224 if (fFitStat!=0 && chi2>0 && (2.*chi2 < oldchi2)) {
226 // Split cluster into two according to fit result
229 AliDebug(1,"Do not Split");
235 // +++++++++++++++++++++++++++++++++++++++
236 // (2) Two local maxima per cathode plane
237 // +++++++++++++++++++++++++++++++++++++++
238 } else if (fNLocal[0]==2 && fNLocal[1]==2) {
240 // Let's look for ghosts first
242 Float_t xm[4][2], ym[4][2];
243 Float_t dpx, dpy, dx, dy;
244 Int_t ixm[4][2], iym[4][2];
245 Int_t isec, im1, im2, ico;
247 // Form the 2x2 combinations
248 // 0-0, 0-1, 1-0, 1-1
250 for (im1=0; im1<2; im1++) {
251 for (im2=0; im2<2; im2++) {
252 xm[ico][0]=fX[fIndLocal[im1][0]][0];
253 ym[ico][0]=fY[fIndLocal[im1][0]][0];
254 xm[ico][1]=fX[fIndLocal[im2][1]][1];
255 ym[ico][1]=fY[fIndLocal[im2][1]][1];
257 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
258 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
259 ixm[ico][1]=fIx[fIndLocal[im2][1]][1];
260 iym[ico][1]=fIy[fIndLocal[im2][1]][1];
264 // ico = 0 : first local maximum on cathodes 1 and 2
265 // ico = 1 : fisrt local maximum on cathode 1 and second on cathode 2
266 // ico = 2 : second local maximum on cathode 1 and first on cathode 1
267 // ico = 3 : second local maximum on cathodes 1 and 2
269 // Analyse the combinations and keep those that are possible !
270 // For each combination check consistency in x and y
273 Float_t dr[4] = {1.e4, 1.e4, 1.e4, 1.e4};
276 // In case of staggering maxima are displaced by exactly half the pad-size in y.
277 // We have to take into account the numerical precision in the consistency check;
280 for (ico=0; ico<4; ico++) {
281 accepted[ico]=kFALSE;
282 // cathode one: x-coordinate
283 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
284 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
286 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
287 // cathode two: y-coordinate
289 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
290 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
292 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
293 AliDebug(2,Form("\n %i %f %f %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy, dx, dpx ));
294 if ((dx <= dpx) && (dy <= dpy+eps)) {
297 dr[ico] = TMath::Sqrt(dx*dx+dy*dy);
301 accepted[ico]=kFALSE;
304 AliDebug(1,Form("\n iacc= %d:\n", iacc));
306 if (accepted[0] && accepted[1]) {
307 if (dr[0] >= dr[1]) {
314 if (accepted[2] && accepted[3]) {
315 if (dr[2] >= dr[3]) {
322 // eliminate one candidate
326 for (ico=0; ico<4; ico++) {
327 if (accepted[ico] && dr[ico] > drmax) {
333 accepted[icobad] = kFALSE;
339 AliDebug(1,Form("\n iacc= %d:\n", iacc));
341 AliDebug(1,"\n iacc=2: No problem ! \n");
342 } else if (iacc==4) {
343 AliDebug(1,"\n iacc=4: Ok, but ghost problem !!! \n");
344 } else if (iacc==0) {
345 AliDebug(1,"\n iacc=0: I don't know what to do with this !!!!!!!!! \n");
348 // Initial value for charge ratios
349 fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/
350 Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]);
351 fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/
352 Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]);
354 // ******* iacc = 0 *******
355 // No combinations found between the 2 cathodes
356 // We keep the center of gravity of the cluster
361 // ******* iacc = 1 *******
362 // Only one combination found between the 2 cathodes
364 // Initial values for the 2 maxima (x,y)
366 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
367 // 1 maximum is initialised with the other maximum of the first cathode
374 } else if (accepted[1]){
380 } else if (accepted[2]){
386 } else if (accepted[3]){
393 AliDebug(1,"cas (2) CombiDoubleMathiesonFit(c)");
394 chi2=CombiDoubleMathiesonFit(c);
395 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
396 // Float_t prob = TMath::Prob(chi2,ndf);
397 // prob2->Fill(prob);
398 // chi2_2->Fill(chi2);
399 AliDebug(1,Form(" chi2 %f\n",chi2));
401 // If reasonable chi^2 add result to the list of rawclusters
406 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
407 // 1 maximum is initialised with the other maximum of the second cathode
414 } else if (accepted[1]){
420 } else if (accepted[2]){
426 } else if (accepted[3]){
433 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
434 chi2=CombiDoubleMathiesonFit(c);
435 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
436 // Float_t prob = TMath::Prob(chi2,ndf);
437 // prob2->Fill(prob);
438 // chi2_2->Fill(chi2);
439 AliDebug(1,Form(" chi2 %f\n",chi2));
441 // If reasonable chi^2 add result to the list of rawclusters
445 //We keep only the combination found (X->cathode 2, Y->cathode 1)
446 for (Int_t ico=0; ico<2; ico++) {
448 AliMUONRawCluster cnew;
450 for (cath=0; cath<2; cath++) {
451 cnew.SetX(cath, Float_t(xm[ico][1]));
452 cnew.SetY(cath, Float_t(ym[ico][0]));
453 cnew.SetZ(cath, fZPlane);
454 cnew.SetMultiplicity(cath,c->GetMultiplicity(cath));
455 for (i=0; i<fMul[cath]; i++) {
456 cnew.SetIndex(i, cath, c->GetIndex(i,cath));
457 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
459 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
460 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
461 FillCluster(&cnew,cath);
463 cnew.SetClusterType(cnew.PhysicsContribution());
472 // ******* iacc = 2 *******
473 // Two combinations found between the 2 cathodes
475 // Was the same maximum taken twice
476 if ((accepted[0]&&accepted[1]) || (accepted[2]&&accepted[3])) {
477 AliDebug(1,"\n Maximum taken twice !!!\n");
479 // Have a try !! with that
480 if (accepted[0]&&accepted[3]) {
491 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
492 chi2=CombiDoubleMathiesonFit(c);
493 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
494 // Float_t prob = TMath::Prob(chi2,ndf);
495 // prob2->Fill(prob);
496 // chi2_2->Fill(chi2);
500 // No ghosts ! No Problems ! - Perform one fit only !
501 if (accepted[0]&&accepted[3]) {
512 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
513 chi2=CombiDoubleMathiesonFit(c);
514 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
515 // Float_t prob = TMath::Prob(chi2,ndf);
516 // prob2->Fill(prob);
517 // chi2_2->Fill(chi2);
518 AliDebug(1,Form(" chi2 %f\n",chi2));
522 // ******* iacc = 4 *******
523 // Four combinations found between the 2 cathodes
525 } else if (iacc==4) {
526 // Perform fits for the two possibilities !!
527 // Accept if charges are compatible on both cathodes
528 // If none are compatible, keep everything
533 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
534 chi2=CombiDoubleMathiesonFit(c);
535 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
536 // Float_t prob = TMath::Prob(chi2,ndf);
537 // prob2->Fill(prob);
538 // chi2_2->Fill(chi2);
539 AliDebug(1,Form(" chi2 %f\n",chi2));
540 // store results of fit and postpone decision
541 Double_t sXFit[2],sYFit[2],sQrFit[2];
543 for (Int_t i=0;i<2;i++) {
553 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
554 chi2=CombiDoubleMathiesonFit(c);
555 // ndf = fgNbins[0]+fgNbins[1]-6;
556 // prob = TMath::Prob(chi2,ndf);
557 // prob2->Fill(prob);
558 // chi2_2->Fill(chi2);
559 AliDebug(1,Form(" chi2 %f\n",chi2));
560 // We have all informations to perform the decision
561 // Compute the chi2 for the 2 possibilities
562 Float_t chi2fi,chi2si,chi2f,chi2s;
564 chi2f = (TMath::Log(fInput->TotalCharge(0)*fQrFit[0]
565 / (fInput->TotalCharge(1)*fQrFit[1]) )
566 / fInput->ChargeCorrel() );
568 chi2fi = (TMath::Log(fInput->TotalCharge(0)*(1-fQrFit[0])
569 / (fInput->TotalCharge(1)*(1-fQrFit[1])) )
570 / fInput->ChargeCorrel() );
571 chi2f += chi2fi*chi2fi;
573 chi2s = (TMath::Log(fInput->TotalCharge(0)*sQrFit[0]
574 / (fInput->TotalCharge(1)*sQrFit[1]) )
575 / fInput->ChargeCorrel() );
577 chi2si = (TMath::Log(fInput->TotalCharge(0)*(1-sQrFit[0])
578 / (fInput->TotalCharge(1)*(1-sQrFit[1])) )
579 / fInput->ChargeCorrel() );
580 chi2s += chi2si*chi2si;
582 // usefull to store the charge matching chi2 in the cluster
583 // fChi2[0]=sChi2[1]=chi2f;
584 // fChi2[1]=sChi2[0]=chi2s;
586 if (chi2f<=fGhostChi2Cut && chi2s<=fGhostChi2Cut)
588 if (chi2f>fGhostChi2Cut && chi2s>fGhostChi2Cut) {
594 if (chi2f<=fGhostChi2Cut)
596 if (chi2s<=fGhostChi2Cut) {
597 // retreive saved values
598 for (Int_t i=0;i<2;i++) {
609 } else if (fNLocal[0]==2 && fNLocal[1]==1) {
610 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
611 // (3) Two local maxima on cathode 1 and one maximum on cathode 2
612 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
614 Float_t xm[4][2], ym[4][2];
615 Float_t dpx, dpy, dx, dy;
616 Int_t ixm[4][2], iym[4][2];
617 Int_t isec, im1, ico;
619 // Form the 2x2 combinations
620 // 0-0, 0-1, 1-0, 1-1
622 for (im1=0; im1<2; im1++) {
623 xm[ico][0]=fX[fIndLocal[im1][0]][0];
624 ym[ico][0]=fY[fIndLocal[im1][0]][0];
625 xm[ico][1]=fX[fIndLocal[0][1]][1];
626 ym[ico][1]=fY[fIndLocal[0][1]][1];
628 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
629 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
630 ixm[ico][1]=fIx[fIndLocal[0][1]][1];
631 iym[ico][1]=fIy[fIndLocal[0][1]][1];
634 // ico = 0 : first local maximum on cathodes 1 and 2
635 // ico = 1 : second local maximum on cathode 1 and first on cathode 2
637 // Analyse the combinations and keep those that are possible !
638 // For each combination check consistency in x and y
642 // In case of staggering maxima are displaced by exactly half the pad-size in y.
643 // We have to take into account the numerical precision in the consistency check;
647 for (ico=0; ico<2; ico++) {
648 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
649 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
651 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
652 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
653 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
655 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
656 AliDebug(2,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
657 if ((dx <= dpx) && (dy <= dpy+eps)) {
663 accepted[ico]=kFALSE;
671 // Initial value for charge ratios
672 fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/
673 Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]);
674 fQrInit[1]=fQrInit[0];
676 if (accepted[0] && accepted[1]) {
678 fXInit[0]=0.5*(xm[0][1]+xm[0][0]);
680 fXInit[1]=0.5*(xm[0][1]+xm[1][0]);
684 chi23=CombiDoubleMathiesonFit(c);
693 } else if (accepted[0]) {
698 chi21=CombiDoubleMathiesonFit(c);
699 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
700 // Float_t prob = TMath::Prob(chi2,ndf);
701 // prob2->Fill(prob);
702 // chi2_2->Fill(chi21);
703 AliDebug(1,Form(" chi2 %f\n",chi21));
704 if (chi21<10) Split(c);
705 } else if (accepted[1]) {
710 chi22=CombiDoubleMathiesonFit(c);
711 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
712 // Float_t prob = TMath::Prob(chi2,ndf);
713 // prob2->Fill(prob);
714 // chi2_2->Fill(chi22);
715 AliDebug(1,Form(" chi2 %f\n",chi22));
716 if (chi22<10) Split(c);
719 if (chi21 > 10 && chi22 > 10 && chi23 > 10) {
720 // We keep only the combination found (X->cathode 2, Y->cathode 1)
721 for (Int_t ico=0; ico<2; ico++) {
723 AliMUONRawCluster cnew;
725 for (cath=0; cath<2; cath++) {
726 cnew.SetX(cath, Float_t(xm[ico][1]));
727 cnew.SetY(cath, Float_t(ym[ico][0]));
728 cnew.SetZ(cath, fZPlane);
729 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
730 for (i=0; i<fMul[cath]; i++) {
731 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
732 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
735 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
736 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
738 FillCluster(&cnew,cath);
740 cnew.SetClusterType(cnew.PhysicsContribution());
747 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
748 // (3') One local maximum on cathode 1 and two maxima on cathode 2
749 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
750 } else if (fNLocal[0]==1 && fNLocal[1]==2) {
751 Float_t xm[4][2], ym[4][2];
752 Float_t dpx, dpy, dx, dy;
753 Int_t ixm[4][2], iym[4][2];
754 Int_t isec, im1, ico;
756 // Form the 2x2 combinations
757 // 0-0, 0-1, 1-0, 1-1
759 for (im1=0; im1<2; im1++) {
760 xm[ico][0]=fX[fIndLocal[0][0]][0];
761 ym[ico][0]=fY[fIndLocal[0][0]][0];
762 xm[ico][1]=fX[fIndLocal[im1][1]][1];
763 ym[ico][1]=fY[fIndLocal[im1][1]][1];
765 ixm[ico][0]=fIx[fIndLocal[0][0]][0];
766 iym[ico][0]=fIy[fIndLocal[0][0]][0];
767 ixm[ico][1]=fIx[fIndLocal[im1][1]][1];
768 iym[ico][1]=fIy[fIndLocal[im1][1]][1];
771 // ico = 0 : first local maximum on cathodes 1 and 2
772 // ico = 1 : first local maximum on cathode 1 and second on cathode 2
774 // Analyse the combinations and keep those that are possible !
775 // For each combination check consistency in x and y
779 // In case of staggering maxima are displaced by exactly half the pad-size in y.
780 // We have to take into account the numerical precision in the consistency check;
784 for (ico=0; ico<2; ico++) {
785 accepted[ico]=kFALSE;
786 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
787 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
789 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
790 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
791 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
793 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
794 AliDebug(1,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
795 if ((dx <= dpx) && (dy <= dpy+eps)) {
798 AliDebug(1,Form("ico %d\n",ico));
802 accepted[ico]=kFALSE;
810 fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/
811 Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]);
813 fQrInit[0]=fQrInit[1];
816 if (accepted[0] && accepted[1]) {
818 fYInit[0]=0.5*(ym[0][0]+ym[0][1]);
820 fYInit[1]=0.5*(ym[0][0]+ym[1][1]);
823 chi23=CombiDoubleMathiesonFit(c);
832 } else if (accepted[0]) {
837 chi21=CombiDoubleMathiesonFit(c);
838 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
839 // Float_t prob = TMath::Prob(chi2,ndf);
840 // prob2->Fill(prob);
841 // chi2_2->Fill(chi21);
842 AliDebug(1,Form(" chi2 %f\n",chi21));
843 if (chi21<10) Split(c);
844 } else if (accepted[1]) {
849 chi22=CombiDoubleMathiesonFit(c);
850 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
851 // Float_t prob = TMath::Prob(chi2,ndf);
852 // prob2->Fill(prob);
853 // chi2_2->Fill(chi22);
854 AliDebug(1,Form(" chi2 %f\n",chi22));
855 if (chi22<10) Split(c);
858 if (chi21 > 10 && chi22 > 10 && chi23 > 10) {
859 //We keep only the combination found (X->cathode 2, Y->cathode 1)
860 for (Int_t ico=0; ico<2; ico++) {
862 AliMUONRawCluster cnew;
864 for (cath=0; cath<2; cath++) {
865 cnew.SetX(cath, Float_t(xm[ico][1]));
866 cnew.SetY(cath, Float_t(ym[ico][0]));
867 cnew.SetZ(cath, fZPlane);
868 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
869 for (i=0; i<fMul[cath]; i++) {
870 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
871 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
873 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
874 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
875 FillCluster(&cnew,cath);
877 cnew.SetClusterType(cnew.PhysicsContribution());
884 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
885 // (4) At least three local maxima on cathode 1 or on cathode 2
886 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
887 } else if (fNLocal[0]>2 || fNLocal[1]>2) {
888 Int_t param = fNLocal[0]*fNLocal[1];
891 Float_t ** xm = new Float_t * [param];
892 for (ii=0; ii<param; ii++) xm[ii]=new Float_t [2];
893 Float_t ** ym = new Float_t * [param];
894 for (ii=0; ii<param; ii++) ym[ii]=new Float_t [2];
895 Int_t ** ixm = new Int_t * [param];
896 for (ii=0; ii<param; ii++) ixm[ii]=new Int_t [2];
897 Int_t ** iym = new Int_t * [param];
898 for (ii=0; ii<param; ii++) iym[ii]=new Int_t [2];
901 Float_t dpx, dpy, dx, dy;
904 for (Int_t im1=0; im1<fNLocal[0]; im1++) {
905 for (Int_t im2=0; im2<fNLocal[1]; im2++) {
906 xm[ico][0]=fX[fIndLocal[im1][0]][0];
907 ym[ico][0]=fY[fIndLocal[im1][0]][0];
908 xm[ico][1]=fX[fIndLocal[im2][1]][1];
909 ym[ico][1]=fY[fIndLocal[im2][1]][1];
911 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
912 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
913 ixm[ico][1]=fIx[fIndLocal[im2][1]][1];
914 iym[ico][1]=fIy[fIndLocal[im2][1]][1];
920 AliDebug(1,Form("nIco %d\n",nIco));
921 for (ico=0; ico<nIco; ico++) {
922 AliDebug(1,Form("ico = %d\n",ico));
923 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
924 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
926 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
927 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
928 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
930 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
931 AliDebug(1,Form("dx %f dpx %f dy %f dpy %f\n",dx,dpx,dy,dpy));
932 AliDebug(1,Form(" X %f Y %f\n",xm[ico][1],ym[ico][0]));
933 if ((dx <= dpx) && (dy <= dpy)) {
936 AliMUONRawCluster cnew;
937 for (cath=0; cath<2; cath++) {
938 cnew.SetX(cath, Float_t(xm[ico][1]));
939 cnew.SetY(cath, Float_t(ym[ico][0]));
940 cnew.SetZ(cath, fZPlane);
941 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
942 for (i=0; i<fMul[cath]; i++) {
943 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
944 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
946 FillCluster(&cnew,cath);
948 cnew.SetClusterType(cnew.PhysicsContribution());
949 // cnew.SetDetElemId(fInput->DetElemId());
961 void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
963 /// Find all local maxima of a cluster
964 AliDebug(1,"\n Find Local maxima !");
968 Int_t cath, cath1; // loops over cathodes
969 Int_t i; // loops over digits
970 Int_t j; // loops over cathodes
974 // counters for number of local maxima
975 fNLocal[0]=fNLocal[1]=0;
976 // flags digits as local maximum
977 Bool_t isLocal[100][2];
978 for (i=0; i<100;i++) {
979 isLocal[i][0]=isLocal[i][1]=kFALSE;
981 // number of next neighbours and arrays to store them
984 // loop over cathodes
985 for (cath=0; cath<2; cath++) {
986 // loop over cluster digits
987 for (i=0; i<fMul[cath]; i++) {
988 // get neighbours for that digit and assume that it is local maximum
992 fSeg2[cath]->Neighbours(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], &nn, x, y);
994 isLocal[i][cath]=kTRUE;
995 isec = fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
996 a0 = fSeg2[cath]->Dpx(fInput->DetElemId(), isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
998 // loop over next neighbours, if at least one neighbour has higher charger assumption
999 // digit is not local maximum
1000 for (j=0; j<nn; j++) {
1001 if (fDigitMap[cath]->TestHit(x[j], y[j])==kEmpty) continue;
1002 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(x[j], y[j]);
1004 isec=fSeg2[cath]->Sector(fInput->DetElemId(), x[j], y[j]);
1005 a1 = fSeg2[cath]->Dpx(fInput->DetElemId(),isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1007 if (digt->Signal()/a1 > fQ[i][cath]/a0) {
1008 isLocal[i][cath]=kFALSE;
1011 // handle special case of neighbouring pads with equal signal
1012 } else if (digt->Signal() == fQ[i][cath]) {
1013 if (fNLocal[cath]>0) {
1014 for (Int_t k=0; k<fNLocal[cath]; k++) {
1015 if (x[j]==fIx[fIndLocal[k][cath]][cath]
1016 && y[j]==fIy[fIndLocal[k][cath]][cath])
1018 isLocal[i][cath]=kFALSE;
1020 } // loop over local maxima
1021 } // are there already local maxima
1023 } // loop over next neighbours
1024 if (isLocal[i][cath]) {
1025 fIndLocal[fNLocal[cath]][cath]=i;
1028 } // loop over all digits
1029 } // loop over cathodes
1031 AliDebug(1,Form("\n Found %d %d %d %d local Maxima\n",
1032 fNLocal[0], fNLocal[1], fMul[0], fMul[1]));
1033 AliDebug(1,Form("\n Cathode 1 local Maxima %d Multiplicite %d\n",fNLocal[0], fMul[0]));
1034 AliDebug(1,Form(" Cathode 2 local Maxima %d Multiplicite %d\n",fNLocal[1], fMul[1]));
1039 if (fNLocal[1]==2 && (fNLocal[0]==1 || fNLocal[0]==0)) {
1040 Int_t iback=fNLocal[0];
1042 // Two local maxima on cathode 2 and one maximum on cathode 1
1043 // Look for local maxima considering up and down neighbours on the 1st cathode only
1045 // Loop over cluster digits
1049 for (i=0; i<fMul[cath]; i++) {
1050 isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
1051 dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1052 dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1054 if (isLocal[i][cath]) continue;
1055 // Pad position should be consistent with position of local maxima on the opposite cathode
1056 if ((TMath::Abs(fX[i][cath]-fX[fIndLocal[0][cath1]][cath1]) > dpx/2.) &&
1057 (TMath::Abs(fX[i][cath]-fX[fIndLocal[1][cath1]][cath1]) > dpx/2.))
1060 // get neighbours for that digit and assume that it is local maximum
1061 isLocal[i][cath]=kTRUE;
1062 // compare signal to that on the two neighbours on the left and on the right
1063 // iNN counts the number of neighbours with signal, it should be 1 or 2
1067 for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, 0., dpy);
1068 fSeg2[cath]->MorePads(fInput->DetElemId());
1069 fSeg2[cath]->NextPad(fInput->DetElemId()))
1071 ix = fSeg2[cath]->Ix();
1072 iy = fSeg2[cath]->Iy();
1073 // skip the current pad
1074 if (iy == fIy[i][cath]) continue;
1076 if (fDigitMap[cath]->TestHit(ix, iy)!=kEmpty) {
1078 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(ix,iy);
1079 if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
1081 } // Loop over pad neighbours in y
1083 if (isLocal[i][cath] && iNN>0) {
1084 fIndLocal[fNLocal[cath]][cath]=i;
1087 } // loop over all digits
1088 // if one additional maximum has been found we are happy
1089 // if more maxima have been found restore the previous situation
1090 AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",
1092 AliDebug(1,Form(" %d local maxima for cathode 2 \n",
1094 if (fNLocal[cath]>2) {
1095 fNLocal[cath]=iback;
1098 } // 1,2 local maxima
1100 if (fNLocal[0]==2 && (fNLocal[1]==1 || fNLocal[1]==0)) {
1101 Int_t iback=fNLocal[1];
1103 // Two local maxima on cathode 1 and one maximum on cathode 2
1104 // Look for local maxima considering left and right neighbours on the 2nd cathode only
1107 Float_t eps = 1.e-5;
1110 // Loop over cluster digits
1111 for (i=0; i<fMul[cath]; i++) {
1112 isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
1113 dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1114 dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1117 if (isLocal[i][cath]) continue;
1118 // Pad position should be consistent with position of local maxima on the opposite cathode
1119 if ((TMath::Abs(fY[i][cath]-fY[fIndLocal[0][cath1]][cath1]) > dpy/2.+eps) &&
1120 (TMath::Abs(fY[i][cath]-fY[fIndLocal[1][cath1]][cath1]) > dpy/2.+eps))
1124 // get neighbours for that digit and assume that it is local maximum
1125 isLocal[i][cath]=kTRUE;
1126 // compare signal to that on the two neighbours on the left and on the right
1128 // iNN counts the number of neighbours with signal, it should be 1 or 2
1130 for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, dpx, 0.);
1131 fSeg2[cath]->MorePads(fInput->DetElemId());
1132 fSeg2[cath]->NextPad(fInput->DetElemId()))
1135 ix = fSeg2[cath]->Ix();
1136 iy = fSeg2[cath]->Iy();
1138 // skip the current pad
1139 if (ix == fIx[i][cath]) continue;
1141 if (fDigitMap[cath]->TestHit(ix, iy)!=kEmpty) {
1143 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(ix,iy);
1144 if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
1146 } // Loop over pad neighbours in x
1148 if (isLocal[i][cath] && iNN>0) {
1149 fIndLocal[fNLocal[cath]][cath]=i;
1152 } // loop over all digits
1153 // if one additional maximum has been found we are happy
1154 // if more maxima have been found restore the previous situation
1155 AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",fNLocal[0]));
1156 AliDebug(1,Form("\n %d local maxima for cathode 2 \n",fNLocal[1]));
1157 AliDebug(1,Form("\n New search gives %d %d \n",fNLocal[0],fNLocal[1]));
1158 if (fNLocal[cath]>2) {
1159 fNLocal[cath]=iback;
1161 } // 2,1 local maxima
1165 void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t flag, Int_t cath)
1167 /// Completes cluster information starting from list of digits
1174 c->SetPeakSignal(cath,c->GetPeakSignal(0));
1176 c->SetPeakSignal(cath,0);
1183 c->SetCharge(cath,0);
1186 AliDebug(1,Form("\n fPeakSignal %d\n",c->GetPeakSignal(cath)));
1187 for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
1189 dig= fInput->Digit(cath,c->GetIndex(i,cath));
1190 ix=dig->PadX()+c->GetOffset(i,cath);
1192 Float_t q=dig->Signal();
1193 if (!flag) q *= c->GetContrib(i,cath);
1194 // fprintf(stderr,"q %d c->fPeakSignal[ %d ] %d\n",q,cath,c->fPeakSignal[cath]);
1195 if (dig->Physics() >= dig->Signal()) {
1197 } else if (dig->Physics() == 0) {
1199 } else c->SetPhysics(i,1);
1202 AliDebug(2,Form("q %d c->fPeakSignal[cath] %d\n",q,c->GetPeakSignal(cath)));
1203 // peak signal and track list
1204 if (q>c->GetPeakSignal(cath)) {
1205 c->SetPeakSignal(cath, q);
1206 c->SetTrack(0,dig->Hit());
1207 c->SetTrack(1,dig->Track(0));
1208 c->SetTrack(2,dig->Track(1));
1209 // fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->fHit,dig->fTracks[0]);
1213 fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
1217 c->AddCharge(cath, q);
1219 } // loop over digits
1220 AliDebug(1," fin du cluster c\n");
1224 c->SetX(cath, c->GetX(cath)/c->GetCharge(cath));
1226 c->SetX(cath, fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
1227 c->SetY(cath, c->GetY(cath)/c->GetCharge(cath));
1229 // apply correction to the coordinate along the anode wire
1235 fSeg2[cath]->GetPadI(fInput->DetElemId(), x, y, fZPlane, ix, iy);
1236 fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
1237 isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix,iy);
1238 cogCorr = fSeg2[cath]->CorrFunc(fInput->DetElemId(), isec-1);
1243 yOnPad=(c->GetY(cath)-y)/fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1245 c->SetY(cath, c->GetY(cath)-cogCorr->Eval(yOnPad, 0, 0));
1246 // slat ID from digit
1252 void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t cath)
1254 /// Completes cluster information starting from list of digits
1264 Float_t xpad, ypad, zpad;
1267 for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
1269 dig = fInput->Digit(cath,c->GetIndex(i,cath));
1271 GetPadC(fInput->DetElemId(),dig->PadX(),dig->PadY(),xpad,ypad, zpad);
1272 AliDebug(1,Form("x %f y %f cx %f cy %f\n",xpad,ypad,c->GetX(0),c->GetY(0)));
1273 dx = xpad - c->GetX(0);
1274 dy = ypad - c->GetY(0);
1275 dr = TMath::Sqrt(dx*dx+dy*dy);
1279 AliDebug(1,Form(" dr %f\n",dr));
1280 Float_t q=dig->Signal();
1281 if (dig->Physics() >= dig->Signal()) {
1283 } else if (dig->Physics() == 0) {
1285 } else c->SetPhysics(i,1);
1286 c->SetPeakSignal(cath,q);
1287 c->SetTrack(0,dig->Hit());
1288 c->SetTrack(1,dig->Track(0));
1289 c->SetTrack(2,dig->Track(1));
1291 AliDebug(1,Form(" c->fTracks[0] %d c->fTracks[1] %d\n",dig->Hit(),
1295 } // loop over digits
1297 // apply correction to the coordinate along the anode wire
1299 c->SetX(cath,fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
1302 void AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONRawCluster &c)
1304 /// Find a super cluster on both cathodes
1305 /// Add i,j as element of the cluster
1307 Int_t idx = fDigitMap[cath]->GetHitIndex(i,j);
1308 AliMUONDigit* dig = (AliMUONDigit*) fDigitMap[cath]->GetHit(i,j);
1309 Float_t q=dig->Signal();
1310 Int_t theX=dig->PadX();
1311 Int_t theY=dig->PadY();
1313 if (q > TMath::Abs(c.GetPeakSignal(0)) && q > TMath::Abs(c.GetPeakSignal(1))) {
1314 c.SetPeakSignal(cath,q);
1315 c.SetTrack(0,dig->Hit());
1316 c.SetTrack(1,dig->Track(0));
1317 c.SetTrack(2,dig->Track(1));
1321 // Make sure that list of digits is ordered
1323 Int_t mu=c.GetMultiplicity(cath);
1324 c.SetIndex(mu, cath, idx);
1326 if (dig->Physics() >= dig->Signal()) {
1328 } else if (dig->Physics() == 0) {
1330 } else c.SetPhysics(mu,1);
1334 for (Int_t ind = mu-1; ind >= 0; ind--) {
1335 Int_t ist=c.GetIndex(ind,cath);
1336 Float_t ql=fInput->Digit(cath, ist)->Signal();
1337 Int_t ix=fInput->Digit(cath, ist)->PadX();
1338 Int_t iy=fInput->Digit(cath, ist)->PadY();
1340 if (q>ql || (q==ql && theX > ix && theY < iy)) {
1341 c.SetIndex(ind, cath, idx);
1342 c.SetIndex(ind+1, cath, ist);
1350 c.SetMultiplicity(cath, c.GetMultiplicity(cath)+1);
1351 if (c.GetMultiplicity(cath) >= 50 ) {
1352 AliDebug(1,Form("FindCluster - multiplicity >50 %d \n",c.GetMultiplicity(0)));
1353 c.SetMultiplicity(cath, 49);
1356 // Prepare center of gravity calculation
1358 fSeg2[cath]->GetPadC(fInput->DetElemId(), i, j, x, y, z);
1361 c.AddCharge(cath,q);
1363 // Flag hit as "taken"
1364 fDigitMap[cath]->FlagHit(i,j);
1366 // Now look recursively for all neighbours and pad hit on opposite cathode
1368 // Loop over neighbours
1372 Int_t xList[10], yList[10];
1373 fSeg2[cath]->Neighbours(fInput->DetElemId(), i,j,&nn,xList,yList);
1374 for (Int_t in=0; in<nn; in++) {
1378 if (fDigitMap[cath]->TestHit(ix,iy)==kUnused) {
1379 AliDebug(2,Form("\n Neighbours %d %d %d", cath, ix, iy));
1380 FindCluster(ix, iy, cath, c);
1385 Int_t iXopp[50], iYopp[50];
1387 // Neighbours on opposite cathode
1388 // Take into account that several pads can overlap with the present pad
1390 isec=fSeg2[cath]->Sector(fInput->DetElemId(), i,j);
1397 dx = (fSeg2[cath]->Dpx(fInput->DetElemId(), isec))/2.;
1402 dy = (fSeg2[cath]->Dpy(fInput->DetElemId(), isec))/2;
1407 // loop over pad neighbours on opposite cathode
1408 for (fSeg2[iop]->FirstPad(fInput->DetElemId(), x, y, fZPlane, dx, dy);
1409 fSeg2[iop]->MorePads(fInput->DetElemId());
1410 fSeg2[iop]->NextPad(fInput->DetElemId()))
1413 ix = fSeg2[iop]->Ix(); iy = fSeg2[iop]->Iy();
1414 AliDebug(2,Form("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector));
1415 if (fDigitMap[iop]->TestHit(ix,iy)==kUnused){
1418 AliDebug(2,Form("\n Opposite %d %d %d", iop, ix, iy));
1421 } // Loop over pad neighbours
1422 // This had to go outside the loop since recursive calls inside the iterator are not possible
1425 for (jopp=0; jopp<nOpp; jopp++) {
1426 if (fDigitMap[iop]->TestHit(iXopp[jopp],iYopp[jopp]) == kUnused)
1427 FindCluster(iXopp[jopp], iYopp[jopp], iop, c);
1432 //_____________________________________________________________________________
1434 void AliMUONClusterFinderVS::FindRawClusters()
1436 /// MUON cluster finder from digits -- finds neighbours on both cathodes and
1437 /// fills the tree with raw clusters
1440 // Return if no input datad available
1441 if (!fInput->NDigits(0) && !fInput->NDigits(1)) return;
1443 fSeg2[0] = fInput->Segmentation2(0);
1444 fSeg2[1] = fInput->Segmentation2(1);
1446 Int_t detElemId = fInput->DetElemId();
1448 Int_t npx0 = fSeg2[0]->Npx(detElemId)+1;
1449 Int_t npy0 = fSeg2[0]->Npy(detElemId)+1;
1450 fDigitMap[0] = new AliMUONDigitMapA1(detElemId, npx0, npy0);
1452 Int_t npx1 = fSeg2[0]->Npx(detElemId)+1;
1453 Int_t npy1 = fSeg2[0]->Npy(detElemId)+1;
1454 fDigitMap[1] = new AliMUONDigitMapA1(detElemId, npx1, npy1);
1462 fDigitMap[0]->FillHits(fInput->Digits(0));
1463 fDigitMap[1]->FillHits(fInput->Digits(1));
1465 // Outer Loop over Cathodes
1466 for (cath = 0; cath < 2; cath++) {
1468 for (ndig=0; ndig<fInput->NDigits(cath); ndig++) {
1469 dig = fInput->Digit(cath, ndig);
1470 Int_t padx = dig->PadX();
1471 Int_t pady = dig->PadY();
1472 if (fDigitMap[cath]->TestHit(padx,pady)==kUsed ||fDigitMap[0]->TestHit(padx,pady)==kEmpty) {
1476 AliDebug(1,Form("\n CATHODE %d CLUSTER %d\n",cath,ncls));
1477 AliMUONRawCluster clus;
1478 clus.SetMultiplicity(0, 0);
1479 clus.SetMultiplicity(1, 0);
1480 clus.SetPeakSignal(cath,dig->Signal());
1481 clus.SetTrack(0, dig->Hit());
1482 clus.SetTrack(1, dig->Track(0));
1483 clus.SetTrack(2, dig->Track(1));
1485 AliDebug(1,Form("idDE %d Padx %d Pady %d", fInput->DetElemId(), padx, pady));
1487 // tag the beginning of cluster list in a raw cluster
1488 clus.SetNcluster(0,-1);
1490 fSeg2[cath]->GetPadC(fInput->DetElemId(), padx, pady, xcu, ycu, fZPlane);
1491 fSector= fSeg2[cath]->Sector(fInput->DetElemId(), padx, pady)/100;
1496 FindCluster(padx,pady,cath,clus);
1497 //^^^^^^^^^^^^^^^^^^^^^^^^
1498 // center of gravity
1499 if (clus.GetX(0)!=0.) clus.SetX(0, clus.GetX(0)/clus.GetCharge(0)); // clus.fX[0] /= clus.fQ[0];
1502 clus.SetX(0,fSeg2[0]->GetAnod(fInput->DetElemId(), clus.GetX(0)));
1503 if (clus.GetY(0)!=0.) clus.SetY(0, clus.GetY(0)/clus.GetCharge(0)); // clus.fY[0] /= clus.fQ[0];
1505 if(clus.GetCharge(1)!=0.) clus.SetX(1, clus.GetX(1)/clus.GetCharge(1)); // clus.fX[1] /= clus.fQ[1];
1508 clus.SetX(1, fSeg2[0]->GetAnod(fInput->DetElemId(),clus.GetX(1)));
1509 if(clus.GetCharge(1)!=0.) clus.SetY(1, clus.GetY(1)/clus.GetCharge(1));// clus.fY[1] /= clus.fQ[1];
1511 clus.SetZ(0, fZPlane);
1512 clus.SetZ(1, fZPlane);
1514 AliDebug(1,Form("\n Cathode 1 multiplicite %d X(CG) %f Y(CG) %f\n",
1515 clus.GetMultiplicity(0),clus.GetX(0),clus.GetY(0)));
1516 AliDebug(1,Form(" Cathode 2 multiplicite %d X(CG) %f Y(CG) %f\n",
1517 clus.GetMultiplicity(1),clus.GetX(1),clus.GetY(1)));
1518 // Analyse cluster and decluster if necessary
1521 clus.SetNcluster(1,fNRawClusters);
1522 clus.SetClusterType(clus.PhysicsContribution());
1529 // reset Cluster object
1530 { // begin local scope
1531 for (int k=0;k<clus.GetMultiplicity(0);k++) clus.SetIndex(k, 0, 0);
1532 } // end local scope
1534 { // begin local scope
1535 for (int k=0;k<clus.GetMultiplicity(1);k++) clus.SetIndex(k, 1, 0);
1536 } // end local scope
1538 clus.SetMultiplicity(0,0);
1539 clus.SetMultiplicity(1,0);
1543 } // end loop cathodes
1544 delete fDigitMap[0];
1545 delete fDigitMap[1];
1548 Float_t AliMUONClusterFinderVS::SingleMathiesonFit(AliMUONRawCluster *c, Int_t cath)
1550 /// Performs a single Mathieson fit on one cathode
1552 Double_t arglist[20];
1554 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1556 clusterInput.Fitter()->SetFCN(fcnS1);
1557 clusterInput.Fitter()->mninit(2,10,7);
1558 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1560 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1561 // Set starting values
1562 static Double_t vstart[2];
1563 vstart[0]=c->GetX(1);
1564 vstart[1]=c->GetY(0);
1567 // lower and upper limits
1568 static Double_t lower[2], upper[2];
1570 fSeg2[cath]->GetPadI(fInput->DetElemId(), c->GetX(cath), c->GetY(cath), fZPlane, ix, iy);
1571 isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix, iy);
1573 lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(), isec)/2;
1574 lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(), isec)/2;
1576 upper[0]=lower[0]+fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1577 upper[1]=lower[1]+fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1581 static Double_t step[2]={0.0005, 0.0005};
1583 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1584 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1585 // ready for minimisation
1589 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1590 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1591 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1592 Double_t fmin, fedm, errdef;
1593 Int_t npari, nparx, istat;
1595 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1599 // Get fitted parameters
1600 Double_t xrec, yrec;
1602 Double_t epxz, b1, b2;
1604 clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg);
1605 clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg);
1611 Float_t AliMUONClusterFinderVS::CombiSingleMathiesonFit(AliMUONRawCluster * /*c*/)
1613 /// Perform combined Mathieson fit on both cathode planes
1615 Double_t arglist[20];
1617 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1618 clusterInput.Fitter()->SetFCN(fcnCombiS1);
1619 clusterInput.Fitter()->mninit(2,10,7);
1620 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1622 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1623 static Double_t vstart[2];
1624 vstart[0]=fXInit[0];
1625 vstart[1]=fYInit[0];
1628 // lower and upper limits
1629 static Float_t lower[2], upper[2];
1633 fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1634 isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
1635 dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
1636 fSeg2[1]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1637 isec=fSeg2[1]->Sector(fInput->DetElemId(), ix, iy);
1638 dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
1641 Float_t xdum, ydum, zdum;
1643 // Find save upper and lower limits
1646 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.);
1647 fSeg2[1]->MorePads(fInput->DetElemId());
1648 fSeg2[1]->NextPad(fInput->DetElemId()))
1650 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1651 fSeg2[1]->GetPadC(fInput->DetElemId(), ix,iy, upper[0], ydum, zdum);
1652 if (icount ==0) lower[0]=upper[0];
1656 if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
1659 AliDebug(1,Form("\n single y %f %f", fXInit[0], fYInit[0]));
1661 for (fSeg2[0]->FirstPad(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, 0., dpy);
1662 fSeg2[0]->MorePads(fInput->DetElemId());
1663 fSeg2[0]->NextPad(fInput->DetElemId()))
1665 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1666 fSeg2[0]->GetPadC(fInput->DetElemId(), ix,iy,xdum,upper[1],zdum);
1667 if (icount ==0) lower[1]=upper[1];
1669 AliDebug(1,Form("\n upper lower %d %f %f", icount, upper[1], lower[1]));
1672 if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
1675 static Double_t step[2]={0.00001, 0.0001};
1677 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1678 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1679 // ready for minimisation
1683 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1684 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1685 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1686 Double_t fmin, fedm, errdef;
1687 Int_t npari, nparx, istat;
1689 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1693 // Get fitted parameters
1694 Double_t xrec, yrec;
1696 Double_t epxz, b1, b2;
1698 clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg);
1699 clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg);
1705 Bool_t AliMUONClusterFinderVS::DoubleMathiesonFit(AliMUONRawCluster * /*c*/, Int_t cath)
1707 /// Performs a double Mathieson fit on one cathode
1710 // Initialise global variables for fit
1711 Double_t arglist[20];
1713 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1714 clusterInput.Fitter()->SetFCN(fcnS2);
1715 clusterInput.Fitter()->mninit(5,10,7);
1716 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1718 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1719 // Set starting values
1720 static Double_t vstart[5];
1721 vstart[0]=fX[fIndLocal[0][cath]][cath];
1722 vstart[1]=fY[fIndLocal[0][cath]][cath];
1723 vstart[2]=fX[fIndLocal[1][cath]][cath];
1724 vstart[3]=fY[fIndLocal[1][cath]][cath];
1725 vstart[4]=Float_t(fQ[fIndLocal[0][cath]][cath])/
1726 Float_t(fQ[fIndLocal[0][cath]][cath]+fQ[fIndLocal[1][cath]][cath]);
1727 // lower and upper limits
1728 static Float_t lower[5], upper[5];
1731 isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[0][cath]][cath],
1732 fIy[fIndLocal[0][cath]][cath]);
1733 lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1734 lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1736 upper[0]=lower[0]+2.*fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1737 upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1739 isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[1][cath]][cath],
1740 fIy[fIndLocal[1][cath]][cath]);
1741 lower[2]=vstart[2]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec)/2;
1742 lower[3]=vstart[3]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec)/2;
1744 upper[2]=lower[2]+fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1745 upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1752 static Double_t step[5]={0.0005, 0.0005, 0.0005, 0.0005, 0.0001};
1754 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1755 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1756 clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
1757 clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
1758 clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
1759 // ready for minimisation
1763 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1764 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1765 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1766 // Get fitted parameters
1767 Double_t xrec[2], yrec[2], qfrac;
1769 Double_t epxz, b1, b2;
1771 clusterInput.Fitter()->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
1772 clusterInput.Fitter()->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
1773 clusterInput.Fitter()->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
1774 clusterInput.Fitter()->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
1775 clusterInput.Fitter()->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
1777 Double_t fmin, fedm, errdef;
1778 Int_t npari, nparx, istat;
1780 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1785 Float_t AliMUONClusterFinderVS::CombiDoubleMathiesonFit(AliMUONRawCluster * /*c*/)
1787 /// Perform combined double Mathieson fit on both cathode planes
1789 Double_t arglist[20];
1791 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1792 clusterInput.Fitter()->SetFCN(fcnCombiS2);
1793 clusterInput.Fitter()->mninit(6,10,7);
1794 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1796 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1797 // Set starting values
1798 static Double_t vstart[6];
1799 vstart[0]=fXInit[0];
1800 vstart[1]=fYInit[0];
1801 vstart[2]=fXInit[1];
1802 vstart[3]=fYInit[1];
1803 vstart[4]=fQrInit[0];
1804 vstart[5]=fQrInit[1];
1805 // lower and upper limits
1806 static Float_t lower[6], upper[6];
1810 fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, ix, iy);
1811 isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
1812 dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
1814 fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1815 isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
1816 dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
1821 Float_t xdum, ydum, zdum;
1822 AliDebug(1,Form("\n Cluster Finder: %f %f %f %f ", fXInit[0], fXInit[1],fYInit[0], fYInit[1] ));
1824 // Find save upper and lower limits
1827 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.);
1828 fSeg2[1]->MorePads(fInput->DetElemId());
1829 fSeg2[1]->NextPad(fInput->DetElemId()))
1831 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1832 // if (fDigitMap[1]->TestHit(ix, iy) == kEmpty) continue;
1833 fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[0],ydum,zdum);
1834 if (icount ==0) lower[0]=upper[0];
1837 if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
1838 // vstart[0] = 0.5*(lower[0]+upper[0]);
1843 for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, 0., dpy);
1844 fSeg2[0]->MorePads(fInput->DetElemId());
1845 fSeg2[0]->NextPad(fInput->DetElemId()))
1847 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1848 // if (fDigitMap[0]->TestHit(ix, iy) == kEmpty) continue;
1849 fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[1],zdum);
1850 if (icount ==0) lower[1]=upper[1];
1854 if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
1855 // vstart[1] = 0.5*(lower[1]+upper[1]);
1858 fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
1859 isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
1860 dpx=fSeg2[1]->Dpx(fInput->DetElemId(),isec);
1861 fSeg2[0]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
1862 isec=fSeg2[0]->Sector(fInput->DetElemId(),ix, iy);
1863 dpy=fSeg2[0]->Dpy(fInput->DetElemId(),isec);
1866 // Find save upper and lower limits
1870 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, dpx, 0);
1871 fSeg2[1]->MorePads(fInput->DetElemId());
1872 fSeg2[1]->NextPad(fInput->DetElemId()))
1874 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1875 // if (fDigitMap[1]->TestHit(ix, iy) == kEmpty) continue;
1876 fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[2],ydum,zdum);
1877 if (icount ==0) lower[2]=upper[2];
1880 if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;}
1881 // vstart[2] = 0.5*(lower[2]+upper[2]);
1885 for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, 0, dpy);
1886 fSeg2[0]-> MorePads(fInput->DetElemId());
1887 fSeg2[0]->NextPad(fInput->DetElemId()))
1889 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1890 // if (fDigitMap[0]->TestHit(ix, iy) != kEmpty) continue;
1892 fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[3],zdum);
1893 if (icount ==0) lower[3]=upper[3];
1897 if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;}
1905 static Double_t step[6]={0.0005, 0.0005, 0.0005, 0.0005, 0.001, 0.001};
1906 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1907 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1908 clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
1909 clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
1910 clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
1911 clusterInput.Fitter()->mnparm(5,"a1",vstart[5],step[5],lower[5],upper[5],ierflag);
1912 // ready for minimisation
1916 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1917 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1918 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1919 // Get fitted parameters
1921 Double_t epxz, b1, b2;
1923 clusterInput.Fitter()->mnpout(0, chname, fXFit[0], epxz, b1, b2, ierflg);
1924 clusterInput.Fitter()->mnpout(1, chname, fYFit[0], epxz, b1, b2, ierflg);
1925 clusterInput.Fitter()->mnpout(2, chname, fXFit[1], epxz, b1, b2, ierflg);
1926 clusterInput.Fitter()->mnpout(3, chname, fYFit[1], epxz, b1, b2, ierflg);
1927 clusterInput.Fitter()->mnpout(4, chname, fQrFit[0], epxz, b1, b2, ierflg);
1928 clusterInput.Fitter()->mnpout(5, chname, fQrFit[1], epxz, b1, b2, ierflg);
1930 Double_t fmin, fedm, errdef;
1931 Int_t npari, nparx, istat;
1933 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1941 void AliMUONClusterFinderVS::Split(AliMUONRawCluster* c)
1943 /// One cluster for each maximum
1946 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1947 for (j=0; j<2; j++) {
1948 AliMUONRawCluster cnew;
1949 cnew.SetGhost(c->GetGhost());
1950 for (cath=0; cath<2; cath++) {
1951 cnew.SetChi2(cath,fChi2[0]);
1952 // ?? why not cnew.fChi2[cath]=fChi2[cath];
1955 cnew.SetNcluster(0,-1);
1956 cnew.SetNcluster(1,fNRawClusters);
1958 cnew.SetNcluster(0,fNPeaks);
1959 cnew.SetNcluster(1,0);
1961 cnew.SetMultiplicity(cath,0);
1962 cnew.SetX(cath, Float_t(fXFit[j]));
1963 cnew.SetY(cath, Float_t(fYFit[j]));
1964 cnew.SetZ(cath, fZPlane);
1966 cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*fQrFit[cath]));
1968 cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*(1-fQrFit[cath])));
1970 fSeg2[cath]->SetHit(fInput->DetElemId(), fXFit[j],fYFit[j],fZPlane);
1972 for (i=0; i<fMul[cath]; i++) {
1974 cnew.SetIndex(cnew.GetMultiplicity(cath), cath, c->GetIndex(i,cath));
1976 fSeg2[cath]->SetPad(fInput->DetElemId(),fIx[i][cath], fIy[i][cath]);
1977 q1 = fInput->Mathieson()->IntXY(fInput->DetElemId(),fSeg2[cath]);
1979 cnew.SetContrib(i, cath, q1*Float_t(cnew.GetCharge(cath))/Float_t(fQ[i][cath]));
1980 cnew.SetMultiplicity(cath, cnew.GetMultiplicity(cath)+1 );
1982 FillCluster(&cnew,0,cath);
1984 cnew.SetClusterType(cnew.PhysicsContribution());
1985 if (cnew.GetCharge(0)>0 && cnew.GetCharge(1)>0) AddRawCluster(cnew);
1989 void AliMUONClusterFinderVS::AddRawCluster(AliMUONRawCluster& c)
1991 /// Add a raw cluster copy to the list
1993 // AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON");
1994 // pMUON->GetMUONData()->AddRawCluster(fInput->Chamber(),c);
1997 // Setting detection element in raw cluster for alignment
1999 c.SetDetElemId(fInput->DetElemId());
2001 TClonesArray &lrawcl = *fRawClusters;
2002 new(lrawcl[fNRawClusters++]) AliMUONRawCluster(c);
2003 AliDebug(1,Form("\nfNRawClusters %d\n",fNRawClusters));
2006 AliMUONClusterFinderVS& AliMUONClusterFinderVS
2007 ::operator = (const AliMUONClusterFinderVS& rhs)
2009 // Protected assignement operator
2011 if (this == &rhs) return *this;
2013 AliFatal("Not implemented.");
2019 // Minimisation functions
2021 void fcnS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2023 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2030 for (i=0; i<clusterInput.Nmul(0); i++) {
2031 Float_t q0=clusterInput.Charge(i,0);
2032 Float_t q1=clusterInput.DiscrChargeS1(i,par);
2041 void fcnCombiS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2043 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2050 for (cath=0; cath<2; cath++) {
2051 for (i=0; i<clusterInput.Nmul(cath); i++) {
2052 Float_t q0=clusterInput.Charge(i,cath);
2053 Float_t q1=clusterInput.DiscrChargeCombiS1(i,par,cath);
2064 void fcnS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2066 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2073 for (i=0; i<clusterInput.Nmul(0); i++) {
2075 Float_t q0=clusterInput.Charge(i,0);
2076 Float_t q1=clusterInput.DiscrChargeS2(i,par);
2086 void fcnCombiS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2088 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2094 for (cath=0; cath<2; cath++) {
2095 for (i=0; i<clusterInput.Nmul(cath); i++) {
2096 Float_t q0=clusterInput.Charge(i,cath);
2097 Float_t q1=clusterInput.DiscrChargeCombiS2(i,par,cath);