CMS 3D CMS Logo

TwoTrackMassKinematicConstraint.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFit/interface/TwoTrackMassKinematicConstraint.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 
00004 
00005 AlgebraicVector  TwoTrackMassKinematicConstraint::value(const vector<KinematicState> states,
00006                         const GlobalPoint& point) const
00007 { 
00008  if(states.size()<2) throw VertexException("TwoTrackMassKinematicConstraint::<2 states passed");
00009  if(states[0].particleCharge() ==0. || states[1].particleCharge()==0) 
00010          throw VertexException("TwoTrackMassKinematicConstraint:: 0 charge states passed");
00011  AlgebraicVector res(1,0);
00012 //  vector<KinematicState>::const_iterator i_st  = states.begin();
00013 //  KinematicState p_1 = *i_st;
00014 //  i_st++;
00015 //  KinematicState p_2 = *i_st;
00016  TrackCharge ch1 = states[0].particleCharge();
00017  TrackCharge ch2 = states[1].particleCharge();
00018  
00019  double field1 = states[0].magneticField()->inInverseGeV(states[0].globalPosition()).z();
00020  double a_1 = -0.29979246*ch1*field1;
00021  double field2 = states[1].magneticField()->inInverseGeV(states[1].globalPosition()).z();
00022  double a_2 = -0.29979246*ch2*field2;
00023 
00024  AlgebraicVector7 p1 = states[0].kinematicParameters().vector();
00025  AlgebraicVector7 p2 = states[1].kinematicParameters().vector();
00026  
00027  double p1vx = p1(3) - a_1*(point.y() - p1(1));
00028  double p1vy = p1(4) + a_1*(point.x() - p1(0));
00029  double p1vz = p1(5);
00030  ParticleMass m1 = p1(6);
00031  
00032  double p2vx = p2(3) - a_2*(point.y() - p2(1));
00033  double p2vy = p2(4) + a_2*(point.x() - p2(0)); 
00034  double p2vz = p2(5);
00035  ParticleMass m2 = p2(6);
00036  
00037  double j_energy = sqrt(p1(3)*p1(3)+p1(4)*p1(4)+p1(5)*p1(5)+m1*m1)+
00038                   sqrt(p2(3)*p2(3)+p2(4)*p2(4)+p2(5)*p2(5)+m2*m2)  ;
00039  
00040                        
00041  double j_m = (p1vx+p2vx)*(p1vx+p2vx) + (p1vy+p2vy)*(p1vy+p2vy) +
00042              (p1vz+p2vz)*(p1vz+p2vz);                   
00043 
00044  res(1)  = j_energy*j_energy - j_m - mass*mass;
00045  return res;
00046 }                       
00047                         
00048 AlgebraicMatrix TwoTrackMassKinematicConstraint::parametersDerivative(const vector<KinematicState> states,
00049                                       const GlobalPoint& point) const
00050 {
00051  int n_st = states.size();
00052  if(n_st<2) throw VertexException("TwoTrackMassKinematicConstraint::<2 states passed");
00053  if(states[0].particleCharge()==0. || states[1].particleCharge()==0) 
00054          throw VertexException("TwoTrackMassKinematicConstraint:: 0 charge states passed");
00055  AlgebraicMatrix res(1,n_st*7,0);
00056  
00057  vector<KinematicState>::const_iterator i_st  = states.begin();
00058  KinematicState p_1 = *i_st;
00059  i_st++;
00060  KinematicState p_2 = *i_st;
00061  TrackCharge ch1 = states[0].particleCharge();
00062  TrackCharge ch2 = states[1].particleCharge();
00063  
00064  double field1 = states[0].magneticField()->inInverseGeV(states[0].globalPosition()).z();
00065  double a_1 = -0.29979246*ch1*field1;
00066  double field2 = states[1].magneticField()->inInverseGeV(states[1].globalPosition()).z();
00067  double a_2 = -0.29979246*ch2*field2;
00068  
00069  AlgebraicVector7 p1 = states[0].kinematicParameters().vector();
00070  AlgebraicVector7 p2 = states[1].kinematicParameters().vector();
00071  
00072  double p1vx = p1(3) - a_1*(point.y() - p1(1));
00073  double p1vy = p1(4) + a_1*(point.x() - p1(0));
00074  double p1vz = p1(5);
00075  ParticleMass m1 = p1(6);
00076  
00077  double p2vx = p2(3) - a_2*(point.y() - p2(1));
00078  double p2vy = p2(4) + a_2*(point.x() - p2(0)); 
00079  double p2vz = p2(5);
00080  ParticleMass m2 = p2(6);
00081  
00082  double e1 = sqrt(p1(3)*p1(3)+p1(4)*p1(4)+p1(5)*p1(5)+m1*m1);
00083  double e2 = sqrt(p2(3)*p2(3)+p2(4)*p2(4)+p2(5)*p2(5)+m2*m2);
00084 
00085 
00086 //x1 and x2 derivatives: 1st and 8th elements 
00087  res(1,1) = 2*a_1*(p2vy + p1vy);
00088  res(1,8) = 2*a_2*(p2vy + p1vy);
00089 
00090 //y1 and y2 derivatives: 2nd and 9th elements:
00091  res(1,2) = -2*a_1*(p1vx + p2vx);
00092  res(1,9) = -2*a_2*(p2vx + p1vx);
00093  
00094 //z1 and z2 components: 3d and 10th elmnets stay 0:
00095  res(1,3)  = 0.;
00096  res(1,10) = 0.;
00097  
00098 //px1 and px2 components: 4th and 11th elements: 
00099  res(1,4)  = 2*(1+e2/e1)*p1(3) - 2*(p1vx + p2vx);
00100  res(1,11) = 2*(1+e1/e2)*p2(3) - 2*(p1vx + p2vx);
00101 
00102 //py1 and py2 components: 5th and 12 elements:
00103   res(1,5)  = 2*(1+e2/e1)*p1(4) - 2*(p1vy + p2vy);
00104   res(1,12) = 2*(1+e1/e2)*p2(4) - 2*(p2vy + p1vy);
00105  
00106 //pz1 and pz2 components: 6th and 13 elements:
00107  res(1,6)  = 2*(1+e2/e1)*p1(5)- 2*(p1vz + p2vz);
00108  res(1,13) = 2*(1+e1/e2)*p2(5)- 2*(p2vz + p1vz);
00109  
00110 //mass components: 7th and 14th elements:
00111  res(1,7)  = 2*m1*(1+e2/e1);
00112  res(1,14) = 2*m2*(1+e1/e2);
00113 
00114   return res;
00115 }                       
00116                                                                       
00117 AlgebraicMatrix TwoTrackMassKinematicConstraint::positionDerivative(const vector<KinematicState> states,
00118                                     const GlobalPoint& point) const
00119 {
00120  AlgebraicMatrix res(1,3,0);
00121  if(states.size()<2) throw VertexException("TwoTrackMassKinematicConstraint::<2 states passed");
00122  if(states[0].particleCharge() ==0. || states[1].particleCharge() ==0) 
00123          throw VertexException("TwoTrackMassKinematicConstraint:: 0 charge states passed");
00124  vector<KinematicState>::const_iterator i_st  = states.begin();
00125  KinematicState p_1 = *i_st;
00126  i_st++;
00127  KinematicState p_2 = *i_st;
00128  TrackCharge ch1 = states[0].particleCharge();
00129  TrackCharge ch2 = states[1].particleCharge();
00130  
00131  double field1 = states[0].magneticField()->inInverseGeV(states[0].globalPosition()).z();
00132  double a_1 = -0.29979246*ch1*field1;
00133  double field2 = states[1].magneticField()->inInverseGeV(states[1].globalPosition()).z();
00134  double a_2 = -0.29979246*ch2*field2;
00135  
00136  AlgebraicVector7 p1 = states[0].kinematicParameters().vector();
00137  AlgebraicVector7 p2 = states[1].kinematicParameters().vector();
00138  
00139  double p1vx = p1(3) - a_1*(point.y() - p1(1));
00140  double p1vy = p1(4) + a_1*(point.x() - p1(0));
00141  
00142  double p2vx = p2(3) - a_2*(point.y() - p2(1));
00143  double p2vy = p2(4) + a_2*(point.x() - p2(0)); 
00144  
00145 //xv component
00146  res(1,1) = -2*(p1vy + p2vy)*(a_1+a_2);
00147 
00148 //yv component
00149  res(1,2) = 2*(p1vx + p2vx)*(a_1+a_2);
00150 
00151 //zv component 
00152  res(1,3) = 0.; 
00153  
00154  return res;
00155 }                                   
00156                                                                     
00157 int TwoTrackMassKinematicConstraint::numberOfEquations() const
00158 {return 1;}

Generated on Tue Jun 9 17:46:10 2009 for CMSSW by  doxygen 1.5.4