28 #include <boost/filesystem.hpp>
50 filename_m(right.filename_m),
51 plane_m(right.plane_m),
81 if (dt *
R(2) < dt * middle &&
82 dt * (
R(2) + P(2) * recpgamma) > dt * middle) {
83 double frac = (middle -
R(2)) / (P(2) * recpgamma);
85 lossDs_m->addParticle(R + frac * recpgamma * P,
103 if (dt *
R(2) < dt * middle &&
104 dt * (
R(2) + P(2) * recpgamma) > dt * middle) {
105 double frac = (middle -
R(2)) / (P(2) * recpgamma);
106 double time = t + frac * dt;
107 Vector_t dR = (0.5 + frac) * P * recpgamma;
118 for (
unsigned int i = 0; i < localNum; ++ i) {
150 double currentPosition = endField;
152 currentPosition = bunch->
get_sPos();
156 currentPosition < startField) {
157 namespace fs = boost::filesystem;
159 fs::path lossFileName = fs::path(
filename_m +
".h5");
160 if (fs::exists(lossFileName)) {
163 fs::remove(lossFileName);
182 for (
auto &stat: stats) {
214 bool hasPriorTrack = instance->hasPriorTrack();
215 bool inRestartRun = instance->inRestartRun();
218 double spos = it->first;
224 writer.
addRow(entry.second);
227 statFileEntries_sm.clear();
ParticleAttrib< Vector_t > P
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Monitor.
Interface for beam position monitors.
static std::map< double, SetStatistics > statFileEntries_sm
CoordinateSystemTrafo csTrafoGlobal2Local_m
std::unique_ptr< LossDataSink > lossDs_m
virtual const std::string & getName() const
Get element name.
unsigned int numPassages_m
virtual void goOffline() override
size_t getTotalNum() const
virtual void finalise() override
static OpalData * getInstance()
virtual void getDimensions(double &zBegin, double &zEnd) const override
static const double halfLength_s
double getGamma(Vector_t p)
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
OPENMODE
Enum for writing to files.
virtual double getElementLength() const
Get design length.
constexpr double c
The velocity of light in m/s.
PartBunchBase< double, 3 > * RefPartBunch_m
OPENMODE getOpenMode() const
virtual ElementBase::ElementType getType() const override
Get element type std::string.
size_t getLocalNum() const
ParticleAttrib< double > dt
static void writeStatistics()
void addRow(const SetStatistics &set)
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
T euclidean_norm(const Vector< T > &)
Euclidean norm.
Vector_t rotateFrom(const Vector_t &r) const
virtual void visitMonitor(const Monitor &)=0
Apply the algorithm to a beam position monitor.
Interface for a single beam element.
virtual bool bends() const override
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 ...
std::string getInputBasename()
get input file name without extension
static Communicate * Comm
virtual void goOnline(const double &kineticEnergy) override
void setOutputFN(std::string fn)
long long getGlobalTrackStep() const
Vector_t transformFrom(const Vector_t &r) const