1 #include "AliMUONClusterFinder.h"
8 #include <TPostScript.h>
11 //----------------------------------------------------------
12 static AliMUONsegmentation* gSegmentation;
13 static AliMUONresponse* gResponse;
14 static Int_t gix[500];
15 static Int_t giy[500];
16 static Float_t gCharge[500];
18 static Int_t gFirst=kTRUE;
19 static TMinuit *gMyMinuit ;
20 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
21 static Int_t gChargeTot;
23 //----------------------------------------------------------
25 ClassImp(AliMUONClusterFinder)
27 AliMUONClusterFinder::AliMUONClusterFinder
28 (AliMUONsegmentation *segmentation, AliMUONresponse *response,
29 TClonesArray *digits, Int_t chamber)
31 fSegmentation=segmentation;
35 fNdigits = fDigits->GetEntriesFast();
37 fRawClusters=new TClonesArray("AliMUONRawCluster",10000);
46 AliMUONClusterFinder::AliMUONClusterFinder()
54 fRawClusters=new TClonesArray("AliMUONRawCluster",10000);
64 void AliMUONClusterFinder::AddRawCluster(const AliMUONRawCluster c)
67 // Add a raw cluster copy to the list
69 AliMUON *MUON=(AliMUON*)gAlice->GetModule("MUON");
70 MUON->AddRawCluster(fChamber,c);
76 void AliMUONClusterFinder::Decluster(AliMUONRawCluster *cluster)
82 Int_t mul = cluster->fMultiplicity;
83 // printf("Decluster - multiplicity %d \n",mul);
85 if (mul == 1 || mul ==2) {
86 // printf("\n Nothing special for 1- and 2-clusters \n");
88 // Nothing special for 1- and 2-clusters
90 cluster->fNcluster[0]=fNPeaks;
91 cluster->fNcluster[1]=0;
93 AddRawCluster(*cluster);
97 // 3-cluster, check topology
98 // printf("\n 3-cluster, check topology \n");
100 if (Centered(cluster)) {
101 // ok, cluster is centered
102 // printf("\n ok, cluster is centered \n");
104 // cluster is not centered, split into 2+1
105 // printf("\n cluster is not centered, split into 2+1 \n");
109 cluster->fNcluster[0]=fNPeaks;
110 cluster->fNcluster[1]=0;
112 AddRawCluster(*cluster);
117 // printf("Decluster - multiplicity > 45 %d \n",mul);
118 //printf("Decluster - multiplicity < 25 %d \n",mul);
120 // 4-and more-pad clusters
122 if (mul <= fClusterSize) {
123 if (fDeclusterFlag) {
124 SplitByLocalMaxima(cluster);
127 cluster->fNcluster[0]=fNPeaks;
128 cluster->fNcluster[1]=0;
130 AddRawCluster(*cluster);
139 Bool_t AliMUONClusterFinder::Centered(AliMUONRawCluster *cluster)
142 dig= (AliMUONdigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
146 Int_t X[kMaxNeighbours], Y[kMaxNeighbours], XN[kMaxNeighbours], YN[kMaxNeighbours];
148 fSegmentation->Neighbours(ix,iy,&nn,X,Y);
150 for (Int_t i=0; i<nn; i++) {
151 if (fHitMap->TestHit(X[i],Y[i]) == used) {
159 // cluster is centered !
161 cluster->fNcluster[0]=fNPeaks;
162 cluster->fNcluster[1]=0;
164 AddRawCluster(*cluster);
169 // Highest signal on an edge, split cluster into 2+1
171 // who is the neighbour ?
172 Int_t nind=fHitMap->GetHitIndex(XN[0], YN[0]);
173 Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
174 Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;
177 AliMUONRawCluster cnew;
179 cnew.fNcluster[0]=-1;
180 cnew.fNcluster[1]=fNRawClusters;
182 cnew.fNcluster[0]=fNPeaks;
185 cnew.fMultiplicity=2;
186 cnew.fIndexMap[0]=cluster->fIndexMap[0];
187 cnew.fIndexMap[1]=cluster->fIndexMap[i1];
189 cnew.fClusterType=cnew.PhysicsContribution();
194 cluster->fMultiplicity=1;
195 cluster->fIndexMap[0]=cluster->fIndexMap[i2];
196 cluster->fIndexMap[1]=0;
197 cluster->fIndexMap[2]=0;
198 FillCluster(cluster);
200 cluster->fNcluster[0]=fNPeaks;
201 cluster->fNcluster[1]=0;
203 cluster->fClusterType=cluster->PhysicsContribution();
204 AddRawCluster(*cluster);
208 printf("\n Completely screwed up %d !! \n",nd);
214 void AliMUONClusterFinder::SplitByLocalMaxima(AliMUONRawCluster *c)
216 AliMUONdigit* dig[100], *digt;
217 Int_t ix[100], iy[100], q[100];
218 Float_t x[100], y[100];
219 Int_t i; // loops over digits
220 Int_t j; // loops over local maxima
223 // Int_t threshold=500;
224 Int_t mul=c->fMultiplicity;
226 // dump digit information into arrays
228 for (i=0; i<mul; i++)
230 dig[i]= (AliMUONdigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
231 ix[i]= dig[i]->fPadX;
232 iy[i]= dig[i]->fPadY;
233 q[i] = dig[i]->fSignal;
234 fSegmentation->GetPadCxy(ix[i], iy[i], x[i], y[i]);
241 Int_t AssocPeak[100];
244 Int_t X[kMaxNeighbours], Y[kMaxNeighbours];
245 for (i=0; i<mul; i++) {
246 fSegmentation->Neighbours(ix[i], iy[i], &nn, X, Y);
248 for (j=0; j<nn; j++) {
249 if (fHitMap->TestHit(X[j],Y[j])==empty) continue;
250 digt=(AliMUONdigit*) fHitMap->GetHit(X[j], Y[j]);
251 if (digt->fSignal > q[i]) {
255 // handle special case of neighbouring pads with equal signal
256 } else if (digt->fSignal == q[i]) {
258 for (Int_t k=0; k<NLocal; k++) {
259 if (X[j]==ix[IndLocal[k]] && Y[j]==iy[IndLocal[k]]){
265 } // loop over next neighbours
266 // Maxima should not be on the edge
271 } // loop over all digits
272 // printf("Found %d local Maxima",NLocal);
274 // If only one local maximum found but multiplicity is high
275 // take global maximum from the list of digits.
276 if (NLocal==1 && mul>12) {
278 for (i=0; i<mul; i++) {
289 // If number of local maxima is 2 try to fit a double gaussian
292 // Initialise global variables for fit
294 gSegmentation=fSegmentation;
295 gResponse =fResponse;
298 for (i=0; i<mul; i++) {
301 gCharge[i]=Float_t(q[i]);
306 gMyMinuit = new TMinuit(5);
308 gMyMinuit->SetFCN(fcn);
309 gMyMinuit->mninit(5,10,7);
310 Double_t arglist[20];
313 // gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
314 // Set starting values
315 static Double_t vstart[5];
316 vstart[0]=x[IndLocal[0]];
317 vstart[1]=y[IndLocal[0]];
318 vstart[2]=x[IndLocal[1]];
319 vstart[3]=y[IndLocal[1]];
320 vstart[4]=Float_t(q[IndLocal[0]])/
321 Float_t(q[IndLocal[0]]+q[IndLocal[1]]);
322 // lower and upper limits
323 static Double_t lower[5], upper[5];
324 Int_t isec=fSegmentation->Sector(ix[IndLocal[0]], iy[IndLocal[0]]);
325 lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
326 lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
327 // lower[1]=vstart[1];
329 upper[0]=lower[0]+fSegmentation->Dpx(isec);
330 upper[1]=lower[1]+fSegmentation->Dpy(isec);
331 // upper[1]=vstart[1];
333 isec=fSegmentation->Sector(ix[IndLocal[1]], iy[IndLocal[1]]);
334 lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
335 lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
336 // lower[3]=vstart[3];
338 upper[2]=lower[2]+fSegmentation->Dpx(isec);
339 upper[3]=lower[3]+fSegmentation->Dpy(isec);
340 // upper[3]=vstart[3];
345 static Double_t step[5]={0.005, 0.03, 0.005, 0.03, 0.01};
347 gMyMinuit->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
348 gMyMinuit->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
349 gMyMinuit->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
350 gMyMinuit->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
351 gMyMinuit->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
352 // ready for minimisation
353 gMyMinuit->SetPrintLevel(-1);
354 gMyMinuit->mnexcm("SET OUT", arglist, 0, ierflag);
358 gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
359 gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
360 gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
362 // Double_t amin,edm,errdef;
363 // Int_t nvpar,nparx,icstat;
364 // gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
365 // gMyMinuit->mnprin(3,amin);
366 // Get fitted parameters
368 Double_t xrec[2], yrec[2], qfrac;
370 Double_t epxz, b1, b2;
372 gMyMinuit->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
373 gMyMinuit->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
374 gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
375 gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
376 gMyMinuit->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
377 printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
382 // One cluster for each maximum
384 for (j=0; j<2; j++) {
385 AliMUONRawCluster cnew;
387 cnew.fNcluster[0]=-1;
388 cnew.fNcluster[1]=fNRawClusters;
390 cnew.fNcluster[0]=fNPeaks;
393 cnew.fMultiplicity=0;
394 cnew.fX=Float_t(xrec[j]);
395 cnew.fY=Float_t(yrec[j]);
397 cnew.fQ=Int_t(gChargeTot*qfrac);
399 cnew.fQ=Int_t(gChargeTot*(1-qfrac));
401 gSegmentation->SetHit(xrec[j],yrec[j]);
402 for (i=0; i<mul; i++) {
403 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
404 gSegmentation->SetPad(gix[i], giy[i]);
405 Float_t q1=gResponse->IntXY(gSegmentation);
406 cnew.fContMap[cnew.fMultiplicity]=Float_t(q[i])/(q1*cnew.fQ);
407 cnew.fMultiplicity++;
409 FillCluster(&cnew,0);
410 //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
411 cnew.fClusterType=cnew.PhysicsContribution();
419 if (NLocal !=2 || !fitted) {
420 // Check if enough local clusters have been found,
421 // if not add global maxima to the list
427 printf("\n Warning, no local maximum found \n");
431 if (nPerMax > fNperMax) {
432 Int_t nGlob=mul/fNperMax-NLocal+1;
435 for (i=0; i<mul; i++) {
442 if (nnew==nGlob) break;
447 // Associate hits to peaks
449 for (i=0; i<mul; i++) {
452 if (IsLocal[i]) continue;
453 for (j=0; j<NLocal; j++) {
454 Int_t il=IndLocal[j];
455 Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
456 +(y[i]-y[il])*(y[i]-y[il]));
459 // Select nearest peak
465 } else if (d==dmin) {
467 // If more than one take highest peak
480 // One cluster for each maximum
482 for (j=0; j<NLocal; j++) {
483 AliMUONRawCluster cnew;
485 cnew.fNcluster[0]=-1;
486 cnew.fNcluster[1]=fNRawClusters;
488 cnew.fNcluster[0]=fNPeaks;
491 cnew.fIndexMap[0]=c->fIndexMap[IndLocal[j]];
492 cnew.fMultiplicity=1;
493 for (i=0; i<mul; i++) {
494 if (IsLocal[i]) continue;
495 if (AssocPeak[i]==j) {
496 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
497 cnew.fMultiplicity++;
501 cnew.fClusterType=cnew.PhysicsContribution();
510 void AliMUONClusterFinder::FillCluster(AliMUONRawCluster* c, Int_t flag)
513 // Completes cluster information starting from list of digits
529 for (Int_t i=0; i<c->fMultiplicity; i++)
531 dig= (AliMUONdigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
532 ix=dig->fPadX+c->fOffsetMap[i];
534 Int_t q=dig->fSignal;
535 if (dig->fPhysics >= dig->fSignal) {
537 } else if (dig->fPhysics == 0) {
539 } else c->fPhysicsMap[i]=1;
542 // peak signal and track list
544 if (q>c->fPeakSignal) {
547 c->fTracks[0]=dig->fTracks[0];
548 c->fTracks[1]=dig->fTracks[1];
549 c->fTracks[2]=dig->fTracks[2];
551 //c->fTracks[0]=dig->fTrack;
552 c->fTracks[0]=dig->fHit;
553 c->fTracks[1]=dig->fTracks[0];
554 c->fTracks[2]=dig->fTracks[1];
557 if (c->fContMap[i] > frac) {
561 c->fTracks[0]=dig->fTracks[0];
562 c->fTracks[1]=dig->fTracks[1];
563 c->fTracks[2]=dig->fTracks[2];
565 //c->fTracks[0]=dig->fTrack;
566 c->fTracks[0]=dig->fHit;
567 c->fTracks[1]=dig->fTracks[0];
568 c->fTracks[2]=dig->fTracks[1];
573 fSegmentation->GetPadCxy(ix, iy, x, y);
579 } // loop over digits
584 c->fX=fSegmentation->GetAnod(c->fX);
587 // apply correction to the coordinate along the anode wire
591 fSegmentation->GetPadIxy(x, y, ix, iy);
592 fSegmentation->GetPadCxy(ix, iy, x, y);
593 Int_t isec=fSegmentation->Sector(ix,iy);
594 TF1* CogCorr = fSegmentation->CorrFunc(isec-1);
597 Float_t YonPad=(c->fY-y)/fSegmentation->Dpy(isec);
598 c->fY=c->fY-CogCorr->Eval(YonPad, 0, 0);
604 void AliMUONClusterFinder::FindCluster(Int_t i, Int_t j, AliMUONRawCluster &c){
609 // Add i,j as element of the cluster
612 Int_t idx = fHitMap->GetHitIndex(i,j);
613 AliMUONdigit* dig = (AliMUONdigit*) fHitMap->GetHit(i,j);
614 Int_t q=dig->fSignal;
615 if (q > TMath::Abs(c.fPeakSignal)) {
618 c.fTracks[0]=dig->fTracks[0];
619 c.fTracks[1]=dig->fTracks[1];
620 c.fTracks[2]=dig->fTracks[2];
622 //c.fTracks[0]=dig->fTrack;
623 c.fTracks[0]=dig->fHit;
624 c.fTracks[1]=dig->fTracks[0];
625 c.fTracks[2]=dig->fTracks[1];
628 // Make sure that list of digits is ordered
630 Int_t mu=c.fMultiplicity;
633 if (dig->fPhysics >= dig->fSignal) {
635 } else if (dig->fPhysics == 0) {
637 } else c.fPhysicsMap[mu]=1;
640 for (Int_t ind=mu-1; ind>=0; ind--) {
641 Int_t ist=(c.fIndexMap)[ind];
642 Int_t ql=((AliMUONdigit*)fDigits
643 ->UncheckedAt(ist))->fSignal;
645 c.fIndexMap[ind]=idx;
646 c.fIndexMap[ind+1]=ist;
655 if (c.fMultiplicity >= 50 ) {
656 printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity);
660 // Prepare center of gravity calculation
662 fSegmentation->GetPadCxy(i, j, x, y);
667 fHitMap->FlagHit(i,j);
669 // Now look recursively for all neighbours
672 Int_t Xlist[kMaxNeighbours], Ylist[kMaxNeighbours];
673 fSegmentation->Neighbours(i,j,&nn,Xlist,Ylist);
674 for (Int_t in=0; in<nn; in++) {
677 if (fHitMap->TestHit(ix,iy)==unused) FindCluster(ix, iy, c);
681 //_____________________________________________________________________________
683 void AliMUONClusterFinder::FindRawClusters()
686 // simple MUON cluster finder from digits -- finds neighbours and
687 // fill the tree with raw clusters
690 if (!fNdigits) return;
692 fHitMap = new AliMUONHitMapA1(fSegmentation, fDigits);
701 for (ndig=0; ndig<fNdigits; ndig++) {
702 dig = (AliMUONdigit*)fDigits->UncheckedAt(ndig);
705 if (fHitMap->TestHit(i,j)==used ||fHitMap->TestHit(i,j)==empty) {
711 c.fPeakSignal=dig->fSignal;
713 c.fTracks[0]=dig->fTracks[0];
714 c.fTracks[1]=dig->fTracks[1];
715 c.fTracks[2]=dig->fTracks[2];
717 //c.fTracks[0]=dig->fTrack;
718 c.fTracks[0]=dig->fHit;
719 c.fTracks[1]=dig->fTracks[0];
720 c.fTracks[2]=dig->fTracks[1];
721 // tag the beginning of cluster list in a raw cluster
726 c.fX=fSegmentation->GetAnod(c.fX);
729 // apply correction to the coordinate along the anode wire
734 fSegmentation->GetPadIxy(x, y, ix, iy);
735 fSegmentation->GetPadCxy(ix, iy, x, y);
736 Int_t isec=fSegmentation->Sector(ix,iy);
737 TF1* CogCorr=fSegmentation->CorrFunc(isec-1);
739 Float_t YonPad=(c.fY-y)/fSegmentation->Dpy(isec);
740 c.fY=c.fY-CogCorr->Eval(YonPad,0,0);
744 // Analyse cluster and decluster if necessary
747 c.fNcluster[1]=fNRawClusters;
748 c.fClusterType=c.PhysicsContribution();
754 // reset Cluster object
755 for (int k=0;k<c.fMultiplicity;k++) {
763 void AliMUONClusterFinder::
771 fSegmentation->GiveTestPoints(n, x, y);
772 for (i=0; i<n; i++) {
775 SinoidalFit(xtest, ytest, func);
776 fSegmentation->SetCorrFunc(i, new TF1(func));
782 void AliMUONClusterFinder::
783 SinoidalFit(Float_t x, Float_t y, TF1 &func)
786 static Int_t count=0;
789 sprintf(canvasname,"c%d",count);
792 Float_t xg[ns], yg[ns], xrg[ns], yrg[ns];
793 Float_t xsig[ns], ysig[ns];
795 AliMUONsegmentation *segmentation=fSegmentation;
798 segmentation->GetPadIxy(x,y,ix,iy);
799 segmentation->GetPadCxy(ix,iy,x,y);
800 Int_t isec=segmentation->Sector(ix,iy);
802 Float_t xmin = x-segmentation->Dpx(isec)/2;
803 Float_t ymin = y-segmentation->Dpy(isec)/2;
805 // Integration Limits
806 Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
807 Float_t dyI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
817 Float_t dy=segmentation->Dpy(isec)/(ns-1);
819 for (i=0; i<ns; i++) {
825 segmentation->SigGenInit(x, yscan, 0);
827 for (segmentation->FirstPad(x, yscan, dxI, dyI);
828 segmentation->MorePads();
829 segmentation->NextPad())
831 qp=fResponse->IntXY(segmentation);
837 Int_t ixs=segmentation->Ix();
838 Int_t iys=segmentation->Iy();
840 segmentation->GetPadCxy(ixs,iys,xs,ys);
844 Float_t ycog=sum/qcheck;
845 yg[i]=(yscan-y)/segmentation->Dpy(isec);
846 yrg[i]=(ycog-y)/segmentation->Dpy(isec);
853 Float_t dx=segmentation->Dpx(isec)/(ns-1);
855 for (i=0; i<ns; i++) {
861 segmentation->SigGenInit(xscan, y, 0);
863 for (segmentation->FirstPad(xscan, y, dxI, dyI);
864 segmentation->MorePads();
865 segmentation->NextPad())
867 qp=fResponse->IntXY(segmentation);
873 Int_t ixs=segmentation->Ix();
874 Int_t iys=segmentation->Iy();
876 segmentation->GetPadCxy(ixs,iys,xs,ys);
880 Float_t xcog=sum/qcheck;
881 xcog=segmentation->GetAnod(xcog);
883 xg[i]=(xscan-x)/segmentation->Dpx(isec);
884 xrg[i]=(xcog-x)/segmentation->Dpx(isec);
889 // Creates a Root function based on function sinoid above
890 // and perform the fit
892 // TGraph *graphx = new TGraph(ns,xg ,xsig);
893 // TGraph *graphxr= new TGraph(ns,xrg,xsig);
894 // TGraph *graphy = new TGraph(ns,yg ,ysig);
895 TGraph *graphyr= new TGraph(ns,yrg,ysig);
897 Double_t sinoid(Double_t *x, Double_t *par);
898 new TF1("sinoidf",sinoid,0.5,0.5,5);
899 graphyr->Fit("sinoidf","Q");
900 func = *((TF1*)((graphyr->GetListOfFunctions())->At(0)));
903 TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
904 TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
905 TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
906 TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
907 TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
908 pad11->SetFillColor(11);
909 pad12->SetFillColor(11);
910 pad13->SetFillColor(11);
911 pad14->SetFillColor(11);
919 graphx->SetFillColor(42);
920 graphx->SetMarkerColor(4);
921 graphx->SetMarkerStyle(21);
923 graphx->GetHistogram()->SetXTitle("x on pad");
924 graphx->GetHistogram()->SetYTitle("xcog-x");
928 graphxr->SetFillColor(42);
929 graphxr->SetMarkerColor(4);
930 graphxr->SetMarkerStyle(21);
932 graphxr->GetHistogram()->SetXTitle("xcog on pad");
933 graphxr->GetHistogram()->SetYTitle("xcog-x");
937 graphy->SetFillColor(42);
938 graphy->SetMarkerColor(4);
939 graphy->SetMarkerStyle(21);
941 graphy->GetHistogram()->SetXTitle("y on pad");
942 graphy->GetHistogram()->SetYTitle("ycog-y");
947 graphyr->SetFillColor(42);
948 graphyr->SetMarkerColor(4);
949 graphyr->SetMarkerStyle(21);
951 graphyr->GetHistogram()->SetXTitle("ycog on pad");
952 graphyr->GetHistogram()->SetYTitle("ycog-y");
958 Double_t sinoid(Double_t *x, Double_t *par)
960 Double_t arg = -2*TMath::Pi()*x[0];
961 Double_t fitval= par[0]*TMath::Sin(arg)+
962 par[1]*TMath::Sin(2*arg)+
963 par[2]*TMath::Sin(3*arg)+
964 par[3]*TMath::Sin(4*arg)+
965 par[4]*TMath::Sin(5*arg);
970 Double_t DoubleGauss(Double_t *x, Double_t *par)
972 Double_t arg1 = (x[0]-par[1])/0.18;
973 Double_t arg2 = (x[0]-par[3])/0.18;
974 Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
975 +par[2]*TMath::Exp(-arg2*arg2/2);
979 Float_t DiscrCharge(Int_t i,Double_t *par)
981 // par[0] x-position of first cluster
982 // par[1] y-position of first cluster
983 // par[2] x-position of second cluster
984 // par[3] y-position of second cluster
985 // par[4] charge fraction of first cluster
986 // 1-par[4] charge fraction of second cluster
991 for (Int_t jbin=0; jbin<gNbins; jbin++) {
995 //printf("\n sum of charge from DiscrCharge %f\n", qtot);
996 gChargeTot=Int_t(qtot);
999 gSegmentation->SetPad(gix[i], giy[i]);
1001 gSegmentation->SetHit(par[0],par[1]);
1002 Float_t q1=gResponse->IntXY(gSegmentation);
1005 gSegmentation->SetHit(par[2],par[3]);
1006 Float_t q2=gResponse->IntXY(gSegmentation);
1008 Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
1013 // Minimisation function
1014 void fcn(Int_t &, Double_t *, Double_t &f, Double_t *par, Int_t )
1022 for (i=0; i<gNbins; i++) {
1023 Float_t q0=gCharge[i];
1024 Float_t q1=DiscrCharge(i,par);
1025 delta=(q0-q1)/TMath::Sqrt(q0);
1030 chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;