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.11.4.1 2003/07/10 17:09:50 hristov
21 Revision 1.12 2003/06/27 10:03:00 rdm
22 avoid assignment of TF1 objects. In SinoidalFit() pass TF1 by pointer.
24 Revision 1.11 2001/10/23 13:03:35 hristov
25 The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
27 Revision 1.10 2001/02/27 15:21:58 jbarbosa
28 Transition to SDigits.
30 Revision 1.9 2001/01/26 20:00:27 hristov
31 Major upgrade of AliRoot code
33 Revision 1.8 2000/11/02 09:11:12 jbarbosa
34 Removed AliRICHRecHit.h from include.
36 Revision 1.7 2000/10/03 21:44:09 morsch
37 Use AliSegmentation and AliHit abstract base classes.
39 Revision 1.6 2000/10/02 21:28:12 fca
40 Removal of useless dependecies via forward declarations
42 Revision 1.5 2000/10/02 15:45:58 jbarbosa
43 Fixed forward declarations.
45 Revision 1.4 2000/06/12 19:01:29 morsch
46 Clean-up bug in Centered() corrected.
48 Revision 1.3 2000/06/12 15:49:44 jbarbosa
49 Removed verbose output.
51 Revision 1.2 2000/06/12 15:18:19 jbarbosa
54 Revision 1.1 2000/04/19 13:01:48 morsch
55 A cluster finder and hit reconstruction class for RICH (adapted from MUON).
56 Cluster Finders for MUON and RICH should derive from the same class in the
62 #include "AliRICHClusterFinder.h"
65 #include "AliRICHHit.h"
66 #include "AliRICHHitMapA1.h"
67 #include "AliRICHCerenkov.h"
68 #include "AliRICHSDigit.h"
69 #include "AliRICHDigit.h"
70 #include "AliRICHRawCluster.h"
78 #include <TPostScript.h>
81 //----------------------------------------------------------
82 static AliSegmentation* gSegmentation;
83 static AliRICHResponse* gResponse;
84 static Int_t gix[500];
85 static Int_t giy[500];
86 static Float_t gCharge[500];
88 static Int_t gFirst=kTRUE;
89 static TMinuit *gMyMinuit ;
90 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
91 static Int_t gChargeTot;
93 ClassImp(AliRICHClusterFinder)
95 AliRICHClusterFinder::AliRICHClusterFinder
96 (AliSegmentation *segmentation, AliRICHResponse *response,
97 TClonesArray *digits, Int_t chamber)
100 // Constructor for Cluster Finder object
102 fSegmentation=segmentation;
106 fNdigits = fDigits->GetEntriesFast();
108 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
117 AliRICHClusterFinder::AliRICHClusterFinder()
120 // Default constructor
128 fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
138 AliRICHClusterFinder::AliRICHClusterFinder(const AliRICHClusterFinder& ClusterFinder)
143 AliRICHClusterFinder::~AliRICHClusterFinder()
151 void AliRICHClusterFinder::AddRawCluster(const AliRICHRawCluster c)
154 // Add a raw cluster copy to the list
156 AliRICH *pRICH=(AliRICH*)gAlice->GetModule("RICH");
157 pRICH->AddRawCluster(fChamber,c);
163 void AliRICHClusterFinder::Decluster(AliRICHRawCluster *cluster)
167 // Decluster algorithm
169 Int_t mul = cluster->fMultiplicity;
170 // printf("Decluster - multiplicity %d \n",mul);
172 if (mul == 1 || mul ==2) {
174 // Nothing special for 1- and 2-clusters
176 cluster->fNcluster[0]=fNPeaks;
177 cluster->fNcluster[1]=0;
179 AddRawCluster(*cluster);
181 } else if (mul ==3) {
183 // 3-cluster, check topology
184 // printf("\n 3-cluster, check topology \n");
185 if (fDeclusterFlag) {
186 if (Centered(cluster)) {
187 // ok, cluster is centered
189 // cluster is not centered, split into 2+1
193 cluster->fNcluster[0]=fNPeaks;
194 cluster->fNcluster[1]=0;
196 AddRawCluster(*cluster);
201 // 4-and more-pad clusters
203 if (mul <= fClusterSize) {
204 if (fDeclusterFlag) {
205 SplitByLocalMaxima(cluster);
208 cluster->fNcluster[0]=fNPeaks;
209 cluster->fNcluster[1]=0;
211 AddRawCluster(*cluster);
219 Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
222 // Is the cluster centered?
225 dig= (AliRICHDigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
226 Int_t ix=dig->PadX();
227 Int_t iy=dig->PadY();
229 Int_t x[kMaxNeighbours], y[kMaxNeighbours], xN[kMaxNeighbours], yN[kMaxNeighbours];
231 fSegmentation->Neighbours(ix,iy,&nn,x,y);
233 for (Int_t i=0; i<nn; i++) {
234 if (fHitMap->TestHit(x[i],y[i]) == kUsed) {
239 //printf("Getting: %d %d %d\n",i,x[i],y[i]);
244 // cluster is centered !
246 cluster->fNcluster[0]=fNPeaks;
247 cluster->fNcluster[1]=0;
250 AddRawCluster(*cluster);
255 // Highest signal on an edge, split cluster into 2+1
257 // who is the neighbour ?
259 //printf("Calling GetIndex with x:%d y:%d\n",xN[0], yN[0]);
261 Int_t nind=fHitMap->GetHitIndex(xN[0], yN[0]);
262 Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
263 Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;
266 AliRICHRawCluster cnew;
268 cnew.fNcluster[0]=-1;
269 cnew.fNcluster[1]=fNRawClusters;
271 cnew.fNcluster[0]=fNPeaks;
274 cnew.fMultiplicity=2;
275 cnew.fIndexMap[0]=cluster->fIndexMap[0];
276 cnew.fIndexMap[1]=cluster->fIndexMap[i1];
278 cnew.fClusterType=cnew.PhysicsContribution();
283 cluster->fMultiplicity=1;
284 cluster->fIndexMap[0]=cluster->fIndexMap[i2];
285 cluster->fIndexMap[1]=0;
286 cluster->fIndexMap[2]=0;
287 FillCluster(cluster);
289 cluster->fNcluster[0]=fNPeaks;
290 cluster->fNcluster[1]=0;
292 cluster->fClusterType=cluster->PhysicsContribution();
293 AddRawCluster(*cluster);
297 printf("\n Completely screwed up %d !! \n",nd);
303 void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
307 // Split the cluster according to the number of maxima inside
310 AliRICHDigit* dig[100], *digt;
311 Int_t ix[100], iy[100], q[100];
312 Float_t x[100], y[100], zdum;
313 Int_t i; // loops over digits
314 Int_t j; // loops over local maxima
317 // Int_t threshold=500;
318 Int_t mul=c->fMultiplicity;
320 // dump digit information into arrays
322 for (i=0; i<mul; i++)
324 dig[i]= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
325 ix[i]= dig[i]->PadX();
326 iy[i]= dig[i]->PadY();
327 q[i] = dig[i]->Signal();
328 fSegmentation->GetPadC(ix[i], iy[i], x[i], y[i], zdum);
335 Int_t associatePeak[100];
338 Int_t xNei[kMaxNeighbours], yNei[kMaxNeighbours];
339 for (i=0; i<mul; i++) {
340 fSegmentation->Neighbours(ix[i], iy[i], &nn, xNei, yNei);
342 for (j=0; j<nn; j++) {
343 if (fHitMap->TestHit(xNei[j], yNei[j])==kEmpty) continue;
344 digt=(AliRICHDigit*) fHitMap->GetHit(xNei[j], yNei[j]);
345 if (digt->Signal() > q[i]) {
349 // handle special case of neighbouring pads with equal signal
350 } else if (digt->Signal() == q[i]) {
352 for (Int_t k=0; k<nLocal; k++) {
353 if (xNei[j]==ix[indLocal[k]] && yNei[j]==iy[indLocal[k]]){
359 } // loop over next neighbours
360 // Maxima should not be on the edge
365 } // loop over all digits
366 // printf("Found %d local Maxima",nLocal);
368 // If only one local maximum found but multiplicity is high
369 // take global maximum from the list of digits.
370 if (nLocal==1 && mul>5) {
372 for (i=0; i<mul; i++) {
383 // If number of local maxima is 2 try to fit a double gaussian
386 // Initialise global variables for fit
388 gSegmentation=fSegmentation;
389 gResponse =fResponse;
392 for (i=0; i<mul; i++) {
395 gCharge[i]=Float_t(q[i]);
400 gMyMinuit = new TMinuit(5);
402 gMyMinuit->SetFCN(fcn);
403 gMyMinuit->mninit(5,10,7);
404 Double_t arglist[20];
407 // gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
408 // Set starting values
409 static Double_t vstart[5];
410 vstart[0]=x[indLocal[0]];
411 vstart[1]=y[indLocal[0]];
412 vstart[2]=x[indLocal[1]];
413 vstart[3]=y[indLocal[1]];
414 vstart[4]=Float_t(q[indLocal[0]])/
415 Float_t(q[indLocal[0]]+q[indLocal[1]]);
416 // lower and upper limits
417 static Double_t lower[5], upper[5];
418 Int_t isec=fSegmentation->Sector(ix[indLocal[0]], iy[indLocal[0]]);
419 lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
420 lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
421 // lower[1]=vstart[1];
423 upper[0]=lower[0]+fSegmentation->Dpx(isec);
424 upper[1]=lower[1]+fSegmentation->Dpy(isec);
425 // upper[1]=vstart[1];
427 isec=fSegmentation->Sector(ix[indLocal[1]], iy[indLocal[1]]);
428 lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
429 lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
430 // lower[3]=vstart[3];
432 upper[2]=lower[2]+fSegmentation->Dpx(isec);
433 upper[3]=lower[3]+fSegmentation->Dpy(isec);
434 // upper[3]=vstart[3];
439 static Double_t step[5]={0.005, 0.03, 0.005, 0.03, 0.01};
441 gMyMinuit->mnparm(0,"x1",vstart[0],step[0],lower[0],upper[0],ierflag);
442 gMyMinuit->mnparm(1,"y1",vstart[1],step[1],lower[1],upper[1],ierflag);
443 gMyMinuit->mnparm(2,"x2",vstart[2],step[2],lower[2],upper[2],ierflag);
444 gMyMinuit->mnparm(3,"y2",vstart[3],step[3],lower[3],upper[3],ierflag);
445 gMyMinuit->mnparm(4,"a0",vstart[4],step[4],lower[4],upper[4],ierflag);
446 // ready for minimisation
447 gMyMinuit->SetPrintLevel(-1);
448 gMyMinuit->mnexcm("SET OUT", arglist, 0, ierflag);
452 gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
453 gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
454 gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
456 // Double_t amin,edm,errdef;
457 // Int_t nvpar,nparx,icstat;
458 // gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
459 // gMyMinuit->mnprin(3,amin);
460 // Get fitted parameters
462 Double_t xrec[2], yrec[2], qfrac;
464 Double_t epxz, b1, b2;
466 gMyMinuit->mnpout(0, chname, xrec[0], epxz, b1, b2, ierflg);
467 gMyMinuit->mnpout(1, chname, yrec[0], epxz, b1, b2, ierflg);
468 gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);
469 gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);
470 gMyMinuit->mnpout(4, chname, qfrac, epxz, b1, b2, ierflg);
471 //printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
476 // One cluster for each maximum
478 for (j=0; j<2; j++) {
479 AliRICHRawCluster cnew;
481 cnew.fNcluster[0]=-1;
482 cnew.fNcluster[1]=fNRawClusters;
484 cnew.fNcluster[0]=fNPeaks;
487 cnew.fMultiplicity=0;
488 cnew.fX=Float_t(xrec[j]);
489 cnew.fY=Float_t(yrec[j]);
491 cnew.fQ=Int_t(gChargeTot*qfrac);
493 cnew.fQ=Int_t(gChargeTot*(1-qfrac));
495 gSegmentation->SetHit(xrec[j],yrec[j],0);
496 for (i=0; i<mul; i++) {
497 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
498 gSegmentation->SetPad(gix[i], giy[i]);
499 Float_t q1=gResponse->IntXY(gSegmentation);
500 cnew.fContMap[cnew.fMultiplicity]=Float_t(q[i])/(q1*cnew.fQ);
501 cnew.fMultiplicity++;
503 FillCluster(&cnew,0);
504 //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
505 cnew.fClusterType=cnew.PhysicsContribution();
513 if (nLocal !=-100 || !fitted) {
514 // Check if enough local clusters have been found,
515 // if not add global maxima to the list
521 printf("\n Warning, no local maximum found \n");
525 if (nPerMax > fNperMax) {
526 Int_t nGlob=mul/fNperMax-nLocal+1;
529 for (i=0; i<mul; i++) {
536 if (nnew==nGlob) break;
541 // Associate hits to peaks
543 for (i=0; i<mul; i++) {
546 if (isLocal[i]) continue;
547 for (j=0; j<nLocal; j++) {
548 Int_t il=indLocal[j];
549 Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
550 +(y[i]-y[il])*(y[i]-y[il]));
553 // Select nearest peak
559 } else if (d==dmin) {
561 // If more than one take highest peak
574 // One cluster for each maximum
576 for (j=0; j<nLocal; j++) {
577 AliRICHRawCluster cnew;
579 cnew.fNcluster[0]=-1;
580 cnew.fNcluster[1]=fNRawClusters;
582 cnew.fNcluster[0]=fNPeaks;
585 cnew.fIndexMap[0]=c->fIndexMap[indLocal[j]];
586 cnew.fMultiplicity=1;
587 for (i=0; i<mul; i++) {
588 if (isLocal[i]) continue;
589 if (associatePeak[i]==j) {
590 cnew.fIndexMap[cnew.fMultiplicity]=c->fIndexMap[i];
591 cnew.fMultiplicity++;
595 cnew.fClusterType=cnew.PhysicsContribution();
603 void AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
606 // Completes cluster information starting from list of digits
622 for (Int_t i=0; i<c->fMultiplicity; i++)
624 dig= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
625 ix=dig->PadX()+c->fOffsetMap[i];
627 Int_t q=dig->Signal();
628 if (dig->Physics() >= dig->Signal()) {
630 } else if (dig->Physics() == 0) {
632 } else c->fPhysicsMap[i]=1;
635 // peak signal and track list
637 if (q>c->fPeakSignal) {
640 c->fTracks[0]=dig->Track(0);
641 c->fTracks[1]=dig->Track(1);
642 c->fTracks[2]=dig->Track(2);
644 //c->fTracks[0]=dig->fTrack;
645 c->fTracks[0]=dig->Hit();
646 c->fTracks[1]=dig->Track(0);
647 c->fTracks[2]=dig->Track(1);
650 if (c->fContMap[i] > frac) {
654 c->fTracks[0]=dig->Track(0);
655 c->fTracks[1]=dig->Track(1);
656 c->fTracks[2]=dig->Track(2);
658 //c->fTracks[0]=dig->fTrack;
659 c->fTracks[0]=dig->Hit();
660 c->fTracks[1]=dig->Track(0);
661 c->fTracks[2]=dig->Track(1);
666 fSegmentation->GetPadC(ix, iy, x, y, z);
672 } // loop over digits
677 c->fX=fSegmentation->GetAnod(c->fX);
680 // apply correction to the coordinate along the anode wire
684 fSegmentation->GetPadI(x, y, 0, ix, iy);
685 fSegmentation->GetPadC(ix, iy, x, y, z);
686 Int_t isec=fSegmentation->Sector(ix,iy);
687 TF1* cogCorr = fSegmentation->CorrFunc(isec-1);
690 Float_t yOnPad=(c->fY-y)/fSegmentation->Dpy(isec);
691 c->fY=c->fY-cogCorr->Eval(yOnPad, 0, 0);
697 void AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
702 // Add i,j as element of the cluster
705 Int_t idx = fHitMap->GetHitIndex(i,j);
706 AliRICHDigit* dig = (AliRICHDigit*) fHitMap->GetHit(i,j);
707 Int_t q=dig->Signal();
708 if (q > TMath::Abs(c.fPeakSignal)) {
711 c.fTracks[0]=dig->fTracks[0];
712 c.fTracks[1]=dig->fTracks[1];
713 c.fTracks[2]=dig->fTracks[2];
715 //c.fTracks[0]=dig->fTrack;
716 c.fTracks[0]=dig->Hit();
717 c.fTracks[1]=dig->Track(0);
718 c.fTracks[2]=dig->Track(1);
721 // Make sure that list of digits is ordered
723 Int_t mu=c.fMultiplicity;
726 if (dig->Physics() >= dig->Signal()) {
728 } else if (dig->Physics() == 0) {
730 } else c.fPhysicsMap[mu]=1;
733 for (Int_t ind=mu-1; ind>=0; ind--) {
734 Int_t ist=(c.fIndexMap)[ind];
735 Int_t ql=((AliRICHDigit*)fDigits
736 ->UncheckedAt(ist))->Signal();
738 c.fIndexMap[ind]=idx;
739 c.fIndexMap[ind+1]=ist;
748 if (c.fMultiplicity >= 50 ) {
749 printf("FindCluster - multiplicity >50 %d \n",c.fMultiplicity);
753 // Prepare center of gravity calculation
755 fSegmentation->GetPadC(i, j, x, y, z);
760 fHitMap->FlagHit(i,j);
762 // Now look recursively for all neighbours
765 Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
766 fSegmentation->Neighbours(i,j,&nn,xList,yList);
767 for (Int_t in=0; in<nn; in++) {
770 if (fHitMap->TestHit(ix,iy)==kUnused) FindCluster(ix, iy, c);
774 //_____________________________________________________________________________
776 void AliRICHClusterFinder::FindRawClusters()
779 // simple RICH cluster finder from digits -- finds neighbours and
780 // fill the tree with raw clusters
782 if (!fNdigits) return;
784 fHitMap = new AliRICHHitMapA1(fSegmentation, fDigits);
788 //printf ("Now I'm here");
794 for (ndig=0; ndig<fNdigits; ndig++) {
795 dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
798 if (fHitMap->TestHit(i,j)==kUsed ||fHitMap->TestHit(i,j)==kEmpty) {
804 c.fPeakSignal=dig->Signal();
806 c.fTracks[0]=dig->fTracks[0];
807 c.fTracks[1]=dig->fTracks[1];
808 c.fTracks[2]=dig->fTracks[2];
810 //c.fTracks[0]=dig->fTrack;
811 c.fTracks[0]=dig->Hit();
812 c.fTracks[1]=dig->Track(0);
813 c.fTracks[2]=dig->Track(1);
814 // tag the beginning of cluster list in a raw cluster
819 c.fX=fSegmentation->GetAnod(c.fX);
822 // apply correction to the coordinate along the anode wire
829 fSegmentation->GetPadI(x, y, 0, ix, iy);
830 fSegmentation->GetPadC(ix, iy, x, y, z);
831 Int_t isec=fSegmentation->Sector(ix,iy);
832 TF1* cogCorr=fSegmentation->CorrFunc(isec-1);
834 Float_t yOnPad=(c.fY-y)/fSegmentation->Dpy(isec);
835 c.fY=c.fY-cogCorr->Eval(yOnPad,0,0);
839 // Analyse cluster and decluster if necessary
842 c.fNcluster[1]=fNRawClusters;
843 c.fClusterType=c.PhysicsContribution();
849 // reset Cluster object
850 for (int k=0;k<c.fMultiplicity;k++) {
858 void AliRICHClusterFinder::
869 fSegmentation->GiveTestPoints(n, x, y);
870 for (i=0; i<n; i++) {
874 SinoidalFit(xtest, ytest, func);
875 if (func) fSegmentation->SetCorrFunc(i, new TF1(*func));
881 void AliRICHClusterFinder::
882 SinoidalFit(Float_t x, Float_t y, TF1 *func)
887 static Int_t count=0;
892 sprintf(canvasname,"c%d",count);
895 Float_t xg[kNs], yg[kNs], xrg[kNs], yrg[kNs];
896 Float_t xsig[kNs], ysig[kNs];
898 AliSegmentation *segmentation=fSegmentation;
901 segmentation->GetPadI(x,y,0,ix,iy);
902 segmentation->GetPadC(ix,iy,x,y,z);
903 Int_t isec=segmentation->Sector(ix,iy);
905 Float_t xmin = x-segmentation->Dpx(isec)/2;
906 Float_t ymin = y-segmentation->Dpy(isec)/2;
908 // Integration Limits
909 Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
910 Float_t dyI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadY();
920 Float_t dy=segmentation->Dpy(isec)/(kNs-1);
922 for (i=0; i<kNs; i++) {
928 segmentation->SigGenInit(x, yscan, 0);
930 for (segmentation->FirstPad(x, yscan,0, 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->GetPadC(ixs,iys,xs,ys,zs);
947 Float_t ycog=sum/qcheck;
948 yg[i]=(yscan-y)/segmentation->Dpy(isec);
949 yrg[i]=(ycog-y)/segmentation->Dpy(isec);
956 Float_t dx=segmentation->Dpx(isec)/(kNs-1);
958 for (i=0; i<kNs; i++) {
964 segmentation->SigGenInit(xscan, y, 0);
966 for (segmentation->FirstPad(xscan, y, 0, dxI, dyI);
967 segmentation->MorePads();
968 segmentation->NextPad())
970 qp=fResponse->IntXY(segmentation);
976 Int_t ixs=segmentation->Ix();
977 Int_t iys=segmentation->Iy();
979 segmentation->GetPadC(ixs,iys,xs,ys,zs);
983 Float_t xcog=sum/qcheck;
984 xcog=segmentation->GetAnod(xcog);
986 xg[i]=(xscan-x)/segmentation->Dpx(isec);
987 xrg[i]=(xcog-x)/segmentation->Dpx(isec);
992 // Creates a Root function based on function sinoid above
993 // and perform the fit
995 // TGraph *graphx = new TGraph(kNs,xg ,xsig);
996 // TGraph *graphxr= new TGraph(kNs,xrg,xsig);
997 // TGraph *graphy = new TGraph(kNs,yg ,ysig);
998 TGraph *graphyr= new TGraph(kNs,yrg,ysig);
1000 Double_t sinoid(Double_t *x, Double_t *par);
1001 new TF1("sinoidf",sinoid,0.5,0.5,5);
1002 graphyr->Fit("sinoidf","Q");
1003 func = (TF1*)graphyr->GetListOfFunctions()->At(0);
1006 TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
1007 TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
1008 TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
1009 TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
1010 TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
1011 pad11->SetFillColor(11);
1012 pad12->SetFillColor(11);
1013 pad13->SetFillColor(11);
1014 pad14->SetFillColor(11);
1022 graphx->SetFillColor(42);
1023 graphx->SetMarkerColor(4);
1024 graphx->SetMarkerStyle(21);
1026 graphx->GetHistogram()->SetXTitle("x on pad");
1027 graphx->GetHistogram()->SetYTitle("xcog-x");
1031 graphxr->SetFillColor(42);
1032 graphxr->SetMarkerColor(4);
1033 graphxr->SetMarkerStyle(21);
1034 graphxr->Draw("AP");
1035 graphxr->GetHistogram()->SetXTitle("xcog on pad");
1036 graphxr->GetHistogram()->SetYTitle("xcog-x");
1040 graphy->SetFillColor(42);
1041 graphy->SetMarkerColor(4);
1042 graphy->SetMarkerStyle(21);
1044 graphy->GetHistogram()->SetXTitle("y on pad");
1045 graphy->GetHistogram()->SetYTitle("ycog-y");
1050 graphyr->SetFillColor(42);
1051 graphyr->SetMarkerColor(4);
1052 graphyr->SetMarkerStyle(21);
1053 graphyr->Draw("AF");
1054 graphyr->GetHistogram()->SetXTitle("ycog on pad");
1055 graphyr->GetHistogram()->SetYTitle("ycog-y");
1061 Double_t sinoid(Double_t *x, Double_t *par)
1066 Double_t arg = -2*TMath::Pi()*x[0];
1067 Double_t fitval= par[0]*TMath::Sin(arg)+
1068 par[1]*TMath::Sin(2*arg)+
1069 par[2]*TMath::Sin(3*arg)+
1070 par[3]*TMath::Sin(4*arg)+
1071 par[4]*TMath::Sin(5*arg);
1076 Double_t DoubleGauss(Double_t *x, Double_t *par)
1079 // Doublr gaussian function
1081 Double_t arg1 = (x[0]-par[1])/0.18;
1082 Double_t arg2 = (x[0]-par[3])/0.18;
1083 Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
1084 +par[2]*TMath::Exp(-arg2*arg2/2);
1088 Float_t DiscrCharge(Int_t i,Double_t *par)
1090 // par[0] x-position of first cluster
1091 // par[1] y-position of first cluster
1092 // par[2] x-position of second cluster
1093 // par[3] y-position of second cluster
1094 // par[4] charge fraction of first cluster
1095 // 1-par[4] charge fraction of second cluster
1097 static Float_t qtot;
1100 for (Int_t jbin=0; jbin<gNbins; jbin++) {
1101 qtot+=gCharge[jbin];
1104 //printf("\n sum of charge from DiscrCharge %f\n", qtot);
1105 gChargeTot=Int_t(qtot);
1108 gSegmentation->SetPad(gix[i], giy[i]);
1110 gSegmentation->SetHit(par[0],par[1],0);
1111 Float_t q1=gResponse->IntXY(gSegmentation);
1114 gSegmentation->SetHit(par[2],par[3],0);
1115 Float_t q2=gResponse->IntXY(gSegmentation);
1117 Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
1122 // Minimisation function
1123 void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
1131 for (i=0; i<gNbins; i++) {
1132 Float_t q0=gCharge[i];
1133 Float_t q1=DiscrCharge(i,par);
1134 delta=(q0-q1)/TMath::Sqrt(q0);
1139 chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;
1144 void AliRICHClusterFinder::SetDigits(TClonesArray *RICHdigits)
1147 // Get all the digits
1150 fNdigits = fDigits->GetEntriesFast();
1153 AliRICHClusterFinder& AliRICHClusterFinder::operator=(const AliRICHClusterFinder& rhs)
1155 // Assignment operator