CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SmartPointingConstraint Class Reference

#include <SmartPointingConstraint.h>

Inheritance diagram for SmartPointingConstraint:
KinematicConstraint

Public Member Functions

virtual SmartPointingConstraintclone () const
 
virtual std::pair< AlgebraicMatrix, AlgebraicVectorderivative (const AlgebraicVector &exPoint) const
 
virtual std::pair< AlgebraicMatrix, AlgebraicVectorderivative (const std::vector< RefCountedKinematicParticle > &par) const
 
virtual AlgebraicVector deviations (int nStates) const
 
virtual int numberOfEquations () const
 
 SmartPointingConstraint (const GlobalPoint &ref)
 
virtual std::pair< AlgebraicVector, AlgebraicVectorvalue (const AlgebraicVector &exPoint) const
 
virtual std::pair< AlgebraicVector, AlgebraicVectorvalue (const std::vector< RefCountedKinematicParticle > &par) const
 
- Public Member Functions inherited from KinematicConstraint
 KinematicConstraint ()
 
virtual ~KinematicConstraint ()
 

Private Member Functions

std::pair< AlgebraicMatrix, AlgebraicVectormakeDerivative (const AlgebraicVector &exPoint) const
 
std::pair< AlgebraicVector, AlgebraicVectormakeValue (const AlgebraicVector &exPoint) const
 

Private Attributes

GlobalPoint refPoint
 

Detailed Description

Topological constraint making a momentum vector to point to the given location in space. Example: if b-meson momentum is reconstructed at b-meson decay position (secondary vertex), making reconstructed momentum pointing the the primary vertex

Multiple track refit is not supported in current version

Kirill Prokofiev, March 2004 MultiState version: July 2004

Definition at line 21 of file SmartPointingConstraint.h.

Constructor & Destructor Documentation

SmartPointingConstraint::SmartPointingConstraint ( const GlobalPoint ref)
inline

Definition at line 25 of file SmartPointingConstraint.h.

References derivative(), deviations(), numberOfEquations(), and value().

Referenced by clone().

25  :refPoint(ref)
26  {}

Member Function Documentation

virtual SmartPointingConstraint* SmartPointingConstraint::clone ( ) const
inlinevirtual

Clone method

Implements KinematicConstraint.

Definition at line 53 of file SmartPointingConstraint.h.

References makeDerivative(), makeValue(), and SmartPointingConstraint().

54  {return new SmartPointingConstraint(*this);}
SmartPointingConstraint(const GlobalPoint &ref)
std::pair< AlgebraicMatrix, AlgebraicVector > SmartPointingConstraint::derivative ( const AlgebraicVector exPoint) const
virtual

Implements KinematicConstraint.

Definition at line 25 of file SmartPointingConstraint.cc.

References runTauDisplay::dr, and makeDerivative().

Referenced by SmartPointingConstraint().

26 {
27  if(exPoint.num_row() ==0 ) throw VertexException("PointingKinematicConstraint::value requested for zero Linearization point");
28 
29 //security check for extended cartesian parametrization
30  int inSize = exPoint.num_row();
31  if((inSize%7) !=0) throw VertexException("PointingKinematicConstraint::linearization point has a wrong dimension");
32  int nStates = inSize/7;
33  if(nStates != 1) throw VertexException("PointingKinematicConstraint::Current version does not support the multistate refit");
34  AlgebraicVector lPar = exPoint;
35 
36 //2x7 derivative matrix for given particle
37  AlgebraicMatrix lDeriv = makeDerivative(lPar).first;
38  AlgebraicMatrix dr(2,7,0);
39  dr.sub(1,1,lDeriv);
40  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,lPar);
41 }
Common base class.
CLHEP::HepMatrix AlgebraicMatrix
CLHEP::HepVector AlgebraicVector
std::pair< AlgebraicMatrix, AlgebraicVector > makeDerivative(const AlgebraicVector &exPoint) const
std::pair< AlgebraicMatrix, AlgebraicVector > SmartPointingConstraint::derivative ( const std::vector< RefCountedKinematicParticle > &  par) const
virtual

