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 **************************************************************************/
16 //////////////////////////////////////////////////////////////////////////
20 // RICH class to perfom pattern recognition based on Hough transfrom //
22 //////////////////////////////////////////////////////////////////////////
24 #include <Riostream.h>
26 #include <TRotation.h>
30 #include "AliRICHParam.h"
31 #include "AliRICHRecon.h"
32 #include "AliRICHHelix.h"
35 #define NPointsOfRing 201
37 //__________________________________________________________________________________________________
38 AliRICHRecon::AliRICHRecon(AliRICHHelix *pHelix,TClonesArray *pClusters,Int_t iMipId)
39 :TTask("RichRec","RichPat")
42 SetFreonScaleFactor(1);
44 fThetaBin=750; fThetaMin = 0.0; fThetaMax = 0.75;
45 fDTheta = 0.001; fWindowWidth = 0.060;
46 fRadiatorWidth = AliRICHParam::Zfreon();
47 fQuartzWidth = AliRICHParam::Zwin();
48 fGapWidth = AliRICHParam::Freon2Pc() - fRadiatorWidth - fQuartzWidth;
49 fXmin = -AliRICHParam::PcSizeX()/2.;
50 fXmax = AliRICHParam::PcSizeX()/2.;
51 fYmin = -AliRICHParam::PcSizeY()/2.;
52 fYmax = AliRICHParam::PcSizeY()/2.;
53 SetTrackTheta(pHelix->Ploc().Theta());
54 SetTrackPhi(pHelix->Ploc().Phi());
56 SetShiftX(pHelix->PosRad().X());
57 SetShiftY(pHelix->PosRad().Y());
58 fpClusters = pClusters;
60 //__________________________________________________________________________________________________
61 Double_t AliRICHRecon::ThetaCerenkov()
63 // Pattern recognition method based on Hough transform
64 // Return theta Cerenkov for a given track and list of clusters which are set in ctor
66 if(fpClusters->GetEntries()==0) return -1;//no clusters at all for a given track
67 Bool_t kPatRec = kFALSE;
69 AliDebug(1,Form("---Track Parameters--- Theta: %f , Phi: %f ",GetTrackTheta()*TMath::RadToDeg(),GetTrackPhi()*TMath::RadToDeg()));
71 Int_t candidatePhotons = 0;
73 SetThetaCerenkov(999.);
75 SetHoughPhotonsNorm(0);
77 for (Int_t j=0; j < fpClusters->GetEntries(); j++){//clusters loop
82 if (j == GetMipIndex()) continue; // do not consider MIP cluster as a candidate photon
83 Float_t xtoentr = ((AliRICHCluster*)fpClusters->UncheckedAt(j))->X() - GetShiftX();
84 Float_t ytoentr = ((AliRICHCluster*)fpClusters->UncheckedAt(j))->Y() - GetShiftY();
85 SetEntranceX(xtoentr);
86 SetEntranceY(ytoentr);
88 // Int_t photonStatus = PhotonInBand();
89 // if(photonStatus == 0) continue;
91 FindThetaPhotonCerenkov();
92 Float_t thetaPhotonCerenkov = GetThetaPhotonCerenkov();
93 AliDebug(1,Form("THETA CERENKOV ---> %f",thetaPhotonCerenkov));
94 SetPhotonEta(thetaPhotonCerenkov);
98 if(candidatePhotons >= 1) kPatRec = kTRUE;
100 if(!kPatRec) return -1;
102 SetPhotonsNumber(fpClusters->GetEntries());
109 Int_t nPhotonHough = GetHoughPhotons();
113 SetThetaCerenkov(999.);
114 SetHoughPhotonsNorm(0.);
120 AliDebug(1,Form("Number of clusters accepted ---> %i",nPhotonHough));
122 // Float_t thetaCerenkov = GetThetaCerenkov();
123 // SetThetaOfRing(thetaCerenkov);
124 // FindAreaAndPortionOfRing();
126 // Float_t nPhotonHoughNorm = ((Float_t)nPhotonHough)/GetPortionOfRing();
127 // SetHoughPhotonsNorm(nPhotonHoughNorm);
129 // Calculate the area where the photon are accepted...
131 Float_t thetaInternal = thetaCerenkov - 0.5*fWindowWidth;
132 SetThetaOfRing(thetaInternal);
133 FindAreaAndPortionOfRing();
134 Float_t internalArea = GetAreaOfRing();
136 Float_t thetaExternal = thetaCerenkov + 0.5*fWindowWidth;
137 SetThetaOfRing(thetaExternal);
138 FindAreaAndPortionOfRing();
139 Float_t externalArea = GetAreaOfRing();
141 Float_t houghArea = externalArea - internalArea;
143 SetHoughArea(houghArea);
145 return GetThetaCerenkov();
148 //__________________________________________________________________________________________________
149 void AliRICHRecon::FindEmissionPoint()
151 //estimate the emission point in radiator
153 // Find emission point
155 Float_t absorbtionLenght=7.83*fRadiatorWidth; //absorption length in the freon (cm)
156 // 7.83 = -1/ln(T0) where
157 // T0->Trasmission freon at 180nm = 0.88 (Eph=6.85eV)
158 Float_t photonLenght, photonLenghtMin, photonLenghtMax;
160 photonLenght=exp(-fRadiatorWidth/(absorbtionLenght*cos(fCerenkovAnglePad)));
161 photonLenghtMin=fRadiatorWidth*photonLenght/(1.-photonLenght);
162 photonLenghtMax=absorbtionLenght*cos(fCerenkovAnglePad);
163 Float_t emissionPoint = fRadiatorWidth + photonLenghtMin - photonLenghtMax;
165 SetEmissionPoint(emissionPoint);
166 SetEmissionPoint(fRadiatorWidth/2); // tune the emission point
168 //__________________________________________________________________________________________________
169 Int_t AliRICHRecon::PhotonInBand()
171 //search band fro photon candidates
173 // Float_t massOfParticle;
178 Float_t xtoentr = GetEntranceX();
179 Float_t ytoentr = GetEntranceY();
184 Float_t phpad = GetPhiPoint();
188 SetPhotonEnergy(5.6);
189 SetEmissionPoint(fRadiatorWidth -0.0001);
190 SetFreonRefractiveIndex();
192 nfreon = GetFreonRefractiveIndex();
195 AliDebug(1,Form("thetacer in photoninband min %f",thetacer));
197 FindThetaAtQuartz(thetacer);
199 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
202 SetXInnerRing(-999.);
203 SetYInnerRing(-999.);
204 SetRadiusInnerRing(-999.);
208 SetThetaPhotonInDRS(GetThetaAtQuartz());
209 SetPhiPhotonInDRS(phpad);
211 innerRadius = FromEmissionToCathode();
212 if(innerRadius == 999.) innerRadius = -999.;
214 SetXInnerRing(GetXPointOnCathode());
215 SetYInnerRing(GetYPointOnCathode());
216 SetRadiusInnerRing(innerRadius);
220 SetPhotonEnergy(7.7);
221 SetEmissionPoint(0.);
222 // SetMassHypotesis(0.139567);
223 SetFreonRefractiveIndex();
225 nfreon = GetFreonRefractiveIndex();
227 thetacer = Cerenkovangle(nfreon,1);
231 AliDebug(1,Form("thetacer in photoninband max %f",thetacer));
233 FindThetaAtQuartz(thetacer);
235 if(thetacer == 999. || GetThetaAtQuartz() == 999.)
240 SetRadiusOuterRing(999.);
244 SetThetaPhotonInDRS(GetThetaAtQuartz());
245 SetPhiPhotonInDRS(phpad);
247 outerRadius = FromEmissionToCathode();
248 // cout << " outerRadius " << outerRadius << endl;
249 SetXOuterRing(GetXPointOnCathode());
250 SetYOuterRing(GetYPointOnCathode());
251 SetRadiusOuterRing(outerRadius);
254 Float_t padradius = sqrt(TMath::Power(xtoentr,2)+TMath::Power(ytoentr,2));
256 AliDebug(1,Form("rmin %f r %f rmax %f",innerRadius,padradius,outerRadius));
258 if(padradius>=innerRadius && padradius<=outerRadius) return 1;
261 //__________________________________________________________________________________________________
262 void AliRICHRecon::FindThetaAtQuartz(Float_t thetaCerenkov)
264 //find the theta at the quartz plate
266 if(thetaCerenkov == 999.)
268 SetThetaAtQuartz(999.);
272 Float_t thetaAtQuartz = 999.;
274 Float_t trackTheta = GetTrackTheta();
276 if(trackTheta == 0) {
278 thetaAtQuartz = thetaCerenkov;
279 SetThetaAtQuartz(thetaAtQuartz);
283 Float_t trackPhi = GetTrackPhi();
284 Float_t phiPoint = GetPhiPoint();
286 Double_t den = TMath::Sin((Double_t)trackTheta)
287 *TMath::Cos((Double_t)trackPhi)
288 *TMath::Cos((Double_t)phiPoint) +
289 TMath::Sin((Double_t)trackTheta)
290 *TMath::Sin((Double_t)trackPhi)
291 *TMath::Sin((Double_t)phiPoint);
292 Double_t b = TMath::Cos((Double_t)trackTheta)/den;
293 Double_t c = -TMath::Cos((Double_t)thetaCerenkov)/den;
295 Double_t underSqrt = 1 + b*b - c*c;
298 SetThetaAtQuartz(999.);
302 Double_t sol1 = (1+TMath::Sqrt(underSqrt))/(b-c);
303 Double_t sol2 = (1-TMath::Sqrt(underSqrt))/(b-c);
305 Double_t thetaSol1 = 2*TMath::ATan(sol1);
306 Double_t thetaSol2 = 2*TMath::ATan(sol2);
308 if(thetaSol1>0 && thetaSol1 < TMath::Pi()) thetaAtQuartz = (Float_t)thetaSol1;
309 if(thetaSol2>0 && thetaSol2 < TMath::Pi()) thetaAtQuartz = (Float_t)thetaSol2;
311 // AliDebug(1,Form(" Theta @ quartz window %f ",thetaAtQuartz));
313 SetThetaAtQuartz(thetaAtQuartz);
315 //__________________________________________________________________________________________________
316 void AliRICHRecon::FindThetaPhotonCerenkov()
318 //find theta cerenkov of ring
320 Float_t thetaCerMin = 0.;
321 Float_t thetaCerMax = 0.75;
322 Float_t thetaCerMean;
324 Float_t radiusMin, radiusMax, radiusMean;
325 Int_t nIteration = 0;
327 const Float_t kTollerance = 0.05;
330 Float_t phiPoint = GetPhiPoint();
332 SetPhotonEnergy(AliRICHParam::MeanCkovEnergy());
333 SetEmissionPoint(fRadiatorWidth/2);
335 Float_t xPoint = GetEntranceX();
336 Float_t yPoint = GetEntranceY();
337 Float_t distPoint = TMath::Sqrt(xPoint*xPoint + yPoint*yPoint);
339 // AliDebug(1,Form(" DistPoint %f ",distPoint));
341 // Star minimization...
345 FindThetaAtQuartz(thetaCerMin);
347 if(GetThetaAtQuartz() == 999.)
353 SetThetaPhotonInDRS(GetThetaAtQuartz());
354 SetPhiPhotonInDRS(phiPoint);
356 radiusMin = FromEmissionToCathode();
361 FindThetaAtQuartz(thetaCerMax);
362 if(GetThetaAtQuartz() == 999.)
368 SetThetaPhotonInDRS(GetThetaAtQuartz());
369 SetPhiPhotonInDRS(phiPoint);
371 radiusMax = FromEmissionToCathode();
375 thetaCerMean = (thetaCerMax + thetaCerMin)/2;
377 FindThetaAtQuartz(thetaCerMean);
378 if(GetThetaAtQuartz() == 999.)
384 SetThetaPhotonInDRS(GetThetaAtQuartz());
385 SetPhiPhotonInDRS(phiPoint);
387 radiusMean = FromEmissionToCathode();
390 // AliDebug(1,Form(" r1 %f rmean %f r2 %f",radiusMin,radiusMean,radiusMax));
392 while (TMath::Abs(radiusMean-distPoint) > kTollerance)
395 if((radiusMin-distPoint)*(radiusMean-distPoint) < 0) thetaCerMax = thetaCerMean;
396 if((radiusMin-distPoint)*(radiusMean-distPoint) > 0) {
398 thetaCerMin = thetaCerMean;
400 FindThetaAtQuartz(thetaCerMin);
401 SetThetaPhotonInDRS(GetThetaAtQuartz());
402 SetPhiPhotonInDRS(phiPoint);
404 radiusMin =FromEmissionToCathode();
407 thetaCerMean = (thetaCerMax + thetaCerMin)/2;
409 FindThetaAtQuartz(thetaCerMean);
410 SetThetaPhotonInDRS(GetThetaAtQuartz());
411 SetPhiPhotonInDRS(phiPoint);
413 radiusMean = FromEmissionToCathode();
417 // AliDebug(1,Form(" max iterations in FindPhotonCerenkov ",nIteration));
418 SetThetaPhotonCerenkov(999.);
423 // AliDebug(1,Form(" distpoint %f radius %f ",distPoint,radiusMean));
424 SetThetaPhotonCerenkov(thetaCerMean);
427 //__________________________________________________________________________________________________
428 void AliRICHRecon::FindAreaAndPortionOfRing()
430 //find fraction of the ring accepted by the RICH
432 Float_t xPoint[NPointsOfRing], yPoint[NPointsOfRing];
434 // Float_t xtoentr = GetEntranceX();
435 // Float_t ytoentr = GetEntranceY();
436 Float_t shiftX = GetShiftX();
437 Float_t shiftY = GetShiftY();
439 Float_t xemiss = GetXCoordOfEmission();
440 Float_t yemiss = GetYCoordOfEmission();
442 Float_t x0 = xemiss + shiftX;
443 Float_t y0 = yemiss + shiftY;
446 SetPhotonEnergy(AliRICHParam::MeanCkovEnergy());
447 SetFreonRefractiveIndex();
449 SetEmissionPoint(fRadiatorWidth/2.);
451 Float_t theta = GetThetaOfRing();
454 Int_t nPsiAccepted = 0;
457 for(Int_t i=0;i<NPointsOfRing-1;i++)
460 Float_t psi = 2*TMath::Pi()*i/NPointsOfRing;
462 SetThetaPhotonInTRS(theta);
463 SetPhiPhotonInTRS(psi);
464 FindPhotonAnglesInDRS();
466 Float_t radius = FromEmissionToCathode();
467 if (radius == 999.) continue;
471 Float_t xPointRing = GetXPointOnCathode() + shiftX;
472 Float_t yPointRing = GetYPointOnCathode() + shiftY;
474 SetDetectorWhereX(xPointRing);
475 SetDetectorWhereY(yPointRing);
477 Int_t zone = CheckDetectorAcceptance();
482 FindIntersectionWithDetector();
483 xPoint[nPoints] = GetIntersectionX();
484 yPoint[nPoints] = GetIntersectionY();
488 xPoint[nPoints] = xPointRing;
489 yPoint[nPoints] = yPointRing;
497 xPoint[nPoints] = xPoint[0];
498 yPoint[nPoints] = yPoint[0];
504 for (Int_t i = 0; i < nPoints; i++)
506 area += TMath::Abs((xPoint[i]-x0)*(yPoint[i+1]-y0) - (xPoint[i+1]-x0)*(yPoint[i]-y0));
511 Float_t portionOfRing = ((Float_t)nPsiAccepted)/((Float_t)(nPsiTotal));
515 SetPortionOfRing(portionOfRing);
517 //__________________________________________________________________________________________________
518 void AliRICHRecon::FindIntersectionWithDetector()
520 // find ring intersection with CsI edges
522 Float_t xIntersect, yIntersect;
523 Float_t x1, x2, y1, y2;
525 Float_t shiftX = GetShiftX();
526 Float_t shiftY = GetShiftY();
528 Float_t xPoint = GetXPointOnCathode() + shiftX;
529 Float_t yPoint = GetYPointOnCathode() + shiftY;
531 Float_t xemiss = GetXCoordOfEmission();
532 Float_t yemiss = GetYCoordOfEmission();
534 Float_t phi = GetPhiPhotonInDRS();
535 Float_t m = tan(phi);
537 Float_t x0 = xemiss + shiftX;
538 Float_t y0 = yemiss + shiftY;
562 yIntersect = m*(xIntersect - x0) + y0;
563 if (yIntersect >= fYmin && yIntersect <= fYmax && xIntersect >= x1 && xIntersect <= x2)
565 SetIntersectionX(xIntersect);
566 SetIntersectionY(yIntersect);
571 yIntersect = m*(xIntersect - x0) + y0;
572 if (yIntersect >= fYmin && yIntersect <= fYmax && xIntersect >= x1 && xIntersect <= x2)
574 SetIntersectionX(xIntersect);
575 SetIntersectionY(yIntersect);
580 xIntersect = (yIntersect - y0)/m + x0;
581 if (xIntersect >= fXmin && xIntersect <= fXmax && yIntersect >= y1 && yIntersect <= y2)
583 SetIntersectionX(xIntersect);
584 SetIntersectionY(yIntersect);
589 xIntersect = (yIntersect - y0)/m + x0;
590 if (xIntersect >= fXmin && xIntersect <= fXmax && yIntersect >= y1 && yIntersect <= y2)
592 SetIntersectionX(xIntersect);
593 SetIntersectionY(yIntersect);
597 cout << " sono fuori!!!!!!" << endl;
600 //__________________________________________________________________________________________________
601 Int_t AliRICHRecon::CheckDetectorAcceptance() const
603 // check for the acceptance
605 // crosses X -2.6 2.6 cm
608 Float_t xcoord = GetDetectorWhereX();
609 Float_t ycoord = GetDetectorWhereY();
613 if(ycoord > fYmax) return 2;
614 if(ycoord > fYmin && ycoord < fYmax) return 3;
615 if(ycoord < fYmin) return 4;
619 if(ycoord > fYmax) return 8;
620 if(ycoord > fYmin && ycoord < fYmax) return 7;
621 if(ycoord < fYmin) return 6;
623 if(xcoord > fXmin && xcoord < fXmax)
625 if(ycoord > fYmax) return 1;
626 if(ycoord > fYmin && ycoord < fYmax) return 0;
627 if(ycoord < fYmin) return 5;
631 //__________________________________________________________________________________________________
632 void AliRICHRecon::FindPhotonAnglesInDRS()
634 // Setup the rotation matrix of the track...
641 Float_t trackTheta = GetTrackTheta();
642 Float_t trackPhi = GetTrackPhi();
644 mtheta.RotateY(trackTheta);
645 mphi.RotateZ(trackPhi);
647 mrot = mphi * mtheta;
648 // minv = mrot.Inverse();
650 TVector3 photonInRadiator(1,1,1);
652 Float_t thetaCerenkov = GetThetaPhotonInTRS();
653 Float_t phiCerenkov = GetPhiPhotonInTRS();
655 photonInRadiator.SetTheta(thetaCerenkov);
656 photonInRadiator.SetPhi(phiCerenkov);
657 photonInRadiator = mrot * photonInRadiator;
658 Float_t theta = photonInRadiator.Theta();
659 Float_t phi = photonInRadiator.Phi();
660 SetThetaPhotonInDRS(theta);
661 SetPhiPhotonInDRS(phi);
664 //__________________________________________________________________________________________________
665 Float_t AliRICHRecon::FromEmissionToCathode()
667 // trace from emission point to cathode
669 Float_t nfreon, nquartz, ngas;
671 SetFreonRefractiveIndex();
672 SetQuartzRefractiveIndex();
673 SetGasRefractiveIndex();
675 nfreon = GetFreonRefractiveIndex();
676 nquartz = GetQuartzRefractiveIndex();
677 ngas = GetGasRefractiveIndex();
679 Float_t trackTheta = GetTrackTheta();
680 Float_t trackPhi = GetTrackPhi();
681 Float_t lengthOfEmissionPoint = GetEmissionPoint();
683 Float_t theta = GetThetaPhotonInDRS();
684 Float_t phi = GetPhiPhotonInDRS();
686 // cout << " Theta " << Theta << " Phi " << Phi << endl;
688 Float_t xemiss = lengthOfEmissionPoint*tan(trackTheta)*cos(trackPhi);
689 Float_t yemiss = lengthOfEmissionPoint*tan(trackTheta)*sin(trackPhi);
691 SetXCoordOfEmission(xemiss);
692 SetYCoordOfEmission(yemiss);
694 Float_t thetaquar = SnellAngle(nfreon, nquartz, theta);
696 if(thetaquar == 999.)
698 SetXPointOnCathode(999.);
699 SetYPointOnCathode(999.);
703 Float_t thetagap = SnellAngle( nquartz, ngas, thetaquar);
707 SetXPointOnCathode(999.);
708 SetYPointOnCathode(999.);
712 Float_t xw = (fRadiatorWidth - lengthOfEmissionPoint)*cos(phi)*tan(theta);
713 Float_t xq = fQuartzWidth*cos(phi)*tan(thetaquar);
714 Float_t xg = fGapWidth*cos(phi)*tan(thetagap);
715 Float_t yw = (fRadiatorWidth - lengthOfEmissionPoint)*sin(phi)*tan(theta);
716 Float_t yq = fQuartzWidth*sin(phi)*tan(thetaquar);
717 Float_t yg = fGapWidth*sin(phi)*tan(thetagap);
720 Float_t xtot = xemiss + xw + xq + xg;
721 Float_t ytot = yemiss + yw + yq + yg;
723 SetXPointOnCathode(xtot);
724 SetYPointOnCathode(ytot);
727 Float_t distanceFromEntrance = sqrt(TMath::Power(fPhotonLimitX,2)
728 +TMath::Power(fPhotonLimitY,2));
730 return distanceFromEntrance;
733 //__________________________________________________________________________________________________
734 void AliRICHRecon::FindPhiPoint()
736 //find phi of generated point
738 Float_t xtoentr = GetEntranceX();
739 Float_t ytoentr = GetEntranceY();
741 Float_t trackTheta = GetTrackTheta();
742 Float_t trackPhi = GetTrackPhi();
744 Float_t emissionPoint = GetEmissionPoint();
746 Float_t argY = ytoentr - emissionPoint*tan(trackTheta)*sin(trackPhi);
747 Float_t argX = xtoentr - emissionPoint*tan(trackTheta)*cos(trackPhi);
748 Float_t phi = atan2(argY,argX);
753 //__________________________________________________________________________________________________
754 Float_t AliRICHRecon::Cerenkovangle(Float_t n, Float_t beta)
756 // cerenkov angle from n and beta
758 // Compute the cerenkov angle
764 // cout << " warning in Cerenkoangle !!!!!! " << endl;
768 thetacer = acos (1./(n*beta));
771 //__________________________________________________________________________________________________
772 Float_t AliRICHRecon::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
776 // Compute the Snell angle
778 Float_t sinrefractangle;
779 Float_t refractangle;
781 sinrefractangle = (n1/n2)*sin(theta1);
783 if(sinrefractangle>1.) {
784 // cout << " PROBLEMS IN SNELL ANGLE !!!!! " << endl;
789 refractangle = asin(sinrefractangle);
792 //__________________________________________________________________________________________________
793 void AliRICHRecon::HoughResponse()
797 // Implement Hough response pat. rec. method
804 int i, j, k, nCorrBand;
805 float hcs[750],hcsw[750];
807 float lowerlimit,upperlimit;
813 float etaPeakPos = -1;
815 Int_t etaPeakCount = -1;
817 Float_t thetaCerenkov = 0.;
819 nBin = (int)(0.5+fThetaMax/(fDTheta));
820 nCorrBand = (int)(0.5+ fWindowWidth/(2 * fDTheta));
822 memset ((void *)hcs, 0, fThetaBin*sizeof(float));
823 memset ((void *)hcsw, 0, fThetaBin*sizeof(float));
825 Int_t nPhotons = GetPhotonsNumber();
827 Int_t weightFlag = 0;
829 for (k=0; k< nPhotons; k++) {
833 angle = GetPhotonEta();
835 if(angle == -999.) continue;
837 if (angle>=fThetaMin && angle<= fThetaMax)
841 bin = (int)(0.5+angle/(fDTheta));
850 lowerlimit = ((Float_t)bin1)*fDTheta + 0.5*fDTheta;
851 SetThetaOfRing(lowerlimit);
852 FindAreaAndPortionOfRing();
853 Float_t area1 = GetAreaOfRing();
855 upperlimit = ((Float_t)bin2)*fDTheta + 0.5*fDTheta;
856 SetThetaOfRing(upperlimit);
857 FindAreaAndPortionOfRing();
858 Float_t area2 = GetAreaOfRing();
860 // cout << "lowerlimit" << lowerlimit << "upperlimit " << upperlimit << endl;
861 Float_t diffarea = area2 - area1;
865 weight = 1./(area2-area1);
873 // cout <<" low "<< lowerlimit << " up " << upperlimit <<
874 // " area1 " << area1 << " area2 " << area2 << " weight " << weight << endl;
882 SetPhotonWeight(weight);
884 // cout << "weight..." << weight << endl;
888 if (bin2>nBin) bin2=nBin;
890 for (j=bin1; j<bin2; j++)
906 // cout << " probems with weight...normal procedure adopted " << endl;
909 HoughFiltering(hCSspace);
911 for (bin=0; bin <nBin; bin++) {
912 angle = (bin+0.5) * (fDTheta);
913 if (hCSspace[bin] && hCSspace[bin] > etaPeakPos) {
915 etaPeakPos = hCSspace[bin];
919 if (hCSspace[bin] == etaPeakPos) {
920 etaPeak[++etaPeakCount] = angle;
925 for (i=0; i<etaPeakCount+1; i++) {
926 thetaCerenkov += etaPeak[i];
928 if (etaPeakCount>=0) {
929 thetaCerenkov /= etaPeakCount+1;
930 fThetaPeakPos = etaPeakPos;
933 SetThetaCerenkov(thetaCerenkov);
935 //__________________________________________________________________________________________________
936 void AliRICHRecon::HoughFiltering(float hcs[])
943 float k[5] = {0.05, 0.25, 0.4, 0.25, 0.05};
948 nBin = (int)(1+fThetaMax/fDTheta);
949 sizeHCS = fThetaBin*sizeof(float);
951 memset ((void *)hcsFilt, 0, sizeHCS);
953 for (nx = 0; nx < nBin; nx++) {
954 for (i = 0; i < 5; i++) {
956 if (nxDx> -1 && nxDx<nBin)
957 hcsFilt[nx] += hcs[nxDx] * k[i];
961 for (nx = 0; nx < nBin; nx++) {
962 hcs[nx] = hcsFilt[nx];
965 //__________________________________________________________________________________________________
966 void AliRICHRecon::FindThetaCerenkov()
968 // manage with weight for photons
971 Float_t weightThetaCerenkov = 0.;
973 Int_t nPhotons = GetPhotonsNumber();
974 for(Int_t i=0;i<nPhotons;i++)
978 if(GetPhotonFlag() == 2)
980 Float_t photonEta = GetPhotonEta();
981 Float_t photonWeight = GetPhotonWeight();
982 weightThetaCerenkov += photonEta*photonWeight;
989 weightThetaCerenkov /= wei;
993 weightThetaCerenkov = 0.;
996 SetThetaCerenkov(weightThetaCerenkov);
998 AliDebug(1,Form(" thetac weighted -> %f",weightThetaCerenkov));
1000 //__________________________________________________________________________________________________
1001 void AliRICHRecon::FlagPhotons()
1005 Int_t nPhotonHough = 0;
1007 Float_t thetaCerenkov = GetThetaCerenkov();
1008 AliDebug(1,Form(" fThetaCerenkov %f ",thetaCerenkov));
1010 Float_t thetaDist= thetaCerenkov - fThetaMin;
1011 Int_t steps = (Int_t)(thetaDist / fDTheta);
1013 Float_t tmin = fThetaMin + (Float_t)(steps - 1)*fDTheta;
1014 Float_t tmax = fThetaMin + (Float_t)(steps)*fDTheta;
1015 Float_t tavg = 0.5*(tmin+tmax);
1017 tmin = tavg - 0.5*fWindowWidth;
1018 tmax = tavg + 0.5*fWindowWidth;
1020 // Int_t candidatePhotonsNumber = GetCandidatePhotonsNumber();
1022 Int_t nPhotons = GetPhotonsNumber();
1024 // for(Int_t i=0;i<candidatePhotonsNumber;i++)
1026 for(Int_t i=0;i<nPhotons;i++)
1030 Float_t photonEta = GetPhotonEta();
1032 if(photonEta == -999.) continue;
1034 if(photonEta >= tmin && photonEta <= tmax)
1040 SetHoughPhotons(nPhotonHough);