/****************************************************************************** * $Id: CbmRichRingFitterCircle.cxx,v 1.6 2006/09/13 14:58:50 hoehne Exp $ * * Class : CbmRichRingFitterCircle * Description: This is the implementation of a particular fitting class. * Here the ring is fitted with equation of a cicle. * * Author : Supriya Das (Algorithm from F77 subroutine of S.Sadovsky) * E-mail : S.Das@gsi.de * ******************************************************************************* * $Log: CbmRichRingFitterCircle.cxx,v $ * Revision 1.6 2006/09/13 14:58:50 hoehne * setting of ReconstructedFlag removed * * Revision 1.5 2006/08/03 13:23:58 hoehne * new ring radius correction parameters (for rich_standard.geo, JUN06) * (Petr Stolpovsky) * * Revision 1.4 2006/07/17 14:06:25 hoehne * ring radius correction added, see P. Stolpovsky, CBM simulation meeting 14.7.2006 * * Revision 1.3 2006/04/11 11:16:21 hoehne * calculate mean values for comparison * * Revision 1.2 2006/01/26 09:59:02 hoehne * CbmRichHit included * * Revision 1.1 2006/01/19 11:49:34 hoehne * initial version: implementation of circle fit to ring * * *******************************************************************************/ #include "CbmRichRingFitterCircle.h" #include "CbmRichRing.h" #include "CbmRichHit.h" #include "CbmRootManager.h" #include "TMath.h" #include using std::cout; using std::endl; ClassImp(CbmRichRingFitterCircle) // ----- Default constructor ------------------------------------------- CbmRichRingFitterCircle::CbmRichRingFitterCircle() { fVerbose = 1; fCorrection = 1; } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------- CbmRichRingFitterCircle::CbmRichRingFitterCircle(Int_t verbose,Double_t correction) { fVerbose = verbose; fCorrection = correction; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmRichRingFitterCircle::~CbmRichRingFitterCircle() { } // ------------------------------------------------------------------------- // ----- Public method DoFit ------------------------------------------ void CbmRichRingFitterCircle::DoFit(CbmRichRing* pRing) { Int_t nHits=pRing->GetNofHits(); if (fVerbose > 1) { cout<<" RingFitCircle: Number of Hits in this ring : "< 1) cout<<" - ERROR - correction value not valid: has to be either 0 (no cor.) or 1 (cor.) "<At(pRing->GetHit(iHit)); b1 += (hit->X()*hit->X() + hit->Y()*hit->Y()) * hit->X(); b2 += (hit->X()*hit->X() + hit->Y()*hit->Y()) * hit->Y(); b3 += (hit->X()*hit->X() + hit->Y()*hit->Y()); b12 += hit->X(); b22 += hit->Y(); a11 += 2*hit->X()*hit->X(); a12 += 2*hit->X()*hit->Y(); a22 += 2*hit->Y()*hit->Y(); fMeanX = fMeanX + hit->X(); fMeanY = fMeanY + hit->Y(); } if (nHits !=0) { fMeanX = fMeanX/(Double_t)(nHits); fMeanY = fMeanY/(Double_t)(nHits); } a21 = a12; a13 = b12; a23 = b22; a31 = 2*b12; a32 = 2*b22; a33 = b32; c[0] = b1*b22 - b2*b12; c[1] = b1*b32 - b3*b12; c[2] = b2*b32 - b3*b22; a[0][0] = a11*b22 - a21*b12; a[1][0] = a12*b22 - a22*b12; a[2][0] = a13*b22 - a23*b12; a[0][1] = a11*b32 - a31*b12; a[1][1] = a12*b32 - a32*b12; a[2][1] = a13*b32 - a33*b12; a[0][2] = a21*b32-a31*b22; a[1][2] = a22*b32-a32*b22; a[2][2] = a23*b32-a33*b22; Float_t det1 = a[0][0]*a[1][1] - a[0][1]*a[1][0]; Float_t x11 = (c[0]*a[1][1] - c[1]*a[1][0])/det1; Float_t x21 = (a[0][0]*c[1] - a[0][1]*c[0])/det1; // Float_t det2 = a[0][1]*a[1][2] - a[0][2]*a[1][1]; // Float_t det3 = a[0][0]*a[1][2] - a[0][2]*a[1][0]; // Float_t x12 = (c[1]*a[1][2] - c[2]*a[1][1])/det2; // Float_t x22 = (a[0][1]*c[2] - a[0][2]*c[1])/det2; fRadius = TMath::Sqrt((b3 + b32*(x11*x11 + x21*x21) - a31*x11 - a32*x21)/a33); fCentreX = x11; fCentreY = x21; if (fVerbose > 1 && fCorrection ==1) cout << " Radius before correction: " << fRadius << endl; // Radius correction (Petr Stolpovsky, for the method see CBM simulation meeting, 14.7.06) x21=TMath::Abs(x21); Double_t Rxy=TMath::Sqrt(x11*x11+(x21-y0)*(x21-y0)); Double_t N=(fCorrection*(A*Rxy+B*Rxy*Rxy+C*Rxy*Rxy*Rxy)/R0)+1.; // if fCorrection = 0: no correction done fRadius=fRadius/N; //end of correction pRing->SetRadius(fRadius); pRing->SetCenterX(fCentreX); pRing->SetCenterY(fCentreY); if (TMath::IsNaN(fRadius) == 1) pRing->SetRadius(0.); if (TMath::IsNaN(fCentreX) == 1) pRing->SetCenterX(0.); if (TMath::IsNaN(fCentreY) == 1) pRing->SetCenterY(0.); if (fVerbose > 1) cout<<"fRadius , fCentreX, fCentreY , fMeanX, fMeanY:"<SetCenterX(fMeanX); //pRing->SetCenterY(fMeanY); }