Vector of values and matrix of derivatives calculated using current state parameters as expansion point

Implements KinematicConstraint.

Definition at line 43 of file SmartPointingConstraint.cc.

References runTauDisplay::dr, and makeDerivative().

44 {
45  int nStates = par.size();
46  if(nStates == 0) throw VertexException("PointingKinematicConstraint::Empty vector of particles passed");
47  if(nStates != 1) throw VertexException("PointingKinematicConstraint::Current version does not support the multistate refit");
48 
49  AlgebraicMatrix dr(2,7,0);
50  AlgebraicVector lPoint = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
51 
52 //2x7 derivative matrix for given state
53  AlgebraicMatrix lDeriv = makeDerivative(lPoint).first;
54  dr.sub(1,1,lDeriv);
55 // cout<<"Derivative returned: "<<dr<<endl;
56 // cout<<"For the value: "<<lPoint<<endl;
57  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,lPoint);
58 }
Common base class.
CLHEP::HepMatrix AlgebraicMatrix
CLHEP::HepVector AlgebraicVector
std::pair< AlgebraicMatrix, AlgebraicVector > makeDerivative(const AlgebraicVector &exPoint) const
AlgebraicVector SmartPointingConstraint::deviations ( int  nStates) const
virtual

Returns vector of sigma squared associated to the KinematicParameters of refitted particles Initial deviations are given by user for the constraining parameters (mass, momentum components etc). In case of multiple states exactly the same values are added to every particle parameters

Implements KinematicConstraint.

Definition at line 75 of file SmartPointingConstraint.cc.

Referenced by SmartPointingConstraint().

76 {return AlgebraicVector(7*nStates,0);}
CLHEP::HepVector AlgebraicVector
std::pair< AlgebraicMatrix, AlgebraicVector > SmartPointingConstraint::makeDerivative ( const AlgebraicVector exPoint) const
private

Definition at line 116 of file SmartPointingConstraint.cc.

References runTauDisplay::dr, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, point, funct::pow(), refPoint, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by clone(), and derivative().

