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 Revision 1.9 2001/01/26 20:00:27 hristov
19 Major upgrade of AliRoot code
21 Revision 1.8 2000/11/02 09:11:12 jbarbosa
22 Removed AliRICHRecHit.h from include.
24 Revision 1.7 2000/10/03 21:44:09 morsch
25 Use AliSegmentation and AliHit abstract base classes.
27 Revision 1.6 2000/10/02 21:28:12 fca
28 Removal of useless dependecies via forward declarations
30 Revision 1.5 2000/10/02 15:45:58 jbarbosa
31 Fixed forward declarations.
33 Revision 1.4 2000/06/12 19:01:29 morsch
34 Clean-up bug in Centered() corrected.
36 Revision 1.3 2000/06/12 15:49:44 jbarbosa
37 Removed verbose output.
39 Revision 1.2 2000/06/12 15:18:19 jbarbosa
42 Revision 1.1 2000/04/19 13:01:48 morsch
43 A cluster finder and hit reconstruction class for RICH (adapted from MUON).
44 Cluster Finders for MUON and RICH should derive from the same class in the
50 #include "AliRICHClusterFinder.h"
53 #include "AliRICHHit.h"
54 #include "AliRICHHitMapA1.h"
55 #include "AliRICHCerenkov.h"
56 #include "AliRICHSDigit.h"
57 #include "AliRICHDigit.h"
58 #include "AliRICHRawCluster.h"
66 #include <TPostScript.h>
69 //----------------------------------------------------------
70 static AliSegmentation* gSegmentation;
71 static AliRICHResponse* gResponse;
72 static Int_t gix[500];
73 static Int_t giy[500];
74 static Float_t gCharge[500];
76 static Int_t gFirst=kTRUE;
77 static TMinuit *gMyMinuit ;
78 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
79 static Int_t gChargeTot;
81 ClassImp(AliRICHClusterFinder)
83 AliRICHClusterFinder::AliRICHClusterFinder
84 (AliSegmentation *segmentation, AliRICHResponse *response,
85 TClonesArray *digits, Int_t chamber)
88 // Constructor for Cluster Finder object
90 fSegmentation=segmentation;
94 fNdigits = fDigits->GetEntriesFast();
96 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
105 AliRICHClusterFinder::AliRICHClusterFinder()
108 // Default constructor
116 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
126 AliRICHClusterFinder::AliRICHClusterFinder(const AliRICHClusterFinder& ClusterFinder)
131 AliRICHClusterFinder::~AliRICHClusterFinder()
139 void AliRICHClusterFinder::AddRawCluster(const AliRICHRawCluster c)
142 // Add a raw cluster copy to the list
144 AliRICH *pRICH=(AliRICH*)gAlice->GetModule("RICH");
145 pRICH->AddRawCluster(fChamber,c);
151 void AliRICHClusterFinder::Decluster(AliRICHRawCluster *cluster)
155 // Decluster algorithm
157 Int_t mul = cluster->fMultiplicity;
158 // printf("Decluster - multiplicity %d \n",mul);
160 if (mul == 1 || mul ==2) {
162 // Nothing special for 1- and 2-clusters
164 cluster->fNcluster[0]=fNPeaks;
165 cluster->fNcluster[1]=0;
167 AddRawCluster(*cluster);
169 } else if (mul ==3) {
171 // 3-cluster, check topology
172 // printf("\n 3-cluster, check topology \n");
173 if (fDeclusterFlag) {
174 if (Centered(cluster)) {
175 // ok, cluster is centered
177 // cluster is not centered, split into 2+1
181 cluster->fNcluster[0]=fNPeaks;
182 cluster->fNcluster[1]=0;
184 AddRawCluster(*cluster);
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);
207 Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
210 // Is the cluster centered?
213 dig= (AliRICHDigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
217 Int_t x[kMaxNeighbours], y[kMaxNeighbours], xN[kMaxNeighbours], yN[kMaxNeighbours];
219 fSegmentation->Neighbours(ix,iy,&nn,x,y);
221 for (Int_t i=0; i<nn; i++) {
222 if (fHitMap->TestHit(x[i],y[i]) == kUsed) {
227 //printf("Getting: %d %d %d\n",i,x[i],y[i]);
232 // cluster is centered !
234 cluster->fNcluster[0]=fNPeaks;
235 cluster->fNcluster[1]=0;
238 AddRawCluster(*cluster);
243 // Highest signal on an edge, split cluster into 2+1
245 // who is the neighbour ?
247 //printf("Calling GetIndex with x:%d y:%d\n",xN[0], yN[0]);
249 Int_t nind=fHitMap->GetHitIndex(xN[0], yN[0]);
250 Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
251 Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;
254 AliRICHRawCluster cnew;
256 cnew.fNcluster[0]=-1;
257 cnew.fNcluster[1]=fNRawClusters;
259 cnew.fNcluster[0]=fNPeaks;
262 cnew.fMultiplicity=2;
263 cnew.fIndexMap[0]=cluster->fIndexMap[0];
264 cnew.fIndexMap[1]=cluster->fIndexMap[i1];
266 cnew.fClusterType=cnew.PhysicsContribution();
271 cluster->fMultiplicity=1;
272 cluster->fIndexMap[0]=cluster->fIndexMap[i2];
273 cluster->fIndexMap[1]=0;
274 cluster->fIndexMap[2]=0;
275 FillCluster(cluster);
277 cluster->fNcluster[0]=fNPeaks;
278 cluster->fNcluster[1]=0;
280 cluster->fClusterType=cluster->PhysicsContribution();
281 AddRawCluster(*cluster);
285 printf("\n Completely screwed up %d !! \n",nd);
291 void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
295 // Split the cluster according to the number of maxima inside
298 AliRICHDigit* dig[100], *digt;
299 Int_t ix[100], iy[100], q[100];
300 Float_t x[100], y[100], zdum;
301 Int_t i; // loops over digits
302 Int_t j; // loops over local maxima
305 // Int_t threshold=500;
306 Int_t mul=c->fMultiplicity;
308 // dump digit information into arrays
310 for (i=0; i<mul; i++)
312 dig[i]= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
313 ix[i]= dig[i]->fPadX;
314 iy[i]= dig[i]->fPadY;
315 q[i] = dig[i]->fSignal;
316 fSegmentation->GetPadC(ix[i], iy[i], x[i], y[i], zdum);
323 Int_t associatePeak[100];
326 Int_t xNei[kMaxNeighbours], yNei[kMaxNeighbours];
327 for (i=0; i<mul; i++) {
328 fSegmentation->Neighbours(ix[i], iy[i], &nn, xNei, yNei);
330 for (j=0; j<nn; j++) {
331 if (fHitMap->TestHit(xNei[j], yNei[j])==kEmpty) continue;
332 digt=(AliRICHDigit*) fHitMap->GetHit(xNei[j], yNei[j]);
333 if (digt->fSignal > q[i]) {
337 // handle special case of neighbouring pads with equal signal
338 } else if (digt->fSignal == q[i]) {
340 for (Int_t k=0; k<nLocal; k++) {
341 if (xNei[j]==ix[indLocal[k]] && yNei[j]==iy[indLocal[k]]){
347 } // loop over next neighbours
348 // Maxima should not be on the edge
353 } // loop over all digits
354 // printf("Found %d local Maxima",nLocal);
356 // If only one local maximum found but multiplicity is high
357 // take global maximum from the list of digits.
358 if (nLocal==1 && mul>5) {
360 for (i=0; i<mul; i++) {
371 // If number of local maxima is 2 try to fit a double gaussian
374 // Initialise global variables for fit
376 gSegmentation=fSegmentation;
377 gResponse =fResponse;
380 for (i=0; i<mul; i++) {
383 gCharge[i]=Float_t(q[i]);
388 gMyMinuit = new TMinuit(5);
390 gMyMinuit->SetFCN(fcn);
391 gMyMinuit->mninit(5,10,7);
392 Double_t arglist[20];
395 // gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
396 // Set starting values
397 static Double_t vstart[5];
398 vstart[0]=x[indLocal[0]];
399 vstart[1]=y[indLocal[0]];
400 vstart[2]=x[indLocal[1]];
401 vstart[3]=y[indLocal[1]];
402 vstart[4]=Float_t(q[indLocal[0]])/
403 Float_t(q[indLocal[0]]+q[indLocal[1]]);
404 // lower and upper limits
405 static Double_t lower[5], upper[5];
406 Int_t isec=fSegmentation->Sector(ix[indLocal[0]], iy[indLocal[0]]);
407 lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
408 lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
409 // lower[1]=vstart[1];
411 upper[0]=lower[0]+fSegmentation->Dpx(isec);
412 upper[1]=lower[1]+fSegmentation->Dpy(isec);
413 // upper[1]=vstart[1];
415 isec=fSegmentation->Sector(ix[indLocal[1]], iy[indLocal[1]]);
416 lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
417 lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
418 // lower[3]=vstart[3];
420 upper[2]=lower[2]+fSegmentation->Dpx(isec);
421 upper[3]=lower[3]+fSegmentation->Dpy(isec);
422 // upper[3]=vstart[3];
427 static Double_t step[5]={0.005, 0.03, 0.005, 0.03, 0.01};
429 gMyMinuit->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
430 gMyMinuit->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
431 gMyMinuit->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
432 gMyMinuit->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
433 gMyMinuit->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
434 // ready for minimisation
435 gMyMinuit->SetPrintLevel(-1);
436 gMyMinuit->mnexcm("SET OUT", arglist, 0, ierflag);
440 gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
441 gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
442 gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
444 // Double_t amin,edm,errdef;
445 // Int_t nvpar,nparx,icstat;
446 // gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
447 // gMyMinuit->mnprin(3,amin);
448 // Get fitted parameters
450 Double_t xrec[2], yrec[2], qfrac;
452 Double_t epxz, b1, b2;
454 gMyMinuit->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
455 gMyMinuit->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
456 gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
457 gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
458 gMyMinuit->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
459 //printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
464 // One cluster for each maximum
466 for (j=0; j<2; j++) {
467 AliRICHRawCluster cnew;
469 cnew.fNcluster[0]=-1;
470 cnew.fNcluster[1]=fNRawClusters;
472 cnew.fNcluster[0]=fNPeaks;
475 cnew.fMultiplicity=0;
476 cnew.fX=Float_t(xrec[j]);
477 cnew.fY=Float_t(yrec[j]);
479 cnew.fQ=Int_t(gChargeTot*qfrac);
481 cnew.fQ=Int_t(gChargeTot*(1-qfrac));
483 gSegmentation->SetHit(xrec[j],yrec[j],0);
484 for (i=0; i<mul; i++) {
485 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
486 gSegmentation->SetPad(gix[i], giy[i]);
487 Float_t q1=gResponse->IntXY(gSegmentation);
488 cnew.fContMap[cnew.fMultiplicity]=Float_t(q[i])/(q1*cnew.fQ);
489 cnew.fMultiplicity++;
491 FillCluster(&cnew,0);
492 //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
493 cnew.fClusterType=cnew.PhysicsContribution();
501 if (nLocal !=-100 || !fitted) {
502 // Check if enough local clusters have been found,
503 // if not add global maxima to the list
509 printf("\n Warning, no local maximum found \n");
513 if (nPerMax > fNperMax) {
514 Int_t nGlob=mul/fNperMax-nLocal+1;
517 for (i=0; i<mul; i++) {
524 if (nnew==nGlob) break;
529 // Associate hits to peaks
531 for (i=0; i<mul; i++) {
534 if (isLocal[i]) continue;
535 for (j=0; j<nLocal; j++) {
536 Int_t il=indLocal[j];
537 Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
538 +(y[i]-y[il])*(y[i]-y[il]));
541 // Select nearest peak
547 } else if (d==dmin) {
549 // If more than one take highest peak
562 // One cluster for each maximum
564 for (j=0; j<nLocal; j++) {
565 AliRICHRawCluster cnew;
567 cnew.fNcluster[0]=-1;
568 cnew.fNcluster[1]=fNRawClusters;
570 cnew.fNcluster[0]=fNPeaks;
573 cnew.fIndexMap[0]=c->fIndexMap[indLocal[j]];
574 cnew.fMultiplicity=1;
575 for (i=0; i<mul; i++) {
576 if (isLocal[i]) continue;
577 if (associatePeak[i]==j) {
578 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
579 cnew.fMultiplicity++;
583 cnew.fClusterType=cnew.PhysicsContribution();
591 void AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
594 // Completes cluster information starting from list of digits
610 for (Int_t i=0; i<c->fMultiplicity; i++)
612 dig= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
613 ix=dig->fPadX+c->fOffsetMap[i];
615 Int_t q=dig->fSignal;
616 if (dig->fPhysics >= dig->fSignal) {
618 } else if (dig->fPhysics == 0) {
620 } else c->fPhysicsMap[i]=1;
623 // peak signal and track list
625 if (q>c->fPeakSignal) {
628 c->fTracks[0]=dig->fTracks[0];
629 c->fTracks[1]=dig->fTracks[1];
630 c->fTracks[2]=dig->fTracks[2];
632 //c->fTracks[0]=dig->fTrack;
633 c->fTracks[0]=dig->fHit;
634 c->fTracks[1]=dig->fTracks[0];
635 c->fTracks[2]=dig->fTracks[1];
638 if (c->fContMap[i] > frac) {
642 c->fTracks[0]=dig->fTracks[0];
643 c->fTracks[1]=dig->fTracks[1];
644 c->fTracks[2]=dig->fTracks[2];
646 //c->fTracks[0]=dig->fTrack;
647 c->fTracks[0]=dig->fHit;
648 c->fTracks[1]=dig->fTracks[0];
649 c->fTracks[2]=dig->fTracks[1];
654 fSegmentation->GetPadC(ix, iy, x, y, z);
660 } // loop over digits
665 c->fX=fSegmentation->GetAnod(c->fX);
668 // apply correction to the coordinate along the anode wire
672 fSegmentation->GetPadI(x, y, 0, ix, iy);
673 fSegmentation->GetPadC(ix, iy, x, y, z);
674 Int_t isec=fSegmentation->Sector(ix,iy);
675 TF1* cogCorr = fSegmentation->CorrFunc(isec-1);
678 Float_t yOnPad=(c->fY-y)/fSegmentation->Dpy(isec);
679 c->fY=c->fY-cogCorr->Eval(yOnPad, 0, 0);
685 void AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
690 // Add i,j as element of the cluster
693 Int_t idx = fHitMap->GetHitIndex(i,j);
694 AliRICHDigit* dig = (AliRICHDigit*) fHitMap->GetHit(i,j);
695 Int_t q=dig->fSignal;
696 if (q > TMath::Abs(c.fPeakSignal)) {
699 c.fTracks[0]=dig->fTracks[0];
700 c.fTracks[1]=dig->fTracks[1];
701 c.fTracks[2]=dig->fTracks[2];
703 //c.fTracks[0]=dig->fTrack;
704 c.fTracks[0]=dig->fHit;
705 c.fTracks[1]=dig->fTracks[0];
706 c.fTracks[2]=dig->fTracks[1];
709 // Make sure that list of digits is ordered
711 Int_t mu=c.fMultiplicity;
714 if (dig->fPhysics >= dig->fSignal) {
716 } else if (dig->fPhysics == 0) {
718 } else c.fPhysicsMap[mu]=1;
721 for (Int_t ind=mu-1; ind>=0; ind--) {
722 Int_t ist=(c.fIndexMap)[ind];
723 Int_t ql=((AliRICHDigit*)fDigits
724 ->UncheckedAt(ist))->fSignal;
726 c.fIndexMap[ind]=idx;
727 c.fIndexMap[ind+1]=ist;
736 if (c.fMultiplicity >= 50 ) {
737 printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity);
741 // Prepare center of gravity calculation
743 fSegmentation->GetPadC(i, j, x, y, z);
748 fHitMap->FlagHit(i,j);
750 // Now look recursively for all neighbours
753 Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
754 fSegmentation->Neighbours(i,j,&nn,xList,yList);
755 for (Int_t in=0; in<nn; in++) {
758 if (fHitMap->TestHit(ix,iy)==kUnused) FindCluster(ix, iy, c);
762 //_____________________________________________________________________________
764 void AliRICHClusterFinder::FindRawClusters()
767 // simple RICH cluster finder from digits -- finds neighbours and
768 // fill the tree with raw clusters
770 if (!fNdigits) return;
772 fHitMap = new AliRICHHitMapA1(fSegmentation, fDigits);
776 //printf ("Now I'm here");
782 for (ndig=0; ndig<fNdigits; ndig++) {
783 dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
786 if (fHitMap->TestHit(i,j)==kUsed ||fHitMap->TestHit(i,j)==kEmpty) {
792 c.fPeakSignal=dig->fSignal;
794 c.fTracks[0]=dig->fTracks[0];
795 c.fTracks[1]=dig->fTracks[1];
796 c.fTracks[2]=dig->fTracks[2];
798 //c.fTracks[0]=dig->fTrack;
799 c.fTracks[0]=dig->fHit;
800 c.fTracks[1]=dig->fTracks[0];
801 c.fTracks[2]=dig->fTracks[1];
802 // tag the beginning of cluster list in a raw cluster
807 c.fX=fSegmentation->GetAnod(c.fX);
810 // apply correction to the coordinate along the anode wire
817 fSegmentation->GetPadI(x, y, 0, ix, iy);
818 fSegmentation->GetPadC(ix, iy, x, y, z);
819 Int_t isec=fSegmentation->Sector(ix,iy);
820 TF1* cogCorr=fSegmentation->CorrFunc(isec-1);
822 Float_t yOnPad=(c.fY-y)/fSegmentation->Dpy(isec);
823 c.fY=c.fY-cogCorr->Eval(yOnPad,0,0);
827 // Analyse cluster and decluster if necessary
830 c.fNcluster[1]=fNRawClusters;
831 c.fClusterType=c.PhysicsContribution();
837 // reset Cluster object
838 for (int k=0;k<c.fMultiplicity;k++) {
846 void AliRICHClusterFinder::
857 fSegmentation->GiveTestPoints(n, x, y);
858 for (i=0; i<n; i++) {
861 SinoidalFit(xtest, ytest, func);
862 fSegmentation->SetCorrFunc(i, new TF1(func));
868 void AliRICHClusterFinder::
869 SinoidalFit(Float_t x, Float_t y, TF1 &func)
874 static Int_t count=0;
879 sprintf(canvasname,"c%d",count);
882 Float_t xg[kNs], yg[kNs], xrg[kNs], yrg[kNs];
883 Float_t xsig[kNs], ysig[kNs];
885 AliSegmentation *segmentation=fSegmentation;
888 segmentation->GetPadI(x,y,0,ix,iy);
889 segmentation->GetPadC(ix,iy,x,y,z);
890 Int_t isec=segmentation->Sector(ix,iy);
892 Float_t xmin = x-segmentation->Dpx(isec)/2;
893 Float_t ymin = y-segmentation->Dpy(isec)/2;
895 // Integration Limits
896 Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
897 Float_t dyI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
907 Float_t dy=segmentation->Dpy(isec)/(kNs-1);
909 for (i=0; i<kNs; i++) {
915 segmentation->SigGenInit(x, yscan, 0);
917 for (segmentation->FirstPad(x, yscan,0, dxI, dyI);
918 segmentation->MorePads();
919 segmentation->NextPad())
921 qp=fResponse->IntXY(segmentation);
927 Int_t ixs=segmentation->Ix();
928 Int_t iys=segmentation->Iy();
930 segmentation->GetPadC(ixs,iys,xs,ys,zs);
934 Float_t ycog=sum/qcheck;
935 yg[i]=(yscan-y)/segmentation->Dpy(isec);
936 yrg[i]=(ycog-y)/segmentation->Dpy(isec);
943 Float_t dx=segmentation->Dpx(isec)/(kNs-1);
945 for (i=0; i<kNs; i++) {
951 segmentation->SigGenInit(xscan, y, 0);
953 for (segmentation->FirstPad(xscan, y, 0, dxI, dyI);
954 segmentation->MorePads();
955 segmentation->NextPad())
957 qp=fResponse->IntXY(segmentation);
963 Int_t ixs=segmentation->Ix();
964 Int_t iys=segmentation->Iy();
966 segmentation->GetPadC(ixs,iys,xs,ys,zs);
970 Float_t xcog=sum/qcheck;
971 xcog=segmentation->GetAnod(xcog);
973 xg[i]=(xscan-x)/segmentation->Dpx(isec);
974 xrg[i]=(xcog-x)/segmentation->Dpx(isec);
979 // Creates a Root function based on function sinoid above
980 // and perform the fit
982 // TGraph *graphx = new TGraph(kNs,xg ,xsig);
983 // TGraph *graphxr= new TGraph(kNs,xrg,xsig);
984 // TGraph *graphy = new TGraph(kNs,yg ,ysig);
985 TGraph *graphyr= new TGraph(kNs,yrg,ysig);
987 Double_t sinoid(Double_t *x, Double_t *par);
988 new TF1("sinoidf",sinoid,0.5,0.5,5);
989 graphyr->Fit("sinoidf","Q");
990 func = *((TF1*)((graphyr->GetListOfFunctions())->At(0)));
993 TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
994 TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
995 TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
996 TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
997 TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
998 pad11->SetFillColor(11);
999 pad12->SetFillColor(11);
1000 pad13->SetFillColor(11);
1001 pad14->SetFillColor(11);
1009 graphx->SetFillColor(42);
1010 graphx->SetMarkerColor(4);
1011 graphx->SetMarkerStyle(21);
1013 graphx->GetHistogram()->SetXTitle("x on pad");
1014 graphx->GetHistogram()->SetYTitle("xcog-x");
1018 graphxr->SetFillColor(42);
1019 graphxr->SetMarkerColor(4);
1020 graphxr->SetMarkerStyle(21);
1021 graphxr->Draw("AP");
1022 graphxr->GetHistogram()->SetXTitle("xcog on pad");
1023 graphxr->GetHistogram()->SetYTitle("xcog-x");
1027 graphy->SetFillColor(42);
1028 graphy->SetMarkerColor(4);
1029 graphy->SetMarkerStyle(21);
1031 graphy->GetHistogram()->SetXTitle("y on pad");
1032 graphy->GetHistogram()->SetYTitle("ycog-y");
1037 graphyr->SetFillColor(42);
1038 graphyr->SetMarkerColor(4);
1039 graphyr->SetMarkerStyle(21);
1040 graphyr->Draw("AF");
1041 graphyr->GetHistogram()->SetXTitle("ycog on pad");
1042 graphyr->GetHistogram()->SetYTitle("ycog-y");
1048 Double_t sinoid(Double_t *x, Double_t *par)
1053 Double_t arg = -2*TMath::Pi()*x[0];
1054 Double_t fitval= par[0]*TMath::Sin(arg)+
1055 par[1]*TMath::Sin(2*arg)+
1056 par[2]*TMath::Sin(3*arg)+
1057 par[3]*TMath::Sin(4*arg)+
1058 par[4]*TMath::Sin(5*arg);
1063 Double_t DoubleGauss(Double_t *x, Double_t *par)
1066 // Doublr gaussian function
1068 Double_t arg1 = (x[0]-par[1])/0.18;
1069 Double_t arg2 = (x[0]-par[3])/0.18;
1070 Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
1071 +par[2]*TMath::Exp(-arg2*arg2/2);
1075 Float_t DiscrCharge(Int_t i,Double_t *par)
1077 // par[0] x-position of first cluster
1078 // par[1] y-position of first cluster
1079 // par[2] x-position of second cluster
1080 // par[3] y-position of second cluster
1081 // par[4] charge fraction of first cluster
1082 // 1-par[4] charge fraction of second cluster
1084 static Float_t qtot;
1087 for (Int_t jbin=0; jbin<gNbins; jbin++) {
1088 qtot+=gCharge[jbin];
1091 //printf("\n sum of charge from DiscrCharge %f\n", qtot);
1092 gChargeTot=Int_t(qtot);
1095 gSegmentation->SetPad(gix[i], giy[i]);
1097 gSegmentation->SetHit(par[0],par[1],0);
1098 Float_t q1=gResponse->IntXY(gSegmentation);
1101 gSegmentation->SetHit(par[2],par[3],0);
1102 Float_t q2=gResponse->IntXY(gSegmentation);
1104 Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
1109 // Minimisation function
1110 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
1118 for (i=0; i<gNbins; i++) {
1119 Float_t q0=gCharge[i];
1120 Float_t q1=DiscrCharge(i,par);
1121 delta=(q0-q1)/TMath::Sqrt(q0);
1126 chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;
1131 void AliRICHClusterFinder::SetDigits(TClonesArray *RICHdigits)
1134 // Get all the digits
1137 fNdigits = fDigits->GetEntriesFast();
1140 AliRICHClusterFinder& AliRICHClusterFinder::operator=(const AliRICHClusterFinder& rhs)
1142 // Assignment operator