47 :
Component(ring), planarArcGeometry_m(1, 1),
50 beamRInit_m(0.), beamPRInit_m(0.), beamPhiInit_m(0.),
51 latticeRInit_m(0.), latticePhiInit_m(0.), latticeThetaInit_m(0.),
52 isLocked_m(false), isClosed_m(true),
53 symmetry_m(0), cyclHarm_m(0), rfFreq_m(0),
66 planarArcGeometry_m(ring.planarArcGeometry_m),
68 beamRInit_m(ring.beamRInit_m),
69 beamPRInit_m(ring.beamPRInit_m),
70 beamPhiInit_m(ring.beamPhiInit_m),
71 latticeRInit_m(ring.latticeRInit_m),
72 latticePhiInit_m(ring.latticePhiInit_m),
73 latticeThetaInit_m(ring.latticeThetaInit_m),
74 willDoAperture_m(ring.willDoAperture_m),
75 minR2_m(ring.minR2_m),
76 maxR2_m(ring.maxR2_m),
77 isLocked_m(ring.isLocked_m),
78 isClosed_m(ring.isClosed_m),
79 symmetry_m(ring.symmetry_m),
80 cyclHarm_m(ring.cyclHarm_m),
81 phiStep_m(ring.phiStep_m),
83 section_list_m(ring.section_list_m.size()) {
87 "Can't copy construct LossDataSink so copy constructor fails");
102 bool flagNeedUpdate =
106 gmsgALL <<
getName() <<
": particle " <<
id
108 <<
" m out of the field map boundary" <<
endl;
118 return flagNeedUpdate;
127 bool outOfBounds =
true;
130 double rSquared =
R[0]*
R[0]+
R[1]*
R[1];
131 if (rSquared < minR2_m || rSquared >
maxR2_m) {
136 for (
size_t i = 0; i < sections.size(); ++i) {
154 "Cannot get s-dimension of a ring");
189 double deltaAngle =
std::atan2(rotationTest(2), rotationTest(0));
191 return elementRotation;
199 std::string(
"Placement of elements out of the ")+
200 "midplane is not supported by Ring");
208 Euclid3D euclid(v(2), v(0), -v(1), r(2), r(0), -r(1));
234 "Attempt to append element "+element.
getName()+
235 " when ring is locked");
252 double startF =
std::atan2(startNorm(1), startNorm(0));
272 double dphi =
atan2(startNorm(0), startNorm(1));
274 msg <<
"* Added " << element.
getName() <<
" to Ring" <<
endl;
275 msg <<
"* Start position ("
282 msg <<
"* End position ("
295 "Attempt to lock ring when it is already locked");
299 if (sectionListSize == 0) {
301 "Failed to find any elements in Ring");
306 msg <<
"Applying symmetry to Ring" <<
endl;
308 for (
size_t j = 0; j < sectionListSize; ++j) {
342 for (
int i = 0; i < 3; ++i) {
346 "Ring is not closed");
354 ringSections_m = std::vector< std::vector<RingSection*> >(nSections);
379 if (minR < 0 || maxR < 0) {
381 "Could not parse negative or undefined aperture limit");
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Inform & endl(Inform &inf)
constexpr double e
The value of.
constexpr double pi
The value of.
ParticleAttrib< int > Bin
ParticleAttrib< double > M
ParticleAttrib< Vector_t > P
ParticleAttrib< double > Q
Vector_t get_centroid() const
virtual void visitRing(const Ring &)=0
Apply the algorithm to a ring.
Interface for a single beam element.
PartBunchBase< double, 3 > * RefPartBunch_m
virtual const std::string & getName() const
Get element name.
virtual ElementBase * clone() const =0
Return clone.
virtual BGeometryBase & getGeometry()=0
Get geometry.
Ring describes a ring type geometry for tracking.
Vector_t getNextPosition() const
std::vector< RingSection * > getSectionsAt(const Vector_t &pos)
Rotation3D getRotationStartToEnd(Euclid3D delta) const
static bool sectionCompare(RingSection const *const sec1, RingSection const *const sec2)
Vector_t getNextNormal() const
virtual void finalise() override
virtual bool apply(const size_t &id, const double &t, Vector_t &E, Vector_t &B) override
RingSection * getLastSectionPlaced() const
void setRefPartBunch(PartBunchBase< double, 3 > *bunch)
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
double latticeThetaInit_m
std::vector< RingSectionList > ringSections_m
virtual void accept(BeamlineVisitor &visitor) const override
void setRingAperture(double minR, double maxR)
RingSectionList section_list_m
void checkMidplane(Euclid3D delta) const
void setLossDataSink(LossDataSink *sink)
virtual void getDimensions(double &zBegin, double &zEnd) const override
void appendElement(const Component &element)
void rotateToCyclCoordinates(Euclid3D &euclid3d) const
static const double lengthTolerance_m
PartBunchBase< double, 3 > * refPartBunch_m
static const double angleTolerance_m
Displacement and rotation in space.
const Vector3D & getVector() const
Get displacement.
const Rotation3D & getRotation() const
Get rotation.
virtual Euclid3D getTotalTransform() const
Get transform.
Rotation in 3-dimensional space.
static Rotation3D ZRotation(double angle)
Make rotation.
Vector3D getAxis() const
Get axis vector.
void addParticle(const OpalParticle &, const boost::optional< std::pair< int, short int >> &turnBunchNumPair=boost::none)
void save(unsigned int numSets=1, OpalData::OPENMODE openMode=OpalData::OPENMODE::UNDEFINED)
Component placement handler in ring geometry.
void setStartNormal(Vector_t orientation)
void setComponentPosition(Vector_t position)
void setComponent(Component *component)
void setStartPosition(Vector_t pos)
Vector_t getStartNormal() const
void setComponentOrientation(Vector_t orientation)
Vector_t getEndPosition() const
Vector_t getStartPosition() const
void setEndPosition(Vector_t pos)
Vector_t getEndNormal() const
void setEndNormal(Vector_t orientation)
Vektor< double, 3 > Vector_t