117 {
118  AlgebraicMatrix dr(2,7,0);
119  AlgebraicVector point = exPoint;
120  double dx = point(1) - refPoint.x();
121  double dy = point(2) - refPoint.y();
122  double dz = point(3) - refPoint.z();
123  double px = point(4);
124  double py = point(5);
125  double pz = point(6);
126 
127 //angular functuions:
128 
129 //half angle solution
130 //d/dx_i
131  dr(1,1) = (dy*(dx*px + dy*py))/(pow(pow(dx,2) + pow(dy,2),1.5)*sqrt(pow(px,2) + pow(py,2))) ;
132 
133  dr(1,2) = -((dx*(dx*px + dy*py))/(pow(pow(dx,2) + pow(dy,2),1.5)*sqrt(pow(px,2) + pow(py,2)))) ;
134 
135  dr(1,3) = 0;
136 
137 //d/dp_i
138 //debug: x->p index xhange in denominator
139  dr(1,4) = -((py*(dx*px + dy*py))/(sqrt(pow(dx,2) + pow(dy,2))*pow(pow(px,2) + pow(py,2),1.5)));
140 
141  dr(1,5) = (px*(dx*px + dy*py))/(sqrt(pow(dx,2) + pow(dy,2))*pow(pow(px,2) + pow(py,2),1.5));
142 
143  dr(1,6) = 0;
144  dr(1,7) = 0;
145 
146 //2nd equation
147 //d/dx_i
148 
149  dr(2,1) = (dx*dz*(sqrt(pow(dx,2) + pow(dy,2))*sqrt(pow(px,2) + pow(py,2)) + dz*pz))/
150  (sqrt(pow(dx,2) + pow(dy,2))*pow(pow(dx,2) + pow(dy,2) + pow(dz,2),1.5)*
151  sqrt(pow(px,2) + pow(py,2) + pow(pz,2)));
152 
153  dr(2,2) = (dy*dz*(sqrt(pow(dx,2) + pow(dy,2))*sqrt(pow(px,2) + pow(py,2)) + dz*pz))/
154  (sqrt(pow(dx,2) + pow(dy,2))*pow(pow(dx,2) + pow(dy,2) + pow(dz,2),1.5)*
155  sqrt(pow(px,2) + pow(py,2) + pow(pz,2)));
156 
157 
158  dr(2,3) = (-((pow(dx,2) + pow(dy,2))*sqrt(pow(px,2) + pow(py,2))) - sqrt(pow(dx,2) + pow(dy,2))*dz*pz)/
159  (pow(pow(dx,2) + pow(dy,2) + pow(dz,2),1.5)*sqrt(pow(px,2) + pow(py,2) + pow(pz,2)));
160 
161 
162 
163 //d/dp_i
164 //debug: x->p index xhange in denominator
165 
166  dr(2,4) = -((px*pz*(sqrt(pow(dx,2) + pow(dy,2))*sqrt(pow(px,2) + pow(py,2)) + dz*pz))/
167  (sqrt(pow(dx,2) + pow(dy,2) + pow(dz,2))*sqrt(pow(px,2) + pow(py,2))*
168  pow(pow(px,2) + pow(py,2) + pow(pz,2),1.5)));
169 
170  dr(2,5) = -((py*pz*(sqrt(pow(dx,2) + pow(dy,2))*sqrt(pow(px,2) + pow(py,2)) + dz*pz))/
171  (sqrt(pow(dx,2) + pow(dy,2) + pow(dz,2))*sqrt(pow(px,2) + pow(py,2))*
172  pow(pow(px,2) + pow(py,2) + pow(pz,2),1.5))) ;
173 
174  dr(2,6) = (sqrt(pow(dx,2) + pow(dy,2))*(pow(px,2) + pow(py,2)) + dz*sqrt(pow(px,2) + pow(py,2))*pz)/
175  (sqrt(pow(dx,2) + pow(dy,2) + pow(dz,2))*pow(pow(px,2) + pow(py,2) + pow(pz,2),1.5)) ;
176 
177  dr(2,7) = 0;
178 
179 // cout<<"derivative matrix "<<dr<<endl;
180  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,point);
181 }
T y() const
Definition: PV3DBase.h:63
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
CLHEP::HepVector AlgebraicVector
T x() const
Definition: PV3DBase.h:62
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
std::pair< AlgebraicVector, AlgebraicVector > SmartPointingConstraint::makeValue ( const AlgebraicVector exPoint) const
private

Definition at line 81 of file SmartPointingConstraint.cc.

References PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, point, refPoint, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by clone(), and value().

82 {
83 // cout<<"Make value called"<<endl;
84  AlgebraicVector vl(2,0);
85  AlgebraicVector point = exPoint;
86  double dx = point(1) - refPoint.x();
87  double dy = point(2) - refPoint.y();
88  double dz = point(3) - refPoint.z();
89  double px = point(4);
90  double py = point(5);
91  double pz = point(6);
92 
93 
94 //full angle solution: sin(alpha - betha) = 0
95 //sign swap allowed
96  double cos_phi_p = px/sqrt(px*px + py*py);
97  double sin_phi_p = py/sqrt(px*px + py*py);
98  double cos_phi_x = dx/sqrt(dx*dx + dy*dy);
99  double sin_phi_x = dy/sqrt(dx*dx + dy*dy);
100 
101  double sin_theta_p = pz/sqrt(px*px + py*py + pz*pz);
102  double sin_theta_x = dz/sqrt(dx*dx + dy*dy + dz*dz);
103 
104  double cos_theta_p = sqrt(px*px + py*py)/sqrt(px*px + py*py + pz*pz);
105  double cos_theta_x = sqrt(dx*dx + dy*dy)/sqrt(dx*dx + dy*dy + dz*dz);
106 
107  float feq = sin_phi_p*cos_phi_x - cos_phi_p*sin_phi_x;
108  float seq = sin_theta_p* cos_theta_x - cos_theta_p * sin_theta_x;
109 
110  vl(1) = feq;
111  vl(2) = seq;
112 
113  return std::pair<AlgebraicVector,AlgebraicVector>(vl,point);
114 }
T y() const
Definition: PV3DBase.h:63
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
CLHEP::HepVector AlgebraicVector
T x() const
Definition: PV3DBase.h:62
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
int SmartPointingConstraint::numberOfEquations ( ) const
virtual

