20#ifndef CLASSIC_TBeamline_HH
21#define CLASSIC_TBeamline_HH
39 explicit TBeamline(
const std::string& name);
163 itsCoordTrafoTo_m(1.0, 0.0, 0.0, 0.0),
164 relativePositions_m(false) {
173 itsCoordTrafoTo_m(1.0, 0.0, 0.0, 0.0),
174 relativePositions_m(false) {
182 itsOrigin_m(rhs.itsOrigin_m),
183 itsCoordTrafoTo_m(rhs.itsCoordTrafoTo_m),
184 relativePositions_m(rhs.relativePositions_m) {
199 for (
typename std::list<T>::const_reverse_iterator op = this->rbegin(); op != this->rend();
204 for (
typename std::list<T>::const_iterator op = this->
begin(); op != this->
end(); ++op) {
214 for (
typename std::list<T>::const_iterator op = this->
begin(); op != this->
end(); ++op) {
217 newObj.setElement(op->getElement()->clone());
236 for (
typename std::list<T>::const_iterator iter = this->
begin(); iter != this->
end();
240 newObj.setElement(iter->getElement()->copyStructure());
257 for (
typename std::list<T>::const_iterator iter = this->
begin(); iter != this->
end(); ++iter) {
258 iter->getElement()->makeSharable();
276 for (
typename std::list<T>::const_iterator iter = this->
begin(); iter != this->
end(); ++iter) {
277 length += iter->getElement()->getArcLength();
287 for (
typename std::list<T>::const_iterator iter = this->
begin(); iter != this->
end(); ++iter) {
288 length += iter->getElement()->getElementLength();
296 return (getArcLength() / 2.0);
301 return (-getOrigin());
306 return (getArcLength() / 2.0);
314 double s1 = getEntrance();
315 typename std::list<T>::const_iterator iter = this->
begin();
317 while (iter != this->
end() && s1 <= toS) {
323 double s0 = (s1 + s2) / 2.0;
324 double arc1 =
std::max(s1, fromS) - s0;
325 double arc2 =
std::min(s2, toS) - s0;
333 double s1 = getExit();
334 typename std::list<T>::const_reverse_iterator iter = this->rbegin();
336 while (iter != this->rend() && s1 >= toS) {
342 double s0 = (s1 + s2) / 2.0;
343 double arc1 =
std::min(s1, fromS) - s0;
344 double arc2 =
std::max(s2, toS) - s0;
360 for (
typename std::list<T>::const_iterator iter = this->
begin(); iter != this->
end(); ++iter) {
361 transform.
dotBy(iter->getElement()->getTotalTransform());
369 return getTransform(0.0, s);
374 return getTransform(0.0, getEntrance());
379 return getTransform(0.0, getExit());
389 this->push_back(obj);
394 this->push_front(obj);
409 itsCoordTrafoTo_m = trafoTo;
414 return itsCoordTrafoTo_m;
419 relativePositions_m = flag;
424 return relativePositions_m;
430 for (
typename std::list<T>::const_iterator iter = this->
begin(); iter != this->
end(); ++iter) {
PartBunch< T, Dim >::ConstIterator end(PartBunch< T, Dim > const &bunch)
PartBunch< T, Dim >::ConstIterator begin(PartBunch< T, Dim > const &bunch)
KOKKOS_INLINE_FUNCTION Vector< T, Dim > max(const Vector< T, Dim > &a, const Vector< T, Dim > &b)
KOKKOS_INLINE_FUNCTION Vector< T, Dim > min(const Vector< T, Dim > &a, const Vector< T, Dim > &b)
virtual void visitBeamline(const Beamline &)=0
Apply the algorithm to a beam line.
virtual double getArcLength() const
Get arc length.
virtual Euclid3D getTransform(double fromS, double toS) const
Get transform.
Displacement and rotation in space.
const Euclid3D & dotBy(const Euclid3D &rhs)
Dot product with assign.
An abstract sequence of beam line components.
Implements the composite geometry of a beam line.
bool getRelativeFlag() const
Quaternion getInitialDirection() const
virtual Euclid3D getEntranceFrame() const
Get transform.
void setRelativeFlag(bool flag)
virtual double getArcLength() const
Get arc length.
virtual TBeamline< T > * clone() const
Make clone.
virtual double getEntrance() const
Get entrance position.
size_t size() const
Get the number of elements in the TBeamline.
void setOrigin3D(const Vector_t< double, 3 > &ori)
virtual TBeamline< T > * copyStructure()
Make structure copy.
virtual Euclid3D getTotalTransform() const
Get transform.
virtual Euclid3D getExitFrame() const
Get transform.
virtual void prepend(const T &)
Prepend a T object.
virtual void makeSharable()
Set sharable flag.
virtual double getOrigin() const
Get origin position.
TBeamline()
Default constructor.
virtual Euclid3D getTransform(double fromS, double toS) const
Get transform.
Vector_t< double, 3 > itsOrigin_m
void setInitialDirection(const Quaternion &rot)
virtual void append(const T &)
Append a T object.
virtual ElementType getType() const
Get beamline type.
Quaternion itsCoordTrafoTo_m
virtual double getElementLength() const
Get design length.
Vector_t< double, 3 > getOrigin3D() const
virtual BeamlineGeometry & getGeometry()
Get geometry.
virtual void accept(BeamlineVisitor &) const
Apply BeamlineVisitor to this line.
virtual double getExit() const
Get exit position.
virtual void iterate(BeamlineVisitor &, bool r2l) const
Apply visitor to all elements of the line.
BeamlineGeometry itsGeometry
The beamline geometry.