Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DHelicalFit Class Reference

#include <DHelicalFit.h>

Public Types

enum  ChiSqSourceType_t { NOFIT, CIRCLE, TRACK }
 

Public Member Functions

 DHelicalFit (void)
 
 DHelicalFit (const DHelicalFit &fit)
 
DHelicalFitoperator= (const DHelicalFit &fit)
 
void Copy (const DHelicalFit &fit)
 
 ~DHelicalFit ()
 
void Reset (void)
 
jerror_t AddStereoHit (const DCDCWire *wire)
 
jerror_t AddHit (float r, float phi, float z)
 
jerror_t AddHitXYZ (float x, float y, float z)
 
jerror_t AddHitXYZ (float x, float y, float z, float covx, float covy, float covxy, bool is_axial=false)
 
jerror_t AddHit (const DFDCPseudo *fdchit)
 
jerror_t PruneHit (int idx)
 
jerror_t Clear (void)
 
jerror_t FitCircle (void)
 
double ChisqCircle (void)
 
jerror_t FitCircleRiemann (float rc=0.)
 
jerror_t FitCircleRiemann (float z_vertex, float BeamRMS)
 
jerror_t FitLineRiemann (void)
 
jerror_t FitCircleStraightTrack ()
 
void SearchPtrans (double ptrans_max=9.0, double ptrans_step=0.5)
 
void QuickPtrans (void)
 
jerror_t GuessChargeFromCircleFit (void)
 
jerror_t FitTrack (void)
 
jerror_t FitTrackRiemann (float rc)
 
jerror_t FitCircleAndLineRiemann (float rc)
 
jerror_t FitTrack_FixedZvertex (float z_vertex)
 
jerror_t FitLine_FixedZvertex (float z_vertex)
 
jerror_t Fill_phi_circle (vector< DHFHit_t * > hits, float x0, float y0)
 
const vector< DHFHit_t * > GetHits () const
 
int GetNhits () const
 
const DMagneticFieldMapGetMagneticFieldMap () const
 
float GetBzAvg () const
 
float GetZMean () const
 
float GetPhiMean () const
 
jerror_t PrintChiSqVector (void) const
 
jerror_t Print (void) const
 
void FindSenseOfRotation (void)
 
jerror_t Dump (void) const
 
void SetMagneticFieldMap (const DMagneticFieldMap *map)
 
void GetPlaneParameters (double &c, DVector3 &n)
 

Public Attributes

float x0
 
float y0
 
float r0
 
float h
 
float phi
 
float theta
 
float tanl
 
float z_vertex
 
float chisq
 
int ndof
 
float dzdphi
 
ChiSqSourceType_t chisq_source
 
DVector3 normal
 
double c_origin
 

Protected Member Functions

jerror_t FillTrackParams (void)
 

Protected Attributes

vector< DHFHit_t * > hits
 
const DMagneticFieldMapbfield
 pointer to magnetic field map More...
 
float Bz_avg
 
float z_mean
 
float phi_mean
 

Private Attributes

double N [3]
 
double xavg [3]
 
double var_avg
 

Detailed Description

Definition at line 99 of file DHelicalFit.h.

Member Enumeration Documentation

Enumerator
NOFIT 
CIRCLE 
TRACK 

Definition at line 149 of file DHelicalFit.h.

Constructor & Destructor Documentation

DHelicalFit::DHelicalFit ( void  )

Definition at line 50 of file DHelicalFit.cc.

References h.

DHelicalFit::DHelicalFit ( const DHelicalFit fit)

Definition at line 68 of file DHelicalFit.cc.

DHelicalFit::~DHelicalFit ( )

Definition at line 149 of file DHelicalFit.cc.

References Clear().

Member Function Documentation

jerror_t DHelicalFit::AddHitXYZ ( float  x,
float  y,
float  z,
float  covx,
float  covy,
float  covxy,
bool  is_axial = false 
)
double DHelicalFit::ChisqCircle ( void  )

Calculate the chisq for the hits and current circle parameters. NOTE: This does not return the chi2/dof, just the raw chi2

Definition at line 449 of file DHelicalFit.cc.