Returns number of constraint equations used for fitting. Method is relevant for proper NDF calculations.

Implements KinematicConstraint.

Definition at line 78 of file SmartPointingConstraint.cc.

Referenced by SmartPointingConstraint().

79 {return 2;}
std::pair< AlgebraicVector, AlgebraicVector > SmartPointingConstraint::value ( const AlgebraicVector exPoint) const
virtual

Vector of values and matrix of derivatives calculated at given expansion 7xNumberOfStates point

Implements KinematicConstraint.

Definition at line 5 of file SmartPointingConstraint.cc.

References makeValue().

Referenced by SmartPointingConstraint().

6 {
7  if(exPoint.num_row() ==0 ) throw VertexException("PointingKinematicConstraint::value requested for zero Linearization point");
8 
9 //security check for extended cartesian parametrization
10  int inSize = exPoint.num_row();
11  if((inSize%7) !=0) throw VertexException("PointingKinematicConstraint::linearization point has a wrong dimension");
12  int nStates = inSize/7;
13  if(nStates != 1) throw VertexException("PointingKinematicConstraint::Current version does not support the multistate refit");
14 
15  AlgebraicVector lPar = exPoint;
16  AlgebraicVector vl(2,0);
17 
18 //vector of values 1x2 for given particle
19  AlgebraicVector lValue = makeValue(lPar).first;
20  vl(1) =lValue(1);
21  vl(2) =lValue(2);
22  return std::pair<AlgebraicVector,AlgebraicVector>(vl,lPar);
23 }
std::pair< AlgebraicVector, AlgebraicVector > makeValue(const AlgebraicVector &exPoint) const
Common base class.
CLHEP::HepVector AlgebraicVector
std::pair< AlgebraicVector, AlgebraicVector > SmartPointingConstraint::value ( const std::vector< RefCountedKinematicParticle > &  par) const
virtual

Methods making value and derivative matrix using current state parameters as expansion 7-point. Constraint can be made equaly for single and multiple states

Implements KinematicConstraint.

Definition at line 60 of file SmartPointingConstraint.cc.

References makeValue().

61 {
62  int nStates = par.size();
63  if(nStates == 0) throw VertexException("PointingKinematicConstraint::Empty vector of particles passed");
64  if(nStates != 1) throw VertexException("PointingKinematicConstraint::Current version does not support the multistate refit");
65  AlgebraicVector vl(2,0);
66  AlgebraicVector lPoint = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
67  vl(1) = makeValue(lPoint).first(1);
68  vl(2) = makeValue(lPoint).first(2);
69 // cout<<"Value returned: "<<vl<<endl;
70 // cout<<"For the point: "<<lPoint<<endl;
71 
72  return std::pair<AlgebraicVector,AlgebraicVector>(vl,lPoint);
73 }
std::pair< AlgebraicVector, AlgebraicVector > makeValue(const AlgebraicVector &exPoint) const
Common base class.
CLHEP::HepVector AlgebraicVector

Member Data Documentation

GlobalPoint SmartPointingConstraint::refPoint
private

Definition at line 61 of file SmartPointingConstraint.h.

Referenced by makeDerivative(), and makeValue().