// $Id$ // /// Do a very fast, linear-regression type fit on a set of hits. /// ///

This class allows one to define a set of 2D or 3D points /// which can then be fit to a circle (2D) or a helical track (3D) /// via the FitCircle() and FitTrack() methods. This is written /// in a generic way such that either CDC or FDC data or any /// combination of the two can be used.

/// ///

DQuickFit, as the name implies, is intended to be very fast. /// it will NOT produce a terribly accurate result.

/// ///

This will hopefully be useful in a couple of places: /// /// -# When trying to find clusters, it can be used to help /// reject outlying hits. /// -# In the Level-3 or filtering application, it can be used /// to quickly identify whether a cluster has a reasonable /// chance of becoming a "track" /// -# To find first-guess parameters for tracks which can /// be used as the starting point for real track fitting. ///

/// ///

To use this class, simply instantiate it and then repeatedly /// call one of the AddHit methods to add points you want to /// fit. When all of the points have been added, invoke either /// the FitCircle() (2D) or FitTrack() (3D) method to perform the fit. /// Note that since the fits are done using a linear regression /// style and other "one-pass" calculations, there is no iteration. /// It also assumes the same error for each point.

/// ///

The fit results are stored in public members of the class. /// The x0,y0 members represent the coordinates of the center of /// the 2D circle in whatever units the hits had when added. The /// chisq value is just the sum of the squares of the differences /// between each hit's distance from x0,y0 and \f$ r_0=\sqrt{x_0^2 + y_0^2} \f$. /// p_trans will have the transverse component of the particle's /// momentum.

/// ///

A few methods are available to remove hits which do not /// match certain criteria. These include PruneHits() and /// PruneWorst() (both of with call PruneHit()). See the notes /// in each for more info.

#ifndef _DQUICK_FIT_H_ #define _DQUICK_FIT_H_ #include using namespace std; #include #include "JANA/jerror.h" #include #ifndef atan2f #define atan2f(x,y) atan2((double)x,(double)y) #endif class DMagneticFieldMap; typedef struct{ float x,y,z; ///< point in lab coordinates float phi_circle; ///< phi angle relative to axis of helix float chisq; ///< chi-sq contribution of this hit }DQFHit_t; class DQuickFit{ public: DQuickFit() { x0 = y0 = 0; chisq = 0; chisq_source = NOFIT; bfield = NULL; } ~DQuickFit(){ for(unsigned int i=0; i hits, float x0, float y0); inline const vector GetHits(){return hits;}; inline int GetNhits(){return hits.size();}; inline float GetZMean(){return z_mean;} jerror_t PrintChiSqVector(void); jerror_t Print(void); jerror_t Dump(void); inline void SetMagneticFieldMap(const DMagneticFieldMap *map){bfield=map;}; enum ChiSqSourceType_t{ NOFIT, CIRCLE, TRACK }; float x0,y0; float q; float p, p_trans; float phi, theta; float z_vertex; float chisq; float dphidz; ChiSqSourceType_t chisq_source; protected: vector hits; const DMagneticFieldMap *bfield; ///< pointer to magnetic field map float Bz_avg; float z_mean, phi_mean; jerror_t FillTrackParams(void); }; #endif //_DQUICK_FIT_H_