References c, DHFHit_t::chisq, DHFHit_t::covx, DHFHit_t::covxy, DHFHit_t::covy, sqrt(), x, DHFHit_t::x, DHFHit_t::y, and y.

jerror_t DHelicalFit::Clear ( void  )

Definition at line 346 of file DHelicalFit.cc.

void DHelicalFit::Copy ( const DHelicalFit fit)

Definition at line 110 of file DHelicalFit.cc.

References chisq, chisq_source, dzdphi, GetHits(), GetPhiMean(), GetZMean(), h, h, ndof, phi, r0, tanl, theta, x0, y0, and z_vertex.

jerror_t DHelicalFit::Dump ( void  ) const
jerror_t DHelicalFit::Fill_phi_circle ( vector< DHFHit_t * >  hits,
float  x0,
float  y0 
)

Definition at line 1084 of file DHelicalFit.cc.

References atan2f, DHFHit_t::phi_circle, DHFHit_t::x, DHFHit_t::y, and DHFHit_t::z.

jerror_t DHelicalFit::FillTrackParams ( void  )
protected

Fill in and tweak some parameters like q, phi, theta using other values already set in the class. This is used by both FitTrack() and FitTrack_FixedZvertex().

Definition at line 1115 of file DHelicalFit.cc.

References h, M_TWO_PI, and sqrt().

jerror_t DHelicalFit::FitCircle ( void  )

Fit the current set of hits to a circle

