00001 #include "jbltools/kinfit/VertexConstraint.h"
00002 #include "jbltools/kinfit/TrackFitObject.h"
00003 #include "jbltools/kinfit/VertexFitObject.h"
00004
00005 #include<iostream>
00006 #include<cassert>
00007
00008 using std::cout;
00009 using std::endl;
00010
00011 VertexConstraint::VertexConstraint (const VertexFitObject& vertex_,
00012 const TrackFitObject& track_,
00013 int ivertex_,
00014 int axis
00015 )
00016 : vertex (&vertex_), track (&track_), ivertex (ivertex_)
00017 {
00018 assert (vertex);
00019 assert (track);
00020 switch (axis) {
00021 case 1:
00022 factor.setValues (0, 10, 0);
00023 break;
00024 case 2:
00025 factor.setValues (0, 0, 10);
00026 break;
00027 default:
00028 factor.setValues (10, 0, 0);
00029 }
00030 }
00031
00032
00033 VertexConstraint::~VertexConstraint () {}
00034
00035
00036 double VertexConstraint::getValue() const {
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 return factor*(vertex->getVertex() - track->getVertex (ivertex));
00047 }
00048
00049
00050
00051 void VertexConstraint::getDerivatives(int idim, double der[]) const {
00052 for (int iglobal = 0; iglobal < idim; iglobal++) der[iglobal] = 0;
00053 for (int ilocal = 0; ilocal < vertex->getNPar(); ilocal++) {
00054 if (!vertex->isParamFixed(ilocal)) {
00055 int iglobal = vertex->getGlobalParNum (ilocal);
00056 assert (iglobal >= 0 && iglobal < idim);
00057 der[iglobal] += factor*vertex->getVertexDerivative (ilocal);
00058 }
00059 }
00060 for (int ilocal = 0; ilocal < track->getNPar(); ilocal++) {
00061 if (!track->isParamFixed(ilocal)) {
00062 int iglobal = track->getGlobalParNum (ilocal);
00063 assert (iglobal >= 0 && iglobal < idim);
00064 der[iglobal] -= factor*track->getVertexDerivative (ivertex, ilocal);
00065 }
00066 }
00067 }
00068
00069 void VertexConstraint::add1stDerivativesToMatrix(int idim, double *M) const {
00070
00071 assert (0);
00072 }
00073
00074 void VertexConstraint::add2ndDerivativesToMatrix(int idim, double *M, double lambda) const {
00075
00076 assert (0);
00077 }
00078