CMS 3D CMS Logo

CartesianLorentzForce.h
Go to the documentation of this file.
1 #ifndef CartesianLorentzForce_H
2 #define CartesianLorentzForce_H
3 
5 #include "RKDerivative.h"
6 #include "RKLocalFieldProvider.h"
7 
9 
10 class dso_internal CartesianLorentzForce final : public RKDerivative<double, 6> {
11 public:
15 
16  CartesianLorentzForce(const RKLocalFieldProvider& field, float ch) : theField(field), theCharge(ch) {}
17 
18  Vector operator()(Scalar z, const Vector& state) const override;
19 
20 private:
22  float theCharge;
23 };
24 
25 #include "CartesianStateAdaptor.h"
27  // derivatives in case S is the free parameter
29  auto bfield = theField.inTesla(RKLocalFieldProvider::LocalPoint(start.position()));
30  constexpr float k = 2.99792458e-3; // conversion to [cm]
31 
33  auto dpos = start.momentum().unit();
34 
36  auto dmom = (k * theCharge) * dpos.cross(bfield);
37 
38  return CartesianStateAdaptor::rkstate(dpos, dmom);
39 }
40 
41 #endif
virtual Vector operator()(Scalar startPar, const Vector &startState) const =0
Basic3DVector unit() const
Vector operator()(Scalar z, const Vector &state) const override
Basic3DVector cross(const Basic3DVector &lh) const
Vector product, or "cross" product, with a vector of same type.
RKSmallVector< double, N > Vector
Definition: RKDerivative.h:15
Derivative calculation for the 6D cartesian case.
RKDerivative< double, 6 > Base
const Vector3D & momentum() const
#define dso_internal
Definition: Visibility.h:13
Base class for derivative calculation.
Definition: RKDerivative.h:12
CartesianLorentzForce(const RKLocalFieldProvider &field, float ch)
static RKSmallVector< double, 6 > rkstate(const Vector3D &pos, const Vector3D &mom)
const Vector3D & position() const
const RKLocalFieldProvider & theField
#define constexpr