54 bool singlemode = (bunch->
getTotalNum() == 1) ?
true :
false;
85 double xmin = (rmin(0) <= 0.0 && rmax(0) >= 0.0)
86 ? 0.0 : std::min(std::abs(rmin(0)), std::abs(rmax(0)));
87 double xmax = std::max(std::abs(rmin(0)), std::abs(rmax(0)));
88 double ymin = (rmin(1) <= 0.0 && rmax(1) >= 0.0)
89 ? 0.0 : std::min(std::abs(rmin(1)), std::abs(rmax(1)));
90 double ymax = std::max(std::abs(rmin(1)), std::abs(rmax(1)));
91 double rbunch_min = std::hypot(xmin, ymin);
92 double rbunch_max = std::hypot(xmax, ymax);
94 if (rbunch_max >
rmin_m - 0.01 && rbunch_min <
rend_m + 0.01 ) {
109 const double reach = 0.5 *
Physics::c * std::abs(tstep) + 1.0e-3;
111 for (
unsigned int i = 0; i < tempnum; ++i) {
112 double dist1 = (
A_m * bunch->
R[i](0) +
B_m * bunch->
R[i](1) +
C_m) /
R_m;
113 if (std::abs(dist1) > reach)
continue;
115 if (bunch->
Bin[i] < 0)
continue;
119 if (pflag == 0)
continue;
128 double dist2 = dist1 * std::sqrt(1.0 + 1.0 / tangle / tangle);
129 double dt = dist2 / (std::sqrt(1.0 - 1.0 / (1.0 +
dot(bunch->
P[i], bunch->
P[i]))) *
Physics::c);
142 t+dt, bunch->
Q[i], mass),
143 std::make_pair(turnnumber, bunch->
bunchNum[i]));
T euclidean_norm(const Vector< T > &)
Euclidean norm.
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Inform & endl(Inform &inf)
constexpr double c
The velocity of light in m/s.
ParticleAttrib< int > Bin
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
size_t getLocalNum() const
ParticleAttrib< double > M
size_t getTotalNum() const
ParticleAttrib< Vector_t > P
ParticleAttrib< ParticleOrigin > POrigin
ParticleAttrib< double > Q
ParticleAttrib< short > bunchNum
virtual void visitProbe(const Probe &)=0
Apply the algorithm to a probe.
virtual const std::string & getName() const
Get element name.
std::string getOutputFN() const
Get output filename.
int checkPoint(const double &x, const double &y) const
Checks if coordinate is within element.
double C_m
Geometric lengths used in calculations.
void changeWidth(PartBunchBase< double, 3 > *bunch, int i, const double tstep, const double tangle)
Change probe width depending on step size and angle of particle.
double calculateIncidentAngle(double xp, double yp) const
Calculate angle of particle/bunch wrt to element.
std::unique_ptr< LossDataSink > lossDs_m
Pointer to Loss instance.
double rmin_m
radius closest to the origin
void setStep(double step)
Set probe histogram bin width.
std::unique_ptr< PeakFinder > peakfinder_m
Pointer to Peakfinder instance.
virtual bool doCheck(PartBunchBase< double, 3 > *bunch, const int turnnumber, const double t, const double tstep) override
Record probe hits when bunch particles pass.
virtual void doInitialise(PartBunchBase< double, 3 > *bunch) override
Initialise peakfinder file.
double step_m
Step size of the probe (bin width in histogram file)
virtual void doGoOffline() override
Hook for goOffline.
virtual ElementType getType() const override
Get element type std::string.
virtual bool doPreCheck(PartBunchBase< double, 3 > *) override
Virtual hook for preCheck.
virtual double getStep() const
Member variable access.
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Probe.