1 #include "AliMUONClusterFinder.h"
8 #include <TPostScript.h>
11 ClassImp(AliMUONRecCluster)
12 //_____________________________________________________________________
13 static AliMUONsegmentation* gSegmentation;
14 static AliMUONresponse* gResponse;
15 static Int_t gix[500];
16 static Int_t giy[500];
17 static Float_t gCharge[500];
19 static Int_t gFirst=kTRUE;
20 static TMinuit *gMyMinuit ;
21 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
22 static Int_t gChargeTot;
25 AliMUONRecCluster::AliMUONRecCluster()
33 AliMUONRecCluster(Int_t FirstDigit,Int_t Ichamber, Int_t Icathod)
37 fDigits = new TArrayI(10);
44 void AliMUONRecCluster::AddDigit(Int_t Digit)
46 if (fNdigit==fDigits->GetSize()) {
47 //enlarge the list by hand!
48 Int_t *array= new Int_t[fNdigit*2];
49 for(Int_t i=0;i<fNdigit;i++)
50 array[i] = fDigits->At(i);
51 fDigits->Adopt(fNdigit*2,array);
53 fDigits->AddAt(Digit,fNdigit);
58 AliMUONRecCluster::~AliMUONRecCluster()
64 Int_t AliMUONRecCluster::FirstDigitIndex()
67 return fDigits->At(fCurrentDigit);
70 Int_t AliMUONRecCluster::NextDigitIndex()
73 if (fCurrentDigit<fNdigit)
74 return fDigits->At(fCurrentDigit);
76 return InvalidDigitIndex();
79 Int_t AliMUONRecCluster::NDigits()
83 void AliMUONRecCluster::Finish()
85 // In order to reconstruct coordinates, one has to
86 // get back to the digits which is not trivial here,
87 // because we don't know where digits are stored!
88 // Center Of Gravity, or other method should be
89 // a property of AliMUON class!
93 //----------------------------------------------------------
94 ClassImp(AliMUONClusterFinder)
96 AliMUONClusterFinder::AliMUONClusterFinder
97 (AliMUONsegmentation *segmentation, AliMUONresponse *response,
98 TClonesArray *digits, Int_t chamber)
100 fSegmentation=segmentation;
104 fNdigits = fDigits->GetEntriesFast();
106 fRawClusters=new TClonesArray("AliMUONRawCluster",10000);
115 AliMUONClusterFinder::AliMUONClusterFinder()
123 fRawClusters=new TClonesArray("AliMUONRawCluster",10000);
133 void AliMUONClusterFinder::AddRawCluster(const AliMUONRawCluster c)
136 // Add a raw cluster copy to the list
138 AliMUON *MUON=(AliMUON*)gAlice->GetModule("MUON");
139 MUON->AddRawCluster(fChamber,c);
145 void AliMUONClusterFinder::Decluster(AliMUONRawCluster *cluster)
147 // AliMUONdigit *dig;
151 Int_t mul = cluster->fMultiplicity;
152 // printf("Decluster - multiplicity %d \n",mul);
154 if (mul == 1 || mul ==2) {
155 // printf("\n Nothing special for 1- and 2-clusters \n");
157 // Nothing special for 1- and 2-clusters
159 cluster->fNcluster[0]=fNPeaks;
160 cluster->fNcluster[1]=0;
162 AddRawCluster(*cluster);
164 } else if (mul ==3) {
166 // 3-cluster, check topology
167 // printf("\n 3-cluster, check topology \n");
168 if (fDeclusterFlag) {
169 if (Centered(cluster)) {
170 // ok, cluster is centered
171 // printf("\n ok, cluster is centered \n");
173 // cluster is not centered, split into 2+1
174 // printf("\n cluster is not centered, split into 2+1 \n");
178 cluster->fNcluster[0]=fNPeaks;
179 cluster->fNcluster[1]=0;
181 AddRawCluster(*cluster);
186 // printf("Decluster - multiplicity > 45 %d \n",mul);
187 //printf("Decluster - multiplicity < 25 %d \n",mul);
189 // 4-and more-pad clusters
191 if (mul <= fClusterSize) {
192 if (fDeclusterFlag) {
193 SplitByLocalMaxima(cluster);
196 cluster->fNcluster[0]=fNPeaks;
197 cluster->fNcluster[1]=0;
199 AddRawCluster(*cluster);
208 Bool_t AliMUONClusterFinder::Centered(AliMUONRawCluster *cluster)
211 dig= (AliMUONdigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
215 Int_t X[kMaxNeighbours], Y[kMaxNeighbours], XN[kMaxNeighbours], YN[kMaxNeighbours];
217 fSegmentation->Neighbours(ix,iy,&nn,X,Y);
219 for (Int_t i=0; i<nn; i++) {
220 if (fHitMap->TestHit(X[i],Y[i]) == used) {
228 // cluster is centered !
230 cluster->fNcluster[0]=fNPeaks;
231 cluster->fNcluster[1]=0;
233 AddRawCluster(*cluster);
238 // Highest signal on an edge, split cluster into 2+1
240 // who is the neighbour ?
241 Int_t nind=fHitMap->GetHitIndex(XN[0], YN[0]);
242 Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
243 Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;
246 AliMUONRawCluster cnew;
248 cnew.fNcluster[0]=-1;
249 cnew.fNcluster[1]=fNRawClusters;
251 cnew.fNcluster[0]=fNPeaks;
254 cnew.fMultiplicity=2;
255 cnew.fIndexMap[0]=cluster->fIndexMap[0];
256 cnew.fIndexMap[1]=cluster->fIndexMap[i1];
258 cnew.fClusterType=cnew.PhysicsContribution();
263 cluster->fMultiplicity=1;
264 cluster->fIndexMap[0]=cluster->fIndexMap[i2];
265 cluster->fIndexMap[1]=0;
266 cluster->fIndexMap[2]=0;
267 FillCluster(cluster);
269 cluster->fNcluster[0]=fNPeaks;
270 cluster->fNcluster[1]=0;
272 cluster->fClusterType=cluster->PhysicsContribution();
273 AddRawCluster(*cluster);
277 printf("\n Completely screwed up %d !! \n",nd);
283 void AliMUONClusterFinder::SplitByLocalMaxima(AliMUONRawCluster *c)
285 AliMUONdigit* dig[100], *digt;
286 Int_t ix[100], iy[100], q[100];
287 Float_t x[100], y[100];
288 Int_t i; // loops over digits
289 Int_t j; // loops over local maxima
292 // Int_t threshold=500;
293 Int_t mul=c->fMultiplicity;
295 // dump digit information into arrays
297 for (i=0; i<mul; i++)
299 dig[i]= (AliMUONdigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
300 ix[i]= dig[i]->fPadX;
301 iy[i]= dig[i]->fPadY;
302 q[i] = dig[i]->fSignal;
303 fSegmentation->GetPadCxy(ix[i], iy[i], x[i], y[i]);
310 Int_t AssocPeak[100];
313 Int_t X[kMaxNeighbours], Y[kMaxNeighbours];
314 for (i=0; i<mul; i++) {
315 fSegmentation->Neighbours(ix[i], iy[i], &nn, X, Y);
317 for (j=0; j<nn; j++) {
318 if (fHitMap->TestHit(X[j], Y[j])==empty) continue;
319 digt=(AliMUONdigit*) fHitMap->GetHit(X[j], Y[j]);
320 if (digt->fSignal > q[i]) {
324 // handle special case of neighbouring pads with equal signal
325 } else if (digt->fSignal == q[i]) {
327 for (Int_t k=0; k<NLocal; k++) {
328 if (X[j]==ix[IndLocal[k]] && Y[j]==iy[IndLocal[k]]){
334 } // loop over next neighbours
335 // Maxima should not be on the edge
340 } // loop over all digits
341 // printf("Found %d local Maxima",NLocal);
343 // If only one local maximum found but multiplicity is high
344 // take global maximum from the list of digits.
345 if (NLocal==1 && mul>12) {
347 for (i=0; i<mul; i++) {
358 // If number of local maxima is 2 try to fit a double gaussian
361 // Initialise global variables for fit
363 gSegmentation=fSegmentation;
364 gResponse =fResponse;
367 for (i=0; i<mul; i++) {
370 gCharge[i]=Float_t(q[i]);
375 gMyMinuit = new TMinuit(5);
377 gMyMinuit->SetFCN(fcn);
378 gMyMinuit->mninit(5,10,7);
379 Double_t arglist[20];
382 // gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
383 // Set starting values
384 static Double_t vstart[5];
385 vstart[0]=x[IndLocal[0]];
386 vstart[1]=y[IndLocal[0]];
387 vstart[2]=x[IndLocal[1]];
388 vstart[3]=y[IndLocal[1]];
389 vstart[4]=Float_t(q[IndLocal[0]])/
390 Float_t(q[IndLocal[0]]+q[IndLocal[1]]);
391 // lower and upper limits
392 static Double_t lower[5], upper[5];
393 Int_t isec=fSegmentation->Sector(ix[IndLocal[0]], iy[IndLocal[0]]);
394 lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
395 lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
396 // lower[1]=vstart[1];
398 upper[0]=lower[0]+fSegmentation->Dpx(isec);
399 upper[1]=lower[1]+fSegmentation->Dpy(isec);
400 // upper[1]=vstart[1];
402 isec=fSegmentation->Sector(ix[IndLocal[1]], iy[IndLocal[1]]);
403 lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
404 lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
405 // lower[3]=vstart[3];
407 upper[2]=lower[2]+fSegmentation->Dpx(isec);
408 upper[3]=lower[3]+fSegmentation->Dpy(isec);
409 // upper[3]=vstart[3];
414 static Double_t step[5]={0.005, 0.03, 0.005, 0.03, 0.01};
416 gMyMinuit->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
417 gMyMinuit->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
418 gMyMinuit->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
419 gMyMinuit->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
420 gMyMinuit->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
421 // ready for minimisation
422 gMyMinuit->SetPrintLevel(-1);
423 gMyMinuit->mnexcm("SET OUT", arglist, 0, ierflag);
427 gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
428 gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
429 gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
431 // Double_t amin,edm,errdef;
432 // Int_t nvpar,nparx,icstat;
433 // gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
434 // gMyMinuit->mnprin(3,amin);
435 // Get fitted parameters
437 Double_t xrec[2], yrec[2], qfrac;
439 Double_t epxz, b1, b2;
441 gMyMinuit->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
442 gMyMinuit->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
443 gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
444 gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
445 gMyMinuit->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
446 printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
451 // One cluster for each maximum
453 for (j=0; j<2; j++) {
454 AliMUONRawCluster cnew;
456 cnew.fNcluster[0]=-1;
457 cnew.fNcluster[1]=fNRawClusters;
459 cnew.fNcluster[0]=fNPeaks;
462 cnew.fMultiplicity=0;
463 cnew.fX=Float_t(xrec[j]);
464 cnew.fY=Float_t(yrec[j]);
466 cnew.fQ=static_cast<Int_t>(gChargeTot*qfrac);
468 cnew.fQ=static_cast<Int_t>(gChargeTot*(1-qfrac));
470 gSegmentation->SetHit(xrec[j],yrec[j]);
471 for (i=0; i<mul; i++) {
472 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
473 gSegmentation->SetPad(gix[i], giy[i]);
474 Float_t q1=gResponse->IntXY(gSegmentation);
475 cnew.fContMap[cnew.fMultiplicity]=Float_t(q[i])/(q1*cnew.fQ);
476 cnew.fMultiplicity++;
478 FillCluster(&cnew,0);
479 //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
480 cnew.fClusterType=cnew.PhysicsContribution();
488 if (NLocal !=2 || !fitted) {
489 // Check if enough local clusters have been found,
490 // if not add global maxima to the list
496 printf("\n Warning, no local maximum found \n");
500 if (nPerMax > fNperMax) {
501 Int_t nGlob=mul/fNperMax-NLocal+1;
504 for (i=0; i<mul; i++) {
511 if (nnew==nGlob) break;
516 // Associate hits to peaks
518 for (i=0; i<mul; i++) {
521 if (IsLocal[i]) continue;
522 for (j=0; j<NLocal; j++) {
523 Int_t il=IndLocal[j];
524 Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
525 +(y[i]-y[il])*(y[i]-y[il]));
528 // Select nearest peak
534 } else if (d==dmin) {
536 // If more than one take highest peak
549 // One cluster for each maximum
551 for (j=0; j<NLocal; j++) {
552 AliMUONRawCluster cnew;
554 cnew.fNcluster[0]=-1;
555 cnew.fNcluster[1]=fNRawClusters;
557 cnew.fNcluster[0]=fNPeaks;
560 cnew.fIndexMap[0]=c->fIndexMap[IndLocal[j]];
561 cnew.fMultiplicity=1;
562 for (i=0; i<mul; i++) {
563 if (IsLocal[i]) continue;
564 if (AssocPeak[i]==j) {
565 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
566 cnew.fMultiplicity++;
570 cnew.fClusterType=cnew.PhysicsContribution();
579 void AliMUONClusterFinder::FillCluster(AliMUONRawCluster* c, Int_t flag)
582 // Completes cluster information starting from list of digits
598 for (Int_t i=0; i<c->fMultiplicity; i++)
600 dig= (AliMUONdigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
601 ix=dig->fPadX+c->fOffsetMap[i];
603 Int_t q=dig->fSignal;
604 if (dig->fPhysics >= dig->fSignal) {
606 } else if (dig->fPhysics == 0) {
608 } else c->fPhysicsMap[i]=1;
611 // peak signal and track list
613 if (q>c->fPeakSignal) {
616 c->fTracks[0]=dig->fTracks[0];
617 c->fTracks[1]=dig->fTracks[1];
618 c->fTracks[2]=dig->fTracks[2];
620 //c->fTracks[0]=dig->fTrack;
621 c->fTracks[0]=dig->fHit;
622 c->fTracks[1]=dig->fTracks[0];
623 c->fTracks[2]=dig->fTracks[1];
626 if (c->fContMap[i] > frac) {
630 c->fTracks[0]=dig->fTracks[0];
631 c->fTracks[1]=dig->fTracks[1];
632 c->fTracks[2]=dig->fTracks[2];
634 //c->fTracks[0]=dig->fTrack;
635 c->fTracks[0]=dig->fHit;
636 c->fTracks[1]=dig->fTracks[0];
637 c->fTracks[2]=dig->fTracks[1];
642 fSegmentation->GetPadCxy(ix, iy, x, y);
648 } // loop over digits
653 c->fX=fSegmentation->GetAnod(c->fX);
656 // apply correction to the coordinate along the anode wire
660 fSegmentation->GetPadIxy(x, y, ix, iy);
661 fSegmentation->GetPadCxy(ix, iy, x, y);
662 Int_t isec=fSegmentation->Sector(ix,iy);
663 TF1* CogCorr = fSegmentation->CorrFunc(isec-1);
666 Float_t YonPad=(c->fY-y)/fSegmentation->Dpy(isec);
667 c->fY=c->fY-CogCorr->Eval(YonPad, 0, 0);
673 void AliMUONClusterFinder::FindCluster(Int_t i, Int_t j, AliMUONRawCluster &c){
678 // Add i,j as element of the cluster
681 Int_t idx = fHitMap->GetHitIndex(i,j);
682 AliMUONdigit* dig = (AliMUONdigit*) fHitMap->GetHit(i,j);
683 Int_t q=dig->fSignal;
684 if (q > TMath::Abs(c.fPeakSignal)) {
687 c.fTracks[0]=dig->fTracks[0];
688 c.fTracks[1]=dig->fTracks[1];
689 c.fTracks[2]=dig->fTracks[2];
691 //c.fTracks[0]=dig->fTrack;
692 c.fTracks[0]=dig->fHit;
693 c.fTracks[1]=dig->fTracks[0];
694 c.fTracks[2]=dig->fTracks[1];
697 // Make sure that list of digits is ordered
699 Int_t mu=c.fMultiplicity;
702 if (dig->fPhysics >= dig->fSignal) {
704 } else if (dig->fPhysics == 0) {
706 } else c.fPhysicsMap[mu]=1;
709 for (Int_t ind=mu-1; ind>=0; ind--) {
710 Int_t ist=(c.fIndexMap)[ind];
711 Int_t ql=((AliMUONdigit*)fDigits
712 ->UncheckedAt(ist))->fSignal;
714 c.fIndexMap[ind]=idx;
715 c.fIndexMap[ind+1]=ist;
724 if (c.fMultiplicity >= 50 ) {
725 printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity);
729 // Prepare center of gravity calculation
731 fSegmentation->GetPadCxy(i, j, x, y);
736 fHitMap->FlagHit(i,j);
738 // Now look recursively for all neighbours
741 Int_t Xlist[kMaxNeighbours], Ylist[kMaxNeighbours];
742 fSegmentation->Neighbours(i,j,&nn,Xlist,Ylist);
743 for (Int_t in=0; in<nn; in++) {
746 if (fHitMap->TestHit(ix,iy)==unused) FindCluster(ix, iy, c);
750 //_____________________________________________________________________________
752 void AliMUONClusterFinder::FindRawClusters()
755 // simple MUON cluster finder from digits -- finds neighbours and
756 // fill the tree with raw clusters
758 if (!fNdigits) return;
760 fHitMap = new AliMUONHitMapA1(fSegmentation, fDigits);
768 for (ndig=0; ndig<fNdigits; ndig++) {
769 dig = (AliMUONdigit*)fDigits->UncheckedAt(ndig);
772 if (fHitMap->TestHit(i,j)==used ||fHitMap->TestHit(i,j)==empty) {
778 c.fPeakSignal=dig->fSignal;
780 c.fTracks[0]=dig->fTracks[0];
781 c.fTracks[1]=dig->fTracks[1];
782 c.fTracks[2]=dig->fTracks[2];
784 //c.fTracks[0]=dig->fTrack;
785 c.fTracks[0]=dig->fHit;
786 c.fTracks[1]=dig->fTracks[0];
787 c.fTracks[2]=dig->fTracks[1];
788 // tag the beginning of cluster list in a raw cluster
793 c.fX=fSegmentation->GetAnod(c.fX);
796 // apply correction to the coordinate along the anode wire
801 fSegmentation->GetPadIxy(x, y, ix, iy);
802 fSegmentation->GetPadCxy(ix, iy, x, y);
803 Int_t isec=fSegmentation->Sector(ix,iy);
804 TF1* CogCorr=fSegmentation->CorrFunc(isec-1);
806 Float_t YonPad=(c.fY-y)/fSegmentation->Dpy(isec);
807 c.fY=c.fY-CogCorr->Eval(YonPad,0,0);
811 // Analyse cluster and decluster if necessary
814 c.fNcluster[1]=fNRawClusters;
815 c.fClusterType=c.PhysicsContribution();
821 // reset Cluster object
822 for (int k=0;k<c.fMultiplicity;k++) {
830 void AliMUONClusterFinder::
838 fSegmentation->GiveTestPoints(n, x, y);
839 for (i=0; i<n; i++) {
842 SinoidalFit(xtest, ytest, func);
843 fSegmentation->SetCorrFunc(i, new TF1(func));
849 void AliMUONClusterFinder::
850 SinoidalFit(Float_t x, Float_t y, TF1 &func)
853 static Int_t count=0;
856 sprintf(canvasname,"c%d",count);
859 Float_t xg[ns], yg[ns], xrg[ns], yrg[ns];
860 Float_t xsig[ns], ysig[ns];
862 AliMUONsegmentation *segmentation=fSegmentation;
865 segmentation->GetPadIxy(x,y,ix,iy);
866 segmentation->GetPadCxy(ix,iy,x,y);
867 Int_t isec=segmentation->Sector(ix,iy);
869 Float_t xmin = x-segmentation->Dpx(isec)/2;
870 Float_t ymin = y-segmentation->Dpy(isec)/2;
872 // Integration Limits
873 Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
874 Float_t dyI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
884 Float_t dy=segmentation->Dpy(isec)/(ns-1);
886 for (i=0; i<ns; i++) {
892 segmentation->SigGenInit(x, yscan, 0);
894 for (segmentation->FirstPad(x, yscan, dxI, dyI);
895 segmentation->MorePads();
896 segmentation->NextPad())
898 qp=fResponse->IntXY(segmentation);
904 Int_t ixs=segmentation->Ix();
905 Int_t iys=segmentation->Iy();
907 segmentation->GetPadCxy(ixs,iys,xs,ys);
911 Float_t ycog=sum/qcheck;
912 yg[i]=(yscan-y)/segmentation->Dpy(isec);
913 yrg[i]=(ycog-y)/segmentation->Dpy(isec);
920 Float_t dx=segmentation->Dpx(isec)/(ns-1);
922 for (i=0; i<ns; i++) {
928 segmentation->SigGenInit(xscan, y, 0);
930 for (segmentation->FirstPad(xscan, y, dxI, dyI);
931 segmentation->MorePads();
932 segmentation->NextPad())
934 qp=fResponse->IntXY(segmentation);
940 Int_t ixs=segmentation->Ix();
941 Int_t iys=segmentation->Iy();
943 segmentation->GetPadCxy(ixs,iys,xs,ys);
947 Float_t xcog=sum/qcheck;
948 xcog=segmentation->GetAnod(xcog);
950 xg[i]=(xscan-x)/segmentation->Dpx(isec);
951 xrg[i]=(xcog-x)/segmentation->Dpx(isec);
956 // Creates a Root function based on function sinoid above
957 // and perform the fit
959 // TGraph *graphx = new TGraph(ns,xg ,xsig);
960 // TGraph *graphxr= new TGraph(ns,xrg,xsig);
961 // TGraph *graphy = new TGraph(ns,yg ,ysig);
962 TGraph *graphyr= new TGraph(ns,yrg,ysig);
964 Double_t sinoid(Double_t *x, Double_t *par);
965 new TF1("sinoidf",sinoid,0.5,0.5,5);
966 graphyr->Fit("sinoidf","Q");
967 func = *((TF1*)((graphyr->GetListOfFunctions())->At(0)));
970 TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
971 TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
972 TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
973 TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
974 TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
975 pad11->SetFillColor(11);
976 pad12->SetFillColor(11);
977 pad13->SetFillColor(11);
978 pad14->SetFillColor(11);
986 graphx->SetFillColor(42);
987 graphx->SetMarkerColor(4);
988 graphx->SetMarkerStyle(21);
990 graphx->GetHistogram()->SetXTitle("x on pad");
991 graphx->GetHistogram()->SetYTitle("xcog-x");
995 graphxr->SetFillColor(42);
996 graphxr->SetMarkerColor(4);
997 graphxr->SetMarkerStyle(21);
999 graphxr->GetHistogram()->SetXTitle("xcog on pad");
1000 graphxr->GetHistogram()->SetYTitle("xcog-x");
1004 graphy->SetFillColor(42);
1005 graphy->SetMarkerColor(4);
1006 graphy->SetMarkerStyle(21);
1008 graphy->GetHistogram()->SetXTitle("y on pad");
1009 graphy->GetHistogram()->SetYTitle("ycog-y");
1014 graphyr->SetFillColor(42);
1015 graphyr->SetMarkerColor(4);
1016 graphyr->SetMarkerStyle(21);
1017 graphyr->Draw("AF");
1018 graphyr->GetHistogram()->SetXTitle("ycog on pad");
1019 graphyr->GetHistogram()->SetYTitle("ycog-y");
1025 Double_t sinoid(Double_t *x, Double_t *par)
1027 Double_t arg = -2*TMath::Pi()*x[0];
1028 Double_t fitval= par[0]*TMath::Sin(arg)+
1029 par[1]*TMath::Sin(2*arg)+
1030 par[2]*TMath::Sin(3*arg)+
1031 par[3]*TMath::Sin(4*arg)+
1032 par[4]*TMath::Sin(5*arg);
1037 Double_t DoubleGauss(Double_t *x, Double_t *par)
1039 Double_t arg1 = (x[0]-par[1])/0.18;
1040 Double_t arg2 = (x[0]-par[3])/0.18;
1041 Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
1042 +par[2]*TMath::Exp(-arg2*arg2/2);
1046 Float_t DiscrCharge(Int_t i,Double_t *par)
1048 // par[0] x-position of first cluster
1049 // par[1] y-position of first cluster
1050 // par[2] x-position of second cluster
1051 // par[3] y-position of second cluster
1052 // par[4] charge fraction of first cluster
1053 // 1-par[4] charge fraction of second cluster
1055 static Float_t qtot;
1058 for (Int_t jbin=0; jbin<gNbins; jbin++) {
1059 qtot+=gCharge[jbin];
1062 //printf("\n sum of charge from DiscrCharge %f\n", qtot);
1063 gChargeTot=static_cast<Int_t>(qtot);
1066 gSegmentation->SetPad(gix[i], giy[i]);
1068 gSegmentation->SetHit(par[0],par[1]);
1069 Float_t q1=gResponse->IntXY(gSegmentation);
1072 gSegmentation->SetHit(par[2],par[3]);
1073 Float_t q2=gResponse->IntXY(gSegmentation);
1075 Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
1080 // Minimisation function
1081 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
1089 for (i=0; i<gNbins; i++) {
1090 Float_t q0=gCharge[i];
1091 Float_t q1=DiscrCharge(i,par);
1092 delta=(q0-q1)/TMath::Sqrt(q0);
1097 chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;