30#include <boost/filesystem.hpp>
46 filename_m(right.filename_m),
47 plane_m(right.plane_m),
76 if (dt *
R(2) < 0.0 &&
77 dt * (
R(2) + singleStep(2)) > 0.0) {
79 double frac = -
R(2) / singleStep(2);
82 R + frac * singleStep,
96 const double tau = -refR(2) / driftPerTimeStep(2);
102 Vector_t dS = (tau - 0.5) * cdt * beta;
103 particle.setR(refToLocalCSTrafo.
transformTo(particle.getR()) + dS);
118 if (dt *
R(2) < 0.0 &&
119 dt * (
R(2) + singleStep(2)) > 0.0) {
120 double frac = -
R(2) / singleStep(2);
121 double time = t + frac * dt;
132 auto stats =
lossDs_m->computeStatistics(1);
133 if (!stats.empty()) {
157 double currentPosition = endField;
159 currentPosition = bunch->
get_sPos();
165 currentPosition < startField) {
167 namespace fs = boost::filesystem;
169 fs::path lossFileName = fs::path(
filename_m +
".h5");
170 if (fs::exists(lossFileName)) {
173 fs::remove(lossFileName);
192 for (
auto &stat: stats) {
220 bool hasPriorTrack = instance->hasPriorTrack();
221 bool inRestartRun = instance->inRestartRun();
224 double spos = it->first;
230 writer.
addRow(entry.second);
Quaternion getQuaternion(Vector_t u, Vector_t ref)
T euclidean_norm(const Vector< T > &)
Euclidean norm.
constexpr double c
The velocity of light in m/s.
unsigned int rewindLinesSDDS(const std::string &fileName, double maxSPos, bool checkForTime)
rewind the SDDS file such that the spos of the last step is less or equal to maxSPos
Vector_t getBeta(Vector_t p)
ParticleAttrib< double > M
size_t getTotalNum() const
ParticleAttrib< Vector_t > P
ParticleAttrib< double > Q
CoordinateSystemTrafo toLabTrafo_m
ParticleAttrib< double > dt
long long getGlobalTrackStep() const
std::string getInputBasename()
get input file name without extension
OpenMode getOpenMode() const
static OpalData * getInstance()
OpenMode
Enum for writing to files.
virtual void visitMonitor(const Monitor &)=0
Apply the algorithm to a beam position monitor.
Interface for a single beam element.
PartBunchBase< double, 3 > * RefPartBunch_m
bool update(const AttributeSet &)
Update element.
CoordinateSystemTrafo getCSTrafoGlobal2Local() const
std::string getOutputFN() const
Get output filename.
CoordinateSystemTrafo csTrafoGlobal2Local_m
static void writeStatistics()
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Monitor.
virtual void goOnline(const double &kineticEnergy) override
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
virtual ElementType getType() const override
Get element type std::string.
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
virtual void goOffline() override
std::unique_ptr< LossDataSink > lossDs_m
virtual void getDimensions(double &zBegin, double &zEnd) const override
static std::map< double, SetStatistics > statFileEntries_sm
virtual void finalise() override
unsigned int numPassages_m
static const double halfLength_s
virtual bool bends() const override
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
void driftToCorrectPositionAndSave(const Vector_t &R, const Vector_t &P)
Vector_t rotateFrom(const Vector_t &r) const
Vector_t transformFrom(const Vector_t &r) const
Vector_t transformTo(const Vector_t &r) const
Vector_t rotateTo(const Vector_t &r) const
void addRow(const SetStatistics &set)
static Communicate * Comm
Vektor< double, 3 > Vector_t