83 bool backBeam,
bool backTrack):
84 Tracker(beamline, nullptr, reference, backBeam, backTrack)
91 bool backBeam,
bool backTrack):
126 for(
unsigned int i = 0; i <
itsBunch_m->getLocalNum(); i++) {
128 if(part.
getX() != std::numeric_limits<double>::max()) {
130 double lByPz = length / std::sqrt(2 * P[2] * P[2] -
dot(P, P));
131 part.
setX(part.
getX() + P[0] * lByPz);
132 part.
setY(part.
getY() + P[1] * lByPz);
133 part.
setZ(part.
getZ() + P[2] * (refTime / std::sqrt(P[2] * P[2] + kin * kin) - lByPz));
142 int order = field.
order();
145 for(
unsigned int i = 0; i <
itsBunch_m->getLocalNum(); i++) {
147 if(part.
getX() != std::numeric_limits<double>::max()) {
148 double x = part.
getX();
149 double y = part.
getY();
150 double kx = + field.
normal(order);
151 double ky = - field.
skew(order);
155 double kxt = x * kx - y * ky;
156 double kyt = x * ky + y * kx;
157 kx = kxt + field.
normal(ord);
158 ky = kyt - field.
skew(ord);
177 for(
unsigned int i = 0; i <
itsBunch_m->getLocalNum(); i++) {
194 for(
unsigned int i = 0; i <
itsBunch_m->getLocalNum(); i++) {
196 double px = part.
getPx();
197 double py = part.
getPy();
198 double pt = part.
getPz() + 1.0;
199 double pz = std::sqrt(pt * pt - px * px - py * py);
201 part.
setPx(euclid.
M(0, 0) * px + euclid.
M(1, 0) * py + euclid.
M(2, 0) * pz);
202 part.
setPy(euclid.
M(0, 1) * px + euclid.
M(1, 1) * py + euclid.
M(2, 1) * pz);
203 pz = euclid.
M(0, 2) * px + euclid.
M(1, 2) * py + euclid.
M(2, 2) * pz;
205 double x = part.
getX() - euclid.
getX();
206 double y = part.
getY() - euclid.
getY();
208 euclid.
M(0, 0) * x + euclid.
M(1, 0) * y - euclid.
M(2, 0) * euclid.
getZ();
210 euclid.
M(0, 1) * x + euclid.
M(1, 1) * y - euclid.
M(2, 1) * euclid.
getZ();
212 euclid.
M(0, 2) * x + euclid.
M(1, 2) * y - euclid.
M(2, 2) * euclid.
getZ();
213 double sByPz = s2 / pz;
215 double E = std::sqrt(pt * pt + kin * kin);
218 part.
setZ(part.
getZ() + pt * (refTime / E + sByPz));
227 int order = field.
order();
239 kx = kxt + field.
normal(order) / double(order);
240 ky = kyt - field.
skew(order) / double(order);
254 int order = field.
order();
260 Series ky = - field.
skew(order) / double(order);
263 Series kxt = x * kx - y * ky;
264 Series kyt = x * ky + y * kx;
266 kx = kxt + field.
normal(order) / double(order);
267 ky = kyt - field.
skew(order) / double(order);
270 Series As = x * kx - y * ky;
281 int order = field.
order();
292 for(
int i = order; --i >= 1;) {
293 Ae = Ae * x + field.
normal(i);
294 Ao = Ao * x - field.
skew(i);
300 Ae = + (Ae * hx1).integral(
X);
314 if(++k > order)
break;
321 if(++k > order)
break;
333 int order = field.
order();
344 for(
int i = order; --i >= 1;) {
345 Ae = Ae * x + field.
normal(i);
346 Ao = Ao * x - field.
skew(i);
352 Ae = + (Ae * hx1).integral(
X);
366 if(++k > order)
break;
373 if(++k > order)
break;
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
FTps< double, 2 > Series2
Interface for a single beam element.
virtual void trackBunch(PartBunchBase< double, 3 > *bunch, const PartData &, bool revBeam, bool revTrack) const
Track particle bunch.
const PartData itsReference
The reference information.
AbstractTracker(const Beamline &, const PartData &, bool backBeam, bool backTrack)
Constructor.
void setPy(double)
Set the vertical momentum.
double getPy() const
Get vertical momentum (no dimension).
const Vector_t & getP() const
Get momentum.
double getPz() const
Get relative momentum error (no dimension).
void setPx(double)
Set the horizontal momentum.
void setZ(double)
Set longitudinal position in m.
void setY(double)
Set the vertical displacement in m.
double getY() const
Get vertical displacement in m.
double getZ() const
Get longitudinal displacement c*t in m.
double getPx() const
Get horizontal momentum (no dimension).
double getX() const
Get horizontal position in m.
void setX(double)
Set the horizontal position in m.
void applyThinMultipole(const BMultipoleField &field, double factor)
void applyTransform(const Euclid3D &, double refLength=0.0)
Apply a geometric transformation.
FTps< double, 2 > buildSBendVectorPotential2D(const BMultipoleField &, double h)
Construct vector potential for a SBend.
FTps< double, 6 > buildSBendVectorPotential(const BMultipoleField &, double h)
Construct vector potential for a SBend.
void applyThinSBend(const BMultipoleField &field, double scale, double h)
FTps< double, 6 > buildMultipoleVectorPotential(const BMultipoleField &)
Construct vector potential for a Multipole.
Tracker(const Beamline &, const PartData &, bool backBeam, bool backTrack)
Constructor.
const Beamline & itsBeamline_m
virtual void visitComponent(const Component &)
Store the bunch.
void addToBunch(const OpalParticle &)
Add particle to bunch.
void applyDrift(double length)
Apply a drift length.
PartBunchBase< double, 3 > * itsBunch_m
The bunch of particles to be tracked.
const PartBunchBase< double, 3 > * getBunch() const
Return the current bunch.
FTps< double, 2 > buildMultipoleVectorPotential2D(const BMultipoleField &)
Construct vector potential for a Multipole.
Displacement and rotation in space.
double getX() const
Get displacement.
double getY() const
Get displacement.
double M(int row, int col) const
Get component.
bool isIdentity() const
Test for identity.
double getZ() const
Get displacement.
An abstract sequence of beam line components.
The magnetic field of a multipole.
int order() const
Return order.
double normal(int) const
Get component.
double skew(int) const
Get component.
Truncated power series in N variables of type T.
void setTruncOrder(int order)
Set truncation order.
FTps derivative(int var) const
Partial derivative.
static FTps makeVariable(int var)
T evaluate(const FVector< T, N > &) const
Evaluate FTps at point.
int getMaxOrder() const
Get maximum order.
A templated representation for vectors.
Vektor< double, 3 > Vector_t