/* $Id: CbmRichRing.cxx,v 1.8 2006/09/13 14:51:28 hoehne Exp $*/ /* History of CVS commits: * * $Log: CbmRichRing.cxx,v $ * Revision 1.8 2006/09/13 14:51:28 hoehne * two variables (Selection2D, SelectionNN) added in which values between 0 and 1 are stored for fake rejection * ReconstructedFlag removed * * Revision 1.7 2006/08/11 14:03:57 hoehne * move SetUncertainty and GetUncertainty to SetChi2 and GetChi2 * * Revision 1.6 2006/07/12 06:27:54 hoehne * new functions: SetDistance and GetDistance added which set/ give the distance between ring center and track attached to this * ring * * Revision 1.5 2006/02/23 11:24:10 hoehne * RecFlag added (Simeon Lebedev) * * Revision 1.4 2006/01/23 11:40:13 hoehne * MCMotherID added * * Revision 1.3 2006/01/19 10:40:06 hoehne * restructured according to new RinfFinder Class: * array of hits belonging to a certain ring added * * * */ // ------------------------------------------------------------------------- // ----- CbmRichRing source file ----- // ----- Created 05/07/04 by A. Soloviev ----- // ------------------------------------------------------------------------- #include "CbmRichRing.h" //#include "CbmRichHit.h" # include "TMath.h" # include # include using std::cout; using std::sqrt; using std::fabs; using std::atan; // ----- Default constructor ------------------------------------------- CbmRichRing::CbmRichRing() : TObject(), fCenterX(), fCenterY(), fRadius(), fTrackID ( -1 ), fMCMotherID ( -1 ), fDistance ( 99 ), fChi2 ( 0 ), fRecFlag(0) { fSelectionNN = -1.; fSelection2D = -1.; } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ CbmRichRing::CbmRichRing ( Double_t x, Double_t y, Double_t r ) : TObject(), fCenterX ( x ), fCenterY ( y ), fRadius ( r ), fTrackID ( -1 ), fMCMotherID ( -1 ), fDistance ( 99 ), fChi2 ( 0 ), fRecFlag(0) { fSelectionNN = -1.; fSelection2D = -1.; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmRichRing::~CbmRichRing() {} // ------------------------------------------------------------------------- void CbmRichRing::SetXYABPhi(Double_t x, Double_t y, Double_t a, Double_t b, Double_t phi) { fCenterX = x; fCenterY = y; fAaxis = a; fBaxis = b; fPhi = phi; } Bool_t CbmRichRing::RemoveHit(Int_t hitId) { //Int_t nofHits = fHitCollection.size(); std::vector::iterator it; for (it = fHitCollection.begin(); it!=fHitCollection.end(); it++){ if (hitId == *it){ fHitCollection.erase(it); return true; } } return false; } Double_t CbmRichRing::GetXF1() const { Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis); Double_t xc = c*cos(fabs(fPhi)); return fCenterX+xc; } Double_t CbmRichRing::GetYF1() const { Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis); Double_t yc = c*sin(fabs(fPhi)); if (fPhi >=0){ return fCenterY+yc; }else{ return fCenterY-yc; } } Double_t CbmRichRing::GetXF2() const { Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis); Double_t xc = c*cos(fabs(fPhi)); return fCenterX-xc; } Double_t CbmRichRing::GetYF2() const { Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis); Double_t yc = c*sin(fabs(fPhi)); if (fPhi >=0){ return fCenterY-yc; }else{ return fCenterY+yc; } } void CbmRichRing::Print(){ cout << " Ring parameters: " << " Aaxis = " << GetAaxis() << ", Baxis = " << GetBaxis() << ", Phi = " << GetPhi() << ", CenterX = " << GetCenterX() << ", CenterY = " << GetCenterY() << ", Radius = " << GetRadius() << ", NofHits = " << GetNofHits() << ", RadialPosition = " << GetRadialPosition() << ", Chi2 = " << GetChi2() << ", RingTrackDistance = "<< GetDistance() << ", Angle() = " << GetAngle() << ", NofHitsOnRing = " << GetNofHitsOnRing() << std::endl; } Double_t CbmRichRing::GetRadialPosition() const{ Double_t radPos; if (fCenterY > 0){ radPos = sqrt((fCenterX - 0)* (fCenterX - 0) + (fCenterY - 110)* (fCenterY - 110)); } else { radPos = sqrt((fCenterX - 0)* (fCenterX - 0) + (fCenterY + 110)* (fCenterY + 110)); } return radPos; } Double_t CbmRichRing::GetRadialAngle() const{ /* if (fCenterY > 0){ return atan((100 - fCenterY) / (0 - fCenterX)); } else { return atan((-100 - fCenterY) / (0 - fCenterX)); }*/ if( fCenterX > 0 && fCenterY > 0 ){ return atan(fabs((100 - fCenterY) / (0 - fCenterX))); } if( fCenterX < 0 && fCenterY > 0 ){ return TMath::Pi() - atan(fabs((100 - fCenterY) / (0 - fCenterX))); } if( fCenterX < 0 && fCenterY < 0 ){ return TMath::Pi() + atan(fabs((-100 - fCenterY) / (0 - fCenterX))); } if( fCenterX > 0 && fCenterY < 0 ){ return 2*TMath::Pi() - atan(fabs((-100 - fCenterY) / (0 - fCenterX))); } return 999.; } ClassImp(CbmRichRing)