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()
52 /// Default constructor
53 fInput=AliMUONClusterInput::Instance();
56 fTrack[0]=fTrack[1]=-1;
57 fGhostChi2Cut = 1e6; // nothing done by default
61 for(Int_t i=0; i<100; i++) {
62 for (Int_t j=0; j<2; j++) {
66 fRawClusters = new TClonesArray("AliMUONRawCluster",1000);
69 //____________________________________________________________________________
70 AliMUONClusterFinderVS::~AliMUONClusterFinderVS()
74 // Reset tracks information
77 fRawClusters->Delete();
82 AliMUONClusterFinderVS::AliMUONClusterFinderVS(const AliMUONClusterFinderVS & clusterFinder):TObject(clusterFinder)
84 /// Protected copy constructor
86 AliFatal("Not implemented.");
88 //____________________________________________________________________________
89 void AliMUONClusterFinderVS::ResetRawClusters()
91 /// Reset tracks information
93 if (fRawClusters) fRawClusters->Clear();
95 //____________________________________________________________________________
96 void AliMUONClusterFinderVS::Decluster(AliMUONRawCluster *cluster)
98 /// Decluster by local maxima
99 SplitByLocalMaxima(cluster);
101 //____________________________________________________________________________
102 void AliMUONClusterFinderVS::SplitByLocalMaxima(AliMUONRawCluster *c)
104 /// Split complex cluster by local maxima
107 fInput->SetCluster(c);
109 fMul[0]=c->GetMultiplicity(0);
110 fMul[1]=c->GetMultiplicity(1);
113 // dump digit information into arrays
118 for (cath=0; cath<2; cath++) {
121 for (i=0; i<fMul[cath]; i++) {
123 fDig[i][cath]=fInput->Digit(cath, c->GetIndex(i, cath));
125 fIx[i][cath]= fDig[i][cath]->PadX();
126 fIy[i][cath]= fDig[i][cath]->PadY();
128 fQ[i][cath] = fDig[i][cath]->Signal();
129 // pad centre coordinates
131 GetPadC(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], fX[i][cath], fY[i][cath], fZ[i][cath]);
132 } // loop over cluster digits
134 } // loop over cathodes
140 // Initialise and perform mathieson fits
141 Float_t chi2, oldchi2;
142 // ++++++++++++++++++*************+++++++++++++++++++++
143 // (1) No more than one local maximum per cathode plane
144 // +++++++++++++++++++++++++++++++*************++++++++
145 if ((fNLocal[0]==1 && (fNLocal[1]==0 || fNLocal[1]==1)) ||
146 (fNLocal[0]==0 && fNLocal[1]==1)) {
147 // Perform combined single Mathieson fit
148 // Initial values for coordinates (x,y)
150 // One local maximum on cathodes 1 and 2 (X->cathode 2, Y->cathode 1)
151 if (fNLocal[0]==1 && fNLocal[1]==1) {
152 fXInit[0]=c->GetX(1);
153 fYInit[0]=c->GetY(0);
154 // One local maximum on cathode 1 (X,Y->cathode 1)
155 } else if (fNLocal[0]==1) {
156 fXInit[0]=c->GetX(0);
157 fYInit[0]=c->GetY(0);
158 // One local maximum on cathode 2 (X,Y->cathode 2)
160 fXInit[0]=c->GetX(1);
161 fYInit[0]=c->GetY(1);
163 AliDebug(1,"cas (1) CombiSingleMathiesonFit(c)");
164 chi2=CombiSingleMathiesonFit(c);
165 // Int_t ndf = fgNbins[0]+fgNbins[1]-2;
166 // Float_t prob = TMath::Prob(Double_t(chi2),ndf);
167 // prob1->Fill(prob);
168 // chi2_1->Fill(chi2);
170 AliDebug(1,Form(" chi2 %f ",chi2));
172 c->SetX(0, fXFit[0]);
173 c->SetY(0, fYFit[0]);
181 c->SetX(0, fSeg2[0]->GetAnod(fInput->DetElemId(), c->GetX(0)));
182 c->SetX(1, fSeg2[1]->GetAnod(fInput->DetElemId(), c->GetX(1)));
184 // c->SetDetElemId(fInput->DetElemId());
185 // If reasonable chi^2 add result to the list of rawclusters
188 // If not try combined double Mathieson Fit
190 AliDebug(1," MAUVAIS CHI2 !!!\n");
191 if (fNLocal[0]==1 && fNLocal[1]==1) {
192 fXInit[0]=fX[fIndLocal[0][1]][1];
193 fYInit[0]=fY[fIndLocal[0][0]][0];
194 fXInit[1]=fX[fIndLocal[0][1]][1];
195 fYInit[1]=fY[fIndLocal[0][0]][0];
196 } else if (fNLocal[0]==1) {
197 fXInit[0]=fX[fIndLocal[0][0]][0];
198 fYInit[0]=fY[fIndLocal[0][0]][0];
199 fXInit[1]=fX[fIndLocal[0][0]][0];
200 fYInit[1]=fY[fIndLocal[0][0]][0];
202 fXInit[0]=fX[fIndLocal[0][1]][1];
203 fYInit[0]=fY[fIndLocal[0][1]][1];
204 fXInit[1]=fX[fIndLocal[0][1]][1];
205 fYInit[1]=fY[fIndLocal[0][1]][1];
208 // Initial value for charge ratios
211 AliDebug(1,"\n cas (1) CombiDoubleMathiesonFit(c)\n");
212 chi2=CombiDoubleMathiesonFit(c);
213 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
214 // Float_t prob = TMath::Prob(chi2,ndf);
215 // prob2->Fill(prob);
216 // chi2_2->Fill(chi2);
218 // Was this any better ??
219 AliDebug(1,Form(" Old and new chi2 %f %f ", oldchi2, chi2));
220 if (fFitStat!=0 && chi2>0 && (2.*chi2 < oldchi2)) {
222 // Split cluster into two according to fit result
225 AliDebug(1,"Do not Split");
231 // +++++++++++++++++++++++++++++++++++++++
232 // (2) Two local maxima per cathode plane
233 // +++++++++++++++++++++++++++++++++++++++
234 } else if (fNLocal[0]==2 && fNLocal[1]==2) {
236 // Let's look for ghosts first
238 Float_t xm[4][2], ym[4][2];
239 Float_t dpx, dpy, dx, dy;
240 Int_t ixm[4][2], iym[4][2];
241 Int_t isec, im1, im2, ico;
243 // Form the 2x2 combinations
244 // 0-0, 0-1, 1-0, 1-1
246 for (im1=0; im1<2; im1++) {
247 for (im2=0; im2<2; im2++) {
248 xm[ico][0]=fX[fIndLocal[im1][0]][0];
249 ym[ico][0]=fY[fIndLocal[im1][0]][0];
250 xm[ico][1]=fX[fIndLocal[im2][1]][1];
251 ym[ico][1]=fY[fIndLocal[im2][1]][1];
253 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
254 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
255 ixm[ico][1]=fIx[fIndLocal[im2][1]][1];
256 iym[ico][1]=fIy[fIndLocal[im2][1]][1];
260 // ico = 0 : first local maximum on cathodes 1 and 2
261 // ico = 1 : fisrt local maximum on cathode 1 and second on cathode 2
262 // ico = 2 : second local maximum on cathode 1 and first on cathode 1
263 // ico = 3 : second local maximum on cathodes 1 and 2
265 // Analyse the combinations and keep those that are possible !
266 // For each combination check consistency in x and y
269 Float_t dr[4] = {1.e4, 1.e4, 1.e4, 1.e4};
272 // In case of staggering maxima are displaced by exactly half the pad-size in y.
273 // We have to take into account the numerical precision in the consistency check;
276 for (ico=0; ico<4; ico++) {
277 accepted[ico]=kFALSE;
278 // cathode one: x-coordinate
279 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
280 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
282 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
283 // cathode two: y-coordinate
285 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
286 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
288 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
289 AliDebug(2,Form("\n %i %f %f %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy, dx, dpx ));
290 if ((dx <= dpx) && (dy <= dpy+eps)) {
293 dr[ico] = TMath::Sqrt(dx*dx+dy*dy);
297 accepted[ico]=kFALSE;
300 AliDebug(1,Form("\n iacc= %d:\n", iacc));
302 if (accepted[0] && accepted[1]) {
303 if (dr[0] >= dr[1]) {
310 if (accepted[2] && accepted[3]) {
311 if (dr[2] >= dr[3]) {
318 // eliminate one candidate
322 for (ico=0; ico<4; ico++) {
323 if (accepted[ico] && dr[ico] > drmax) {
329 accepted[icobad] = kFALSE;
335 AliDebug(1,Form("\n iacc= %d:\n", iacc));
337 AliDebug(1,"\n iacc=2: No problem ! \n");
338 } else if (iacc==4) {
339 AliDebug(1,"\n iacc=4: Ok, but ghost problem !!! \n");
340 } else if (iacc==0) {
341 AliDebug(1,"\n iacc=0: I don't know what to do with this !!!!!!!!! \n");
344 // Initial value for charge ratios
345 fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/
346 Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]);
347 fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/
348 Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]);
350 // ******* iacc = 0 *******
351 // No combinations found between the 2 cathodes
352 // We keep the center of gravity of the cluster
357 // ******* iacc = 1 *******
358 // Only one combination found between the 2 cathodes
360 // Initial values for the 2 maxima (x,y)
362 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
363 // 1 maximum is initialised with the other maximum of the first cathode
370 } else if (accepted[1]){
376 } else if (accepted[2]){
382 } else if (accepted[3]){
389 AliDebug(1,"cas (2) CombiDoubleMathiesonFit(c)");
390 chi2=CombiDoubleMathiesonFit(c);
391 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
392 // Float_t prob = TMath::Prob(chi2,ndf);
393 // prob2->Fill(prob);
394 // chi2_2->Fill(chi2);
395 AliDebug(1,Form(" chi2 %f\n",chi2));
397 // If reasonable chi^2 add result to the list of rawclusters
402 // 1 maximum is initialised with the maximum of the combination found (X->cathode 2, Y->cathode 1)
403 // 1 maximum is initialised with the other maximum of the second cathode
410 } else if (accepted[1]){
416 } else if (accepted[2]){
422 } else if (accepted[3]){
429 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
430 chi2=CombiDoubleMathiesonFit(c);
431 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
432 // Float_t prob = TMath::Prob(chi2,ndf);
433 // prob2->Fill(prob);
434 // chi2_2->Fill(chi2);
435 AliDebug(1,Form(" chi2 %f\n",chi2));
437 // If reasonable chi^2 add result to the list of rawclusters
441 //We keep only the combination found (X->cathode 2, Y->cathode 1)
442 for (Int_t ico=0; ico<2; ico++) {
444 AliMUONRawCluster cnew;
446 for (cath=0; cath<2; cath++) {
447 cnew.SetX(cath, Float_t(xm[ico][1]));
448 cnew.SetY(cath, Float_t(ym[ico][0]));
449 cnew.SetZ(cath, fZPlane);
450 cnew.SetMultiplicity(cath,c->GetMultiplicity(cath));
451 for (i=0; i<fMul[cath]; i++) {
452 cnew.SetIndex(i, cath, c->GetIndex(i,cath));
453 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
455 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
456 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
457 FillCluster(&cnew,cath);
459 cnew.SetClusterType(cnew.PhysicsContribution());
468 // ******* iacc = 2 *******
469 // Two combinations found between the 2 cathodes
471 // Was the same maximum taken twice
472 if ((accepted[0]&&accepted[1]) || (accepted[2]&&accepted[3])) {
473 AliDebug(1,"\n Maximum taken twice !!!\n");
475 // Have a try !! with that
476 if (accepted[0]&&accepted[3]) {
487 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
488 chi2=CombiDoubleMathiesonFit(c);
489 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
490 // Float_t prob = TMath::Prob(chi2,ndf);
491 // prob2->Fill(prob);
492 // chi2_2->Fill(chi2);
496 // No ghosts ! No Problems ! - Perform one fit only !
497 if (accepted[0]&&accepted[3]) {
508 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
509 chi2=CombiDoubleMathiesonFit(c);
510 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
511 // Float_t prob = TMath::Prob(chi2,ndf);
512 // prob2->Fill(prob);
513 // chi2_2->Fill(chi2);
514 AliDebug(1,Form(" chi2 %f\n",chi2));
518 // ******* iacc = 4 *******
519 // Four combinations found between the 2 cathodes
521 } else if (iacc==4) {
522 // Perform fits for the two possibilities !!
523 // Accept if charges are compatible on both cathodes
524 // If none are compatible, keep everything
529 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
530 chi2=CombiDoubleMathiesonFit(c);
531 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
532 // Float_t prob = TMath::Prob(chi2,ndf);
533 // prob2->Fill(prob);
534 // chi2_2->Fill(chi2);
535 AliDebug(1,Form(" chi2 %f\n",chi2));
536 // store results of fit and postpone decision
537 Double_t sXFit[2],sYFit[2],sQrFit[2];
539 for (Int_t i=0;i<2;i++) {
549 AliDebug(1,"\n cas (2) CombiDoubleMathiesonFit(c)\n");
550 chi2=CombiDoubleMathiesonFit(c);
551 // ndf = fgNbins[0]+fgNbins[1]-6;
552 // prob = TMath::Prob(chi2,ndf);
553 // prob2->Fill(prob);
554 // chi2_2->Fill(chi2);
555 AliDebug(1,Form(" chi2 %f\n",chi2));
556 // We have all informations to perform the decision
557 // Compute the chi2 for the 2 possibilities
558 Float_t chi2fi,chi2si,chi2f,chi2s;
560 chi2f = (TMath::Log(fInput->TotalCharge(0)*fQrFit[0]
561 / (fInput->TotalCharge(1)*fQrFit[1]) )
562 / fInput->ChargeCorrel() );
564 chi2fi = (TMath::Log(fInput->TotalCharge(0)*(1-fQrFit[0])
565 / (fInput->TotalCharge(1)*(1-fQrFit[1])) )
566 / fInput->ChargeCorrel() );
567 chi2f += chi2fi*chi2fi;
569 chi2s = (TMath::Log(fInput->TotalCharge(0)*sQrFit[0]
570 / (fInput->TotalCharge(1)*sQrFit[1]) )
571 / fInput->ChargeCorrel() );
573 chi2si = (TMath::Log(fInput->TotalCharge(0)*(1-sQrFit[0])
574 / (fInput->TotalCharge(1)*(1-sQrFit[1])) )
575 / fInput->ChargeCorrel() );
576 chi2s += chi2si*chi2si;
578 // usefull to store the charge matching chi2 in the cluster
579 // fChi2[0]=sChi2[1]=chi2f;
580 // fChi2[1]=sChi2[0]=chi2s;
582 if (chi2f<=fGhostChi2Cut && chi2s<=fGhostChi2Cut)
584 if (chi2f>fGhostChi2Cut && chi2s>fGhostChi2Cut) {
590 if (chi2f<=fGhostChi2Cut)
592 if (chi2s<=fGhostChi2Cut) {
593 // retreive saved values
594 for (Int_t i=0;i<2;i++) {
605 } else if (fNLocal[0]==2 && fNLocal[1]==1) {
606 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
607 // (3) Two local maxima on cathode 1 and one maximum on cathode 2
608 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
610 Float_t xm[4][2], ym[4][2];
611 Float_t dpx, dpy, dx, dy;
612 Int_t ixm[4][2], iym[4][2];
613 Int_t isec, im1, ico;
615 // Form the 2x2 combinations
616 // 0-0, 0-1, 1-0, 1-1
618 for (im1=0; im1<2; im1++) {
619 xm[ico][0]=fX[fIndLocal[im1][0]][0];
620 ym[ico][0]=fY[fIndLocal[im1][0]][0];
621 xm[ico][1]=fX[fIndLocal[0][1]][1];
622 ym[ico][1]=fY[fIndLocal[0][1]][1];
624 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
625 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
626 ixm[ico][1]=fIx[fIndLocal[0][1]][1];
627 iym[ico][1]=fIy[fIndLocal[0][1]][1];
630 // ico = 0 : first local maximum on cathodes 1 and 2
631 // ico = 1 : second local maximum on cathode 1 and first on cathode 2
633 // Analyse the combinations and keep those that are possible !
634 // For each combination check consistency in x and y
638 // In case of staggering maxima are displaced by exactly half the pad-size in y.
639 // We have to take into account the numerical precision in the consistency check;
643 for (ico=0; ico<2; ico++) {
644 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
645 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
647 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
648 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
649 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
651 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
652 AliDebug(2,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
653 if ((dx <= dpx) && (dy <= dpy+eps)) {
659 accepted[ico]=kFALSE;
667 // Initial value for charge ratios
668 fQrInit[0]=Float_t(fQ[fIndLocal[0][0]][0])/
669 Float_t(fQ[fIndLocal[0][0]][0]+fQ[fIndLocal[1][0]][0]);
670 fQrInit[1]=fQrInit[0];
672 if (accepted[0] && accepted[1]) {
674 fXInit[0]=0.5*(xm[0][1]+xm[0][0]);
676 fXInit[1]=0.5*(xm[0][1]+xm[1][0]);
680 chi23=CombiDoubleMathiesonFit(c);
689 } else if (accepted[0]) {
694 chi21=CombiDoubleMathiesonFit(c);
695 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
696 // Float_t prob = TMath::Prob(chi2,ndf);
697 // prob2->Fill(prob);
698 // chi2_2->Fill(chi21);
699 AliDebug(1,Form(" chi2 %f\n",chi21));
700 if (chi21<10) Split(c);
701 } else if (accepted[1]) {
706 chi22=CombiDoubleMathiesonFit(c);
707 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
708 // Float_t prob = TMath::Prob(chi2,ndf);
709 // prob2->Fill(prob);
710 // chi2_2->Fill(chi22);
711 AliDebug(1,Form(" chi2 %f\n",chi22));
712 if (chi22<10) Split(c);
715 if (chi21 > 10 && chi22 > 10 && chi23 > 10) {
716 // We keep only the combination found (X->cathode 2, Y->cathode 1)
717 for (Int_t ico=0; ico<2; ico++) {
719 AliMUONRawCluster cnew;
721 for (cath=0; cath<2; cath++) {
722 cnew.SetX(cath, Float_t(xm[ico][1]));
723 cnew.SetY(cath, Float_t(ym[ico][0]));
724 cnew.SetZ(cath, fZPlane);
725 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
726 for (i=0; i<fMul[cath]; i++) {
727 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
728 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
731 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
732 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
734 FillCluster(&cnew,cath);
736 cnew.SetClusterType(cnew.PhysicsContribution());
743 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
744 // (3') One local maximum on cathode 1 and two maxima on cathode 2
745 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
746 } else if (fNLocal[0]==1 && fNLocal[1]==2) {
747 Float_t xm[4][2], ym[4][2];
748 Float_t dpx, dpy, dx, dy;
749 Int_t ixm[4][2], iym[4][2];
750 Int_t isec, im1, ico;
752 // Form the 2x2 combinations
753 // 0-0, 0-1, 1-0, 1-1
755 for (im1=0; im1<2; im1++) {
756 xm[ico][0]=fX[fIndLocal[0][0]][0];
757 ym[ico][0]=fY[fIndLocal[0][0]][0];
758 xm[ico][1]=fX[fIndLocal[im1][1]][1];
759 ym[ico][1]=fY[fIndLocal[im1][1]][1];
761 ixm[ico][0]=fIx[fIndLocal[0][0]][0];
762 iym[ico][0]=fIy[fIndLocal[0][0]][0];
763 ixm[ico][1]=fIx[fIndLocal[im1][1]][1];
764 iym[ico][1]=fIy[fIndLocal[im1][1]][1];
767 // ico = 0 : first local maximum on cathodes 1 and 2
768 // ico = 1 : first local maximum on cathode 1 and second on cathode 2
770 // Analyse the combinations and keep those that are possible !
771 // For each combination check consistency in x and y
775 // In case of staggering maxima are displaced by exactly half the pad-size in y.
776 // We have to take into account the numerical precision in the consistency check;
780 for (ico=0; ico<2; ico++) {
781 accepted[ico]=kFALSE;
782 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
783 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
785 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
786 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
787 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
789 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
790 AliDebug(1,Form("\n %i %f %f %f %f \n", ico, ym[ico][0], ym[ico][1], dy, dpy ));
791 if ((dx <= dpx) && (dy <= dpy+eps)) {
794 AliDebug(1,Form("ico %d\n",ico));
798 accepted[ico]=kFALSE;
806 fQrInit[1]=Float_t(fQ[fIndLocal[0][1]][1])/
807 Float_t(fQ[fIndLocal[0][1]][1]+fQ[fIndLocal[1][1]][1]);
809 fQrInit[0]=fQrInit[1];
812 if (accepted[0] && accepted[1]) {
814 fYInit[0]=0.5*(ym[0][0]+ym[0][1]);
816 fYInit[1]=0.5*(ym[0][0]+ym[1][1]);
819 chi23=CombiDoubleMathiesonFit(c);
828 } else if (accepted[0]) {
833 chi21=CombiDoubleMathiesonFit(c);
834 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
835 // Float_t prob = TMath::Prob(chi2,ndf);
836 // prob2->Fill(prob);
837 // chi2_2->Fill(chi21);
838 AliDebug(1,Form(" chi2 %f\n",chi21));
839 if (chi21<10) Split(c);
840 } else if (accepted[1]) {
845 chi22=CombiDoubleMathiesonFit(c);
846 // Int_t ndf = fgNbins[0]+fgNbins[1]-6;
847 // Float_t prob = TMath::Prob(chi2,ndf);
848 // prob2->Fill(prob);
849 // chi2_2->Fill(chi22);
850 AliDebug(1,Form(" chi2 %f\n",chi22));
851 if (chi22<10) Split(c);
854 if (chi21 > 10 && chi22 > 10 && chi23 > 10) {
855 //We keep only the combination found (X->cathode 2, Y->cathode 1)
856 for (Int_t ico=0; ico<2; ico++) {
858 AliMUONRawCluster cnew;
860 for (cath=0; cath<2; cath++) {
861 cnew.SetX(cath, Float_t(xm[ico][1]));
862 cnew.SetY(cath, Float_t(ym[ico][0]));
863 cnew.SetZ(cath, fZPlane);
864 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
865 for (i=0; i<fMul[cath]; i++) {
866 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
867 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
869 AliDebug(1,Form("\nRawCluster %d cath %d\n",ico,cath));
870 AliDebug(1,Form("mult_av %d\n",c->GetMultiplicity(cath)));
871 FillCluster(&cnew,cath);
873 cnew.SetClusterType(cnew.PhysicsContribution());
880 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
881 // (4) At least three local maxima on cathode 1 or on cathode 2
882 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
883 } else if (fNLocal[0]>2 || fNLocal[1]>2) {
884 Int_t param = fNLocal[0]*fNLocal[1];
887 Float_t ** xm = new Float_t * [param];
888 for (ii=0; ii<param; ii++) xm[ii]=new Float_t [2];
889 Float_t ** ym = new Float_t * [param];
890 for (ii=0; ii<param; ii++) ym[ii]=new Float_t [2];
891 Int_t ** ixm = new Int_t * [param];
892 for (ii=0; ii<param; ii++) ixm[ii]=new Int_t [2];
893 Int_t ** iym = new Int_t * [param];
894 for (ii=0; ii<param; ii++) iym[ii]=new Int_t [2];
897 Float_t dpx, dpy, dx, dy;
900 for (Int_t im1=0; im1<fNLocal[0]; im1++) {
901 for (Int_t im2=0; im2<fNLocal[1]; im2++) {
902 xm[ico][0]=fX[fIndLocal[im1][0]][0];
903 ym[ico][0]=fY[fIndLocal[im1][0]][0];
904 xm[ico][1]=fX[fIndLocal[im2][1]][1];
905 ym[ico][1]=fY[fIndLocal[im2][1]][1];
907 ixm[ico][0]=fIx[fIndLocal[im1][0]][0];
908 iym[ico][0]=fIy[fIndLocal[im1][0]][0];
909 ixm[ico][1]=fIx[fIndLocal[im2][1]][1];
910 iym[ico][1]=fIy[fIndLocal[im2][1]][1];
916 AliDebug(1,Form("nIco %d\n",nIco));
917 for (ico=0; ico<nIco; ico++) {
918 AliDebug(1,Form("ico = %d\n",ico));
919 isec=fSeg2[0]->Sector(fInput->DetElemId(), ixm[ico][0], iym[ico][0]);
920 dpx=fSeg2[0]->Dpx(fInput->DetElemId(), isec)/2.;
922 dx=TMath::Abs(xm[ico][0]-xm[ico][1]);
923 isec=fSeg2[1]->Sector(fInput->DetElemId(), ixm[ico][1], iym[ico][1]);
924 dpy=fSeg2[1]->Dpy(fInput->DetElemId(), isec)/2.;
926 dy=TMath::Abs(ym[ico][0]-ym[ico][1]);
927 AliDebug(1,Form("dx %f dpx %f dy %f dpy %f\n",dx,dpx,dy,dpy));
928 AliDebug(1,Form(" X %f Y %f\n",xm[ico][1],ym[ico][0]));
929 if ((dx <= dpx) && (dy <= dpy)) {
932 AliMUONRawCluster cnew;
933 for (cath=0; cath<2; cath++) {
934 cnew.SetX(cath, Float_t(xm[ico][1]));
935 cnew.SetY(cath, Float_t(ym[ico][0]));
936 cnew.SetZ(cath, fZPlane);
937 cnew.SetMultiplicity(cath, c->GetMultiplicity(cath));
938 for (i=0; i<fMul[cath]; i++) {
939 cnew.SetIndex(i, cath, c->GetIndex(i, cath));
940 fSeg2[cath]->SetPad(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
942 FillCluster(&cnew,cath);
944 cnew.SetClusterType(cnew.PhysicsContribution());
945 // cnew.SetDetElemId(fInput->DetElemId());
957 void AliMUONClusterFinderVS::FindLocalMaxima(AliMUONRawCluster* /*c*/)
959 /// Find all local maxima of a cluster
960 AliDebug(1,"\n Find Local maxima !");
964 Int_t cath, cath1; // loops over cathodes
965 Int_t i; // loops over digits
966 Int_t j; // loops over cathodes
970 // counters for number of local maxima
971 fNLocal[0]=fNLocal[1]=0;
972 // flags digits as local maximum
973 Bool_t isLocal[100][2];
974 for (i=0; i<100;i++) {
975 isLocal[i][0]=isLocal[i][1]=kFALSE;
977 // number of next neighbours and arrays to store them
980 // loop over cathodes
981 for (cath=0; cath<2; cath++) {
982 // loop over cluster digits
983 for (i=0; i<fMul[cath]; i++) {
984 // get neighbours for that digit and assume that it is local maximum
988 fSeg2[cath]->Neighbours(fInput->DetElemId(), fIx[i][cath], fIy[i][cath], &nn, x, y);
990 isLocal[i][cath]=kTRUE;
991 isec = fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath], fIy[i][cath]);
992 a0 = fSeg2[cath]->Dpx(fInput->DetElemId(), isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
994 // loop over next neighbours, if at least one neighbour has higher charger assumption
995 // digit is not local maximum
996 for (j=0; j<nn; j++) {
997 if (fDigitMap[cath]->TestHit(x[j], y[j])==kEmpty) continue;
998 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(x[j], y[j]);
1000 isec=fSeg2[cath]->Sector(fInput->DetElemId(), x[j], y[j]);
1001 a1 = fSeg2[cath]->Dpx(fInput->DetElemId(),isec)*fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1003 if (digt->Signal()/a1 > fQ[i][cath]/a0) {
1004 isLocal[i][cath]=kFALSE;
1007 // handle special case of neighbouring pads with equal signal
1008 } else if (digt->Signal() == fQ[i][cath]) {
1009 if (fNLocal[cath]>0) {
1010 for (Int_t k=0; k<fNLocal[cath]; k++) {
1011 if (x[j]==fIx[fIndLocal[k][cath]][cath]
1012 && y[j]==fIy[fIndLocal[k][cath]][cath])
1014 isLocal[i][cath]=kFALSE;
1016 } // loop over local maxima
1017 } // are there already local maxima
1019 } // loop over next neighbours
1020 if (isLocal[i][cath]) {
1021 fIndLocal[fNLocal[cath]][cath]=i;
1024 } // loop over all digits
1025 } // loop over cathodes
1027 AliDebug(1,Form("\n Found %d %d %d %d local Maxima\n",
1028 fNLocal[0], fNLocal[1], fMul[0], fMul[1]));
1029 AliDebug(1,Form("\n Cathode 1 local Maxima %d Multiplicite %d\n",fNLocal[0], fMul[0]));
1030 AliDebug(1,Form(" Cathode 2 local Maxima %d Multiplicite %d\n",fNLocal[1], fMul[1]));
1035 if (fNLocal[1]==2 && (fNLocal[0]==1 || fNLocal[0]==0)) {
1036 Int_t iback=fNLocal[0];
1038 // Two local maxima on cathode 2 and one maximum on cathode 1
1039 // Look for local maxima considering up and down neighbours on the 1st cathode only
1041 // Loop over cluster digits
1045 for (i=0; i<fMul[cath]; i++) {
1046 isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
1047 dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1048 dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1050 if (isLocal[i][cath]) continue;
1051 // Pad position should be consistent with position of local maxima on the opposite cathode
1052 if ((TMath::Abs(fX[i][cath]-fX[fIndLocal[0][cath1]][cath1]) > dpx/2.) &&
1053 (TMath::Abs(fX[i][cath]-fX[fIndLocal[1][cath1]][cath1]) > dpx/2.))
1056 // get neighbours for that digit and assume that it is local maximum
1057 isLocal[i][cath]=kTRUE;
1058 // compare signal to that on the two neighbours on the left and on the right
1059 // iNN counts the number of neighbours with signal, it should be 1 or 2
1063 for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, 0., dpy);
1064 fSeg2[cath]->MorePads(fInput->DetElemId());
1065 fSeg2[cath]->NextPad(fInput->DetElemId()))
1067 ix = fSeg2[cath]->Ix();
1068 iy = fSeg2[cath]->Iy();
1069 // skip the current pad
1070 if (iy == fIy[i][cath]) continue;
1072 if (fDigitMap[cath]->TestHit(ix, iy)!=kEmpty) {
1074 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(ix,iy);
1075 if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
1077 } // Loop over pad neighbours in y
1079 if (isLocal[i][cath] && iNN>0) {
1080 fIndLocal[fNLocal[cath]][cath]=i;
1083 } // loop over all digits
1084 // if one additional maximum has been found we are happy
1085 // if more maxima have been found restore the previous situation
1086 AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",
1088 AliDebug(1,Form(" %d local maxima for cathode 2 \n",
1090 if (fNLocal[cath]>2) {
1091 fNLocal[cath]=iback;
1094 } // 1,2 local maxima
1096 if (fNLocal[0]==2 && (fNLocal[1]==1 || fNLocal[1]==0)) {
1097 Int_t iback=fNLocal[1];
1099 // Two local maxima on cathode 1 and one maximum on cathode 2
1100 // Look for local maxima considering left and right neighbours on the 2nd cathode only
1103 Float_t eps = 1.e-5;
1106 // Loop over cluster digits
1107 for (i=0; i<fMul[cath]; i++) {
1108 isec=fSeg2[cath]->Sector(fInput->DetElemId(), fIx[i][cath],fIy[i][cath]);
1109 dpx=fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1110 dpy=fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1113 if (isLocal[i][cath]) continue;
1114 // Pad position should be consistent with position of local maxima on the opposite cathode
1115 if ((TMath::Abs(fY[i][cath]-fY[fIndLocal[0][cath1]][cath1]) > dpy/2.+eps) &&
1116 (TMath::Abs(fY[i][cath]-fY[fIndLocal[1][cath1]][cath1]) > dpy/2.+eps))
1120 // get neighbours for that digit and assume that it is local maximum
1121 isLocal[i][cath]=kTRUE;
1122 // compare signal to that on the two neighbours on the left and on the right
1124 // iNN counts the number of neighbours with signal, it should be 1 or 2
1126 for (fSeg2[cath]->FirstPad(fInput->DetElemId(), fX[i][cath], fY[i][cath], fZPlane, dpx, 0.);
1127 fSeg2[cath]->MorePads(fInput->DetElemId());
1128 fSeg2[cath]->NextPad(fInput->DetElemId()))
1131 ix = fSeg2[cath]->Ix();
1132 iy = fSeg2[cath]->Iy();
1134 // skip the current pad
1135 if (ix == fIx[i][cath]) continue;
1137 if (fDigitMap[cath]->TestHit(ix, iy)!=kEmpty) {
1139 digt=(AliMUONDigit*) fDigitMap[cath]->GetHit(ix,iy);
1140 if (digt->Signal() > fQ[i][cath]) isLocal[i][cath]=kFALSE;
1142 } // Loop over pad neighbours in x
1144 if (isLocal[i][cath] && iNN>0) {
1145 fIndLocal[fNLocal[cath]][cath]=i;
1148 } // loop over all digits
1149 // if one additional maximum has been found we are happy
1150 // if more maxima have been found restore the previous situation
1151 AliDebug(1,Form("\n New search gives %d local maxima for cathode 1 \n",fNLocal[0]));
1152 AliDebug(1,Form("\n %d local maxima for cathode 2 \n",fNLocal[1]));
1153 AliDebug(1,Form("\n New search gives %d %d \n",fNLocal[0],fNLocal[1]));
1154 if (fNLocal[cath]>2) {
1155 fNLocal[cath]=iback;
1157 } // 2,1 local maxima
1161 void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t flag, Int_t cath)
1163 /// Completes cluster information starting from list of digits
1170 c->SetPeakSignal(cath,c->GetPeakSignal(0));
1172 c->SetPeakSignal(cath,0);
1179 c->SetCharge(cath,0);
1182 AliDebug(1,Form("\n fPeakSignal %d\n",c->GetPeakSignal(cath)));
1183 for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
1185 dig= fInput->Digit(cath,c->GetIndex(i,cath));
1186 ix=dig->PadX()+c->GetOffset(i,cath);
1188 Int_t q=dig->Signal();
1189 if (!flag) q=Int_t(q*c->GetContrib(i,cath));
1190 // fprintf(stderr,"q %d c->fPeakSignal[ %d ] %d\n",q,cath,c->fPeakSignal[cath]);
1191 if (dig->Physics() >= dig->Signal()) {
1193 } else if (dig->Physics() == 0) {
1195 } else c->SetPhysics(i,1);
1198 AliDebug(2,Form("q %d c->fPeakSignal[cath] %d\n",q,c->GetPeakSignal(cath)));
1199 // peak signal and track list
1200 if (q>c->GetPeakSignal(cath)) {
1201 c->SetPeakSignal(cath, q);
1202 c->SetTrack(0,dig->Hit());
1203 c->SetTrack(1,dig->Track(0));
1204 c->SetTrack(2,dig->Track(1));
1205 // fprintf(stderr," c->fTracks[0] %d c->fTracks[1] %d\n",dig->fHit,dig->fTracks[0]);
1209 fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
1213 c->AddCharge(cath, q);
1215 } // loop over digits
1216 AliDebug(1," fin du cluster c\n");
1220 c->SetX(cath, c->GetX(cath)/c->GetCharge(cath));
1222 c->SetX(cath, fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
1223 c->SetY(cath, c->GetY(cath)/c->GetCharge(cath));
1225 // apply correction to the coordinate along the anode wire
1231 fSeg2[cath]->GetPadI(fInput->DetElemId(), x, y, fZPlane, ix, iy);
1232 fSeg2[cath]->GetPadC(fInput->DetElemId(), ix, iy, x, y, z);
1233 isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix,iy);
1234 cogCorr = fSeg2[cath]->CorrFunc(fInput->DetElemId(), isec-1);
1239 yOnPad=(c->GetY(cath)-y)/fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1241 c->SetY(cath, c->GetY(cath)-cogCorr->Eval(yOnPad, 0, 0));
1242 // slat ID from digit
1248 void AliMUONClusterFinderVS::FillCluster(AliMUONRawCluster* c, Int_t cath)
1250 /// Completes cluster information starting from list of digits
1260 Float_t xpad, ypad, zpad;
1263 for (Int_t i=0; i<c->GetMultiplicity(cath); i++)
1265 dig = fInput->Digit(cath,c->GetIndex(i,cath));
1267 GetPadC(fInput->DetElemId(),dig->PadX(),dig->PadY(),xpad,ypad, zpad);
1268 AliDebug(1,Form("x %f y %f cx %f cy %f\n",xpad,ypad,c->GetX(0),c->GetY(0)));
1269 dx = xpad - c->GetX(0);
1270 dy = ypad - c->GetY(0);
1271 dr = TMath::Sqrt(dx*dx+dy*dy);
1275 AliDebug(1,Form(" dr %f\n",dr));
1276 Int_t q=dig->Signal();
1277 if (dig->Physics() >= dig->Signal()) {
1279 } else if (dig->Physics() == 0) {
1281 } else c->SetPhysics(i,1);
1282 c->SetPeakSignal(cath,q);
1283 c->SetTrack(0,dig->Hit());
1284 c->SetTrack(1,dig->Track(0));
1285 c->SetTrack(2,dig->Track(1));
1287 AliDebug(1,Form(" c->fTracks[0] %d c->fTracks[1] %d\n",dig->Hit(),
1291 } // loop over digits
1293 // apply correction to the coordinate along the anode wire
1295 c->SetX(cath,fSeg2[cath]->GetAnod(fInput->DetElemId(), c->GetX(cath)));
1298 void AliMUONClusterFinderVS::FindCluster(Int_t i, Int_t j, Int_t cath, AliMUONRawCluster &c)
1300 /// Find a super cluster on both cathodes
1301 /// Add i,j as element of the cluster
1303 Int_t idx = fDigitMap[cath]->GetHitIndex(i,j);
1304 AliMUONDigit* dig = (AliMUONDigit*) fDigitMap[cath]->GetHit(i,j);
1305 Int_t q=dig->Signal();
1306 Int_t theX=dig->PadX();
1307 Int_t theY=dig->PadY();
1309 if (q > TMath::Abs(c.GetPeakSignal(0)) && q > TMath::Abs(c.GetPeakSignal(1))) {
1310 c.SetPeakSignal(cath,q);
1311 c.SetTrack(0,dig->Hit());
1312 c.SetTrack(1,dig->Track(0));
1313 c.SetTrack(2,dig->Track(1));
1317 // Make sure that list of digits is ordered
1319 Int_t mu=c.GetMultiplicity(cath);
1320 c.SetIndex(mu, cath, idx);
1322 if (dig->Physics() >= dig->Signal()) {
1324 } else if (dig->Physics() == 0) {
1326 } else c.SetPhysics(mu,1);
1330 for (Int_t ind = mu-1; ind >= 0; ind--) {
1331 Int_t ist=c.GetIndex(ind,cath);
1332 Int_t ql=fInput->Digit(cath, ist)->Signal();
1333 Int_t ix=fInput->Digit(cath, ist)->PadX();
1334 Int_t iy=fInput->Digit(cath, ist)->PadY();
1336 if (q>ql || (q==ql && theX > ix && theY < iy)) {
1337 c.SetIndex(ind, cath, idx);
1338 c.SetIndex(ind+1, cath, ist);
1346 c.SetMultiplicity(cath, c.GetMultiplicity(cath)+1);
1347 if (c.GetMultiplicity(cath) >= 50 ) {
1348 AliDebug(1,Form("FindCluster - multiplicity >50 %d \n",c.GetMultiplicity(0)));
1349 c.SetMultiplicity(cath, 49);
1352 // Prepare center of gravity calculation
1354 fSeg2[cath]->GetPadC(fInput->DetElemId(), i, j, x, y, z);
1357 c.AddCharge(cath,q);
1359 // Flag hit as "taken"
1360 fDigitMap[cath]->FlagHit(i,j);
1362 // Now look recursively for all neighbours and pad hit on opposite cathode
1364 // Loop over neighbours
1368 Int_t xList[10], yList[10];
1369 fSeg2[cath]->Neighbours(fInput->DetElemId(), i,j,&nn,xList,yList);
1370 for (Int_t in=0; in<nn; in++) {
1374 if (fDigitMap[cath]->TestHit(ix,iy)==kUnused) {
1375 AliDebug(2,Form("\n Neighbours %d %d %d", cath, ix, iy));
1376 FindCluster(ix, iy, cath, c);
1381 Int_t iXopp[50], iYopp[50];
1383 // Neighbours on opposite cathode
1384 // Take into account that several pads can overlap with the present pad
1386 isec=fSeg2[cath]->Sector(fInput->DetElemId(), i,j);
1393 dx = (fSeg2[cath]->Dpx(fInput->DetElemId(), isec))/2.;
1398 dy = (fSeg2[cath]->Dpy(fInput->DetElemId(), isec))/2;
1403 // loop over pad neighbours on opposite cathode
1404 for (fSeg2[iop]->FirstPad(fInput->DetElemId(), x, y, fZPlane, dx, dy);
1405 fSeg2[iop]->MorePads(fInput->DetElemId());
1406 fSeg2[iop]->NextPad(fInput->DetElemId()))
1409 ix = fSeg2[iop]->Ix(); iy = fSeg2[iop]->Iy();
1410 AliDebug(2,Form("\n ix, iy: %f %f %f %d %d %d", x,y,z,ix, iy, fSector));
1411 if (fDigitMap[iop]->TestHit(ix,iy)==kUnused){
1414 AliDebug(2,Form("\n Opposite %d %d %d", iop, ix, iy));
1417 } // Loop over pad neighbours
1418 // This had to go outside the loop since recursive calls inside the iterator are not possible
1421 for (jopp=0; jopp<nOpp; jopp++) {
1422 if (fDigitMap[iop]->TestHit(iXopp[jopp],iYopp[jopp]) == kUnused)
1423 FindCluster(iXopp[jopp], iYopp[jopp], iop, c);
1428 //_____________________________________________________________________________
1430 void AliMUONClusterFinderVS::FindRawClusters()
1432 /// MUON cluster finder from digits -- finds neighbours on both cathodes and
1433 /// fills the tree with raw clusters
1436 // Return if no input datad available
1437 if (!fInput->NDigits(0) && !fInput->NDigits(1)) return;
1439 fSeg2[0] = fInput->Segmentation2(0);
1440 fSeg2[1] = fInput->Segmentation2(1);
1442 Int_t detElemId = fInput->DetElemId();
1444 Int_t npx0 = fSeg2[0]->Npx(detElemId)+1;
1445 Int_t npy0 = fSeg2[0]->Npy(detElemId)+1;
1446 fDigitMap[0] = new AliMUONDigitMapA1(detElemId, npx0, npy0);
1448 Int_t npx1 = fSeg2[0]->Npx(detElemId)+1;
1449 Int_t npy1 = fSeg2[0]->Npy(detElemId)+1;
1450 fDigitMap[1] = new AliMUONDigitMapA1(detElemId, npx1, npy1);
1458 fDigitMap[0]->FillHits(fInput->Digits(0));
1459 fDigitMap[1]->FillHits(fInput->Digits(1));
1461 // Outer Loop over Cathodes
1462 for (cath = 0; cath < 2; cath++) {
1464 for (ndig=0; ndig<fInput->NDigits(cath); ndig++) {
1465 dig = fInput->Digit(cath, ndig);
1466 Int_t padx = dig->PadX();
1467 Int_t pady = dig->PadY();
1468 if (fDigitMap[cath]->TestHit(padx,pady)==kUsed ||fDigitMap[0]->TestHit(padx,pady)==kEmpty) {
1472 AliDebug(1,Form("\n CATHODE %d CLUSTER %d\n",cath,ncls));
1473 AliMUONRawCluster clus;
1474 clus.SetMultiplicity(0, 0);
1475 clus.SetMultiplicity(1, 0);
1476 clus.SetPeakSignal(cath,dig->Signal());
1477 clus.SetTrack(0, dig->Hit());
1478 clus.SetTrack(1, dig->Track(0));
1479 clus.SetTrack(2, dig->Track(1));
1481 AliDebug(1,Form("idDE %d Padx %d Pady %d", fInput->DetElemId(), padx, pady));
1483 // tag the beginning of cluster list in a raw cluster
1484 clus.SetNcluster(0,-1);
1486 fSeg2[cath]->GetPadC(fInput->DetElemId(), padx, pady, xcu, ycu, fZPlane);
1487 fSector= fSeg2[cath]->Sector(fInput->DetElemId(), padx, pady)/100;
1492 FindCluster(padx,pady,cath,clus);
1493 //^^^^^^^^^^^^^^^^^^^^^^^^
1494 // center of gravity
1495 if (clus.GetX(0)!=0.) clus.SetX(0, clus.GetX(0)/clus.GetCharge(0)); // clus.fX[0] /= clus.fQ[0];
1498 clus.SetX(0,fSeg2[0]->GetAnod(fInput->DetElemId(), clus.GetX(0)));
1499 if (clus.GetY(0)!=0.) clus.SetY(0, clus.GetY(0)/clus.GetCharge(0)); // clus.fY[0] /= clus.fQ[0];
1501 if(clus.GetCharge(1)!=0.) clus.SetX(1, clus.GetX(1)/clus.GetCharge(1)); // clus.fX[1] /= clus.fQ[1];
1504 clus.SetX(1, fSeg2[0]->GetAnod(fInput->DetElemId(),clus.GetX(1)));
1505 if(clus.GetCharge(1)!=0.) clus.SetY(1, clus.GetY(1)/clus.GetCharge(1));// clus.fY[1] /= clus.fQ[1];
1507 clus.SetZ(0, fZPlane);
1508 clus.SetZ(1, fZPlane);
1510 AliDebug(1,Form("\n Cathode 1 multiplicite %d X(CG) %f Y(CG) %f\n",
1511 clus.GetMultiplicity(0),clus.GetX(0),clus.GetY(0)));
1512 AliDebug(1,Form(" Cathode 2 multiplicite %d X(CG) %f Y(CG) %f\n",
1513 clus.GetMultiplicity(1),clus.GetX(1),clus.GetY(1)));
1514 // Analyse cluster and decluster if necessary
1517 clus.SetNcluster(1,fNRawClusters);
1518 clus.SetClusterType(clus.PhysicsContribution());
1525 // reset Cluster object
1526 { // begin local scope
1527 for (int k=0;k<clus.GetMultiplicity(0);k++) clus.SetIndex(k, 0, 0);
1528 } // end local scope
1530 { // begin local scope
1531 for (int k=0;k<clus.GetMultiplicity(1);k++) clus.SetIndex(k, 1, 0);
1532 } // end local scope
1534 clus.SetMultiplicity(0,0);
1535 clus.SetMultiplicity(1,0);
1539 } // end loop cathodes
1540 delete fDigitMap[0];
1541 delete fDigitMap[1];
1544 Float_t AliMUONClusterFinderVS::SingleMathiesonFit(AliMUONRawCluster *c, Int_t cath)
1546 /// Performs a single Mathieson fit on one cathode
1548 Double_t arglist[20];
1550 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1552 clusterInput.Fitter()->SetFCN(fcnS1);
1553 clusterInput.Fitter()->mninit(2,10,7);
1554 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1556 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1557 // Set starting values
1558 static Double_t vstart[2];
1559 vstart[0]=c->GetX(1);
1560 vstart[1]=c->GetY(0);
1563 // lower and upper limits
1564 static Double_t lower[2], upper[2];
1566 fSeg2[cath]->GetPadI(fInput->DetElemId(), c->GetX(cath), c->GetY(cath), fZPlane, ix, iy);
1567 isec=fSeg2[cath]->Sector(fInput->DetElemId(), ix, iy);
1569 lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(), isec)/2;
1570 lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(), isec)/2;
1572 upper[0]=lower[0]+fSeg2[cath]->Dpx(fInput->DetElemId(), isec);
1573 upper[1]=lower[1]+fSeg2[cath]->Dpy(fInput->DetElemId(), isec);
1577 static Double_t step[2]={0.0005, 0.0005};
1579 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1580 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1581 // ready for minimisation
1585 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1586 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1587 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1588 Double_t fmin, fedm, errdef;
1589 Int_t npari, nparx, istat;
1591 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1595 // Get fitted parameters
1596 Double_t xrec, yrec;
1598 Double_t epxz, b1, b2;
1600 clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg);
1601 clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg);
1607 Float_t AliMUONClusterFinderVS::CombiSingleMathiesonFit(AliMUONRawCluster * /*c*/)
1609 /// Perform combined Mathieson fit on both cathode planes
1611 Double_t arglist[20];
1613 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1614 clusterInput.Fitter()->SetFCN(fcnCombiS1);
1615 clusterInput.Fitter()->mninit(2,10,7);
1616 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1618 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1619 static Double_t vstart[2];
1620 vstart[0]=fXInit[0];
1621 vstart[1]=fYInit[0];
1624 // lower and upper limits
1625 static Float_t lower[2], upper[2];
1629 fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1630 isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
1631 dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
1632 fSeg2[1]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1633 isec=fSeg2[1]->Sector(fInput->DetElemId(), ix, iy);
1634 dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
1637 Float_t xdum, ydum, zdum;
1639 // Find save upper and lower limits
1642 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.);
1643 fSeg2[1]->MorePads(fInput->DetElemId());
1644 fSeg2[1]->NextPad(fInput->DetElemId()))
1646 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1647 fSeg2[1]->GetPadC(fInput->DetElemId(), ix,iy, upper[0], ydum, zdum);
1648 if (icount ==0) lower[0]=upper[0];
1652 if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
1655 AliDebug(1,Form("\n single y %f %f", fXInit[0], fYInit[0]));
1657 for (fSeg2[0]->FirstPad(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, 0., dpy);
1658 fSeg2[0]->MorePads(fInput->DetElemId());
1659 fSeg2[0]->NextPad(fInput->DetElemId()))
1661 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1662 fSeg2[0]->GetPadC(fInput->DetElemId(), ix,iy,xdum,upper[1],zdum);
1663 if (icount ==0) lower[1]=upper[1];
1665 AliDebug(1,Form("\n upper lower %d %f %f", icount, upper[1], lower[1]));
1668 if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
1671 static Double_t step[2]={0.00001, 0.0001};
1673 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1674 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1675 // ready for minimisation
1679 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1680 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1681 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1682 Double_t fmin, fedm, errdef;
1683 Int_t npari, nparx, istat;
1685 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1689 // Get fitted parameters
1690 Double_t xrec, yrec;
1692 Double_t epxz, b1, b2;
1694 clusterInput.Fitter()->mnpout(0, chname, xrec, epxz, b1, b2, ierflg);
1695 clusterInput.Fitter()->mnpout(1, chname, yrec, epxz, b1, b2, ierflg);
1701 Bool_t AliMUONClusterFinderVS::DoubleMathiesonFit(AliMUONRawCluster * /*c*/, Int_t cath)
1703 /// Performs a double Mathieson fit on one cathode
1706 // Initialise global variables for fit
1707 Double_t arglist[20];
1709 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1710 clusterInput.Fitter()->SetFCN(fcnS2);
1711 clusterInput.Fitter()->mninit(5,10,7);
1712 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1714 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1715 // Set starting values
1716 static Double_t vstart[5];
1717 vstart[0]=fX[fIndLocal[0][cath]][cath];
1718 vstart[1]=fY[fIndLocal[0][cath]][cath];
1719 vstart[2]=fX[fIndLocal[1][cath]][cath];
1720 vstart[3]=fY[fIndLocal[1][cath]][cath];
1721 vstart[4]=Float_t(fQ[fIndLocal[0][cath]][cath])/
1722 Float_t(fQ[fIndLocal[0][cath]][cath]+fQ[fIndLocal[1][cath]][cath]);
1723 // lower and upper limits
1724 static Float_t lower[5], upper[5];
1727 isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[0][cath]][cath],
1728 fIy[fIndLocal[0][cath]][cath]);
1729 lower[0]=vstart[0]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1730 lower[1]=vstart[1]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1732 upper[0]=lower[0]+2.*fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1733 upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1735 isec=fSeg2[cath]->Sector(fInput->DetElemId(),fIx[fIndLocal[1][cath]][cath],
1736 fIy[fIndLocal[1][cath]][cath]);
1737 lower[2]=vstart[2]-fSeg2[cath]->Dpx(fInput->DetElemId(),isec)/2;
1738 lower[3]=vstart[3]-fSeg2[cath]->Dpy(fInput->DetElemId(),isec)/2;
1740 upper[2]=lower[2]+fSeg2[cath]->Dpx(fInput->DetElemId(),isec);
1741 upper[1]=lower[1]+2.*fSeg2[cath]->Dpy(fInput->DetElemId(),isec);
1748 static Double_t step[5]={0.0005, 0.0005, 0.0005, 0.0005, 0.0001};
1750 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1751 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1752 clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
1753 clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
1754 clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
1755 // ready for minimisation
1759 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1760 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1761 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1762 // Get fitted parameters
1763 Double_t xrec[2], yrec[2], qfrac;
1765 Double_t epxz, b1, b2;
1767 clusterInput.Fitter()->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
1768 clusterInput.Fitter()->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
1769 clusterInput.Fitter()->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
1770 clusterInput.Fitter()->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
1771 clusterInput.Fitter()->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
1773 Double_t fmin, fedm, errdef;
1774 Int_t npari, nparx, istat;
1776 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1781 Float_t AliMUONClusterFinderVS::CombiDoubleMathiesonFit(AliMUONRawCluster * /*c*/)
1783 /// Perform combined double Mathieson fit on both cathode planes
1785 Double_t arglist[20];
1787 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1788 clusterInput.Fitter()->SetFCN(fcnCombiS2);
1789 clusterInput.Fitter()->mninit(6,10,7);
1790 clusterInput.Fitter()->SetPrintLevel(-1 + AliLog::GetGlobalDebugLevel());
1792 clusterInput.Fitter()->mnexcm("SET NOW", arglist, 0, ierflag);
1793 // Set starting values
1794 static Double_t vstart[6];
1795 vstart[0]=fXInit[0];
1796 vstart[1]=fYInit[0];
1797 vstart[2]=fXInit[1];
1798 vstart[3]=fYInit[1];
1799 vstart[4]=fQrInit[0];
1800 vstart[5]=fQrInit[1];
1801 // lower and upper limits
1802 static Float_t lower[6], upper[6];
1806 fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, ix, iy);
1807 isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
1808 dpx=fSeg2[1]->Dpx(fInput->DetElemId(), isec);
1810 fSeg2[0]->GetPadI(fInput->DetElemId(), fXInit[0], fYInit[0], fZPlane, ix, iy);
1811 isec=fSeg2[0]->Sector(fInput->DetElemId(), ix, iy);
1812 dpy=fSeg2[0]->Dpy(fInput->DetElemId(), isec);
1817 Float_t xdum, ydum, zdum;
1818 AliDebug(1,Form("\n Cluster Finder: %f %f %f %f ", fXInit[0], fXInit[1],fYInit[0], fYInit[1] ));
1820 // Find save upper and lower limits
1823 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, dpx, 0.);
1824 fSeg2[1]->MorePads(fInput->DetElemId());
1825 fSeg2[1]->NextPad(fInput->DetElemId()))
1827 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1828 // if (fDigitMap[1]->TestHit(ix, iy) == kEmpty) continue;
1829 fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[0],ydum,zdum);
1830 if (icount ==0) lower[0]=upper[0];
1833 if (lower[0]>upper[0]) {xdum=lower[0]; lower[0]=upper[0]; upper[0]=xdum;}
1834 // vstart[0] = 0.5*(lower[0]+upper[0]);
1839 for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[0], fYInit[0], fZPlane, 0., dpy);
1840 fSeg2[0]->MorePads(fInput->DetElemId());
1841 fSeg2[0]->NextPad(fInput->DetElemId()))
1843 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1844 // if (fDigitMap[0]->TestHit(ix, iy) == kEmpty) continue;
1845 fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[1],zdum);
1846 if (icount ==0) lower[1]=upper[1];
1850 if (lower[1]>upper[1]) {xdum=lower[1]; lower[1]=upper[1]; upper[1]=xdum;}
1851 // vstart[1] = 0.5*(lower[1]+upper[1]);
1854 fSeg2[1]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
1855 isec=fSeg2[1]->Sector(fInput->DetElemId(),ix, iy);
1856 dpx=fSeg2[1]->Dpx(fInput->DetElemId(),isec);
1857 fSeg2[0]->GetPadI(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, ix, iy);
1858 isec=fSeg2[0]->Sector(fInput->DetElemId(),ix, iy);
1859 dpy=fSeg2[0]->Dpy(fInput->DetElemId(),isec);
1862 // Find save upper and lower limits
1866 for (fSeg2[1]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, dpx, 0);
1867 fSeg2[1]->MorePads(fInput->DetElemId());
1868 fSeg2[1]->NextPad(fInput->DetElemId()))
1870 ix=fSeg2[1]->Ix(); iy=fSeg2[1]->Iy();
1871 // if (fDigitMap[1]->TestHit(ix, iy) == kEmpty) continue;
1872 fSeg2[1]->GetPadC(fInput->DetElemId(),ix,iy,upper[2],ydum,zdum);
1873 if (icount ==0) lower[2]=upper[2];
1876 if (lower[2]>upper[2]) {xdum=lower[2]; lower[2]=upper[2]; upper[2]=xdum;}
1877 // vstart[2] = 0.5*(lower[2]+upper[2]);
1881 for (fSeg2[0]->FirstPad(fInput->DetElemId(),fXInit[1], fYInit[1], fZPlane, 0, dpy);
1882 fSeg2[0]-> MorePads(fInput->DetElemId());
1883 fSeg2[0]->NextPad(fInput->DetElemId()))
1885 ix=fSeg2[0]->Ix(); iy=fSeg2[0]->Iy();
1886 // if (fDigitMap[0]->TestHit(ix, iy) != kEmpty) continue;
1888 fSeg2[0]->GetPadC(fInput->DetElemId(),ix,iy,xdum,upper[3],zdum);
1889 if (icount ==0) lower[3]=upper[3];
1893 if (lower[3]>upper[3]) {xdum=lower[3]; lower[3]=upper[3]; upper[3]=xdum;}
1901 static Double_t step[6]={0.0005, 0.0005, 0.0005, 0.0005, 0.001, 0.001};
1902 clusterInput.Fitter()->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
1903 clusterInput.Fitter()->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
1904 clusterInput.Fitter()->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
1905 clusterInput.Fitter()->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
1906 clusterInput.Fitter()->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
1907 clusterInput.Fitter()->mnparm(5,"a1",vstart[5],step[5],lower[5],upper[5],ierflag);
1908 // ready for minimisation
1912 clusterInput.Fitter()->mnexcm("SET NOGR", arglist, 0, ierflag);
1913 clusterInput.Fitter()->mnexcm("MIGRAD", arglist, 0, ierflag);
1914 // clusterInput.Fitter()->mnexcm("EXIT" , arglist, 0, ierflag);
1915 // Get fitted parameters
1917 Double_t epxz, b1, b2;
1919 clusterInput.Fitter()->mnpout(0, chname, fXFit[0], epxz, b1, b2, ierflg);
1920 clusterInput.Fitter()->mnpout(1, chname, fYFit[0], epxz, b1, b2, ierflg);
1921 clusterInput.Fitter()->mnpout(2, chname, fXFit[1], epxz, b1, b2, ierflg);
1922 clusterInput.Fitter()->mnpout(3, chname, fYFit[1], epxz, b1, b2, ierflg);
1923 clusterInput.Fitter()->mnpout(4, chname, fQrFit[0], epxz, b1, b2, ierflg);
1924 clusterInput.Fitter()->mnpout(5, chname, fQrFit[1], epxz, b1, b2, ierflg);
1926 Double_t fmin, fedm, errdef;
1927 Int_t npari, nparx, istat;
1929 clusterInput.Fitter()->mnstat(fmin, fedm, errdef, npari, nparx, istat);
1937 void AliMUONClusterFinderVS::Split(AliMUONRawCluster* c)
1939 /// One cluster for each maximum
1942 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
1943 for (j=0; j<2; j++) {
1944 AliMUONRawCluster cnew;
1945 cnew.SetGhost(c->GetGhost());
1946 for (cath=0; cath<2; cath++) {
1947 cnew.SetChi2(cath,fChi2[0]);
1948 // ?? why not cnew.fChi2[cath]=fChi2[cath];
1951 cnew.SetNcluster(0,-1);
1952 cnew.SetNcluster(1,fNRawClusters);
1954 cnew.SetNcluster(0,fNPeaks);
1955 cnew.SetNcluster(1,0);
1957 cnew.SetMultiplicity(cath,0);
1958 cnew.SetX(cath, Float_t(fXFit[j]));
1959 cnew.SetY(cath, Float_t(fYFit[j]));
1960 cnew.SetZ(cath, fZPlane);
1962 cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*fQrFit[cath]));
1964 cnew.SetCharge(cath, Int_t(clusterInput.TotalCharge(cath)*(1-fQrFit[cath])));
1966 fSeg2[cath]->SetHit(fInput->DetElemId(), fXFit[j],fYFit[j],fZPlane);
1968 for (i=0; i<fMul[cath]; i++) {
1970 cnew.SetIndex(cnew.GetMultiplicity(cath), cath, c->GetIndex(i,cath));
1972 fSeg2[cath]->SetPad(fInput->DetElemId(),fIx[i][cath], fIy[i][cath]);
1973 q1 = fInput->Mathieson()->IntXY(fInput->DetElemId(),fSeg2[cath]);
1975 cnew.SetContrib(i, cath, q1*Float_t(cnew.GetCharge(cath))/Float_t(fQ[i][cath]));
1976 cnew.SetMultiplicity(cath, cnew.GetMultiplicity(cath)+1 );
1978 FillCluster(&cnew,0,cath);
1980 cnew.SetClusterType(cnew.PhysicsContribution());
1981 if (cnew.GetCharge(0)>0 && cnew.GetCharge(1)>0) AddRawCluster(cnew);
1985 void AliMUONClusterFinderVS::AddRawCluster(AliMUONRawCluster& c)
1987 /// Add a raw cluster copy to the list
1989 // AliMUON *pMUON=(AliMUON*)gAlice->GetModule("MUON");
1990 // pMUON->GetMUONData()->AddRawCluster(fInput->Chamber(),c);
1993 // Setting detection element in raw cluster for alignment
1995 c.SetDetElemId(fInput->DetElemId());
1997 TClonesArray &lrawcl = *fRawClusters;
1998 new(lrawcl[fNRawClusters++]) AliMUONRawCluster(c);
1999 AliDebug(1,Form("\nfNRawClusters %d\n",fNRawClusters));
2002 AliMUONClusterFinderVS& AliMUONClusterFinderVS
2003 ::operator = (const AliMUONClusterFinderVS& rhs)
2005 // Protected assignement operator
2007 if (this == &rhs) return *this;
2009 AliFatal("Not implemented.");
2015 // Minimisation functions
2017 void fcnS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2019 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2026 for (i=0; i<clusterInput.Nmul(0); i++) {
2027 Float_t q0=clusterInput.Charge(i,0);
2028 Float_t q1=clusterInput.DiscrChargeS1(i,par);
2037 void fcnCombiS1(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2039 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2046 for (cath=0; cath<2; cath++) {
2047 for (i=0; i<clusterInput.Nmul(cath); i++) {
2048 Float_t q0=clusterInput.Charge(i,cath);
2049 Float_t q1=clusterInput.DiscrChargeCombiS1(i,par,cath);
2060 void fcnS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2062 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2069 for (i=0; i<clusterInput.Nmul(0); i++) {
2071 Float_t q0=clusterInput.Charge(i,0);
2072 Float_t q1=clusterInput.DiscrChargeS2(i,par);
2082 void fcnCombiS2(Int_t & /*npar*/, Double_t * /*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
2084 AliMUONClusterInput& clusterInput = *(AliMUONClusterInput::Instance());
2090 for (cath=0; cath<2; cath++) {
2091 for (i=0; i<clusterInput.Nmul(cath); i++) {
2092 Float_t q0=clusterInput.Charge(i,cath);
2093 Float_t q1=clusterInput.DiscrChargeCombiS2(i,par,cath);