CMS 3D CMS Logo

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