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  double fac = state.charge() / state.parameters().magneticFieldInInverseGeV(point).z();
30 
31  GlobalVectorDouble xOrig2Centre(fac * inMom.y(), -fac * inMom.x(), 0.);
32  GlobalVectorDouble xOrigProj(inPos.x(), inPos.y(), 0.);
33  GlobalVectorDouble xRefProj(point.x(), point.y(), 0.);
34  GlobalVectorDouble deltax = xRefProj - xOrigProj - xOrig2Centre;
35  GlobalVectorDouble ndeltax = deltax.unit();
36 
39 
40  // Need to define plane with orientation as the ImpactPointSurface
41  GlobalVector X(ndeltax.x(), ndeltax.y(), ndeltax.z());
42  GlobalVector Y(0., 0., 1.);
45  HelixBarrelPlaneCrossingByCircle planeCrossing(HelixPlaneCrossing::PositionType(inPos.x(), inPos.y(), inPos.z()),
46  HelixPlaneCrossing::DirectionType(inMom.x(), inMom.y(), inMom.z()),
47  kappa,
48  direction);
49  return std::pair<HelixBarrelPlaneCrossingByCircle, Plane::PlanePointer>(planeCrossing, plane);
50  }
51 } // namespace
52 
54  const GlobalPoint& point) const {
55  if (state.particleCharge() == 0.)
56  return true;
57 
58  // copied from below...
59  FreeTrajectoryState const& fState = state.freeTrajectoryState();
60  std::pair<HelixBarrelPlaneCrossingByCircle, BoundPlane::BoundPlanePointer> cros = planeCrossing(fState, point);
61 
62  HelixBarrelPlaneCrossingByCircle planeCrossing = cros.first;
63  BoundPlane::BoundPlanePointer plane = cros.second;
64  std::pair<bool, double> propResult = planeCrossing.pathLength(*plane);
65  return propResult.first;
66 }
67 
69  const KinematicState& state, const GlobalPoint& referencePoint) const {
70  //first use the existing FTS propagator to obtain parameters at PCA
71  //in transverse plane to the given point
72 
73  //final parameters and covariance
74 
75  //initial parameters as class and vectors:
76  //making a free trajectory state and looking
77  //for helix barrel plane crossing
78  FreeTrajectoryState const& fState = state.freeTrajectoryState();
79  const GlobalPoint& iP = referencePoint;
80  std::pair<HelixBarrelPlaneCrossingByCircle, BoundPlane::BoundPlanePointer> cros = planeCrossing(fState, iP);
81 
82  HelixBarrelPlaneCrossingByCircle planeCrossing = cros.first;
83  BoundPlane::BoundPlanePointer plane = cros.second;
84  std::pair<bool, double> propResult = planeCrossing.pathLength(*plane);
85  if (!propResult.first) {
86  LogDebug("RecoVertex/TrackKinematicStatePropagator") << "Propagation failed! State is invalid\n";
87  return KinematicState();
88  }
89  double s = propResult.second;
90 
91  GlobalTrajectoryParameters const& inPar = state.trajectoryParameters();
92  ParticleMass mass = state.mass();
93  GlobalVector inMom = state.globalMomentum();
94 
95  HelixPlaneCrossing::PositionType xGen = planeCrossing.position(s);
96  GlobalPoint nPosition(xGen.x(), xGen.y(), xGen.z());
97  HelixPlaneCrossing::DirectionType pGen = planeCrossing.direction(s);
98  pGen *= inMom.mag() / pGen.mag();
99  GlobalVector nMomentum(pGen.x(), pGen.y(), pGen.z());
100  AlgebraicVector7 par;
102  par(0) = nPosition.x();
103  par(1) = nPosition.y();
104  par(2) = nPosition.z();
105  par(3) = nMomentum.x();
106  par(4) = nMomentum.y();
107  par(5) = nMomentum.z();
108  par(6) = mass;
109 
110  //covariance matrix business
111  //elements of 7x7 covariance matrix responcible for the mass and
112  //mass - momentum projections corellations do change under such a transformation:
113  //special Jacobian needed
114  GlobalTrajectoryParameters fPar(nPosition, nMomentum, state.particleCharge(), state.magneticField());
115 
116  // check if correlation are present between mass and others
117  bool thereIsNoCorr = true;
118 
119  for (auto i = 0; i < 6; ++i)
120  thereIsNoCorr &= (0 == state.kinematicParametersError().matrix()(i, 6));
121 
122  if (thereIsNoCorr) {
123  // easy life
124  AnalyticalCurvilinearJacobian prop(inPar, nPosition, nMomentum, s);
125  AlgebraicSymMatrix55 cov2 = ROOT::Math::Similarity(prop.jacobian(), fState.curvilinearError().matrix());
127 
128  return KinematicState(fts, state.mass(), std::sqrt(state.kinematicParametersError().matrix()(6, 6)));
129 
130  //KinematicState kRes(fts, state.mass(), std::sqrt(state.kinematicParametersError().matrix()(6,6)));
131  //std::cout << "\n\ncart from final Kstate\n" << kRes.kinematicParametersError().matrix() << std::endl;
132  // std::cout << "curv from final K\n" << kRes.freeTrajectoryState().curvilinearError().matrix() << std::endl;
133 
134  } else {
135  JacobianCartesianToCurvilinear cart2curv(inPar);
136  JacobianCurvilinearToCartesian curv2cart(fPar);
137 
138  AlgebraicMatrix67 ca2cu;
139  AlgebraicMatrix76 cu2ca;
140  ca2cu.Place_at(cart2curv.jacobian(), 0, 0);
141  cu2ca.Place_at(curv2cart.jacobian(), 0, 0);
142  ca2cu(5, 6) = 1;
143  cu2ca(6, 5) = 1;
144 
145  //now both transformation jacobians: cartesian to curvilinear and back are done
146  //We transform matrix to curv frame, then propagate it and translate it back to
147  //cartesian frame.
148  AlgebraicSymMatrix66 cov1 = ROOT::Math::Similarity(ca2cu, state.kinematicParametersError().matrix());
149 
150  /*
151  std::cout << "\n\ncurv from Kstate\n" << cov1 << std::endl;
152  std::cout << "curv from fts\n" << fState.curvilinearError().matrix() << std::endl;
153  */
154 
155  //propagation jacobian
156  AnalyticalCurvilinearJacobian prop(inPar, nPosition, nMomentum, s);
158  pr(5, 5) = 1;
159  pr.Place_at(prop.jacobian(), 0, 0);
160 
161  //transportation
162  AlgebraicSymMatrix66 cov2 = ROOT::Math::Similarity(pr, cov1);
163 
164  //now geting back to 7-parametrization from curvilinear
165  cov = ROOT::Math::Similarity(cu2ca, cov2);
166 
167  /*
168  std::cout << "curv prop \n" << cov2 << std::endl;
169  std::cout << "cart prop\n" << cov << std::endl;
170  */
171 
172  //return parameters as a kiematic state
173  KinematicParameters resPar(par);
174  KinematicParametersError resEr(cov);
175 
176  return KinematicState(resPar, resEr, state.particleCharge(), state.magneticField());
177 
178  /*
179  KinematicState resK(resPar,resEr,state.particleCharge(), state.magneticField());
180  std::cout << "\ncurv from K prop\n" << resK.freeTrajectoryState().curvilinearError().matrix() << std::endl;
181  return resK;
182  */
183  }
184 }
185 
187  const KinematicState& state, const GlobalPoint& referencePoint) const {
188  //new parameters vector and covariance:
189  AlgebraicVector7 par;
191 
192  //AlgebraicVector7 inStatePar = state.kinematicParameters().vector();
193  GlobalTrajectoryParameters const& inPar = state.trajectoryParameters();
194 
195  //first making a free trajectory state and propagating it according
196  //to the algorithm provided by Thomas Speer and Wolfgang Adam
197  FreeTrajectoryState const& fState = state.freeTrajectoryState();
198 
199  GlobalPoint xvecOrig = fState.position();
200  double phi = fState.momentum().phi();
201  double theta = fState.momentum().theta();
202  double xOrig = xvecOrig.x();
203  double yOrig = xvecOrig.y();
204  double zOrig = xvecOrig.z();
205  double xR = referencePoint.x();
206  double yR = referencePoint.y();
207 
208  double s2D = (xR - xOrig) * cos(phi) + (yR - yOrig) * sin(phi);
209  double s = s2D / sin(theta);
210  double xGen = xOrig + s2D * cos(phi);
211  double yGen = yOrig + s2D * sin(phi);
212  double zGen = zOrig + s2D / tan(theta);
213  GlobalPoint xPerigee = GlobalPoint(xGen, yGen, zGen);
214 
215  //new parameters
216  GlobalVector pPerigee = fState.momentum();
217  par(0) = xPerigee.x();
218  par(1) = xPerigee.y();
219  par(2) = xPerigee.z();
220  par(3) = pPerigee.x();
221  par(4) = pPerigee.y();
222  par(5) = pPerigee.z();
223  // par(6) = inStatePar(7);
224  par(6) = state.mass();
225 
226  //covariance matrix business:
227  //everything lake it was before: jacobains are smart enouhg to
228  //distinguish between neutral and charged states themselves
229 
230  GlobalTrajectoryParameters fPar(xPerigee, pPerigee, state.particleCharge(), state.magneticField());
231 
232  JacobianCartesianToCurvilinear cart2curv(inPar);
233  JacobianCurvilinearToCartesian curv2cart(fPar);
234 
235  AlgebraicMatrix67 ca2cu;
236  AlgebraicMatrix76 cu2ca;
237  ca2cu.Place_at(cart2curv.jacobian(), 0, 0);
238  cu2ca.Place_at(curv2cart.jacobian(), 0, 0);
239  ca2cu(5, 6) = 1;
240  cu2ca(6, 5) = 1;
241 
242  //now both transformation jacobians: cartesian to curvilinear and back are done
243  //We transform matrix to curv frame, then propagate it and translate it back to
244  //cartesian frame.
245  AlgebraicSymMatrix66 cov1 = ROOT::Math::Similarity(ca2cu, state.kinematicParametersError().matrix());
246 
247  //propagation jacobian
248  AnalyticalCurvilinearJacobian prop(inPar, xPerigee, pPerigee, s);
250  pr(5, 5) = 1;
251  pr.Place_at(prop.jacobian(), 0, 0);
252 
253  //transportation
254  AlgebraicSymMatrix66 cov2 = ROOT::Math::Similarity(pr, cov1);
255 
256  //now geting back to 7-parametrization from curvilinear
257  cov = ROOT::Math::Similarity(cu2ca, cov2);
258 
259  // FreeTrajectoryState fts(fPar);
260 
261  //return parameters as a kiematic state
262  KinematicParameters resPar(par);
263  KinematicParametersError resEr(cov);
264  return KinematicState(resPar, resEr, state.particleCharge(), state.magneticField());
265 
266  //return KinematicState(fts,state.mass(), cov(6,6));
267 }
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:19
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
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
Geom::Theta< T > theta() 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