Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

VertexConstraint.C

Go to the documentation of this file.
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 // destructor
00033 VertexConstraint::~VertexConstraint () {}
00034 
00035 // calculate current value of constraint function
00036 double VertexConstraint::getValue() const {
00037 //   cout << "VertexConstraint: vertex " << vertex->getName()
00038 //        << " = " << vertex->getVertex()
00039 //        << ", Track " << track->getName()
00040 //        << ", vertex " << ivertex 
00041 //        << " = " << track->getVertex(ivertex)
00042 //        << "factor = " << factor
00043 //        << ", result = " << factor*(vertex->getVertex() - track->getVertex (ivertex))
00044 //        << endl;
00045 //  
00046   return factor*(vertex->getVertex() - track->getVertex (ivertex));
00047 }
00048 
00049 // calculate vector/array of derivatives of this contraint 
00050 // w.r.t. to ALL parameters of all fitobjects
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   

Generated on Fri Sep 14 17:38:21 2007 for Kinfit by doxygen 1.3.2