Hall-D Software
alpha
|
#include <DQuickFit.h>
Public Types | |
enum | ChiSqSourceType_t { NOFIT, CIRCLE, TRACK } |
Public Member Functions | |
DQuickFit (void) | |
DQuickFit (const DQuickFit &fit) | |
DQuickFit & | operator= (const DQuickFit &fit) |
void | Copy (const DQuickFit &fit) |
~DQuickFit () | |
jerror_t | AddHit (float r, float phi, float z) |
jerror_t | AddHitXYZ (float x, float y, float z) |
jerror_t | PruneHit (int idx) |
jerror_t | Clear (void) |
jerror_t | FitCircle (void) |
double | ChisqCircle (void) |
jerror_t | FitCircleRiemann (double BeamRMS=0.100) |
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 | FitTrack_FixedZvertex (float z_vertex) |
jerror_t | FitLine_FixedZvertex (float z_vertex) |
jerror_t | Fill_phi_circle (vector< DQFHit_t * > hits, float x0, float y0) |
const vector< DQFHit_t * > | GetHits () const |
int | GetNhits () const |
const DMagneticFieldMap * | GetMagneticFieldMap () const |
float | GetBzAvg () const |
float | GetZMean () const |
float | GetPhiMean () const |
jerror_t | PrintChiSqVector (void) const |
jerror_t | Print (void) const |
jerror_t | Dump (void) const |
void | SetMagneticFieldMap (const DMagneticFieldMap *map) |
Public Attributes | |
float | x0 |
float | y0 |
float | r0 |
float | q |
float | p |
float | p_trans |
float | phi |
float | theta |
float | z_vertex |
float | chisq |
float | dzdphi |
ChiSqSourceType_t | chisq_source |
DVector3 | normal |
double | c_origin |
Protected Member Functions | |
jerror_t | FillTrackParams (void) |
Protected Attributes | |
vector< DQFHit_t * > | hits |
const DMagneticFieldMap * | bfield |
pointer to magnetic field map More... | |
float | Bz_avg |
float | z_mean |
float | phi_mean |
Definition at line 69 of file DQuickFit.h.
Enumerator | |
---|---|
NOFIT | |
CIRCLE | |
TRACK |
Definition at line 103 of file DQuickFit.h.
DQuickFit::DQuickFit | ( | void | ) |
Definition at line 33 of file DQuickFit.cc.
DQuickFit::DQuickFit | ( | const DQuickFit & | fit | ) |
Definition at line 47 of file DQuickFit.cc.
DQuickFit::~DQuickFit | ( | ) |
Definition at line 94 of file DQuickFit.cc.
References Clear().
jerror_t DQuickFit::AddHit | ( | float | r, |
float | phi, | ||
float | z | ||
) |
Add a hit to the list of hits using cylindrical coordinates
Definition at line 102 of file DQuickFit.cc.
References sin().
jerror_t DQuickFit::AddHitXYZ | ( | float | x, |
float | y, | ||
float | z | ||
) |
Add a hit to the list of hits useing Cartesian coordinates
Definition at line 112 of file DQuickFit.cc.
References DQFHit_t::chisq, x, DQFHit_t::x, DQFHit_t::y, y, and DQFHit_t::z.
double DQuickFit::ChisqCircle | ( | void | ) |
Calculate the chisq for the hits and current circle parameters. NOTE: This does not return the chi2/dof, just the raw chi2 with errs set to 1.0
Definition at line 258 of file DQuickFit.cc.
References c, DQFHit_t::chisq, sqrt(), x, DQFHit_t::x, DQFHit_t::y, and y.
jerror_t DQuickFit::Clear | ( | void | ) |
Remove all hits
Definition at line 144 of file DQuickFit.cc.
void DQuickFit::Copy | ( | const DQuickFit & | fit | ) |
Definition at line 54 of file DQuickFit.cc.
References Bz_avg, chisq, chisq_source, dzdphi, GetBzAvg(), GetHits(), GetMagneticFieldMap(), GetPhiMean(), GetZMean(), p, p_trans, phi, q, theta, x0, y0, and z_vertex.
jerror_t DQuickFit::Dump | ( | void | ) | const |
Definition at line 818 of file DQuickFit.cc.
References DQFHit_t::chisq, DQFHit_t::phi_circle, Print(), DQFHit_t::x, DQFHit_t::y, and DQFHit_t::z.
jerror_t DQuickFit::Fill_phi_circle | ( | vector< DQFHit_t * > | hits, |
float | x0, | ||
float | y0 | ||
) |
Definition at line 710 of file DQuickFit.cc.
References atan2f, DQFHit_t::phi_circle, DQFHit_t::x, DQFHit_t::y, and DQFHit_t::z.
|
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 741 of file DQuickFit.cc.
jerror_t DQuickFit::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:
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.
ALSO IMPORTANT: This assumes a charge of +1 for the particle. If the particle actually has a charge of +2, then the resulting value of p_trans will be half of what it should be.
Definition at line 183 of file DQuickFit.cc.
References alpha, Bz_avg, qBr2p, sqrt(), x, DQFHit_t::x, DQFHit_t::y, and y.
jerror_t DQuickFit::FitCircleRiemann | ( | double | BeamRMS = 0.100 | ) |
This is a temporary solution for doing a Riemann circle fit. It uses Simon's DRiemannFit class. This is not very efficient since it creates a new DRiemann fit object, copies the hits into it, and then copies the reults back to this DQuickFit object every time this is called. At some point, the DRiemannFit class will be merged into DQuickFit.
Definition at line 282 of file DQuickFit.cc.
References DRiemannFit::AddHit(), DRiemannFit::AddHitXYZ(), BeamRMS, Bz_avg, DRiemannFit::FitCircle(), DRiemannFit::GetPlaneParameters(), DRiemannFit::phi, qBr2p, DRiemannFit::rc, sqrt(), DQFHit_t::x, DRiemannFit::xc, DQFHit_t::y, DRiemannFit::yc, DQFHit_t::z, and Z_VERTEX.
jerror_t DQuickFit::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 342 of file DQuickFit.cc.
References sqrt(), x, DQFHit_t::x, X, DQFHit_t::y, and y.
jerror_t DQuickFit::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 640 of file DQuickFit.cc.
References DQFHitLessThanZ_C(), DQFHit_t::phi_circle, sqrt(), and DQFHit_t::z.
jerror_t DQuickFit::FitTrack | ( | void | ) |
Find theta, sign of electric charge, total momentum and vertex z position.
Definition at line 574 of file DQuickFit.cc.
References DQFHitLessThanZ_C(), DQFHit_t::phi_circle, and DQFHit_t::z.
jerror_t DQuickFit::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 623 of file DQuickFit.cc.
|
inline |
|
inline |
Definition at line 92 of file DQuickFit.h.
Referenced by Copy().
|
inline |
Definition at line 94 of file DQuickFit.h.
Referenced by Copy().
|
inline |
Definition at line 93 of file DQuickFit.h.
|
inline |
Definition at line 97 of file DQuickFit.h.
Referenced by Copy().
|
inline |
Definition at line 96 of file DQuickFit.h.
Referenced by Copy().
jerror_t DQuickFit::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 537 of file DQuickFit.cc.
Definition at line 83 of file DQuickFit.cc.
jerror_t DQuickFit::Print | ( | void | ) | const |
Definition at line 790 of file DQuickFit.cc.
References Bz_avg.
jerror_t DQuickFit::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 156 of file DQuickFit.cc.
jerror_t DQuickFit::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 128 of file DQuickFit.cc.
void DQuickFit::QuickPtrans | ( | void | ) |
Quickly calculate a value of p_trans by looking for the hit furthest out and the hit closest to half that distance. Those 2 hits along with the origin are used to define a circle from which p_trans is calculated.
Definition at line 468 of file DQuickFit.cc.
References Rmax, sqrt(), x, DQFHit_t::x, DQFHit_t::y, and y.
void DQuickFit::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 408 of file DQuickFit.cc.
|
inline |
Definition at line 101 of file DQuickFit.h.
|
protected |
pointer to magnetic field map
Definition at line 123 of file DQuickFit.h.
|
protected |
Definition at line 124 of file DQuickFit.h.
double DQuickFit::c_origin |
Definition at line 119 of file DQuickFit.h.
float DQuickFit::chisq |
Definition at line 114 of file DQuickFit.h.
Referenced by Copy().
ChiSqSourceType_t DQuickFit::chisq_source |
Definition at line 116 of file DQuickFit.h.
Referenced by Copy().
float DQuickFit::dzdphi |
Definition at line 115 of file DQuickFit.h.
Referenced by Copy().
|
protected |
Definition at line 122 of file DQuickFit.h.
DVector3 DQuickFit::normal |
Definition at line 118 of file DQuickFit.h.
float DQuickFit::p |
Definition at line 111 of file DQuickFit.h.
Referenced by Copy().
float DQuickFit::p_trans |
Definition at line 111 of file DQuickFit.h.
Referenced by Copy().
float DQuickFit::phi |
Definition at line 112 of file DQuickFit.h.
Referenced by Copy().
|
protected |
Definition at line 125 of file DQuickFit.h.
float DQuickFit::q |
Definition at line 110 of file DQuickFit.h.
Referenced by Copy().
float DQuickFit::r0 |
Definition at line 109 of file DQuickFit.h.
float DQuickFit::theta |
Definition at line 112 of file DQuickFit.h.
Referenced by Copy().
float DQuickFit::x0 |
Definition at line 109 of file DQuickFit.h.
Referenced by Copy().
float DQuickFit::y0 |
Definition at line 109 of file DQuickFit.h.
Referenced by Copy().
|
protected |
Definition at line 125 of file DQuickFit.h.
float DQuickFit::z_vertex |
Definition at line 113 of file DQuickFit.h.
Referenced by Copy().