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...
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
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
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 }
JacobianCartesianToCurvilinear.h
Vector3DBase
Definition: Vector3DBase.h:8
OpenBounds.h
KinematicState::particleCharge
TrackCharge particleCharge() const
Definition: KinematicState.h:71
TkRotation< float >
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
mps_fire.i
i
Definition: mps_fire.py:355
anyDirection
Definition: PropagationDirection.h:4
AnalyticalCurvilinearJacobian::jacobian
const AlgebraicMatrix55 & jacobian() const
Definition: AnalyticalCurvilinearJacobian.h:51
AnalyticalCurvilinearJacobian
Definition: AnalyticalCurvilinearJacobian.h:21
MessageLogger.h
JacobianCurvilinearToCartesian.h
AlgebraicMatrix76
ROOT::Math::SMatrix< double, 7, 6, ROOT::Math::MatRepStd< double, 7, 6 > > AlgebraicMatrix76
Definition: Matrices.h:12
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
ParticleMass
double ParticleMass
Definition: ParticleMass.h:4
X
#define X(str)
Definition: MuonsGrabber.cc:38
KinematicState
Definition: KinematicState.h:17
pos
Definition: PixelAliasList.h:18
JacobianCurvilinearToCartesian::jacobian
const AlgebraicMatrix65 & jacobian() const
Definition: JacobianCurvilinearToCartesian.h:24
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
KinematicState::globalMomentum
GlobalVector globalMomentum() const
Definition: KinematicState.h:67
AlgebraicSymMatrix77
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
Definition: Matrices.h:9
TrackKinematicStatePropagator.h
TrackKinematicStatePropagator::willPropagateToTheTransversePCA
bool willPropagateToTheTransversePCA(const KinematicState &state, const GlobalPoint &point) const override
Definition: TrackKinematicStatePropagator.cc:53
AnalyticalCurvilinearJacobian.h
ReferenceCountingPointer< Plane >
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HelixBarrelPlaneCrossingByCircle::pathLength
std::pair< bool, double > pathLength(const Plane &) override
Definition: HelixBarrelPlaneCrossingByCircle.cc:47
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Basic3DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic3DVector.h:97
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlgebraicSymMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Definition: AlgebraicROOTObjects.h:24
KinematicState::trajectoryParameters
GlobalTrajectoryParameters const & trajectoryParameters() const
Definition: KinematicState.h:65
KinematicState::kinematicParametersError
KinematicParametersError const & kinematicParametersError() const
Definition: KinematicState.h:63
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
AlgebraicMatrix67
ROOT::Math::SMatrix< double, 6, 7, ROOT::Math::MatRepStd< double, 6, 7 > > AlgebraicMatrix67
Definition: Matrices.h:11
Point3DBase< float, GlobalTag >
HelixBarrelPlaneCrossingByCircle::direction
DirectionType direction(double s) const override
Definition: HelixBarrelPlaneCrossingByCircle.cc:168
Plane::build
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
JacobianCartesianToCurvilinear::jacobian
const AlgebraicMatrix56 & jacobian() const
Definition: JacobianCartesianToCurvilinear.h:24
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:38
HelixBarrelPlaneCrossingByCircle
Definition: HelixBarrelPlaneCrossingByCircle.h:13
KinematicParametersError::matrix
AlgebraicSymMatrix77 const & matrix() const
Definition: KinematicParametersError.h:36
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
KinematicParameters
Definition: KinematicParameters.h:15
FreeTrajectoryState::parameters
const GlobalTrajectoryParameters & parameters() const
Definition: FreeTrajectoryState.h:79
KinematicParametersError
Definition: KinematicParametersError.h:20
AlgebraicVector7
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:8
KinematicState::mass
ParticleMass mass() const
Definition: KinematicState.h:54
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
HelixBarrelPlaneCrossingByCircle::position
PositionType position(double s) const override
Definition: HelixBarrelPlaneCrossingByCircle.cc:149
std
Definition: JetResolutionObject.h:76
AlgebraicMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
Definition: AlgebraicROOTObjects.h:62
DOFs::Y
Definition: AlignPCLThresholdsWriter.cc:37
TrackKinematicStatePropagator::propagateToTheTransversePCANeutral
virtual KinematicState propagateToTheTransversePCANeutral(const KinematicState &state, const GlobalPoint &referencePoint) const
Definition: TrackKinematicStatePropagator.cc:186
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
JacobianCurvilinearToCartesian
Definition: JacobianCurvilinearToCartesian.h:14
TrackKinematicStatePropagator::propagateToTheTransversePCA
KinematicState propagateToTheTransversePCA(const KinematicState &state, const GlobalPoint &referencePoint) const override
Definition: TrackKinematicStatePropagator.cc:11
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
GlobalTrajectoryParameters::magneticFieldInInverseGeV
GlobalVector magneticFieldInInverseGeV(const GlobalPoint &x) const
Definition: GlobalTrajectoryParameters.cc:35
Basic3DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic3DVector.h:94
BoundPlane.h
KinematicState::magneticField
const MagneticField * magneticField() const
Definition: KinematicState.h:86
kappa
static const G4double kappa
Definition: UrbanMscModel93.cc:35
hcaldqm::quantity::fState
Definition: ValueQuantity.h:47
point
*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
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
Basic3DVector::z
T z() const
Cartesian z coordinate.
Definition: extBasic3DVector.h:100
KinematicState::freeTrajectoryState
FreeTrajectoryState freeTrajectoryState() const
Definition: KinematicState.h:77
FreeTrajectoryState::transverseCurvature
double transverseCurvature() const
Definition: FreeTrajectoryState.h:71
Basic3DVector< float >
JacobianCartesianToCurvilinear
Definition: JacobianCartesianToCurvilinear.h:14
TrackKinematicStatePropagator::propagateToTheTransversePCACharged
virtual KinematicState propagateToTheTransversePCACharged(const KinematicState &state, const GlobalPoint &referencePoint) const
Definition: TrackKinematicStatePropagator.cc:68