CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackKinematicStatePropagator.cc
Go to the documentation of this file.
8 
9 using namespace std;
10 
13  (const KinematicState& state, const GlobalPoint& referencePoint) const
14 {
15  if( state.particleCharge() == 0. ) {
16  return propagateToTheTransversePCANeutral(state, referencePoint);
17  } else {
18  return propagateToTheTransversePCACharged(state, referencePoint);
19  }
20 }
21 
22 namespace {
23  inline
24  pair<HelixBarrelPlaneCrossingByCircle, BoundPlane::BoundPlanePointer>
25  planeCrossing(const FreeTrajectoryState& state,
26  const GlobalPoint& point) {
27 
28  typedef Point3DBase< double, GlobalTag> GlobalPointDouble;
29  typedef Vector3DBase< double, GlobalTag> GlobalVectorDouble;
30 
31  GlobalPoint inPos = state.position();
32  GlobalVector inMom = state.momentum();
33  double kappa = state.transverseCurvature();
34  double fac = state.charge()/state.parameters().magneticFieldInInverseGeV(point).z();
35 
36  GlobalVectorDouble xOrig2Centre(fac * inMom.y(), -fac * inMom.x(), 0.);
37  GlobalVectorDouble xOrigProj(inPos.x(), inPos.y(), 0.);
38  GlobalVectorDouble xRefProj(point.x(), point.y(), 0.);
39  GlobalVectorDouble deltax = xRefProj-xOrigProj-xOrig2Centre;
40  GlobalVectorDouble ndeltax = deltax.unit();
41 
43  Surface::PositionType pos(point);
44 
45  // Need to define plane with orientation as the ImpactPointSurface
46  GlobalVector X(ndeltax.x(), ndeltax.y(), ndeltax.z());
47  GlobalVector Y(0.,0.,1.);
50  HelixBarrelPlaneCrossingByCircle
51  planeCrossing(HelixPlaneCrossing::PositionType(inPos.x(), inPos.y(), inPos.z()),
52  HelixPlaneCrossing::DirectionType(inMom.x(), inMom.y(), inMom.z()),
53  kappa, direction);
54  return std::pair<HelixBarrelPlaneCrossingByCircle,Plane::PlanePointer>(planeCrossing,plane);
55  }
56 }
57 
59  if( state.particleCharge() == 0. ) return true;
60 
61  // copied from below...
62  FreeTrajectoryState const & fState = state.freeTrajectoryState();
63  std::pair<HelixBarrelPlaneCrossingByCircle, BoundPlane::BoundPlanePointer> cros = planeCrossing(fState,point);
64 
65  HelixBarrelPlaneCrossingByCircle planeCrossing = cros.first;
66  BoundPlane::BoundPlanePointer plane = cros.second;
67  std::pair<bool,double> propResult = planeCrossing.pathLength(*plane);
68  return propResult.first;
69 
70 }
71 
74 (const KinematicState& state, const GlobalPoint& referencePoint) const {
75  //first use the existing FTS propagator to obtain parameters at PCA
76  //in transverse plane to the given point
77 
78  //final parameters and covariance
79 
80  //initial parameters as class and vectors:
81  //making a free trajectory state and looking
82  //for helix barrel plane crossing
83  FreeTrajectoryState const & fState = state.freeTrajectoryState();
84  GlobalPoint iP = referencePoint;
85  std::pair<HelixBarrelPlaneCrossingByCircle, BoundPlane::BoundPlanePointer> cros = planeCrossing(fState,iP);
86 
87  HelixBarrelPlaneCrossingByCircle planeCrossing = cros.first;
88  BoundPlane::BoundPlanePointer plane = cros.second;
89  std::pair<bool,double> propResult = planeCrossing.pathLength(*plane);
90  if ( !propResult.first ) {
91  LogDebug("RecoVertex/TrackKinematicStatePropagator")
92  << "Propagation failed! State is invalid\n";
93  return KinematicState();
94  }
95  double s = propResult.second;
96 
97 
98  GlobalTrajectoryParameters const & inPar = state.trajectoryParameters();
99  ParticleMass mass = state.mass();
100  GlobalVector inMom = state.globalMomentum();
101 
102  HelixPlaneCrossing::PositionType xGen = planeCrossing.position(s);
103  GlobalPoint nPosition(xGen.x(),xGen.y(),xGen.z());
104  HelixPlaneCrossing::DirectionType pGen = planeCrossing.direction(s);
105  pGen *= inMom.mag()/pGen.mag();
106  GlobalVector nMomentum(pGen.x(),pGen.y(),pGen.z());
107  AlgebraicVector7 par;
109  par(0) = nPosition.x();
110  par(1) = nPosition.y();
111  par(2) = nPosition.z();
112  par(3) = nMomentum.x();
113  par(4) = nMomentum.y();
114  par(5) = nMomentum.z();
115  par(6) = mass;
116 
117  //covariance matrix business
118  //elements of 7x7 covariance matrix responcible for the mass and
119  //mass - momentum projections corellations do change under such a transformation:
120  //special Jacobian needed
121  GlobalTrajectoryParameters fPar(nPosition, nMomentum, state.particleCharge(),
122  state.magneticField());
123 
124  // check if correlation are present between mass and others
125  bool thereIsNoCorr=true;
126 
127  for (auto i=0; i<6; ++i) thereIsNoCorr &= (0==state.kinematicParametersError().matrix()(i,6));
128 
129  if (thereIsNoCorr) {
130  // easy life
131  AnalyticalCurvilinearJacobian prop(inPar,nPosition,nMomentum,s);
132  AlgebraicSymMatrix55 cov2 = ROOT::Math::Similarity(prop.jacobian(), fState.curvilinearError().matrix());
134 
135  return KinematicState(fts, state.mass(), std::sqrt(state.kinematicParametersError().matrix()(6,6)));
136 
137  //KinematicState kRes(fts, state.mass(), std::sqrt(state.kinematicParametersError().matrix()(6,6)));
138  //std::cout << "\n\ncart from final Kstate\n" << kRes.kinematicParametersError().matrix() << std::endl;
139  // std::cout << "curv from final K\n" << kRes.freeTrajectoryState().curvilinearError().matrix() << std::endl;
140 
141  } else {
142 
143 
144  JacobianCartesianToCurvilinear cart2curv(inPar);
145  JacobianCurvilinearToCartesian curv2cart(fPar);
146 
147 
148  AlgebraicMatrix67 ca2cu;
149  AlgebraicMatrix76 cu2ca;
150  ca2cu.Place_at(cart2curv.jacobian(),0,0);
151  cu2ca.Place_at(curv2cart.jacobian(),0,0);
152  ca2cu(5,6) = 1;
153  cu2ca(6,5) = 1;
154 
155  //now both transformation jacobians: cartesian to curvilinear and back are done
156  //We transform matrix to curv frame, then propagate it and translate it back to
157  //cartesian frame.
158  AlgebraicSymMatrix66 cov1 = ROOT::Math::Similarity(ca2cu, state.kinematicParametersError().matrix());
159 
160  /*
161  std::cout << "\n\ncurv from Kstate\n" << cov1 << std::endl;
162  std::cout << "curv from fts\n" << fState.curvilinearError().matrix() << std::endl;
163  */
164 
165 
166  //propagation jacobian
167  AnalyticalCurvilinearJacobian prop(inPar,nPosition,nMomentum,s);
169  pr(5,5) = 1;
170  pr.Place_at(prop.jacobian(),0,0);
171 
172  //transportation
173  AlgebraicSymMatrix66 cov2 = ROOT::Math::Similarity(pr, cov1);
174 
175  //now geting back to 7-parametrization from curvilinear
176  cov = ROOT::Math::Similarity(cu2ca, cov2);
177 
178  /*
179  std::cout << "curv prop \n" << cov2 << std::endl;
180  std::cout << "cart prop\n" << cov << std::endl;
181  */
182 
183  //return parameters as a kiematic state
184  KinematicParameters resPar(par);
185  KinematicParametersError resEr(cov);
186 
187  return KinematicState(resPar,resEr,state.particleCharge(), state.magneticField());
188 
189  /*
190  KinematicState resK(resPar,resEr,state.particleCharge(), state.magneticField());
191  std::cout << "\ncurv from K prop\n" << resK.freeTrajectoryState().curvilinearError().matrix() << std::endl;
192  return resK;
193  */
194  }
195 
196  }
197 
199  (const KinematicState& state, const GlobalPoint& referencePoint) const
200 {
201 //new parameters vector and covariance:
202  AlgebraicVector7 par;
204 
205  //AlgebraicVector7 inStatePar = state.kinematicParameters().vector();
206  GlobalTrajectoryParameters const & inPar = state.trajectoryParameters();
207 
208  //first making a free trajectory state and propagating it according
209  //to the algorithm provided by Thomas Speer and Wolfgang Adam
210  FreeTrajectoryState const & fState = state.freeTrajectoryState();
211 
212  GlobalPoint xvecOrig = fState.position();
213  double phi = fState.momentum().phi();
214  double theta = fState.momentum().theta();
215  double xOrig = xvecOrig.x();
216  double yOrig = xvecOrig.y();
217  double zOrig = xvecOrig.z();
218  double xR = referencePoint.x();
219  double yR = referencePoint.y();
220 
221  double s2D = (xR - xOrig) * cos(phi) + (yR - yOrig) * sin(phi);
222  double s = s2D / sin(theta);
223  double xGen = xOrig + s2D*cos(phi);
224  double yGen = yOrig + s2D*sin(phi);
225  double zGen = zOrig + s2D/tan(theta);
226  GlobalPoint xPerigee = GlobalPoint(xGen, yGen, zGen);
227 
228 //new parameters
229  GlobalVector pPerigee = fState.momentum();
230  par(0) = xPerigee.x();
231  par(1) = xPerigee.y();
232  par(2) = xPerigee.z();
233  par(3) = pPerigee.x();
234  par(4) = pPerigee.y();
235  par(5) = pPerigee.z();
236  // par(6) = inStatePar(7);
237  par(6) = state.mass();
238 
239 //covariance matrix business:
240 //everything lake it was before: jacobains are smart enouhg to
241 //distinguish between neutral and charged states themselves
242 
243  GlobalTrajectoryParameters fPar(xPerigee, pPerigee, state.particleCharge(),
244  state.magneticField());
245 
246  JacobianCartesianToCurvilinear cart2curv(inPar);
247  JacobianCurvilinearToCartesian curv2cart(fPar);
248 
249  AlgebraicMatrix67 ca2cu;
250  AlgebraicMatrix76 cu2ca;
251  ca2cu.Place_at(cart2curv.jacobian(),0,0);
252  cu2ca.Place_at(curv2cart.jacobian(),0,0);
253  ca2cu(5,6) = 1;
254  cu2ca(6,5) = 1;
255 
256  //now both transformation jacobians: cartesian to curvilinear and back are done
257  //We transform matrix to curv frame, then propagate it and translate it back to
258  //cartesian frame.
259  AlgebraicSymMatrix66 cov1 = ROOT::Math::Similarity(ca2cu, state.kinematicParametersError().matrix());
260 
261  //propagation jacobian
262  AnalyticalCurvilinearJacobian prop(inPar,xPerigee,pPerigee,s);
264  pr(5,5) = 1;
265  pr.Place_at(prop.jacobian(),0,0);
266 
267  //transportation
268  AlgebraicSymMatrix66 cov2 = ROOT::Math::Similarity(pr, cov1);
269 
270  //now geting back to 7-parametrization from curvilinear
271  cov = ROOT::Math::Similarity(cu2ca, cov2);
272 
273  // FreeTrajectoryState fts(fPar);
274 
275  //return parameters as a kiematic state
276  KinematicParameters resPar(par);
277  KinematicParametersError resEr(cov);
278  return KinematicState(resPar,resEr,state.particleCharge(), state.magneticField());
279 
280  //return KinematicState(fts,state.mass(), cov(6,6));
281 
282 }
283 
284 
#define LogDebug(id)
virtual KinematicState propagateToTheTransversePCANeutral(const KinematicState &state, const GlobalPoint &referencePoint) const
int i
Definition: DBlmapReader.cc:9
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
const GlobalTrajectoryParameters & parameters() const
const AlgebraicMatrix55 & jacobian() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
ROOT::Math::SMatrix< double, 7, 6, ROOT::Math::MatRepStd< double, 7, 6 > > AlgebraicMatrix76
Definition: Matrices.h:19
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double ParticleMass
Definition: ParticleMass.h:5
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
const AlgebraicMatrix56 & jacobian() const
#define X(str)
Definition: MuonsGrabber.cc:48
virtual bool willPropagateToTheTransversePCA(const KinematicState &state, const GlobalPoint &point) const
GlobalVector globalMomentum() const
AlgebraicSymMatrix77 const & matrix() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
PropagationDirection
TrackCharge charge() const
GlobalVector magneticFieldInInverseGeV(const GlobalPoint &x) const
const CurvilinearTrajectoryError & curvilinearError() const
ParticleMass mass() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
Definition: Matrices.h:16
T mag() const
Definition: PV3DBase.h:67
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:15
T z() const
Cartesian z coordinate.
T sqrt(T t)
Definition: SSEVec.h:48
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
KinematicParametersError const & kinematicParametersError() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
GlobalVector momentum() const
GlobalPoint position() const
const AlgebraicMatrix65 & jacobian() const
const MagneticField * magneticField() const
ROOT::Math::SMatrix< double, 6, 7, ROOT::Math::MatRepStd< double, 6, 7 > > AlgebraicMatrix67
Definition: Matrices.h:18
double transverseCurvature() const
TrackCharge particleCharge() const
virtual KinematicState propagateToTheTransversePCA(const KinematicState &state, const GlobalPoint &referencePoint) const
const AlgebraicSymMatrix55 & matrix() const
FreeTrajectoryState freeTrajectoryState() const
static const G4double kappa
virtual KinematicState propagateToTheTransversePCACharged(const KinematicState &state, const GlobalPoint &referencePoint) const
T x() const
Definition: PV3DBase.h:62
GlobalTrajectoryParameters const & trajectoryParameters() const
*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
Definition: DDAxes.h:10