Go to the documentation of this file.00001 #include "RecoVertex/KinematicFit/interface/MultiTrackMassKinematicConstraint.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003
00004
00005 AlgebraicVector MultiTrackMassKinematicConstraint::value(const std::vector<KinematicState> states,
00006 const GlobalPoint& point) const
00007 {
00008 if(states.size()<nPart) throw VertexException("MultiTrackMassKinematicConstraint::not enough states given");
00009
00010 double sumEnergy = 0, sumPx=0, sumPy=0., sumPz=0.;
00011
00012 double a;
00013 for (unsigned int i=0;i<nPart;++i) {
00014 a = -states[i].particleCharge() * states[i].magneticField()->inInverseGeV(states[i].globalPosition()).z();
00015
00016 sumEnergy += states[i].kinematicParameters().energy();
00017 sumPx += states[i].kinematicParameters()(3) - a*(point.y() - states[i].kinematicParameters()(1));
00018 sumPy += states[i].kinematicParameters()(4) + a*(point.x() - states[i].kinematicParameters()(0));
00019 sumPz += states[i].kinematicParameters()(5);
00020 }
00021
00022 double j_m = sumPx*sumPx + sumPy*sumPy + sumPz*sumPz;
00023
00024 AlgebraicVector res(1,0);
00025 res(1) = sumEnergy*sumEnergy - j_m - mass*mass;
00026 return res;
00027 }
00028
00029 AlgebraicMatrix MultiTrackMassKinematicConstraint::parametersDerivative(const std::vector<KinematicState> states,
00030 const GlobalPoint& point) const
00031 {
00032 if(states.size()<nPart) throw VertexException("MultiTrackMassKinematicConstraint::not enough states given");
00033
00034 AlgebraicMatrix res(1,states.size()*7,0);
00035
00036 double sumEnergy = 0, sumPx=0, sumPy=0., sumPz=0.;
00037
00038 double a;
00039 for (unsigned int i=0;i<nPart;++i) {
00040 a = -states[i].particleCharge() * states[i].magneticField()->inInverseGeV(states[i].globalPosition()).z();
00041
00042 sumEnergy += states[i].kinematicParameters().energy();
00043 sumPx += states[i].kinematicParameters()(3) - a*(point.y() - states[i].kinematicParameters()(1));
00044 sumPy += states[i].kinematicParameters()(4) + a*(point.x() - states[i].kinematicParameters()(0));
00045 sumPz += states[i].kinematicParameters()(5);
00046 }
00047
00048 for (unsigned int i=0;i<nPart;++i) {
00049 a = -states[i].particleCharge() * states[i].magneticField()->inInverseGeV(states[i].globalPosition()).z();
00050
00051
00052 res(1,1+i*7) = 2*a*sumPy;
00053
00054
00055 res(1,2+i*7) = -2*a*sumPx;
00056
00057
00058 res(1,3+i*7) = 0.;
00059
00060
00061 res(1,4+i*7) = 2*sumEnergy/states[i].kinematicParameters().energy()*states[i].kinematicParameters()(3) - 2*sumPx;
00062
00063
00064 res(1,5+i*7) = 2*sumEnergy/states[i].kinematicParameters().energy()*states[i].kinematicParameters()(4) - 2*sumPy;
00065
00066
00067 res(1,6+i*7) = 2*sumEnergy/states[i].kinematicParameters().energy()*states[i].kinematicParameters()(5) - 2*sumPz;
00068
00069
00070 res(1,7+i*7) = 2*states[i].kinematicParameters().mass()*sumEnergy/states[i].kinematicParameters().energy();
00071 }
00072 return res;
00073 }
00074
00075 AlgebraicMatrix MultiTrackMassKinematicConstraint::positionDerivative(const std::vector<KinematicState> states,
00076 const GlobalPoint& point) const
00077 {
00078 AlgebraicMatrix res(1,3,0);
00079 if(states.size()<nPart) throw VertexException("MultiTrackMassKinematicConstraint::not enough states given");
00080
00081 double sumA = 0, sumPx=0, sumPy=0.;
00082
00083 double a;
00084 for (unsigned int i=0;i<nPart;++i) {
00085 a = -states[i].particleCharge() * states[i].magneticField()->inInverseGeV(states[i].globalPosition()).z();
00086 sumA += a;
00087
00088 sumPx += states[i].kinematicParameters()(3) - a*(point.y() - states[i].kinematicParameters()(1));
00089 sumPy += states[i].kinematicParameters()(4) + a*(point.x() - states[i].kinematicParameters()(0));
00090 }
00091
00092
00093 res(1,1) = - 2 * sumPy * sumA;
00094
00095
00096 res(1,2) = 2 * sumPx * sumA;
00097
00098
00099 res(1,3) = 0.;
00100
00101 return res;
00102 }