Fitting service




The fitting service is in charge of fitting clusters, trajectories and vertices via its fitters (IFitter). The user can either use one of the existing fitters or provide his own. Two fitters for trajectories ,least squares and Kalman filter, are available. In the case of a Kalman Filter fit a seed state must be provided. A Trajectory fitter takes a raw Trajectory (a collection of Node's with Measurement's and empty State's) and transforms it into a fitted Trajectory, in which the State's have meaningful contents.

Fitting algorithms need two setup--dependent operations: the prediction of the trajectory at the next measurement surface (propagation) and the comparison betweed this prediction and the actual experimental measurement, which requires the projection of the predicted state to form a residual. Fitting equations can be kept independent of the model and measurement type(s) if these two operations are external to the fitter. As described in the model service page, propagation and projection are performed by each Model.

The fitting service needs to be properly initialized. For the moment the user can only select the fitting method and the state representation to be used by the fitter, that is the state vector definition. For example, when fitting a track in a particle detector the sense of the track cannot be in general determined using spatial informaton only; thus the state representation cannot contain information about the sense. When fitting in a magnetic field an appropriate representation could be (x,y,z,dx/dz,dy/dz,q/p), which is called RP::slopes_curv_z. The required code at initialization level:

manager.fitting_svc().set_fitting_representation(RP::slopes_curv_z);

Information about all available representations can be found here.

To select a fitter:

// select the least squares fitter
manager.fitting_svc().select_fitter(RP::lsq);
// select the Kalman Filter fitter
manager.fitting_svc().select_fitter(RP::kalman);


The lsq fit is global, that is, the trajectory parameters along the trajectory can be obtained by a simple propagation. The Kalman filter fit is a local method since the trajectory parameters are locally modified at each measurement. Hence the necessity of having as many State’s as Measurements.

Two main fitting operations can be performed: fit a trajectory and filter a measurement.

// fit a trajectory provided a seed state
bool ok = manager.fitting_svc().fit(seed, trajectory);
// filter a measurement
bool ok = manager.fitting_svc().filter(measurement, seed, trajectory);


A example on how to fit a Trajectory can be found here.