42 informed_m(right.informed_m) {
66 double rbunch_min = std::hypot(xmin, ymin);
67 double rbunch_max = std::hypot(xmax, ymax);
79 const double t,
const double ) {
81 bool flagNeedUpdate =
false;
85 for (
unsigned int i = 0; i < tempnum; ++i) {
90 if ((pflag != 0) && (bunch->
Bin[i] != -1)) {
92 bunch->
R[i], bunch->
P[i],
93 t, bunch->
Q[i], bunch->
M[i]),
94 std::make_pair(turnnumber, bunch->
bunchNum[i]));
97 flagNeedUpdate =
true;
101 return flagNeedUpdate;
109 *gmsg <<
level2 <<
"============== START PARTICLE MATTER INTERACTION CALCULATION =============" <<
endl;
116 unsigned int totalNum = 0;
119 bool allParticlesInMat = (totalNum == 0 && collWithParticles);
120 if (allParticlesInMat) {
126 std::pair<Vector_t, double> boundingSphere;
127 boundingSphere.first = 0.5 * (rmax + rmin);
128 boundingSphere.second =
euclidean_norm(rmax - boundingSphere.first);
135 *gmsg <<
level2 <<
"============== END PARTICLE MATTER INTERACTION CALCULATION =============" <<
endl;
137 return flagNeedUpdate;
150 *gmsg <<
"* Finalize cyclotron collimator " <<
getName() <<
endl;
159 std::ofstream omsg(
"errormsg.txt", std::ios_base::app);
170 double ystart,
double yend,
171 double zstart,
double zend,
196 for (
int i=0; i<4; i++) {
void setDimensions(double xstart, double xend, double ystart, double yend, double zstart, double zend, double width)
Set dimensions and consistency checks.
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual bool doPreCheck(PartBunchBase< double, 3 > *) override
Virtual hook for preCheck.
virtual void goOnline(const double &kineticEnergy) override
Override implementation of PluginElement.
virtual void doFinalise() override
Virtual hook for finalise.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual bool stillActive()=0
virtual void print(Inform &os)=0
ParticleAttrib< Vector_t > P
double xstart_m
input geometry positions
ParticleAttrib< short > bunchNum
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
ParticleAttrib< double > M
PartBunchBase< double, 3 > * RefPartBunch_m
static std::string typeset_msg(const std::string &msg, const std::string &title)
virtual void accept(BeamlineVisitor &) const override
Apply visitor to CCollimator.
virtual const std::string & getName() const
Get element name.
Inform & endl(Inform &inf)
std::unique_ptr< LossDataSink > lossDs_m
Pointer to Loss instance.
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
double rmin_m
radius closest to the origin
virtual bool doCheck(PartBunchBase< double, 3 > *bunch, const int turnnumber, const double t, const double tstep) override
Record hits when bunch particles pass.
double rmax_m
maximum extend in r
virtual size_t getParticlesInMat()=0
T euclidean_norm(const Vector< T > &)
Euclidean norm.
virtual ElementType getType() const override
Get element type std::string.
double zstart_m
input geometry positions
ParticleMatterInteractionHandler * parmatint_m
void print()
unused check method
int checkPoint(const double &x, const double &y) const
Checks if coordinate is within element.
size_t getLocalNum() const
ParticleAttrib< double > Q
Point geom_m[5]
actual geometry positions with adaptive width such that each particle hits element once per turn ...
virtual double getElementLength() const
Get design length.
virtual void apply(PartBunchBase< double, 3 > *bunch, const std::pair< Vector_t, double > &boundingSphere)=0
virtual bool doFinaliseCheck(PartBunchBase< double, 3 > *bunch, bool flagNeedUpdate) override
Virtual hook for finaliseCheck.
virtual void doSetGeom() override
Calculate extend in r.
virtual void visitCCollimator(const CCollimator &)=0
Apply the algorithm to a collimator.
void setFlagAllParticlesIn(bool p)
virtual ParticleMatterInteractionHandler * getParticleMatterInteraction() const
Inform & level2(Inform &inf)
ParticleAttrib< int > Bin
virtual void doInitialise(PartBunchBase< double, 3 > *bunch) override
Initialise particle matter interaction.
void setGeom(const double dist)
Sets geometry geom_m with element width dist.
bool informed_m
Flag if error information already printed.
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)