subroutine kfit_3momentum(ktrk, update_track, p3c, chisq, error) * * begin_doc * * Fit a track by constraining it to a fixed 3-momentum. * * Note: If the track is not updated here, you can update it later by * calling kfit_update_tracks. * * Input Parameters: * ktrk integer variable * Track number to fit * * update_track integer variable * 0 ==> Calculate chisquare only (do not update track) * 1 ==> Calculate chisquare, update track * 2 ==> Calculate chisquare, update track & cov matrix * * p3c(4) double precision variable * 3-momentum to constrain to * * Output Parameters: * chisq double precision variable * Chisquare of fit * * error integer variable * 0 ==> All OK * >0 ==> Error * * Other routines: * * Notes: * * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> * The energy constraint is imposed by the method of Lagrange multipliers * * chisq = (alpha-alpha0)(t) * Valpha0(inv) * (alpha-alpha0) * + 2*lambda(t)*(D*dalpha + d) * * where * alpha0 are the unconstrained parameters, * alpha are the final parameters and * D*dalpha + d = 0 is the linearized constraint equation. * * The solution is * * alpha = alpha0 - Valpha0*D(t)*lambda * lambda = VD * (D*dalpha0 + d) * VD = [D * Valpha0 * D(t)](inv) * Valpha = Valpha0 - Valpha0*D(t)*VD*D*Valpha0 * * The 3-momentum constraint has the form * * Px - Pxc = 0 * Py - Pyc = 0 * Pz - Pzc = 0 * * So D and d can be written (expanding about P) * * | 1 0 0 | * D = | 0 1 0 | * | 0 0 1 | * * | Px1 - Pxc| * d1= | Py1 - Pyc| * | Pz1 - Pzc| * * The covariance matrix of the resulting track can be computed as * * Valpha = Valpha0 - Valpha0*D(t)*VD*D*Valpha0 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> * * Author: Paul Avery Created: Fri Aug 29 16:12:52 EDT 1997 * * Major revisions: * * * end_doc