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 **************************************************************************/
21 #include "AliRICHClusterFinder.h"
28 #include <TPostScript.h>
31 //----------------------------------------------------------
32 static AliRICHSegmentation* gSegmentation;
33 static AliRICHResponse* gResponse;
34 static Int_t gix[500];
35 static Int_t giy[500];
36 static Float_t gCharge[500];
38 static Int_t gFirst=kTRUE;
39 static TMinuit *gMyMinuit ;
40 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
41 static Int_t gChargeTot;
43 ClassImp(AliRICHClusterFinder)
45 AliRICHClusterFinder::AliRICHClusterFinder
46 (AliRICHSegmentation *segmentation, AliRICHResponse *response,
47 TClonesArray *digits, Int_t chamber)
49 fSegmentation=segmentation;
53 fNdigits = fDigits->GetEntriesFast();
55 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
64 AliRICHClusterFinder::AliRICHClusterFinder()
72 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
82 void AliRICHClusterFinder::AddRawCluster(const AliRICHRawCluster c)
85 // Add a raw cluster copy to the list
87 AliRICH *RICH=(AliRICH*)gAlice->GetModule("RICH");
88 RICH->AddRawCluster(fChamber,c);
94 void AliRICHClusterFinder::Decluster(AliRICHRawCluster *cluster)
100 Int_t mul = cluster->fMultiplicity;
101 // printf("Decluster - multiplicity %d \n",mul);
103 if (mul == 1 || mul ==2) {
105 // Nothing special for 1- and 2-clusters
107 cluster->fNcluster[0]=fNPeaks;
108 cluster->fNcluster[1]=0;
110 AddRawCluster(*cluster);
112 } else if (mul ==3) {
114 // 3-cluster, check topology
115 // printf("\n 3-cluster, check topology \n");
116 if (fDeclusterFlag) {
117 if (Centered(cluster)) {
118 // ok, cluster is centered
120 // cluster is not centered, split into 2+1
124 cluster->fNcluster[0]=fNPeaks;
125 cluster->fNcluster[1]=0;
127 AddRawCluster(*cluster);
132 // 4-and more-pad clusters
134 if (mul <= fClusterSize) {
135 if (fDeclusterFlag) {
136 SplitByLocalMaxima(cluster);
139 cluster->fNcluster[0]=fNPeaks;
140 cluster->fNcluster[1]=0;
142 AddRawCluster(*cluster);
150 Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
153 dig= (AliRICHDigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
157 Int_t X[kMaxNeighbours], Y[kMaxNeighbours], XN[kMaxNeighbours], YN[kMaxNeighbours];
159 fSegmentation->Neighbours(ix,iy,&nn,X,Y);
161 for (Int_t i=0; i<nn; i++) {
162 if (fHitMap->TestHit(X[i],Y[i]) == used) {
170 // cluster is centered !
172 cluster->fNcluster[0]=fNPeaks;
173 cluster->fNcluster[1]=0;
176 AddRawCluster(*cluster);
181 // Highest signal on an edge, split cluster into 2+1
183 // who is the neighbour ?
184 Int_t nind=fHitMap->GetHitIndex(XN[0], YN[0]);
185 Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
186 Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;
189 AliRICHRawCluster cnew;
191 cnew.fNcluster[0]=-1;
192 cnew.fNcluster[1]=fNRawClusters;
194 cnew.fNcluster[0]=fNPeaks;
197 cnew.fMultiplicity=2;
198 cnew.fIndexMap[0]=cluster->fIndexMap[0];
199 cnew.fIndexMap[1]=cluster->fIndexMap[i1];
201 cnew.fClusterType=cnew.PhysicsContribution();
206 cluster->fMultiplicity=1;
207 cluster->fIndexMap[0]=cluster->fIndexMap[i2];
208 cluster->fIndexMap[1]=0;
209 cluster->fIndexMap[2]=0;
210 FillCluster(cluster);
212 cluster->fNcluster[0]=fNPeaks;
213 cluster->fNcluster[1]=0;
215 cluster->fClusterType=cluster->PhysicsContribution();
216 AddRawCluster(*cluster);
220 printf("\n Completely screwed up %d !! \n",nd);
226 void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
228 AliRICHDigit* dig[100], *digt;
229 Int_t ix[100], iy[100], q[100];
230 Float_t x[100], y[100];
231 Int_t i; // loops over digits
232 Int_t j; // loops over local maxima
235 // Int_t threshold=500;
236 Int_t mul=c->fMultiplicity;
238 // dump digit information into arrays
240 for (i=0; i<mul; i++)
242 dig[i]= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
243 ix[i]= dig[i]->fPadX;
244 iy[i]= dig[i]->fPadY;
245 q[i] = dig[i]->fSignal;
246 fSegmentation->GetPadCxy(ix[i], iy[i], x[i], y[i]);
253 Int_t AssocPeak[100];
256 Int_t X[kMaxNeighbours], Y[kMaxNeighbours];
257 for (i=0; i<mul; i++) {
258 fSegmentation->Neighbours(ix[i], iy[i], &nn, X, Y);
260 for (j=0; j<nn; j++) {
261 if (fHitMap->TestHit(X[j], Y[j])==empty) continue;
262 digt=(AliRICHDigit*) fHitMap->GetHit(X[j], Y[j]);
263 if (digt->fSignal > q[i]) {
267 // handle special case of neighbouring pads with equal signal
268 } else if (digt->fSignal == q[i]) {
270 for (Int_t k=0; k<NLocal; k++) {
271 if (X[j]==ix[IndLocal[k]] && Y[j]==iy[IndLocal[k]]){
277 } // loop over next neighbours
278 // Maxima should not be on the edge
283 } // loop over all digits
284 // printf("Found %d local Maxima",NLocal);
286 // If only one local maximum found but multiplicity is high
287 // take global maximum from the list of digits.
288 if (NLocal==1 && mul>5) {
290 for (i=0; i<mul; i++) {
301 // If number of local maxima is 2 try to fit a double gaussian
304 // Initialise global variables for fit
306 gSegmentation=fSegmentation;
307 gResponse =fResponse;
310 for (i=0; i<mul; i++) {
313 gCharge[i]=Float_t(q[i]);
318 gMyMinuit = new TMinuit(5);
320 gMyMinuit->SetFCN(fcn);
321 gMyMinuit->mninit(5,10,7);
322 Double_t arglist[20];
325 // gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
326 // Set starting values
327 static Double_t vstart[5];
328 vstart[0]=x[IndLocal[0]];
329 vstart[1]=y[IndLocal[0]];
330 vstart[2]=x[IndLocal[1]];
331 vstart[3]=y[IndLocal[1]];
332 vstart[4]=Float_t(q[IndLocal[0]])/
333 Float_t(q[IndLocal[0]]+q[IndLocal[1]]);
334 // lower and upper limits
335 static Double_t lower[5], upper[5];
336 Int_t isec=fSegmentation->Sector(ix[IndLocal[0]], iy[IndLocal[0]]);
337 lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
338 lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
339 // lower[1]=vstart[1];
341 upper[0]=lower[0]+fSegmentation->Dpx(isec);
342 upper[1]=lower[1]+fSegmentation->Dpy(isec);
343 // upper[1]=vstart[1];
345 isec=fSegmentation->Sector(ix[IndLocal[1]], iy[IndLocal[1]]);
346 lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
347 lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
348 // lower[3]=vstart[3];
350 upper[2]=lower[2]+fSegmentation->Dpx(isec);
351 upper[3]=lower[3]+fSegmentation->Dpy(isec);
352 // upper[3]=vstart[3];
357 static Double_t step[5]={0.005, 0.03, 0.005, 0.03, 0.01};
359 gMyMinuit->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
360 gMyMinuit->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
361 gMyMinuit->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
362 gMyMinuit->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
363 gMyMinuit->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
364 // ready for minimisation
365 gMyMinuit->SetPrintLevel(-1);
366 gMyMinuit->mnexcm("SET OUT", arglist, 0, ierflag);
370 gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
371 gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
372 gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
374 // Double_t amin,edm,errdef;
375 // Int_t nvpar,nparx,icstat;
376 // gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
377 // gMyMinuit->mnprin(3,amin);
378 // Get fitted parameters
380 Double_t xrec[2], yrec[2], qfrac;
382 Double_t epxz, b1, b2;
384 gMyMinuit->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
385 gMyMinuit->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
386 gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
387 gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
388 gMyMinuit->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
389 //printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
394 // One cluster for each maximum
396 for (j=0; j<2; j++) {
397 AliRICHRawCluster cnew;
399 cnew.fNcluster[0]=-1;
400 cnew.fNcluster[1]=fNRawClusters;
402 cnew.fNcluster[0]=fNPeaks;
405 cnew.fMultiplicity=0;
406 cnew.fX=Float_t(xrec[j]);
407 cnew.fY=Float_t(yrec[j]);
409 cnew.fQ=Int_t(gChargeTot*qfrac);
411 cnew.fQ=Int_t(gChargeTot*(1-qfrac));
413 gSegmentation->SetHit(xrec[j],yrec[j]);
414 for (i=0; i<mul; i++) {
415 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
416 gSegmentation->SetPad(gix[i], giy[i]);
417 Float_t q1=gResponse->IntXY(gSegmentation);
418 cnew.fContMap[cnew.fMultiplicity]=Float_t(q[i])/(q1*cnew.fQ);
419 cnew.fMultiplicity++;
421 FillCluster(&cnew,0);
422 //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
423 cnew.fClusterType=cnew.PhysicsContribution();
431 if (NLocal !=-100 || !fitted) {
432 // Check if enough local clusters have been found,
433 // if not add global maxima to the list
439 printf("\n Warning, no local maximum found \n");
443 if (nPerMax > fNperMax) {
444 Int_t nGlob=mul/fNperMax-NLocal+1;
447 for (i=0; i<mul; i++) {
454 if (nnew==nGlob) break;
459 // Associate hits to peaks
461 for (i=0; i<mul; i++) {
464 if (IsLocal[i]) continue;
465 for (j=0; j<NLocal; j++) {
466 Int_t il=IndLocal[j];
467 Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
468 +(y[i]-y[il])*(y[i]-y[il]));
471 // Select nearest peak
477 } else if (d==dmin) {
479 // If more than one take highest peak
492 // One cluster for each maximum
494 for (j=0; j<NLocal; j++) {
495 AliRICHRawCluster cnew;
497 cnew.fNcluster[0]=-1;
498 cnew.fNcluster[1]=fNRawClusters;
500 cnew.fNcluster[0]=fNPeaks;
503 cnew.fIndexMap[0]=c->fIndexMap[IndLocal[j]];
504 cnew.fMultiplicity=1;
505 for (i=0; i<mul; i++) {
506 if (IsLocal[i]) continue;
507 if (AssocPeak[i]==j) {
508 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
509 cnew.fMultiplicity++;
513 cnew.fClusterType=cnew.PhysicsContribution();
521 void AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
524 // Completes cluster information starting from list of digits
540 for (Int_t i=0; i<c->fMultiplicity; i++)
542 dig= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
543 ix=dig->fPadX+c->fOffsetMap[i];
545 Int_t q=dig->fSignal;
546 if (dig->fPhysics >= dig->fSignal) {
548 } else if (dig->fPhysics == 0) {
550 } else c->fPhysicsMap[i]=1;
553 // peak signal and track list
555 if (q>c->fPeakSignal) {
558 c->fTracks[0]=dig->fTracks[0];
559 c->fTracks[1]=dig->fTracks[1];
560 c->fTracks[2]=dig->fTracks[2];
562 //c->fTracks[0]=dig->fTrack;
563 c->fTracks[0]=dig->fHit;
564 c->fTracks[1]=dig->fTracks[0];
565 c->fTracks[2]=dig->fTracks[1];
568 if (c->fContMap[i] > frac) {
572 c->fTracks[0]=dig->fTracks[0];
573 c->fTracks[1]=dig->fTracks[1];
574 c->fTracks[2]=dig->fTracks[2];
576 //c->fTracks[0]=dig->fTrack;
577 c->fTracks[0]=dig->fHit;
578 c->fTracks[1]=dig->fTracks[0];
579 c->fTracks[2]=dig->fTracks[1];
584 fSegmentation->GetPadCxy(ix, iy, x, y);
590 } // loop over digits
595 c->fX=fSegmentation->GetAnod(c->fX);
598 // apply correction to the coordinate along the anode wire
602 fSegmentation->GetPadIxy(x, y, ix, iy);
603 fSegmentation->GetPadCxy(ix, iy, x, y);
604 Int_t isec=fSegmentation->Sector(ix,iy);
605 TF1* CogCorr = fSegmentation->CorrFunc(isec-1);
608 Float_t YonPad=(c->fY-y)/fSegmentation->Dpy(isec);
609 c->fY=c->fY-CogCorr->Eval(YonPad, 0, 0);
615 void AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
620 // Add i,j as element of the cluster
623 Int_t idx = fHitMap->GetHitIndex(i,j);
624 AliRICHDigit* dig = (AliRICHDigit*) fHitMap->GetHit(i,j);
625 Int_t q=dig->fSignal;
626 if (q > TMath::Abs(c.fPeakSignal)) {
629 c.fTracks[0]=dig->fTracks[0];
630 c.fTracks[1]=dig->fTracks[1];
631 c.fTracks[2]=dig->fTracks[2];
633 //c.fTracks[0]=dig->fTrack;
634 c.fTracks[0]=dig->fHit;
635 c.fTracks[1]=dig->fTracks[0];
636 c.fTracks[2]=dig->fTracks[1];
639 // Make sure that list of digits is ordered
641 Int_t mu=c.fMultiplicity;
644 if (dig->fPhysics >= dig->fSignal) {
646 } else if (dig->fPhysics == 0) {
648 } else c.fPhysicsMap[mu]=1;
651 for (Int_t ind=mu-1; ind>=0; ind--) {
652 Int_t ist=(c.fIndexMap)[ind];
653 Int_t ql=((AliRICHDigit*)fDigits
654 ->UncheckedAt(ist))->fSignal;
656 c.fIndexMap[ind]=idx;
657 c.fIndexMap[ind+1]=ist;
666 if (c.fMultiplicity >= 50 ) {
667 printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity);
671 // Prepare center of gravity calculation
673 fSegmentation->GetPadCxy(i, j, x, y);
678 fHitMap->FlagHit(i,j);
680 // Now look recursively for all neighbours
683 Int_t Xlist[kMaxNeighbours], Ylist[kMaxNeighbours];
684 fSegmentation->Neighbours(i,j,&nn,Xlist,Ylist);
685 for (Int_t in=0; in<nn; in++) {
688 if (fHitMap->TestHit(ix,iy)==unused) FindCluster(ix, iy, c);
692 //_____________________________________________________________________________
694 void AliRICHClusterFinder::FindRawClusters()
697 // simple RICH cluster finder from digits -- finds neighbours and
698 // fill the tree with raw clusters
700 if (!fNdigits) return;
702 fHitMap = new AliRICHHitMapA1(fSegmentation, fDigits);
706 //printf ("Now I'm here");
712 for (ndig=0; ndig<fNdigits; ndig++) {
713 dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
716 if (fHitMap->TestHit(i,j)==used ||fHitMap->TestHit(i,j)==empty) {
722 c.fPeakSignal=dig->fSignal;
724 c.fTracks[0]=dig->fTracks[0];
725 c.fTracks[1]=dig->fTracks[1];
726 c.fTracks[2]=dig->fTracks[2];
728 //c.fTracks[0]=dig->fTrack;
729 c.fTracks[0]=dig->fHit;
730 c.fTracks[1]=dig->fTracks[0];
731 c.fTracks[2]=dig->fTracks[1];
732 // tag the beginning of cluster list in a raw cluster
737 c.fX=fSegmentation->GetAnod(c.fX);
740 // apply correction to the coordinate along the anode wire
745 fSegmentation->GetPadIxy(x, y, ix, iy);
746 fSegmentation->GetPadCxy(ix, iy, x, y);
747 Int_t isec=fSegmentation->Sector(ix,iy);
748 TF1* CogCorr=fSegmentation->CorrFunc(isec-1);
750 Float_t YonPad=(c.fY-y)/fSegmentation->Dpy(isec);
751 c.fY=c.fY-CogCorr->Eval(YonPad,0,0);
755 // Analyse cluster and decluster if necessary
758 c.fNcluster[1]=fNRawClusters;
759 c.fClusterType=c.PhysicsContribution();
765 // reset Cluster object
766 for (int k=0;k<c.fMultiplicity;k++) {
774 void AliRICHClusterFinder::
782 fSegmentation->GiveTestPoints(n, x, y);
783 for (i=0; i<n; i++) {
786 SinoidalFit(xtest, ytest, func);
787 fSegmentation->SetCorrFunc(i, new TF1(func));
793 void AliRICHClusterFinder::
794 SinoidalFit(Float_t x, Float_t y, TF1 &func)
797 static Int_t count=0;
800 sprintf(canvasname,"c%d",count);
803 Float_t xg[ns], yg[ns], xrg[ns], yrg[ns];
804 Float_t xsig[ns], ysig[ns];
806 AliRICHSegmentation *segmentation=fSegmentation;
809 segmentation->GetPadIxy(x,y,ix,iy);
810 segmentation->GetPadCxy(ix,iy,x,y);
811 Int_t isec=segmentation->Sector(ix,iy);
813 Float_t xmin = x-segmentation->Dpx(isec)/2;
814 Float_t ymin = y-segmentation->Dpy(isec)/2;
816 // Integration Limits
817 Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
818 Float_t dyI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
828 Float_t dy=segmentation->Dpy(isec)/(ns-1);
830 for (i=0; i<ns; i++) {
836 segmentation->SigGenInit(x, yscan, 0);
838 for (segmentation->FirstPad(x, yscan, dxI, dyI);
839 segmentation->MorePads();
840 segmentation->NextPad())
842 qp=fResponse->IntXY(segmentation);
848 Int_t ixs=segmentation->Ix();
849 Int_t iys=segmentation->Iy();
851 segmentation->GetPadCxy(ixs,iys,xs,ys);
855 Float_t ycog=sum/qcheck;
856 yg[i]=(yscan-y)/segmentation->Dpy(isec);
857 yrg[i]=(ycog-y)/segmentation->Dpy(isec);
864 Float_t dx=segmentation->Dpx(isec)/(ns-1);
866 for (i=0; i<ns; i++) {
872 segmentation->SigGenInit(xscan, y, 0);
874 for (segmentation->FirstPad(xscan, y, dxI, dyI);
875 segmentation->MorePads();
876 segmentation->NextPad())
878 qp=fResponse->IntXY(segmentation);
884 Int_t ixs=segmentation->Ix();
885 Int_t iys=segmentation->Iy();
887 segmentation->GetPadCxy(ixs,iys,xs,ys);
891 Float_t xcog=sum/qcheck;
892 xcog=segmentation->GetAnod(xcog);
894 xg[i]=(xscan-x)/segmentation->Dpx(isec);
895 xrg[i]=(xcog-x)/segmentation->Dpx(isec);
900 // Creates a Root function based on function sinoid above
901 // and perform the fit
903 // TGraph *graphx = new TGraph(ns,xg ,xsig);
904 // TGraph *graphxr= new TGraph(ns,xrg,xsig);
905 // TGraph *graphy = new TGraph(ns,yg ,ysig);
906 TGraph *graphyr= new TGraph(ns,yrg,ysig);
908 Double_t sinoid(Double_t *x, Double_t *par);
909 new TF1("sinoidf",sinoid,0.5,0.5,5);
910 graphyr->Fit("sinoidf","Q");
911 func = *((TF1*)((graphyr->GetListOfFunctions())->At(0)));
914 TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
915 TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
916 TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
917 TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
918 TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
919 pad11->SetFillColor(11);
920 pad12->SetFillColor(11);
921 pad13->SetFillColor(11);
922 pad14->SetFillColor(11);
930 graphx->SetFillColor(42);
931 graphx->SetMarkerColor(4);
932 graphx->SetMarkerStyle(21);
934 graphx->GetHistogram()->SetXTitle("x on pad");
935 graphx->GetHistogram()->SetYTitle("xcog-x");
939 graphxr->SetFillColor(42);
940 graphxr->SetMarkerColor(4);
941 graphxr->SetMarkerStyle(21);
943 graphxr->GetHistogram()->SetXTitle("xcog on pad");
944 graphxr->GetHistogram()->SetYTitle("xcog-x");
948 graphy->SetFillColor(42);
949 graphy->SetMarkerColor(4);
950 graphy->SetMarkerStyle(21);
952 graphy->GetHistogram()->SetXTitle("y on pad");
953 graphy->GetHistogram()->SetYTitle("ycog-y");
958 graphyr->SetFillColor(42);
959 graphyr->SetMarkerColor(4);
960 graphyr->SetMarkerStyle(21);
962 graphyr->GetHistogram()->SetXTitle("ycog on pad");
963 graphyr->GetHistogram()->SetYTitle("ycog-y");
969 Double_t sinoid(Double_t *x, Double_t *par)
971 Double_t arg = -2*TMath::Pi()*x[0];
972 Double_t fitval= par[0]*TMath::Sin(arg)+
973 par[1]*TMath::Sin(2*arg)+
974 par[2]*TMath::Sin(3*arg)+
975 par[3]*TMath::Sin(4*arg)+
976 par[4]*TMath::Sin(5*arg);
981 Double_t DoubleGauss(Double_t *x, Double_t *par)
983 Double_t arg1 = (x[0]-par[1])/0.18;
984 Double_t arg2 = (x[0]-par[3])/0.18;
985 Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
986 +par[2]*TMath::Exp(-arg2*arg2/2);
990 Float_t DiscrCharge(Int_t i,Double_t *par)
992 // par[0] x-position of first cluster
993 // par[1] y-position of first cluster
994 // par[2] x-position of second cluster
995 // par[3] y-position of second cluster
996 // par[4] charge fraction of first cluster
997 // 1-par[4] charge fraction of second cluster
1002 for (Int_t jbin=0; jbin<gNbins; jbin++) {
1003 qtot+=gCharge[jbin];
1006 //printf("\n sum of charge from DiscrCharge %f\n", qtot);
1007 gChargeTot=Int_t(qtot);
1010 gSegmentation->SetPad(gix[i], giy[i]);
1012 gSegmentation->SetHit(par[0],par[1]);
1013 Float_t q1=gResponse->IntXY(gSegmentation);
1016 gSegmentation->SetHit(par[2],par[3]);
1017 Float_t q2=gResponse->IntXY(gSegmentation);
1019 Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
1024 // Minimisation function
1025 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
1033 for (i=0; i<gNbins; i++) {
1034 Float_t q0=gCharge[i];
1035 Float_t q1=DiscrCharge(i,par);
1036 delta=(q0-q1)/TMath::Sqrt(q0);
1041 chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;