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);
47 ClassImp(AliMUONClusterFinderVS)
49 AliMUONClusterFinderVS::AliMUONClusterFinderVS()
51 fInput(AliMUONClusterInput::Instance()),
63 /// Default constructor
66 fTrack[0]=fTrack[1]=-1;
70 for(Int_t i=0; i<100; i++) {
71 for (Int_t j=0; j<2; j++) {
75 fRawClusters = new TClonesArray("AliMUONRawCluster",1000);
77 //____________________________________________________________________________
78 AliMUONClusterFinderVS::~AliMUONClusterFinderVS()
82 // Reset tracks information
85 fRawClusters->Delete();
90 //____________________________________________________________________________
91 void AliMUONClusterFinderVS::ResetRawClusters()
93 /// Reset tracks information
95 if (fRawClusters) fRawClusters->Clear();
97 //____________________________________________________________________________
98 void AliMUONClusterFinderVS::Decluster(AliMUONRawCluster *cluster)
100 /// Decluster by local maxima
101 SplitByLocalMaxima(cluster);
103 //____________________________________________________________________________
104 void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
106 /// Split complex cluster by local maxima
109 fInput->SetCluster(c);
111 fMul[0]=c->GetMultiplicity(0);
112 fMul[1]=c->GetMultiplicity(1);
115 // dump digit information into arrays
120 for (cath=0; cath<2; cath++) {
123 for (i=0; i<fMul[cath]; i++) {
125 fDig[i][cath]=fInput->Digit(cath, c->GetIndex(i, cath));
127 fIx[i][cath]= fDig[i][cath]->PadX();
128 fIy[i][cath]= fDig[i][cath]->PadY();
130 fQ[i][cath] = fDig[i][cath]->Signal();
131 // pad centre coordinates
133 GetPadC(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]);
134 } // loop over cluster digits
136 } // loop over cathodes
142 // Initialise and perform mathieson fits
143 Float_t chi2, oldchi2;
144 // ++++++++++++++++++*************+++++++++++++++++++++
145 // (1) No more than one local maximum per cathode plane
146 // +++++++++++++++++++++++++++++++*************++++++++
147 if ((fNLocal[0]==1 && (fNLocal[1]==0 || fNLocal[1]==1)) ||
148 (fNLocal[0]==0 && fNLocal[1]==1)) {
149 // Perform combined single Mathieson fit
150 // Initial values for coordinates (x,y)
152 // One local maximum on cathodes 1 and 2 (X->cathode 2, Y->cathode 1)
153 if (fNLocal[0]==1 && fNLocal[1]==1) {
154 fXInit[0]=c->GetX(1);
155 fYInit[0]=c->GetY(0);
156 // One local maximum on cathode 1 (X,Y->cathode 1)
157 } else if (fNLocal[0]==1) {
158 fXInit[0]=c->GetX(0);
159 fYInit[0]=c->GetY(0);
160 // One local maximum on cathode 2 (X,Y->cathode 2)
162 fXInit[0]=c->GetX(1);
163 fYInit[0]=c->GetY(1);
165 AliDebug(1,"cas (1) CombiSingleMathiesonFit(c)");
166 chi2=CombiSingleMathiesonFit(c);
167 // Int_t ndf = fgNbins[0]+fgNbins[1]-2;
168 // Float_t prob = TMath::Prob(Double_t(chi2),ndf);
169 // prob1->Fill(prob);
170 // chi2_1->Fill(chi2);
172 AliDebug(1,Form(" chi2 %f ",chi2));
174 c->SetX(0, fXFit[0]);
175 c->SetY(0, fYFit[0]);
183 c->SetX(0, fSeg2[0]->GetAnod(fInput->DetElemId(), c->GetX(0)));
184 c->SetX(1, fSeg2[1]->GetAnod(fInput->DetElemId(), c->GetX(1)));
186 // c->SetDetElemId(fInput->DetElemId());
187 // If reasonable chi^2 add result to the list of rawclusters
190 // If not try combined double Mathieson Fit
192 AliDebug(1," MAUVAIS CHI2 !!!\n");
193 if (fNLocal[0]==1 && fNLocal[1]==1) {
194 fXInit[0]=fX[fIndLocal[0][1]][1];
195 fYInit[0]=fY[fIndLocal[0][0]][0];
196 fXInit[1]=fX[fIndLocal[0][1]][1];
197 fYInit[1]=fY[fIndLocal[0][0]][0];
198 } else if (fNLocal[0]==1) {
199 fXInit[0]=fX[fIndLocal[0][0]][0];
200 fYInit[0]=fY[fIndLocal[0][0]][0];
201 fXInit[1]=fX[fIndLocal[0][0]][0];
202 fYInit[1]=fY[fIndLocal[0][0]][0];
204 fXInit[0]=fX[fIndLocal[0][1]][1];
205 fYInit[0]=fY[fIndLocal[0][1]][1];
206 fXInit[1]=fX[fIndLocal[0][1]][1];
207 fYInit[1]=fY[fIndLocal[0][1]][1];
210 // Initial value for charge ratios
213 AliDebug(1,"\n cas (1) CombiDoubleMathiesonFit(c)\n");
214 chi2=CombiDoubleMathiesonFit(c);
215 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
216 // Float_t prob = TMath::Prob(chi2,ndf);
217 // prob2->Fill(prob);
218 // chi2_2->Fill(chi2);
220 // Was this any better ??
221 AliDebug(1,Form(" Old and new chi2 %f %f ", oldchi2, chi2));
222 if (fFitStat!=0 && chi2>0 && (2.*chi2 < oldchi2)) {
224 // Split cluster into two according to fit result
227 AliDebug(1,"Do not Split");
233 // +++++++++++++++++++++++++++++++++++++++
234 // (2) Two local maxima per cathode plane
235 // +++++++++++++++++++++++++++++++++++++++
236 } else if (fNLocal[0]==2 && fNLocal[1]==2) {
238 // Let's look for ghosts first
240 Float_t xm[4][2], ym[4][2];
241 Float_t dpx, dpy, dx, dy;
242 Int_t ixm[4][2], iym[4][2];
243 Int_t isec, im1, im2, ico;
245 // Form the 2x2 combinations
246 // 0-0, 0-1, 1-0, 1-1
248 for (im1=0; im1<2; im1++) {
249 for (im2=0; im2<2; im2++) {
250 xm[ico][0]=fX[fIndLocal[im1][0]][0];
251 ym[ico][0]=fY[fIndLocal[im1][0]][0];
252 xm[ico][1]=fX[fIndLocal[im2][1]][1];
253 ym[ico][1]=fY[fIndLocal[im2][1]][1];
255 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
256 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
257 ixm[ico][1]=fIx[fIndLocal[im2][1]][1];
258 iym[ico][1]=fIy[fIndLocal[im2][1]][1];
262 // ico = 0 : first local maximum on cathodes 1 and 2
263 // ico = 1 : fisrt local maximum on cathode 1 and second on cathode 2
264 // ico = 2 : second local maximum on cathode 1 and first on cathode 1
265 // ico = 3 : second local maximum on cathodes 1 and 2
267 // Analyse the combinations and keep those that are possible !
268 // For each combination check consistency in x and y
271 Float_t dr[4] = {1.e4, 1.e4, 1.e4, 1.e4};
274 // In case of staggering maxima are displaced by exactly half the pad-size in y.
275 // We have to take into account the numerical precision in the consistency check;
278 for (ico=0; ico<4; ico++) {
279 accepted[ico]=kFALSE;
280 // cathode one: x-coordinate
281 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
282 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
284 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
285 // cathode two: y-coordinate
287 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
288 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
290 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
291 AliDebug(2,Form("\n %i %f %f %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy, dx, dpx ));
292 if ((dx <= dpx) && (dy <= dpy+eps)) {
295 dr[ico] = TMath::Sqrt(dx*dx+dy*dy);
299 accepted[ico]=kFALSE;
302 AliDebug(1,Form("\n iacc= %d:\n", iacc));
304 if (accepted[0] && accepted[1]) {
305 if (dr[0] >= dr[1]) {
312 if (accepted[2] && accepted[3]) {
313 if (dr[2] >= dr[3]) {
320 // eliminate one candidate
324 for (ico=0; ico<4; ico++) {
325 if (accepted[ico] && dr[ico] > drmax) {
331 accepted[icobad] = kFALSE;
337 AliDebug(1,Form("\n iacc= %d:\n", iacc));
339 AliDebug(1,"\n iacc=2: No problem ! \n");
340 } else if (iacc==4) {
341 AliDebug(1,"\n iacc=4: Ok, but ghost problem !!! \n");
342 } else if (iacc==0) {
343 AliDebug(1,"\n iacc=0: I don't know what to do with this !!!!!!!!! \n");
346 // Initial value for charge ratios
347 fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/
348 Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]);
349 fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/
350 Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]);
352 // ******* iacc = 0 *******
353 // No combinations found between the 2 cathodes
354 // We keep the center of gravity of the cluster
359 // ******* iacc = 1 *******
360 // Only one combination found between the 2 cathodes
362 // Initial values for the 2 maxima (x,y)
364 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
365 // 1 maximum is initialised with the other maximum of the first cathode
372 } else if (accepted[1]){
378 } else if (accepted[2]){
384 } else if (accepted[3]){
391 AliDebug(1,"cas (2) CombiDoubleMathiesonFit(c)");
392 chi2=CombiDoubleMathiesonFit(c);
393 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
394 // Float_t prob = TMath::Prob(chi2,ndf);
395 // prob2->Fill(prob);
396 // chi2_2->Fill(chi2);
397 AliDebug(1,Form(" chi2 %f\n",chi2));
399 // If reasonable chi^2 add result to the list of rawclusters
404 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
405 // 1 maximum is initialised with the other maximum of the second cathode
412 } else if (accepted[1]){
418 } else if (accepted[2]){
424 } else if (accepted[3]){
431 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
432 chi2=CombiDoubleMathiesonFit(c);
433 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
434 // Float_t prob = TMath::Prob(chi2,ndf);
435 // prob2->Fill(prob);
436 // chi2_2->Fill(chi2);
437 AliDebug(1,Form(" chi2 %f\n",chi2));
439 // If reasonable chi^2 add result to the list of rawclusters
443 //We keep only the combination found (X->cathode 2, Y->cathode 1)
444 for (Int_t ico=0; ico<2; ico++) {
446 AliMUONRawCluster cnew;
448 for (cath=0; cath<2; cath++) {
449 cnew.SetX(cath, Float_t(xm[ico][1]));
450 cnew.SetY(cath, Float_t(ym[ico][0]));
451 cnew.SetZ(cath, fZPlane);
452 cnew.SetMultiplicity(cath,c->GetMultiplicity(cath));
453 for (i=0; i<fMul[cath]; i++) {
454 cnew.SetIndex(i, cath, c->GetIndex(i,cath));
455 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
457 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
458 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
459 FillCluster(&cnew,cath);
461 cnew.SetClusterType(cnew.PhysicsContribution());
470 // ******* iacc = 2 *******
471 // Two combinations found between the 2 cathodes
473 // Was the same maximum taken twice
474 if ((accepted[0]&&accepted[1]) || (accepted[2]&&accepted[3])) {
475 AliDebug(1,"\n Maximum taken twice !!!\n");
477 // Have a try !! with that
478 if (accepted[0]&&accepted[3]) {
489 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
490 chi2=CombiDoubleMathiesonFit(c);
491 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
492 // Float_t prob = TMath::Prob(chi2,ndf);
493 // prob2->Fill(prob);
494 // chi2_2->Fill(chi2);
498 // No ghosts ! No Problems ! - Perform one fit only !
499 if (accepted[0]&&accepted[3]) {
510 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
511 chi2=CombiDoubleMathiesonFit(c);
512 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
513 // Float_t prob = TMath::Prob(chi2,ndf);
514 // prob2->Fill(prob);
515 // chi2_2->Fill(chi2);
516 AliDebug(1,Form(" chi2 %f\n",chi2));
520 // ******* iacc = 4 *******
521 // Four combinations found between the 2 cathodes
523 } else if (iacc==4) {
524 // Perform fits for the two possibilities !!
525 // Accept if charges are compatible on both cathodes
526 // If none are compatible, keep everything
531 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
532 chi2=CombiDoubleMathiesonFit(c);
533 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
534 // Float_t prob = TMath::Prob(chi2,ndf);
535 // prob2->Fill(prob);
536 // chi2_2->Fill(chi2);
537 AliDebug(1,Form(" chi2 %f\n",chi2));
538 // store results of fit and postpone decision
539 Double_t sXFit[2],sYFit[2],sQrFit[2];
541 for (Int_t i=0;i<2;i++) {
551 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
552 chi2=CombiDoubleMathiesonFit(c);
553 // ndf = fgNbins[0]+fgNbins[1]-6;
554 // prob = TMath::Prob(chi2,ndf);
555 // prob2->Fill(prob);
556 // chi2_2->Fill(chi2);
557 AliDebug(1,Form(" chi2 %f\n",chi2));
558 // We have all informations to perform the decision
559 // Compute the chi2 for the 2 possibilities
560 Float_t chi2fi,chi2si,chi2f,chi2s;
562 chi2f = (TMath::Log(fInput->TotalCharge(0)*fQrFit[0]
563 / (fInput->TotalCharge(1)*fQrFit[1]) )
564 / fInput->ChargeCorrel() );
566 chi2fi = (TMath::Log(fInput->TotalCharge(0)*(1-fQrFit[0])
567 / (fInput->TotalCharge(1)*(1-fQrFit[1])) )
568 / fInput->ChargeCorrel() );
569 chi2f += chi2fi*chi2fi;
571 chi2s = (TMath::Log(fInput->TotalCharge(0)*sQrFit[0]
572 / (fInput->TotalCharge(1)*sQrFit[1]) )
573 / fInput->ChargeCorrel() );
575 chi2si = (TMath::Log(fInput->TotalCharge(0)*(1-sQrFit[0])
576 / (fInput->TotalCharge(1)*(1-sQrFit[1])) )
577 / fInput->ChargeCorrel() );
578 chi2s += chi2si*chi2si;
580 // usefull to store the charge matching chi2 in the cluster
581 // fChi2[0]=sChi2[1]=chi2f;
582 // fChi2[1]=sChi2[0]=chi2s;
584 if (chi2f<=fGhostChi2Cut && chi2s<=fGhostChi2Cut)
586 if (chi2f>fGhostChi2Cut && chi2s>fGhostChi2Cut) {
592 if (chi2f<=fGhostChi2Cut)
594 if (chi2s<=fGhostChi2Cut) {
595 // retreive saved values
596 for (Int_t i=0;i<2;i++) {
607 } else if (fNLocal[0]==2 && fNLocal[1]==1) {
608 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
609 // (3) Two local maxima on cathode 1 and one maximum on cathode 2
610 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
612 Float_t xm[4][2], ym[4][2];
613 Float_t dpx, dpy, dx, dy;
614 Int_t ixm[4][2], iym[4][2];
615 Int_t isec, im1, ico;
617 // Form the 2x2 combinations
618 // 0-0, 0-1, 1-0, 1-1
620 for (im1=0; im1<2; im1++) {
621 xm[ico][0]=fX[fIndLocal[im1][0]][0];
622 ym[ico][0]=fY[fIndLocal[im1][0]][0];
623 xm[ico][1]=fX[fIndLocal[0][1]][1];
624 ym[ico][1]=fY[fIndLocal[0][1]][1];
626 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
627 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
628 ixm[ico][1]=fIx[fIndLocal[0][1]][1];
629 iym[ico][1]=fIy[fIndLocal[0][1]][1];
632 // ico = 0 : first local maximum on cathodes 1 and 2
633 // ico = 1 : second local maximum on cathode 1 and first on cathode 2
635 // Analyse the combinations and keep those that are possible !
636 // For each combination check consistency in x and y
640 // In case of staggering maxima are displaced by exactly half the pad-size in y.
641 // We have to take into account the numerical precision in the consistency check;
645 for (ico=0; ico<2; ico++) {
646 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
647 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
649 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
650 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
651 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
653 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
654 AliDebug(2,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
655 if ((dx <= dpx) && (dy <= dpy+eps)) {
661 accepted[ico]=kFALSE;
669 // Initial value for charge ratios
670 fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/
671 Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]);
672 fQrInit[1]=fQrInit[0];
674 if (accepted[0] && accepted[1]) {
676 fXInit[0]=0.5*(xm[0][1]+xm[0][0]);
678 fXInit[1]=0.5*(xm[0][1]+xm[1][0]);
682 chi23=CombiDoubleMathiesonFit(c);
691 } else if (accepted[0]) {
696 chi21=CombiDoubleMathiesonFit(c);
697 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
698 // Float_t prob = TMath::Prob(chi2,ndf);
699 // prob2->Fill(prob);
700 // chi2_2->Fill(chi21);
701 AliDebug(1,Form(" chi2 %f\n",chi21));
702 if (chi21<10) Split(c);
703 } else if (accepted[1]) {
708 chi22=CombiDoubleMathiesonFit(c);
709 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
710 // Float_t prob = TMath::Prob(chi2,ndf);
711 // prob2->Fill(prob);
712 // chi2_2->Fill(chi22);
713 AliDebug(1,Form(" chi2 %f\n",chi22));
714 if (chi22<10) Split(c);
717 if (chi21 > 10 && chi22 > 10 && chi23 > 10) {
718 // We keep only the combination found (X->cathode 2, Y->cathode 1)
719 for (Int_t ico=0; ico<2; ico++) {
721 AliMUONRawCluster cnew;
723 for (cath=0; cath<2; cath++) {
724 cnew.SetX(cath, Float_t(xm[ico][1]));
725 cnew.SetY(cath, Float_t(ym[ico][0]));
726 cnew.SetZ(cath, fZPlane);
727 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
728 for (i=0; i<fMul[cath]; i++) {
729 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
730 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
733 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
734 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
736 FillCluster(&cnew,cath);
738 cnew.SetClusterType(cnew.PhysicsContribution());
745 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
746 // (3') One local maximum on cathode 1 and two maxima on cathode 2
747 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
748 } else if (fNLocal[0]==1 && fNLocal[1]==2) {
749 Float_t xm[4][2], ym[4][2];
750 Float_t dpx, dpy, dx, dy;
751 Int_t ixm[4][2], iym[4][2];
752 Int_t isec, im1, ico;
754 // Form the 2x2 combinations
755 // 0-0, 0-1, 1-0, 1-1
757 for (im1=0; im1<2; im1++) {
758 xm[ico][0]=fX[fIndLocal[0][0]][0];
759 ym[ico][0]=fY[fIndLocal[0][0]][0];
760 xm[ico][1]=fX[fIndLocal[im1][1]][1];
761 ym[ico][1]=fY[fIndLocal[im1][1]][1];
763 ixm[ico][0]=fIx[fIndLocal[0][0]][0];
764 iym[ico][0]=fIy[fIndLocal[0][0]][0];
765 ixm[ico][1]=fIx[fIndLocal[im1][1]][1];
766 iym[ico][1]=fIy[fIndLocal[im1][1]][1];
769 // ico = 0 : first local maximum on cathodes 1 and 2
770 // ico = 1 : first local maximum on cathode 1 and second on cathode 2
772 // Analyse the combinations and keep those that are possible !
773 // For each combination check consistency in x and y
777 // In case of staggering maxima are displaced by exactly half the pad-size in y.
778 // We have to take into account the numerical precision in the consistency check;
782 for (ico=0; ico<2; ico++) {
783 accepted[ico]=kFALSE;
784 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
785 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
787 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
788 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
789 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
791 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
792 AliDebug(1,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
793 if ((dx <= dpx) && (dy <= dpy+eps)) {
796 AliDebug(1,Form("ico %d\n",ico));
800 accepted[ico]=kFALSE;
808 fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/
809 Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]);
811 fQrInit[0]=fQrInit[1];
814 if (accepted[0] && accepted[1]) {
816 fYInit[0]=0.5*(ym[0][0]+ym[0][1]);
818 fYInit[1]=0.5*(ym[0][0]+ym[1][1]);
821 chi23=CombiDoubleMathiesonFit(c);
830 } else if (accepted[0]) {
835 chi21=CombiDoubleMathiesonFit(c);
836 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
837 // Float_t prob = TMath::Prob(chi2,ndf);
838 // prob2->Fill(prob);
839 // chi2_2->Fill(chi21);
840 AliDebug(1,Form(" chi2 %f\n",chi21));
841 if (chi21<10) Split(c);
842 } else if (accepted[1]) {
847 chi22=CombiDoubleMathiesonFit(c);
848 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
849 // Float_t prob = TMath::Prob(chi2,ndf);
850 // prob2->Fill(prob);
851 // chi2_2->Fill(chi22);
852 AliDebug(1,Form(" chi2 %f\n",chi22));
853 if (chi22<10) Split(c);
856 if (chi21 > 10 && chi22 > 10 && chi23 > 10) {
857 //We keep only the combination found (X->cathode 2, Y->cathode 1)
858 for (Int_t ico=0; ico<2; ico++) {
860 AliMUONRawCluster cnew;
862 for (cath=0; cath<2; cath++) {
863 cnew.SetX(cath, Float_t(xm[ico][1]));
864 cnew.SetY(cath, Float_t(ym[ico][0]));
865 cnew.SetZ(cath, fZPlane);
866 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
867 for (i=0; i<fMul[cath]; i++) {
868 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
869 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
871 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
872 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
873 FillCluster(&cnew,cath);
875 cnew.SetClusterType(cnew.PhysicsContribution());
882 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
883 // (4) At least three local maxima on cathode 1 or on cathode 2
884 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
885 } else if (fNLocal[0]>2 || fNLocal[1]>2) {
886 Int_t param = fNLocal[0]*fNLocal[1];
889 Float_t ** xm = new Float_t * [param];
890 for (ii=0; ii<param; ii++) xm[ii]=new Float_t [2];
891 Float_t ** ym = new Float_t * [param];
892 for (ii=0; ii<param; ii++) ym[ii]=new Float_t [2];
893 Int_t ** ixm = new Int_t * [param];
894 for (ii=0; ii<param; ii++) ixm[ii]=new Int_t [2];
895 Int_t ** iym = new Int_t * [param];
896 for (ii=0; ii<param; ii++) iym[ii]=new Int_t [2];
899 Float_t dpx, dpy, dx, dy;
902 for (Int_t im1=0; im1<fNLocal[0]; im1++) {
903 for (Int_t im2=0; im2<fNLocal[1]; im2++) {
904 xm[ico][0]=fX[fIndLocal[im1][0]][0];
905 ym[ico][0]=fY[fIndLocal[im1][0]][0];
906 xm[ico][1]=fX[fIndLocal[im2][1]][1];
907 ym[ico][1]=fY[fIndLocal[im2][1]][1];
909 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
910 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
911 ixm[ico][1]=fIx[fIndLocal[im2][1]][1];
912 iym[ico][1]=fIy[fIndLocal[im2][1]][1];
918 AliDebug(1,Form("nIco %d\n",nIco));
919 for (ico=0; ico<nIco; ico++) {
920 AliDebug(1,Form("ico = %d\n",ico));
921 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
922 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
924 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
925 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
926 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
928 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
929 AliDebug(1,Form("dx %f dpx %f dy %f dpy %f\n",dx,dpx,dy,dpy));
930 AliDebug(1,Form(" X %f Y %f\n",xm[ico][1],ym[ico][0]));
931 if ((dx <= dpx) && (dy <= dpy)) {
934 AliMUONRawCluster cnew;
935 for (cath=0; cath<2; cath++) {
936 cnew.SetX(cath, Float_t(xm[ico][1]));
937 cnew.SetY(cath, Float_t(ym[ico][0]));
938 cnew.SetZ(cath, fZPlane);
939 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
940 for (i=0; i<fMul[cath]; i++) {
941 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
942 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
944 FillCluster(&cnew,cath);
946 cnew.SetClusterType(cnew.PhysicsContribution());
947 // cnew.SetDetElemId(fInput->DetElemId());
959 void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
961 /// Find all local maxima of a cluster
962 AliDebug(1,"\n Find Local maxima !");
966 Int_t cath, cath1; // loops over cathodes
967 Int_t i; // loops over digits
968 Int_t j; // loops over cathodes
972 // counters for number of local maxima
973 fNLocal[0]=fNLocal[1]=0;
974 // flags digits as local maximum
975 Bool_t isLocal[100][2];
976 for (i=0; i<100;i++) {
977 isLocal[i][0]=isLocal[i][1]=kFALSE;
979 // number of next neighbours and arrays to store them
982 // loop over cathodes
983 for (cath=0; cath<2; cath++) {
984 // loop over cluster digits
985 for (i=0; i<fMul[cath]; i++) {
986 // get neighbours for that digit and assume that it is local maximum
990 fSeg2[cath]->Neighbours(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], &nn, x, y);
992 isLocal[i][cath]=kTRUE;
993 isec = fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
994 a0 = fSeg2[cath]->Dpx(fInput->DetElemId(), isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
996 // loop over next neighbours, if at least one neighbour has higher charger assumption
997 // digit is not local maximum
998 for (j=0; j<nn; j++) {
999 if (fDigitMap[cath]->TestHit(x[j], y[j])==kEmpty) continue;
1000 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(x[j], y[j]);
1002 isec=fSeg2[cath]->Sector(fInput->DetElemId(), x[j], y[j]);
1003 a1 = fSeg2[cath]->Dpx(fInput->DetElemId(),isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1005 if (digt->Signal()/a1 > fQ[i][cath]/a0) {
1006 isLocal[i][cath]=kFALSE;
1009 // handle special case of neighbouring pads with equal signal
1010 } else if (digt->Signal() == fQ[i][cath]) {
1011 if (fNLocal[cath]>0) {
1012 for (Int_t k=0; k<fNLocal[cath]; k++) {
1013 if (x[j]==fIx[fIndLocal[k][cath]][cath]
1014 && y[j]==fIy[fIndLocal[k][cath]][cath])
1016 isLocal[i][cath]=kFALSE;
1018 } // loop over local maxima
1019 } // are there already local maxima
1021 } // loop over next neighbours
1022 if (isLocal[i][cath]) {
1023 fIndLocal[fNLocal[cath]][cath]=i;
1026 } // loop over all digits
1027 } // loop over cathodes
1029 AliDebug(1,Form("\n Found %d %d %d %d local Maxima\n",
1030 fNLocal[0], fNLocal[1], fMul[0], fMul[1]));
1031 AliDebug(1,Form("\n Cathode 1 local Maxima %d Multiplicite %d\n",fNLocal[0], fMul[0]));
1032 AliDebug(1,Form(" Cathode 2 local Maxima %d Multiplicite %d\n",fNLocal[1], fMul[1]));
1037 if (fNLocal[1]==2 && (fNLocal[0]==1 || fNLocal[0]==0)) {
1038 Int_t iback=fNLocal[0];
1040 // Two local maxima on cathode 2 and one maximum on cathode 1
1041 // Look for local maxima considering up and down neighbours on the 1st cathode only
1043 // Loop over cluster digits
1047 for (i=0; i<fMul[cath]; i++) {
1048 isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
1049 dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1050 dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1052 if (isLocal[i][cath]) continue;
1053 // Pad position should be consistent with position of local maxima on the opposite cathode
1054 if ((TMath::Abs(fX[i][cath]-fX[fIndLocal[0][cath1]][cath1]) > dpx/2.) &&
1055 (TMath::Abs(fX[i][cath]-fX[fIndLocal[1][cath1]][cath1]) > dpx/2.))
1058 // get neighbours for that digit and assume that it is local maximum
1059 isLocal[i][cath]=kTRUE;
1060 // compare signal to that on the two neighbours on the left and on the right
1061 // iNN counts the number of neighbours with signal, it should be 1 or 2
1065 for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, 0., dpy);
1066 fSeg2[cath]->MorePads(fInput->DetElemId());
1067 fSeg2[cath]->NextPad(fInput->DetElemId()))
1069 ix = fSeg2[cath]->Ix();
1070 iy = fSeg2[cath]->Iy();
1071 // skip the current pad
1072 if (iy == fIy[i][cath]) continue;
1074 if (fDigitMap[cath]->TestHit(ix, iy)!=kEmpty) {
1076 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(ix,iy);
1077 if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
1079 } // Loop over pad neighbours in y
1081 if (isLocal[i][cath] && iNN>0) {
1082 fIndLocal[fNLocal[cath]][cath]=i;
1085 } // loop over all digits
1086 // if one additional maximum has been found we are happy
1087 // if more maxima have been found restore the previous situation
1088 AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",
1090 AliDebug(1,Form(" %d local maxima for cathode 2 \n",
1092 if (fNLocal[cath]>2) {
1093 fNLocal[cath]=iback;
1096 } // 1,2 local maxima
1098 if (fNLocal[0]==2 && (fNLocal[1]==1 || fNLocal[1]==0)) {
1099 Int_t iback=fNLocal[1];
1101 // Two local maxima on cathode 1 and one maximum on cathode 2
1102 // Look for local maxima considering left and right neighbours on the 2nd cathode only
1105 Float_t eps = 1.e-5;
1108 // Loop over cluster digits
1109 for (i=0; i<fMul[cath]; i++) {
1110 isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
1111 dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1112 dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1115 if (isLocal[i][cath]) continue;
1116 // Pad position should be consistent with position of local maxima on the opposite cathode
1117 if ((TMath::Abs(fY[i][cath]-fY[fIndLocal[0][cath1]][cath1]) > dpy/2.+eps) &&
1118 (TMath::Abs(fY[i][cath]-fY[fIndLocal[1][cath1]][cath1]) > dpy/2.+eps))
1122 // get neighbours for that digit and assume that it is local maximum
1123 isLocal[i][cath]=kTRUE;
1124 // compare signal to that on the two neighbours on the left and on the right
1126 // iNN counts the number of neighbours with signal, it should be 1 or 2
1128 for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, dpx, 0.);
1129 fSeg2[cath]->MorePads(fInput->DetElemId());
1130 fSeg2[cath]->NextPad(fInput->DetElemId()))
1133 ix = fSeg2[cath]->Ix();
1134 iy = fSeg2[cath]->Iy();
1136 // skip the current pad
1137 if (ix == fIx[i][cath]) continue;
1139 if (fDigitMap[cath]->TestHit(ix, iy)!=kEmpty) {
1141 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(ix,iy);
1142 if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
1144 } // Loop over pad neighbours in x
1146 if (isLocal[i][cath] && iNN>0) {
1147 fIndLocal[fNLocal[cath]][cath]=i;
1150 } // loop over all digits
1151 // if one additional maximum has been found we are happy
1152 // if more maxima have been found restore the previous situation
1153 AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",fNLocal[0]));
1154 AliDebug(1,Form("\n %d local maxima for cathode 2 \n",fNLocal[1]));
1155 AliDebug(1,Form("\n New search gives %d %d \n",fNLocal[0],fNLocal[1]));
1156 if (fNLocal[cath]>2) {
1157 fNLocal[cath]=iback;
1159 } // 2,1 local maxima
1163 void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t flag, Int_t cath)
1165 /// Completes cluster information starting from list of digits
1172 c->SetPeakSignal(cath,c->GetPeakSignal(0));
1174 c->SetPeakSignal(cath,0);
1181 c->SetCharge(cath,0);
1184 AliDebug(1,Form("\n fPeakSignal %d\n",c->GetPeakSignal(cath)));
1185 for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
1187 dig= fInput->Digit(cath,c->GetIndex(i,cath));
1188 ix=dig->PadX()+c->GetOffset(i,cath);
1190 Int_t q=dig->Signal();
1191 if (!flag) q=Int_t(q*c->GetContrib(i,cath));
1192 // fprintf(stderr,"q %d c->fPeakSignal[ %d ] %d\n",q,cath,c->fPeakSignal[cath]);
1193 if (dig->Physics() >= dig->Signal()) {
1195 } else if (dig->Physics() == 0) {
1197 } else c->SetPhysics(i,1);
1200 AliDebug(2,Form("q %d c->fPeakSignal[cath] %d\n",q,c->GetPeakSignal(cath)));
1201 // peak signal and track list
1202 if (q>c->GetPeakSignal(cath)) {
1203 c->SetPeakSignal(cath, q);
1204 c->SetTrack(0,dig->Hit());
1205 c->SetTrack(1,dig->Track(0));
1206 c->SetTrack(2,dig->Track(1));
1207 // fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->fHit,dig->fTracks[0]);
1211 fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
1215 c->AddCharge(cath, q);
1217 } // loop over digits
1218 AliDebug(1," fin du cluster c\n");
1222 c->SetX(cath, c->GetX(cath)/c->GetCharge(cath));
1224 c->SetX(cath, fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
1225 c->SetY(cath, c->GetY(cath)/c->GetCharge(cath));
1227 // apply correction to the coordinate along the anode wire
1233 fSeg2[cath]->GetPadI(fInput->DetElemId(), x, y, fZPlane, ix, iy);
1234 fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
1235 isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix,iy);
1236 cogCorr = fSeg2[cath]->CorrFunc(fInput->DetElemId(), isec-1);
1241 yOnPad=(c->GetY(cath)-y)/fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1243 c->SetY(cath, c->GetY(cath)-cogCorr->Eval(yOnPad, 0, 0));
1244 // slat ID from digit
1250 void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t cath)
1252 /// Completes cluster information starting from list of digits
1262 Float_t xpad, ypad, zpad;
1265 for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
1267 dig = fInput->Digit(cath,c->GetIndex(i,cath));
1269 GetPadC(fInput->DetElemId(),dig->PadX(),dig->PadY(),xpad,ypad, zpad);
1270 AliDebug(1,Form("x %f y %f cx %f cy %f\n",xpad,ypad,c->GetX(0),c->GetY(0)));
1271 dx = xpad - c->GetX(0);
1272 dy = ypad - c->GetY(0);
1273 dr = TMath::Sqrt(dx*dx+dy*dy);
1277 AliDebug(1,Form(" dr %f\n",dr));
1278 Int_t q=dig->Signal();
1279 if (dig->Physics() >= dig->Signal()) {
1281 } else if (dig->Physics() == 0) {
1283 } else c->SetPhysics(i,1);
1284 c->SetPeakSignal(cath,q);
1285 c->SetTrack(0,dig->Hit());
1286 c->SetTrack(1,dig->Track(0));
1287 c->SetTrack(2,dig->Track(1));
1289 AliDebug(1,Form(" c->fTracks[0] %d c->fTracks[1] %d\n",dig->Hit(),
1293 } // loop over digits
1295 // apply correction to the coordinate along the anode wire
1297 c->SetX(cath,fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
1300 void AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONRawCluster &c)
1302 /// Find a super cluster on both cathodes
1303 /// Add i,j as element of the cluster
1305 Int_t idx = fDigitMap[cath]->GetHitIndex(i,j);
1306 AliMUONDigit* dig = (AliMUONDigit*) fDigitMap[cath]->GetHit(i,j);
1307 Int_t q=dig->Signal();
1308 Int_t theX=dig->PadX();
1309 Int_t theY=dig->PadY();
1311 if (q > TMath::Abs(c.GetPeakSignal(0)) && q > TMath::Abs(c.GetPeakSignal(1))) {
1312 c.SetPeakSignal(cath,q);
1313 c.SetTrack(0,dig->Hit());
1314 c.SetTrack(1,dig->Track(0));
1315 c.SetTrack(2,dig->Track(1));
1319 // Make sure that list of digits is ordered
1321 Int_t mu=c.GetMultiplicity(cath);
1322 c.SetIndex(mu, cath, idx);
1324 if (dig->Physics() >= dig->Signal()) {
1326 } else if (dig->Physics() == 0) {
1328 } else c.SetPhysics(mu,1);
1332 for (Int_t ind = mu-1; ind >= 0; ind--) {
1333 Int_t ist=c.GetIndex(ind,cath);
1334 Int_t ql=fInput->Digit(cath, ist)->Signal();
1335 Int_t ix=fInput->Digit(cath, ist)->PadX();
1336 Int_t iy=fInput->Digit(cath, ist)->PadY();
1338 if (q>ql || (q==ql && theX > ix && theY < iy)) {
1339 c.SetIndex(ind, cath, idx);
1340 c.SetIndex(ind+1, cath, ist);
1348 c.SetMultiplicity(cath, c.GetMultiplicity(cath)+1);
1349 if (c.GetMultiplicity(cath) >= 50 ) {
1350 AliDebug(1,Form("FindCluster - multiplicity >50 %d \n",c.GetMultiplicity(0)));
1351 c.SetMultiplicity(cath, 49);
1354 // Prepare center of gravity calculation
1356 fSeg2[cath]->GetPadC(fInput->DetElemId(), i, j, x, y, z);
1359 c.AddCharge(cath,q);
1361 // Flag hit as "taken"
1362 fDigitMap[cath]->FlagHit(i,j);
1364 // Now look recursively for all neighbours and pad hit on opposite cathode
1366 // Loop over neighbours
1370 Int_t xList[10], yList[10];
1371 fSeg2[cath]->Neighbours(fInput->DetElemId(), i,j,&nn,xList,yList);
1372 for (Int_t in=0; in<nn; in++) {
1376 if (fDigitMap[cath]->TestHit(ix,iy)==kUnused) {
1377 AliDebug(2,Form("\n Neighbours %d %d %d", cath, ix, iy));
1378 FindCluster(ix, iy, cath, c);
1383 Int_t iXopp[50], iYopp[50];
1385 // Neighbours on opposite cathode
1386 // Take into account that several pads can overlap with the present pad
1388 isec=fSeg2[cath]->Sector(fInput->DetElemId(), i,j);
1395 dx = (fSeg2[cath]->Dpx(fInput->DetElemId(), isec))/2.;
1400 dy = (fSeg2[cath]->Dpy(fInput->DetElemId(), isec))/2;
1405 // loop over pad neighbours on opposite cathode
1406 for (fSeg2[iop]->FirstPad(fInput->DetElemId(), x, y, fZPlane, dx, dy);
1407 fSeg2[iop]->MorePads(fInput->DetElemId());
1408 fSeg2[iop]->NextPad(fInput->DetElemId()))
1411 ix = fSeg2[iop]->Ix(); iy = fSeg2[iop]->Iy();
1412 AliDebug(2,Form("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector));
1413 if (fDigitMap[iop]->TestHit(ix,iy)==kUnused){
1416 AliDebug(2,Form("\n Opposite %d %d %d", iop, ix, iy));
1419 } // Loop over pad neighbours
1420 // This had to go outside the loop since recursive calls inside the iterator are not possible
1423 for (jopp=0; jopp<nOpp; jopp++) {
1424 if (fDigitMap[iop]->TestHit(iXopp[jopp],iYopp[jopp]) == kUnused)
1425 FindCluster(iXopp[jopp], iYopp[jopp], iop, c);
1430 //_____________________________________________________________________________
1432 void AliMUONClusterFinderVS::FindRawClusters()
1434 /// MUON cluster finder from digits -- finds neighbours on both cathodes and
1435 /// fills the tree with raw clusters
1438 // Return if no input datad available
1439 if (!fInput->NDigits(0) && !fInput->NDigits(1)) return;
1441 fSeg2[0] = fInput->Segmentation2(0);
1442 fSeg2[1] = fInput->Segmentation2(1);
1444 Int_t detElemId = fInput->DetElemId();
1446 Int_t npx0 = fSeg2[0]->Npx(detElemId)+1;
1447 Int_t npy0 = fSeg2[0]->Npy(detElemId)+1;
1448 fDigitMap[0] = new AliMUONDigitMapA1(detElemId, npx0, npy0);
1450 Int_t npx1 = fSeg2[0]->Npx(detElemId)+1;
1451 Int_t npy1 = fSeg2[0]->Npy(detElemId)+1;
1452 fDigitMap[1] = new AliMUONDigitMapA1(detElemId, npx1, npy1);
1460 fDigitMap[0]->FillHits(fInput->Digits(0));
1461 fDigitMap[1]->FillHits(fInput->Digits(1));
1463 // Outer Loop over Cathodes
1464 for (cath = 0; cath < 2; cath++) {
1466 for (ndig=0; ndig<fInput->NDigits(cath); ndig++) {
1467 dig = fInput->Digit(cath, ndig);
1468 Int_t padx = dig->PadX();
1469 Int_t pady = dig->PadY();
1470 if (fDigitMap[cath]->TestHit(padx,pady)==kUsed ||fDigitMap[0]->TestHit(padx,pady)==kEmpty) {
1474 AliDebug(1,Form("\n CATHODE %d CLUSTER %d\n",cath,ncls));
1475 AliMUONRawCluster clus;
1476 clus.SetMultiplicity(0, 0);
1477 clus.SetMultiplicity(1, 0);
1478 clus.SetPeakSignal(cath,dig->Signal());
1479 clus.SetTrack(0, dig->Hit());
1480 clus.SetTrack(1, dig->Track(0));
1481 clus.SetTrack(2, dig->Track(1));
1483 AliDebug(1,Form("idDE %d Padx %d Pady %d", fInput->DetElemId(), padx, pady));
1485 // tag the beginning of cluster list in a raw cluster
1486 clus.SetNcluster(0,-1);
1488 fSeg2[cath]->GetPadC(fInput->DetElemId(), padx, pady, xcu, ycu, fZPlane);
1489 fSector= fSeg2[cath]->Sector(fInput->DetElemId(), padx, pady)/100;
1494 FindCluster(padx,pady,cath,clus);
1495 //^^^^^^^^^^^^^^^^^^^^^^^^
1496 // center of gravity
1497 if (clus.GetX(0)!=0.) clus.SetX(0, clus.GetX(0)/clus.GetCharge(0)); // clus.fX[0] /= clus.fQ[0];
1500 clus.SetX(0,fSeg2[0]->GetAnod(fInput->DetElemId(), clus.GetX(0)));
1501 if (clus.GetY(0)!=0.) clus.SetY(0, clus.GetY(0)/clus.GetCharge(0)); // clus.fY[0] /= clus.fQ[0];
1503 if(clus.GetCharge(1)!=0.) clus.SetX(1, clus.GetX(1)/clus.GetCharge(1)); // clus.fX[1] /= clus.fQ[1];
1506 clus.SetX(1, fSeg2[0]->GetAnod(fInput->DetElemId(),clus.GetX(1)));
1507 if(clus.GetCharge(1)!=0.) clus.SetY(1, clus.GetY(1)/clus.GetCharge(1));// clus.fY[1] /= clus.fQ[1];
1509 clus.SetZ(0, fZPlane);
1510 clus.SetZ(1, fZPlane);
1512 AliDebug(1,Form("\n Cathode 1 multiplicite %d X(CG) %f Y(CG) %f\n",
1513 clus.GetMultiplicity(0),clus.GetX(0),clus.GetY(0)));
1514 AliDebug(1,Form(" Cathode 2 multiplicite %d X(CG) %f Y(CG) %f\n",
1515 clus.GetMultiplicity(1),clus.GetX(1),clus.GetY(1)));
1516 // Analyse cluster and decluster if necessary
1519 clus.SetNcluster(1,fNRawClusters);
1520 clus.SetClusterType(clus.PhysicsContribution());
1527 // reset Cluster object
1528 { // begin local scope
1529 for (int k=0;k<clus.GetMultiplicity(0);k++) clus.SetIndex(k, 0, 0);
1530 } // end local scope
1532 { // begin local scope
1533 for (int k=0;k<clus.GetMultiplicity(1);k++) clus.SetIndex(k, 1, 0);
1534 } // end local scope
1536 clus.SetMultiplicity(0,0);
1537 clus.SetMultiplicity(1,0);
1541 } // end loop cathodes
1542 delete fDigitMap[0];
1543 delete fDigitMap[1];
1546 Float_t AliMUONClusterFinderVS::SingleMathiesonFit(AliMUONRawCluster *c, Int_t cath)
1548 /// Performs a single Mathieson fit on one cathode
1550 Double_t arglist[20];
1552 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1554 clusterInput.Fitter()->SetFCN(fcnS1);
1555 clusterInput.Fitter()->mninit(2,10,7);
1556 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1558 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1559 // Set starting values
1560 static Double_t vstart[2];
1561 vstart[0]=c->GetX(1);
1562 vstart[1]=c->GetY(0);
1565 // lower and upper limits
1566 static Double_t lower[2], upper[2];
1568 fSeg2[cath]->GetPadI(fInput->DetElemId(), c->GetX(cath), c->GetY(cath), fZPlane, ix, iy);
1569 isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix, iy);
1571 lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(), isec)/2;
1572 lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(), isec)/2;
1574 upper[0]=lower[0]+fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1575 upper[1]=lower[1]+fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1579 static Double_t step[2]={0.0005, 0.0005};
1581 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1582 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1583 // ready for minimisation
1587 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1588 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1589 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1590 Double_t fmin, fedm, errdef;
1591 Int_t npari, nparx, istat;
1593 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1597 // Get fitted parameters
1598 Double_t xrec, yrec;
1600 Double_t epxz, b1, b2;
1602 clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg);
1603 clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg);
1609 Float_t AliMUONClusterFinderVS::CombiSingleMathiesonFit(AliMUONRawCluster * /*c*/)
1611 /// Perform combined Mathieson fit on both cathode planes
1613 Double_t arglist[20];
1615 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1616 clusterInput.Fitter()->SetFCN(fcnCombiS1);
1617 clusterInput.Fitter()->mninit(2,10,7);
1618 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1620 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1621 static Double_t vstart[2];
1622 vstart[0]=fXInit[0];
1623 vstart[1]=fYInit[0];
1626 // lower and upper limits
1627 static Float_t lower[2], upper[2];
1631 fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1632 isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
1633 dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
1634 fSeg2[1]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1635 isec=fSeg2[1]->Sector(fInput->DetElemId(), ix, iy);
1636 dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
1639 Float_t xdum, ydum, zdum;
1641 // Find save upper and lower limits
1644 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.);
1645 fSeg2[1]->MorePads(fInput->DetElemId());
1646 fSeg2[1]->NextPad(fInput->DetElemId()))
1648 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1649 fSeg2[1]->GetPadC(fInput->DetElemId(), ix,iy, upper[0], ydum, zdum);
1650 if (icount ==0) lower[0]=upper[0];
1654 if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
1657 AliDebug(1,Form("\n single y %f %f", fXInit[0], fYInit[0]));
1659 for (fSeg2[0]->FirstPad(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, 0., dpy);
1660 fSeg2[0]->MorePads(fInput->DetElemId());
1661 fSeg2[0]->NextPad(fInput->DetElemId()))
1663 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1664 fSeg2[0]->GetPadC(fInput->DetElemId(), ix,iy,xdum,upper[1],zdum);
1665 if (icount ==0) lower[1]=upper[1];
1667 AliDebug(1,Form("\n upper lower %d %f %f", icount, upper[1], lower[1]));
1670 if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
1673 static Double_t step[2]={0.00001, 0.0001};
1675 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1676 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1677 // ready for minimisation
1681 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1682 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1683 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1684 Double_t fmin, fedm, errdef;
1685 Int_t npari, nparx, istat;
1687 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1691 // Get fitted parameters
1692 Double_t xrec, yrec;
1694 Double_t epxz, b1, b2;
1696 clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg);
1697 clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg);
1703 Bool_t AliMUONClusterFinderVS::DoubleMathiesonFit(AliMUONRawCluster * /*c*/, Int_t cath)
1705 /// Performs a double Mathieson fit on one cathode
1708 // Initialise global variables for fit
1709 Double_t arglist[20];
1711 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1712 clusterInput.Fitter()->SetFCN(fcnS2);
1713 clusterInput.Fitter()->mninit(5,10,7);
1714 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1716 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1717 // Set starting values
1718 static Double_t vstart[5];
1719 vstart[0]=fX[fIndLocal[0][cath]][cath];
1720 vstart[1]=fY[fIndLocal[0][cath]][cath];
1721 vstart[2]=fX[fIndLocal[1][cath]][cath];
1722 vstart[3]=fY[fIndLocal[1][cath]][cath];
1723 vstart[4]=Float_t(fQ[fIndLocal[0][cath]][cath])/
1724 Float_t(fQ[fIndLocal[0][cath]][cath]+fQ[fIndLocal[1][cath]][cath]);
1725 // lower and upper limits
1726 static Float_t lower[5], upper[5];
1729 isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[0][cath]][cath],
1730 fIy[fIndLocal[0][cath]][cath]);
1731 lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1732 lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1734 upper[0]=lower[0]+2.*fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1735 upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1737 isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[1][cath]][cath],
1738 fIy[fIndLocal[1][cath]][cath]);
1739 lower[2]=vstart[2]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec)/2;
1740 lower[3]=vstart[3]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec)/2;
1742 upper[2]=lower[2]+fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1743 upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1750 static Double_t step[5]={0.0005, 0.0005, 0.0005, 0.0005, 0.0001};
1752 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1753 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1754 clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
1755 clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
1756 clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
1757 // ready for minimisation
1761 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1762 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1763 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1764 // Get fitted parameters
1765 Double_t xrec[2], yrec[2], qfrac;
1767 Double_t epxz, b1, b2;
1769 clusterInput.Fitter()->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
1770 clusterInput.Fitter()->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
1771 clusterInput.Fitter()->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
1772 clusterInput.Fitter()->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
1773 clusterInput.Fitter()->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
1775 Double_t fmin, fedm, errdef;
1776 Int_t npari, nparx, istat;
1778 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1783 Float_t AliMUONClusterFinderVS::CombiDoubleMathiesonFit(AliMUONRawCluster * /*c*/)
1785 /// Perform combined double Mathieson fit on both cathode planes
1787 Double_t arglist[20];
1789 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1790 clusterInput.Fitter()->SetFCN(fcnCombiS2);
1791 clusterInput.Fitter()->mninit(6,10,7);
1792 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1794 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1795 // Set starting values
1796 static Double_t vstart[6];
1797 vstart[0]=fXInit[0];
1798 vstart[1]=fYInit[0];
1799 vstart[2]=fXInit[1];
1800 vstart[3]=fYInit[1];
1801 vstart[4]=fQrInit[0];
1802 vstart[5]=fQrInit[1];
1803 // lower and upper limits
1804 static Float_t lower[6], upper[6];
1808 fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, ix, iy);
1809 isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
1810 dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
1812 fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1813 isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
1814 dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
1819 Float_t xdum, ydum, zdum;
1820 AliDebug(1,Form("\n Cluster Finder: %f %f %f %f ", fXInit[0], fXInit[1],fYInit[0], fYInit[1] ));
1822 // Find save upper and lower limits
1825 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.);
1826 fSeg2[1]->MorePads(fInput->DetElemId());
1827 fSeg2[1]->NextPad(fInput->DetElemId()))
1829 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1830 // if (fDigitMap[1]->TestHit(ix, iy) == kEmpty) continue;
1831 fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[0],ydum,zdum);
1832 if (icount ==0) lower[0]=upper[0];
1835 if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
1836 // vstart[0] = 0.5*(lower[0]+upper[0]);
1841 for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, 0., dpy);
1842 fSeg2[0]->MorePads(fInput->DetElemId());
1843 fSeg2[0]->NextPad(fInput->DetElemId()))
1845 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1846 // if (fDigitMap[0]->TestHit(ix, iy) == kEmpty) continue;
1847 fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[1],zdum);
1848 if (icount ==0) lower[1]=upper[1];
1852 if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
1853 // vstart[1] = 0.5*(lower[1]+upper[1]);
1856 fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
1857 isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
1858 dpx=fSeg2[1]->Dpx(fInput->DetElemId(),isec);
1859 fSeg2[0]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
1860 isec=fSeg2[0]->Sector(fInput->DetElemId(),ix, iy);
1861 dpy=fSeg2[0]->Dpy(fInput->DetElemId(),isec);
1864 // Find save upper and lower limits
1868 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, dpx, 0);
1869 fSeg2[1]->MorePads(fInput->DetElemId());
1870 fSeg2[1]->NextPad(fInput->DetElemId()))
1872 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1873 // if (fDigitMap[1]->TestHit(ix, iy) == kEmpty) continue;
1874 fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[2],ydum,zdum);
1875 if (icount ==0) lower[2]=upper[2];
1878 if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;}
1879 // vstart[2] = 0.5*(lower[2]+upper[2]);
1883 for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, 0, dpy);
1884 fSeg2[0]-> MorePads(fInput->DetElemId());
1885 fSeg2[0]->NextPad(fInput->DetElemId()))
1887 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1888 // if (fDigitMap[0]->TestHit(ix, iy) != kEmpty) continue;
1890 fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[3],zdum);
1891 if (icount ==0) lower[3]=upper[3];
1895 if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;}
1903 static Double_t step[6]={0.0005, 0.0005, 0.0005, 0.0005, 0.001, 0.001};
1904 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1905 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1906 clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
1907 clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
1908 clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
1909 clusterInput.Fitter()->mnparm(5,"a1",vstart[5],step[5],lower[5],upper[5],ierflag);
1910 // ready for minimisation
1914 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1915 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1916 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1917 // Get fitted parameters
1919 Double_t epxz, b1, b2;
1921 clusterInput.Fitter()->mnpout(0, chname, fXFit[0], epxz, b1, b2, ierflg);
1922 clusterInput.Fitter()->mnpout(1, chname, fYFit[0], epxz, b1, b2, ierflg);
1923 clusterInput.Fitter()->mnpout(2, chname, fXFit[1], epxz, b1, b2, ierflg);
1924 clusterInput.Fitter()->mnpout(3, chname, fYFit[1], epxz, b1, b2, ierflg);
1925 clusterInput.Fitter()->mnpout(4, chname, fQrFit[0], epxz, b1, b2, ierflg);
1926 clusterInput.Fitter()->mnpout(5, chname, fQrFit[1], epxz, b1, b2, ierflg);
1928 Double_t fmin, fedm, errdef;
1929 Int_t npari, nparx, istat;
1931 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1939 void AliMUONClusterFinderVS::Split(AliMUONRawCluster* c)
1941 /// One cluster for each maximum
1944 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1945 for (j=0; j<2; j++) {
1946 AliMUONRawCluster cnew;
1947 cnew.SetGhost(c->GetGhost());
1948 for (cath=0; cath<2; cath++) {
1949 cnew.SetChi2(cath,fChi2[0]);
1950 // ?? why not cnew.fChi2[cath]=fChi2[cath];
1953 cnew.SetNcluster(0,-1);
1954 cnew.SetNcluster(1,fNRawClusters);
1956 cnew.SetNcluster(0,fNPeaks);
1957 cnew.SetNcluster(1,0);
1959 cnew.SetMultiplicity(cath,0);
1960 cnew.SetX(cath, Float_t(fXFit[j]));
1961 cnew.SetY(cath, Float_t(fYFit[j]));
1962 cnew.SetZ(cath, fZPlane);
1964 cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*fQrFit[cath]));
1966 cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*(1-fQrFit[cath])));
1968 fSeg2[cath]->SetHit(fInput->DetElemId(), fXFit[j],fYFit[j],fZPlane);
1970 for (i=0; i<fMul[cath]; i++) {
1972 cnew.SetIndex(cnew.GetMultiplicity(cath), cath, c->GetIndex(i,cath));
1974 fSeg2[cath]->SetPad(fInput->DetElemId(),fIx[i][cath], fIy[i][cath]);
1975 q1 = fInput->Mathieson()->IntXY(fInput->DetElemId(),fSeg2[cath]);
1977 cnew.SetContrib(i, cath, q1*Float_t(cnew.GetCharge(cath))/Float_t(fQ[i][cath]));
1978 cnew.SetMultiplicity(cath, cnew.GetMultiplicity(cath)+1 );
1980 FillCluster(&cnew,0,cath);
1982 cnew.SetClusterType(cnew.PhysicsContribution());
1983 if (cnew.GetCharge(0)>0 && cnew.GetCharge(1)>0) AddRawCluster(cnew);
1987 void AliMUONClusterFinderVS::AddRawCluster(AliMUONRawCluster& c)
1989 /// Add a raw cluster copy to the list
1991 // AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON");
1992 // pMUON->GetMUONData()->AddRawCluster(fInput->Chamber(),c);
1995 // Setting detection element in raw cluster for alignment
1997 c.SetDetElemId(fInput->DetElemId());
1999 TClonesArray &lrawcl = *fRawClusters;
2000 new(lrawcl[fNRawClusters++]) AliMUONRawCluster(c);
2001 AliDebug(1,Form("\nfNRawClusters %d\n",fNRawClusters));
2004 AliMUONClusterFinderVS& AliMUONClusterFinderVS
2005 ::operator = (const AliMUONClusterFinderVS& rhs)
2007 // Protected assignement operator
2009 if (this == &rhs) return *this;
2011 AliFatal("Not implemented.");
2017 // Minimisation functions
2019 void fcnS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2021 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2028 for (i=0; i<clusterInput.Nmul(0); i++) {
2029 Float_t q0=clusterInput.Charge(i,0);
2030 Float_t q1=clusterInput.DiscrChargeS1(i,par);
2039 void fcnCombiS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2041 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2048 for (cath=0; cath<2; cath++) {
2049 for (i=0; i<clusterInput.Nmul(cath); i++) {
2050 Float_t q0=clusterInput.Charge(i,cath);
2051 Float_t q1=clusterInput.DiscrChargeCombiS1(i,par,cath);
2062 void fcnS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2064 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2071 for (i=0; i<clusterInput.Nmul(0); i++) {
2073 Float_t q0=clusterInput.Charge(i,0);
2074 Float_t q1=clusterInput.DiscrChargeS2(i,par);
2084 void fcnCombiS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2086 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2092 for (cath=0; cath<2; cath++) {
2093 for (i=0; i<clusterInput.Nmul(cath); i++) {
2094 Float_t q0=clusterInput.Charge(i,cath);
2095 Float_t q1=clusterInput.DiscrChargeCombiS2(i,par,cath);