This takes the hits which have been added thus far via one of the AddHit() methods and fits them to a circle. The alogorithm used here calculates the parameters directly using a technique very much like linear regression. The key assumptions are:

  1. The magnetic field is uniform and along z so that the projection of the track onto the X/Y plane will fall on a circle (this also implies no multiple-scattering or energy loss)
  2. The vertex is at the target center (i.e. 0,0 in the coordinate system of the points passed to us.

IMPORTANT: The value of phi which results from this assumes the particle was positively charged. If the particle was negatively charged, then phi will be 180 degrees off. To correct this, one needs z-coordinate information to determine the sign of the charge.

Definition at line 385 of file DHelicalFit.cc.

References alpha, M_TWO_PI, sqrt(), x, DHFHit_t::x, DHFHit_t::y, and y.

Referenced by DTrackCandidate_factory::DoRefit(), DTrackCandidate_factory_FDCCathodes::evnt(), DTrackCandidate_factory_CDC::Fit_Circles(), DTrackCandidate_factory::MatchMethod10(), DTrackCandidate_factory::MatchMethod4(), DTrackCandidate_factory::MatchMethod7(), DTrackCandidate_factory::MatchMethod8(), and DTrackCandidate_factory::MatchMethod9().

jerror_t DHelicalFit::FitCircleAndLineRiemann ( float  rc)

Definition at line 983 of file DHelicalFit.cc.

jerror_t DHelicalFit::FitCircleRiemann ( float  rc = 0.)

Riemann Circle fit: points on a circle in x,y project onto a plane cutting the circular paraboloid surface described by (x,y,x^2+y^2). Therefore the task of fitting points in (x,y) to a circle is transormed to the task of fitting planes in (x,y, w=x^2+y^2) space

Definition at line 505 of file DHelicalFit.cc.

References B0, M_TWO_PI, ONE_THIRD, RiemannFit_hit_cmp(), S, sqrt(), SQRT3, temp, x, X, and y.

Referenced by DTrackCandidate_factory::DoRefit(), DTrackCandidate_factory_CDC::Fit_Circles(), DTrackCandidate_factory::MatchMethod10(), DTrackCandidate_factory::MatchMethod12(), DTrackCandidate_factory::MatchMethod13(), DTrackCandidate_factory::MatchMethod4(), DTrackCandidate_factory::MatchMethod7(), DTrackCandidate_factory::MatchMethod8(), and DTrackCandidate_factory::MatchMethod9().

jerror_t DHelicalFit::FitCircleRiemann ( float  z_vertex,
float  BeamRMS 
)

Definition at line 478 of file DHelicalFit.cc.

References BeamRMS, and M_TWO_PI.

jerror_t DHelicalFit::FitCircleStraightTrack ( void  )

This is a last resort! The circle fit can fail for high momentum tracks that are nearly straight tracks. In these cases (when pt~2GeV or more) there is not enough position resolution with wire positions only to measure the curvature of the track. We can though, fit the X/Y points with a straight line in order to get phi and project out the stereo angles.

For the radius of the circle (i.e. p_trans) we loop over momenta from 1 to 9GeV and just use the one with the smallest chisq.

Definition at line 762 of file DHelicalFit.cc.

References M_TWO_PI, sqrt(), x, X, DHFHit_t::x, DHFHit_t::y, and y.

Referenced by DTrackCandidate_factory_CDC::Fit_Circles(), and DTrackCandidate_factory::MatchMethod10().

jerror_t DHelicalFit::FitLine_FixedZvertex ( float  z_vertex)

Fit the points, but hold the z_vertex fixed at the specified value.

This assumes FitCircle has already been called and the values in x0 and y0 are valid.

This just fits the phi-z angle by minimizing the chi-squared using a linear regression technique. As it turns out, the chi-squared weights points by their distances squared which leads to a quadratic equation for cot(theta) (where theta is the angle in the phi-z plane). To pick the right solution of the quadratic equation, we pick the one closest to the linearly weighted angle. One could argue that we should just use the linear weighting here rather than the square weighting. The choice depends though on how likely the "out-lier" points are to really be from this track. If they are likely, to be, then we would want to leverage their "longer" lever arms with the squared weighting. If they are more likely to be bad points, then we would want to minimize their influence with a linear (or maybe even root) weighting. It is expected than for our use, the points are all likely valid so we use the square weighting.

Definition at line 1014 of file DHelicalFit.cc.

References DHFHitLessThanZ_C(), DHFHit_t::phi_circle, sqrt(), and DHFHit_t::z.

jerror_t DHelicalFit::FitLineRiemann ( void  )

Riemann Line fit: linear regression of s on z to determine the tangent of the dip angle and the z position of the closest approach to the beam line. Computes intersection points along the helical path. Note: this implementation assumes that the error in the z-position is negligible; practically speaking, this means it should only be used for FDC hits...

Definition at line 660 of file DHelicalFit.cc.

References DHFProjection_t::covR, DHFProjection_cmp(), EPS, sqrt(), temp, DHFProjection_t::xy, and DHFProjection_t::z.

Referenced by DTrackCandidate_factory::MatchMethod10(), DTrackCandidate_factory::MatchMethod12(), DTrackCandidate_factory::MatchMethod13(), DTrackCandidate_factory::MatchMethod3(), DTrackCandidate_factory::MatchMethod4(), and DTrackCandidate_factory::MatchMethod9().

jerror_t DHelicalFit::FitTrack ( void  )

Find theta, sign of electric charge, total momentum and vertex z position.

Definition at line 924 of file DHelicalFit.cc.

References DHFHitLessThanZ_C(), DHFHit_t::phi_circle, and DHFHit_t::z.

jerror_t DHelicalFit::FitTrack_FixedZvertex ( float  z_vertex)

Fit the points, but hold the z_vertex fixed at the specified value.

This just calls FitCircle and FitLine_FixedZvertex to find all parameters of the track

Definition at line 997 of file DHelicalFit.cc.

Referenced by DTrackCandidate_factory_FDCCathodes::evnt().

jerror_t DHelicalFit::FitTrackRiemann ( float  rc)
float DHelicalFit::GetBzAvg ( ) const
inline

Definition at line 135 of file DHelicalFit.h.

References Bz_avg.

const DMagneticFieldMap* DHelicalFit::GetMagneticFieldMap ( ) const
inline

Definition at line 134 of file DHelicalFit.h.

int DHelicalFit::GetNhits ( ) const
inline

Definition at line 133 of file DHelicalFit.h.

Referenced by DTrackCandidate_factory_CDC::Fit_Circles().

float DHelicalFit::GetPhiMean ( ) const
inline

Definition at line 137 of file DHelicalFit.h.

Referenced by Copy().

void DHelicalFit::GetPlaneParameters ( double &  c,
DVector3 n 
)
inline

Definition at line 144 of file DHelicalFit.h.

float DHelicalFit::GetZMean ( ) const
inline

Definition at line 136 of file DHelicalFit.h.

Referenced by Copy().

jerror_t DHelicalFit::GuessChargeFromCircleFit ( void  )

Adjust the sign of the charge (magnitude will stay 1) based on whether the hits tend to be to the right or to the left of the line going from the origin through the center of the circle. If the sign is flipped, the phi angle will also be shifted by +/- pi since the majority of hits are assumed to come from outgoing tracks.

This is just a guess since tracks can bend all the way around and have hits that look exactly like tracks from an outgoing particle of opposite charge. The final charge should come from the sign of the dphi/dz slope.

Definition at line 887 of file DHelicalFit.cc.

References h, M_TWO_PI, x, and y.

Referenced by DTrackCandidate_factory_CDC::Fit_Circles(), and DTrackCandidate_factory::MatchMethod8().

DHelicalFit & DHelicalFit::operator= ( const DHelicalFit fit)

Definition at line 138 of file DHelicalFit.cc.

jerror_t DHelicalFit::Print ( void  ) const

Definition at line 1158 of file DHelicalFit.cc.

References h.

jerror_t DHelicalFit::PrintChiSqVector ( void  ) const

Dump the latest chi-squared vector to the screen. This prints the individual hits' chi-squared contributions in the order in which the hits were added. See PruneHits() for more detail.

Definition at line 358 of file DHelicalFit.cc.

jerror_t DHelicalFit::PruneHit ( int  idx)

Remove the hit specified by idx from the list of hits. The value of idx can be anywhere from 0 to GetNhits()-1.

Definition at line 330 of file DHelicalFit.cc.

Referenced by DTrackCandidate_factory_FDCCathodes::evnt(), and DTrackCandidate_factory::MatchMethod8().

void DHelicalFit::QuickPtrans ( void  )
void DHelicalFit::Reset ( void  )

Definition at line 73 of file DHelicalFit.cc.

References Clear(), and h.

Referenced by DTrackCandidate_factory_CDC::Get_Resource_HelicalFit().

void DHelicalFit::SearchPtrans ( double  ptrans_max = 9.0,
double  ptrans_step = 0.5 
)

Search the chi2 space as a function of the transverse momentum for the minimal chi2. The values corresponding to the minmal chi2 are left in chisq, x0, y0, r0, q, and p_trans.

This does NOT optimize the value of p_trans. It simply does a straight forward chisq calculation on a grid and keeps the best one. It is intended for use in finding a reasonable value for p_trans for straight tracks that are contained to less than p_trans_max which is presumably chosen based on a known θ.

Definition at line 829 of file DHelicalFit.cc.

References alpha, h, and sin().

void DHelicalFit::SetMagneticFieldMap ( const DMagneticFieldMap map)
inline

Definition at line 142 of file DHelicalFit.h.

Member Data Documentation

const DMagneticFieldMap* DHelicalFit::bfield
protected

pointer to magnetic field map

Definition at line 169 of file DHelicalFit.h.

float DHelicalFit::Bz_avg
protected

Definition at line 170 of file DHelicalFit.h.

double DHelicalFit::c_origin

Definition at line 165 of file DHelicalFit.h.

ChiSqSourceType_t DHelicalFit::chisq_source

Definition at line 162 of file DHelicalFit.h.

Referenced by Copy().

float DHelicalFit::dzdphi

Definition at line 161 of file DHelicalFit.h.

Referenced by Copy().

vector<DHFHit_t*> DHelicalFit::hits
protected

Definition at line 168 of file DHelicalFit.h.

double DHelicalFit::N[3]
private

Definition at line 178 of file DHelicalFit.h.

DVector3 DHelicalFit::normal

Definition at line 164 of file DHelicalFit.h.

Referenced by DTrackCandidate_factory_CDC::Find_ThetaZ_Regression().

float DHelicalFit::phi_mean
protected

Definition at line 171 of file DHelicalFit.h.

float DHelicalFit::theta

Definition at line 157 of file DHelicalFit.h.

Referenced by Copy().

double DHelicalFit::var_avg
private

Definition at line 179 of file DHelicalFit.h.

double DHelicalFit::xavg[3]
private

Definition at line 179 of file DHelicalFit.h.

float DHelicalFit::z_mean
protected

Definition at line 171 of file DHelicalFit.h.


The documentation for this class was generated from the following files: