subroutine kfit_energy(ktrk, update_track, energy, chisq, error) * * begin_doc * * Fit a track by constraining it to a fixed energy. * * 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 * * energy double precision variable * Energy 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 energy constraint has the form * * E - Ec = 0 * * This means that D and d1 can be written * * D = (0, 0, 0, 1) * d1= E - Ec * * 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