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.7 2000/10/03 21:44:09 morsch
19 Use AliSegmentation and AliHit abstract base classes.
21 Revision 1.6 2000/10/02 21:28:12 fca
22 Removal of useless dependecies via forward declarations
24 Revision 1.5 2000/10/02 15:45:58 jbarbosa
25 Fixed forward declarations.
27 Revision 1.4 2000/06/12 19:01:29 morsch
28 Clean-up bug in Centered() corrected.
30 Revision 1.3 2000/06/12 15:49:44 jbarbosa
31 Removed verbose output.
33 Revision 1.2 2000/06/12 15:18:19 jbarbosa
36 Revision 1.1 2000/04/19 13:01:48 morsch
37 A cluster finder and hit reconstruction class for RICH (adapted from MUON).
38 Cluster Finders for MUON and RICH should derive from the same class in the
44 #include "AliRICHClusterFinder.h"
47 #include "AliRICHHit.h"
48 #include "AliRICHHitMapA1.h"
49 #include "AliRICHCerenkov.h"
50 #include "AliRICHPadHit.h"
51 #include "AliRICHDigit.h"
52 #include "AliRICHRawCluster.h"
60 #include <TPostScript.h>
63 //----------------------------------------------------------
64 static AliSegmentation* gSegmentation;
65 static AliRICHResponse* gResponse;
66 static Int_t gix[500];
67 static Int_t giy[500];
68 static Float_t gCharge[500];
70 static Int_t gFirst=kTRUE;
71 static TMinuit *gMyMinuit ;
72 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
73 static Int_t gChargeTot;
75 ClassImp(AliRICHClusterFinder)
77 AliRICHClusterFinder::AliRICHClusterFinder
78 (AliSegmentation *segmentation, AliRICHResponse *response,
79 TClonesArray *digits, Int_t chamber)
82 // Constructor for Cluster Finder object
84 fSegmentation=segmentation;
88 fNdigits = fDigits->GetEntriesFast();
90 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
99 AliRICHClusterFinder::AliRICHClusterFinder()
102 // Default constructor
110 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
120 AliRICHClusterFinder::AliRICHClusterFinder(const AliRICHClusterFinder& ClusterFinder)
125 AliRICHClusterFinder::~AliRICHClusterFinder()
133 void AliRICHClusterFinder::AddRawCluster(const AliRICHRawCluster c)
136 // Add a raw cluster copy to the list
138 AliRICH *pRICH=(AliRICH*)gAlice->GetModule("RICH");
139 pRICH->AddRawCluster(fChamber,c);
145 void AliRICHClusterFinder::Decluster(AliRICHRawCluster *cluster)
149 // Decluster algorithm
151 Int_t mul = cluster->fMultiplicity;
152 // printf("Decluster - multiplicity %d \n",mul);
154 if (mul == 1 || mul ==2) {
156 // Nothing special for 1- and 2-clusters
158 cluster->fNcluster[0]=fNPeaks;
159 cluster->fNcluster[1]=0;
161 AddRawCluster(*cluster);
163 } else if (mul ==3) {
165 // 3-cluster, check topology
166 // printf("\n 3-cluster, check topology \n");
167 if (fDeclusterFlag) {
168 if (Centered(cluster)) {
169 // ok, cluster is centered
171 // cluster is not centered, split into 2+1
175 cluster->fNcluster[0]=fNPeaks;
176 cluster->fNcluster[1]=0;
178 AddRawCluster(*cluster);
183 // 4-and more-pad clusters
185 if (mul <= fClusterSize) {
186 if (fDeclusterFlag) {
187 SplitByLocalMaxima(cluster);
190 cluster->fNcluster[0]=fNPeaks;
191 cluster->fNcluster[1]=0;
193 AddRawCluster(*cluster);
201 Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
204 // Is the cluster centered?
207 dig= (AliRICHDigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
211 Int_t x[kMaxNeighbours], y[kMaxNeighbours], xN[kMaxNeighbours], yN[kMaxNeighbours];
213 fSegmentation->Neighbours(ix,iy,&nn,x,y);
215 for (Int_t i=0; i<nn; i++) {
216 if (fHitMap->TestHit(x[i],y[i]) == kUsed) {
221 //printf("Getting: %d %d %d\n",i,x[i],y[i]);
226 // cluster is centered !
228 cluster->fNcluster[0]=fNPeaks;
229 cluster->fNcluster[1]=0;
232 AddRawCluster(*cluster);
237 // Highest signal on an edge, split cluster into 2+1
239 // who is the neighbour ?
241 //printf("Calling GetIndex with x:%d y:%d\n",xN[0], yN[0]);
243 Int_t nind=fHitMap->GetHitIndex(xN[0], yN[0]);
244 Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
245 Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;
248 AliRICHRawCluster cnew;
250 cnew.fNcluster[0]=-1;
251 cnew.fNcluster[1]=fNRawClusters;
253 cnew.fNcluster[0]=fNPeaks;
256 cnew.fMultiplicity=2;
257 cnew.fIndexMap[0]=cluster->fIndexMap[0];
258 cnew.fIndexMap[1]=cluster->fIndexMap[i1];
260 cnew.fClusterType=cnew.PhysicsContribution();
265 cluster->fMultiplicity=1;
266 cluster->fIndexMap[0]=cluster->fIndexMap[i2];
267 cluster->fIndexMap[1]=0;
268 cluster->fIndexMap[2]=0;
269 FillCluster(cluster);
271 cluster->fNcluster[0]=fNPeaks;
272 cluster->fNcluster[1]=0;
274 cluster->fClusterType=cluster->PhysicsContribution();
275 AddRawCluster(*cluster);
279 printf("\n Completely screwed up %d !! \n",nd);
285 void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
289 // Split the cluster according to the number of maxima inside
292 AliRICHDigit* dig[100], *digt;
293 Int_t ix[100], iy[100], q[100];
294 Float_t x[100], y[100], zdum;
295 Int_t i; // loops over digits
296 Int_t j; // loops over local maxima
299 // Int_t threshold=500;
300 Int_t mul=c->fMultiplicity;
302 // dump digit information into arrays
304 for (i=0; i<mul; i++)
306 dig[i]= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
307 ix[i]= dig[i]->fPadX;
308 iy[i]= dig[i]->fPadY;
309 q[i] = dig[i]->fSignal;
310 fSegmentation->GetPadC(ix[i], iy[i], x[i], y[i], zdum);
317 Int_t associatePeak[100];
320 Int_t xNei[kMaxNeighbours], yNei[kMaxNeighbours];
321 for (i=0; i<mul; i++) {
322 fSegmentation->Neighbours(ix[i], iy[i], &nn, xNei, yNei);
324 for (j=0; j<nn; j++) {
325 if (fHitMap->TestHit(xNei[j], yNei[j])==kEmpty) continue;
326 digt=(AliRICHDigit*) fHitMap->GetHit(xNei[j], yNei[j]);
327 if (digt->fSignal > q[i]) {
331 // handle special case of neighbouring pads with equal signal
332 } else if (digt->fSignal == q[i]) {
334 for (Int_t k=0; k<nLocal; k++) {
335 if (xNei[j]==ix[indLocal[k]] && yNei[j]==iy[indLocal[k]]){
341 } // loop over next neighbours
342 // Maxima should not be on the edge
347 } // loop over all digits
348 // printf("Found %d local Maxima",nLocal);
350 // If only one local maximum found but multiplicity is high
351 // take global maximum from the list of digits.
352 if (nLocal==1 && mul>5) {
354 for (i=0; i<mul; i++) {
365 // If number of local maxima is 2 try to fit a double gaussian
368 // Initialise global variables for fit
370 gSegmentation=fSegmentation;
371 gResponse =fResponse;
374 for (i=0; i<mul; i++) {
377 gCharge[i]=Float_t(q[i]);
382 gMyMinuit = new TMinuit(5);
384 gMyMinuit->SetFCN(fcn);
385 gMyMinuit->mninit(5,10,7);
386 Double_t arglist[20];
389 // gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
390 // Set starting values
391 static Double_t vstart[5];
392 vstart[0]=x[indLocal[0]];
393 vstart[1]=y[indLocal[0]];
394 vstart[2]=x[indLocal[1]];
395 vstart[3]=y[indLocal[1]];
396 vstart[4]=Float_t(q[indLocal[0]])/
397 Float_t(q[indLocal[0]]+q[indLocal[1]]);
398 // lower and upper limits
399 static Double_t lower[5], upper[5];
400 Int_t isec=fSegmentation->Sector(ix[indLocal[0]], iy[indLocal[0]]);
401 lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
402 lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
403 // lower[1]=vstart[1];
405 upper[0]=lower[0]+fSegmentation->Dpx(isec);
406 upper[1]=lower[1]+fSegmentation->Dpy(isec);
407 // upper[1]=vstart[1];
409 isec=fSegmentation->Sector(ix[indLocal[1]], iy[indLocal[1]]);
410 lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
411 lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
412 // lower[3]=vstart[3];
414 upper[2]=lower[2]+fSegmentation->Dpx(isec);
415 upper[3]=lower[3]+fSegmentation->Dpy(isec);
416 // upper[3]=vstart[3];
421 static Double_t step[5]={0.005, 0.03, 0.005, 0.03, 0.01};
423 gMyMinuit->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
424 gMyMinuit->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
425 gMyMinuit->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
426 gMyMinuit->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
427 gMyMinuit->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
428 // ready for minimisation
429 gMyMinuit->SetPrintLevel(-1);
430 gMyMinuit->mnexcm("SET OUT", arglist, 0, ierflag);
434 gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
435 gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
436 gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
438 // Double_t amin,edm,errdef;
439 // Int_t nvpar,nparx,icstat;
440 // gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
441 // gMyMinuit->mnprin(3,amin);
442 // Get fitted parameters
444 Double_t xrec[2], yrec[2], qfrac;
446 Double_t epxz, b1, b2;
448 gMyMinuit->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
449 gMyMinuit->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
450 gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
451 gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
452 gMyMinuit->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
453 //printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
458 // One cluster for each maximum
460 for (j=0; j<2; j++) {
461 AliRICHRawCluster cnew;
463 cnew.fNcluster[0]=-1;
464 cnew.fNcluster[1]=fNRawClusters;
466 cnew.fNcluster[0]=fNPeaks;
469 cnew.fMultiplicity=0;
470 cnew.fX=Float_t(xrec[j]);
471 cnew.fY=Float_t(yrec[j]);
473 cnew.fQ=Int_t(gChargeTot*qfrac);
475 cnew.fQ=Int_t(gChargeTot*(1-qfrac));
477 gSegmentation->SetHit(xrec[j],yrec[j],0);
478 for (i=0; i<mul; i++) {
479 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
480 gSegmentation->SetPad(gix[i], giy[i]);
481 Float_t q1=gResponse->IntXY(gSegmentation);
482 cnew.fContMap[cnew.fMultiplicity]=Float_t(q[i])/(q1*cnew.fQ);
483 cnew.fMultiplicity++;
485 FillCluster(&cnew,0);
486 //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
487 cnew.fClusterType=cnew.PhysicsContribution();
495 if (nLocal !=-100 || !fitted) {
496 // Check if enough local clusters have been found,
497 // if not add global maxima to the list
503 printf("\n Warning, no local maximum found \n");
507 if (nPerMax > fNperMax) {
508 Int_t nGlob=mul/fNperMax-nLocal+1;
511 for (i=0; i<mul; i++) {
518 if (nnew==nGlob) break;
523 // Associate hits to peaks
525 for (i=0; i<mul; i++) {
528 if (isLocal[i]) continue;
529 for (j=0; j<nLocal; j++) {
530 Int_t il=indLocal[j];
531 Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
532 +(y[i]-y[il])*(y[i]-y[il]));
535 // Select nearest peak
541 } else if (d==dmin) {
543 // If more than one take highest peak
556 // One cluster for each maximum
558 for (j=0; j<nLocal; j++) {
559 AliRICHRawCluster cnew;
561 cnew.fNcluster[0]=-1;
562 cnew.fNcluster[1]=fNRawClusters;
564 cnew.fNcluster[0]=fNPeaks;
567 cnew.fIndexMap[0]=c->fIndexMap[indLocal[j]];
568 cnew.fMultiplicity=1;
569 for (i=0; i<mul; i++) {
570 if (isLocal[i]) continue;
571 if (associatePeak[i]==j) {
572 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
573 cnew.fMultiplicity++;
577 cnew.fClusterType=cnew.PhysicsContribution();
585 void AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
588 // Completes cluster information starting from list of digits
604 for (Int_t i=0; i<c->fMultiplicity; i++)
606 dig= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
607 ix=dig->fPadX+c->fOffsetMap[i];
609 Int_t q=dig->fSignal;
610 if (dig->fPhysics >= dig->fSignal) {
612 } else if (dig->fPhysics == 0) {
614 } else c->fPhysicsMap[i]=1;
617 // peak signal and track list
619 if (q>c->fPeakSignal) {
622 c->fTracks[0]=dig->fTracks[0];
623 c->fTracks[1]=dig->fTracks[1];
624 c->fTracks[2]=dig->fTracks[2];
626 //c->fTracks[0]=dig->fTrack;
627 c->fTracks[0]=dig->fHit;
628 c->fTracks[1]=dig->fTracks[0];
629 c->fTracks[2]=dig->fTracks[1];
632 if (c->fContMap[i] > frac) {
636 c->fTracks[0]=dig->fTracks[0];
637 c->fTracks[1]=dig->fTracks[1];
638 c->fTracks[2]=dig->fTracks[2];
640 //c->fTracks[0]=dig->fTrack;
641 c->fTracks[0]=dig->fHit;
642 c->fTracks[1]=dig->fTracks[0];
643 c->fTracks[2]=dig->fTracks[1];
648 fSegmentation->GetPadC(ix, iy, x, y, z);
654 } // loop over digits
659 c->fX=fSegmentation->GetAnod(c->fX);
662 // apply correction to the coordinate along the anode wire
666 fSegmentation->GetPadI(x, y, 0, ix, iy);
667 fSegmentation->GetPadC(ix, iy, x, y, z);
668 Int_t isec=fSegmentation->Sector(ix,iy);
669 TF1* cogCorr = fSegmentation->CorrFunc(isec-1);
672 Float_t yOnPad=(c->fY-y)/fSegmentation->Dpy(isec);
673 c->fY=c->fY-cogCorr->Eval(yOnPad, 0, 0);
679 void AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
684 // Add i,j as element of the cluster
687 Int_t idx = fHitMap->GetHitIndex(i,j);
688 AliRICHDigit* dig = (AliRICHDigit*) fHitMap->GetHit(i,j);
689 Int_t q=dig->fSignal;
690 if (q > TMath::Abs(c.fPeakSignal)) {
693 c.fTracks[0]=dig->fTracks[0];
694 c.fTracks[1]=dig->fTracks[1];
695 c.fTracks[2]=dig->fTracks[2];
697 //c.fTracks[0]=dig->fTrack;
698 c.fTracks[0]=dig->fHit;
699 c.fTracks[1]=dig->fTracks[0];
700 c.fTracks[2]=dig->fTracks[1];
703 // Make sure that list of digits is ordered
705 Int_t mu=c.fMultiplicity;
708 if (dig->fPhysics >= dig->fSignal) {
710 } else if (dig->fPhysics == 0) {
712 } else c.fPhysicsMap[mu]=1;
715 for (Int_t ind=mu-1; ind>=0; ind--) {
716 Int_t ist=(c.fIndexMap)[ind];
717 Int_t ql=((AliRICHDigit*)fDigits
718 ->UncheckedAt(ist))->fSignal;
720 c.fIndexMap[ind]=idx;
721 c.fIndexMap[ind+1]=ist;
730 if (c.fMultiplicity >= 50 ) {
731 printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity);
735 // Prepare center of gravity calculation
737 fSegmentation->GetPadC(i, j, x, y, z);
742 fHitMap->FlagHit(i,j);
744 // Now look recursively for all neighbours
747 Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
748 fSegmentation->Neighbours(i,j,&nn,xList,yList);
749 for (Int_t in=0; in<nn; in++) {
752 if (fHitMap->TestHit(ix,iy)==kUnused) FindCluster(ix, iy, c);
756 //_____________________________________________________________________________
758 void AliRICHClusterFinder::FindRawClusters()
761 // simple RICH cluster finder from digits -- finds neighbours and
762 // fill the tree with raw clusters
764 if (!fNdigits) return;
766 fHitMap = new AliRICHHitMapA1(fSegmentation, fDigits);
770 //printf ("Now I'm here");
776 for (ndig=0; ndig<fNdigits; ndig++) {
777 dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
780 if (fHitMap->TestHit(i,j)==kUsed ||fHitMap->TestHit(i,j)==kEmpty) {
786 c.fPeakSignal=dig->fSignal;
788 c.fTracks[0]=dig->fTracks[0];
789 c.fTracks[1]=dig->fTracks[1];
790 c.fTracks[2]=dig->fTracks[2];
792 //c.fTracks[0]=dig->fTrack;
793 c.fTracks[0]=dig->fHit;
794 c.fTracks[1]=dig->fTracks[0];
795 c.fTracks[2]=dig->fTracks[1];
796 // tag the beginning of cluster list in a raw cluster
801 c.fX=fSegmentation->GetAnod(c.fX);
804 // apply correction to the coordinate along the anode wire
811 fSegmentation->GetPadI(x, y, 0, ix, iy);
812 fSegmentation->GetPadC(ix, iy, x, y, z);
813 Int_t isec=fSegmentation->Sector(ix,iy);
814 TF1* cogCorr=fSegmentation->CorrFunc(isec-1);
816 Float_t yOnPad=(c.fY-y)/fSegmentation->Dpy(isec);
817 c.fY=c.fY-cogCorr->Eval(yOnPad,0,0);
821 // Analyse cluster and decluster if necessary
824 c.fNcluster[1]=fNRawClusters;
825 c.fClusterType=c.PhysicsContribution();
831 // reset Cluster object
832 for (int k=0;k<c.fMultiplicity;k++) {
840 void AliRICHClusterFinder::
851 fSegmentation->GiveTestPoints(n, x, y);
852 for (i=0; i<n; i++) {
855 SinoidalFit(xtest, ytest, func);
856 fSegmentation->SetCorrFunc(i, new TF1(func));
862 void AliRICHClusterFinder::
863 SinoidalFit(Float_t x, Float_t y, TF1 &func)
868 static Int_t count=0;
873 sprintf(canvasname,"c%d",count);
876 Float_t xg[kNs], yg[kNs], xrg[kNs], yrg[kNs];
877 Float_t xsig[kNs], ysig[kNs];
879 AliSegmentation *segmentation=fSegmentation;
882 segmentation->GetPadI(x,y,0,ix,iy);
883 segmentation->GetPadC(ix,iy,x,y,z);
884 Int_t isec=segmentation->Sector(ix,iy);
886 Float_t xmin = x-segmentation->Dpx(isec)/2;
887 Float_t ymin = y-segmentation->Dpy(isec)/2;
889 // Integration Limits
890 Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
891 Float_t dyI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
901 Float_t dy=segmentation->Dpy(isec)/(kNs-1);
903 for (i=0; i<kNs; i++) {
909 segmentation->SigGenInit(x, yscan, 0);
911 for (segmentation->FirstPad(x, yscan,0, dxI, dyI);
912 segmentation->MorePads();
913 segmentation->NextPad())
915 qp=fResponse->IntXY(segmentation);
921 Int_t ixs=segmentation->Ix();
922 Int_t iys=segmentation->Iy();
924 segmentation->GetPadC(ixs,iys,xs,ys,zs);
928 Float_t ycog=sum/qcheck;
929 yg[i]=(yscan-y)/segmentation->Dpy(isec);
930 yrg[i]=(ycog-y)/segmentation->Dpy(isec);
937 Float_t dx=segmentation->Dpx(isec)/(kNs-1);
939 for (i=0; i<kNs; i++) {
945 segmentation->SigGenInit(xscan, y, 0);
947 for (segmentation->FirstPad(xscan, y, 0, dxI, dyI);
948 segmentation->MorePads();
949 segmentation->NextPad())
951 qp=fResponse->IntXY(segmentation);
957 Int_t ixs=segmentation->Ix();
958 Int_t iys=segmentation->Iy();
960 segmentation->GetPadC(ixs,iys,xs,ys,zs);
964 Float_t xcog=sum/qcheck;
965 xcog=segmentation->GetAnod(xcog);
967 xg[i]=(xscan-x)/segmentation->Dpx(isec);
968 xrg[i]=(xcog-x)/segmentation->Dpx(isec);
973 // Creates a Root function based on function sinoid above
974 // and perform the fit
976 // TGraph *graphx = new TGraph(kNs,xg ,xsig);
977 // TGraph *graphxr= new TGraph(kNs,xrg,xsig);
978 // TGraph *graphy = new TGraph(kNs,yg ,ysig);
979 TGraph *graphyr= new TGraph(kNs,yrg,ysig);
981 Double_t sinoid(Double_t *x, Double_t *par);
982 new TF1("sinoidf",sinoid,0.5,0.5,5);
983 graphyr->Fit("sinoidf","Q");
984 func = *((TF1*)((graphyr->GetListOfFunctions())->At(0)));
987 TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
988 TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
989 TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
990 TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
991 TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
992 pad11->SetFillColor(11);
993 pad12->SetFillColor(11);
994 pad13->SetFillColor(11);
995 pad14->SetFillColor(11);
1003 graphx->SetFillColor(42);
1004 graphx->SetMarkerColor(4);
1005 graphx->SetMarkerStyle(21);
1007 graphx->GetHistogram()->SetXTitle("x on pad");
1008 graphx->GetHistogram()->SetYTitle("xcog-x");
1012 graphxr->SetFillColor(42);
1013 graphxr->SetMarkerColor(4);
1014 graphxr->SetMarkerStyle(21);
1015 graphxr->Draw("AP");
1016 graphxr->GetHistogram()->SetXTitle("xcog on pad");
1017 graphxr->GetHistogram()->SetYTitle("xcog-x");
1021 graphy->SetFillColor(42);
1022 graphy->SetMarkerColor(4);
1023 graphy->SetMarkerStyle(21);
1025 graphy->GetHistogram()->SetXTitle("y on pad");
1026 graphy->GetHistogram()->SetYTitle("ycog-y");
1031 graphyr->SetFillColor(42);
1032 graphyr->SetMarkerColor(4);
1033 graphyr->SetMarkerStyle(21);
1034 graphyr->Draw("AF");
1035 graphyr->GetHistogram()->SetXTitle("ycog on pad");
1036 graphyr->GetHistogram()->SetYTitle("ycog-y");
1042 Double_t sinoid(Double_t *x, Double_t *par)
1047 Double_t arg = -2*TMath::Pi()*x[0];
1048 Double_t fitval= par[0]*TMath::Sin(arg)+
1049 par[1]*TMath::Sin(2*arg)+
1050 par[2]*TMath::Sin(3*arg)+
1051 par[3]*TMath::Sin(4*arg)+
1052 par[4]*TMath::Sin(5*arg);
1057 Double_t DoubleGauss(Double_t *x, Double_t *par)
1060 // Doublr gaussian function
1062 Double_t arg1 = (x[0]-par[1])/0.18;
1063 Double_t arg2 = (x[0]-par[3])/0.18;
1064 Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
1065 +par[2]*TMath::Exp(-arg2*arg2/2);
1069 Float_t DiscrCharge(Int_t i,Double_t *par)
1071 // par[0] x-position of first cluster
1072 // par[1] y-position of first cluster
1073 // par[2] x-position of second cluster
1074 // par[3] y-position of second cluster
1075 // par[4] charge fraction of first cluster
1076 // 1-par[4] charge fraction of second cluster
1078 static Float_t qtot;
1081 for (Int_t jbin=0; jbin<gNbins; jbin++) {
1082 qtot+=gCharge[jbin];
1085 //printf("\n sum of charge from DiscrCharge %f\n", qtot);
1086 gChargeTot=Int_t(qtot);
1089 gSegmentation->SetPad(gix[i], giy[i]);
1091 gSegmentation->SetHit(par[0],par[1],0);
1092 Float_t q1=gResponse->IntXY(gSegmentation);
1095 gSegmentation->SetHit(par[2],par[3],0);
1096 Float_t q2=gResponse->IntXY(gSegmentation);
1098 Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
1103 // Minimisation function
1104 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
1112 for (i=0; i<gNbins; i++) {
1113 Float_t q0=gCharge[i];
1114 Float_t q1=DiscrCharge(i,par);
1115 delta=(q0-q1)/TMath::Sqrt(q0);
1120 chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;
1125 void AliRICHClusterFinder::SetDigits(TClonesArray *RICHdigits)
1128 // Get all the digits
1131 fNdigits = fDigits->GetEntriesFast();
1134 AliRICHClusterFinder& AliRICHClusterFinder::operator=(const AliRICHClusterFinder& rhs)
1136 // Assignment operator
1141 //______________________________________________________________________________
1142 void AliRICHClusterFinder::Streamer(TBuffer &R__b)
1144 // Stream an object of class AliRICHClusterFinder.
1146 if (R__b.IsReading()) {
1147 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1148 TObject::Streamer(R__b);
1149 R__b >> fSegmentation;
1151 R__b >> fRawClusters;
1157 R__b >> fNRawClusters;
1159 R__b >> fDeclusterFlag;
1160 R__b >> fClusterSize;
1163 R__b.WriteVersion(AliRICHClusterFinder::IsA());
1164 TObject::Streamer(R__b);
1165 R__b << fSegmentation;
1167 R__b << fRawClusters;
1173 R__b << fNRawClusters;
1175 R__b << fDeclusterFlag;
1176 R__b << fClusterSize;