Commit e4215f3a authored by snuverink_j's avatar snuverink_j
Browse files

add STEP option to probe for flexible bin width in peak histogram

parent 9f8f6442
......@@ -110,7 +110,7 @@ void Probe::initialise(PartBunchBase<double, 3> *bunch) {
name = filename_m.substr(0, filename_m.rfind("."));
bool singlemode = (bunch->getTotalNum() == 1) ? true : false;
peakfinder_m = std::unique_ptr<PeakFinder> (new PeakFinder (name, r_start, r_end, singlemode));
peakfinder_m = std::unique_ptr<PeakFinder> (new PeakFinder (name, r_start, r_end, step_m, singlemode));
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(name, !Options::asciidump));
}
......@@ -143,14 +143,17 @@ void Probe::setYstart(double ystart) {
ystart_m = ystart;
}
void Probe::setYend(double yend) {
yend_m = yend;
}
void Probe::setWidth(double width) {
width_m = width;
}
void Probe::setStep(double step) {
step_m = step;
}
double Probe::getXstart() const {
return xstart_m;
......@@ -167,10 +170,15 @@ double Probe::getYstart() const {
double Probe::getYend() const {
return yend_m;
}
double Probe::getWidth() const {
return width_m;
}
double Probe::getStep() const {
return step_m;
}
void Probe::setGeom(const double dist) {
double slope;
......@@ -239,6 +247,7 @@ bool Probe::checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, c
sk2 = - A_m/B_m;
stangle = std::abs(( sk1-sk2 )/(1 + sk1*sk2));
}
// change probe width depending on step size on angle of particle
double lstep = (sqrt(1.0-1.0/(1.0+dot(meanP, meanP))) * Physics::c) * tstep*1.0e-6; // [mm]
double Swidth = lstep / sqrt( 1 + 1/stangle/stangle );
setGeom(Swidth);
......
......@@ -22,6 +22,7 @@
// ------------------------------------------------------------------------
#include "AbsBeamline/Component.h"
#include <string>
#include <utility>
template <class T, unsigned Dim>
......@@ -59,24 +60,23 @@ public:
virtual void goOffline();
void setXstart(double xstart);
void setXend(double xend);
void setYstart(double ystart);
void setYend(double yend);
void setWidth(double width);
void setStep(double step);
virtual double getXstart() const;
virtual double getXend() const;
virtual double getYstart() const;
virtual double getYend() const;
virtual double getWidth() const;
virtual double getStep() const;
bool checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, const double t, const double tstep);
virtual ElementBase::ElementType getType() const;
......@@ -85,13 +85,15 @@ public:
private:
std::string filename_m; /**< The name of the inputfile*/
double position_m;
///@{ input geometry positions
double xstart_m;
double xend_m;
double ystart_m;
double yend_m;
double width_m;
Point geom_m[5];
int step_m;
///@}
double width_m; ///< bin width, not used
Point geom_m[5]; ///< actual geometry positions with adaptive width such that each particle hits probe once per turn
int step_m; ///< Step size of the probe (bin width in histogram file)
double A_m, B_m,R_m, C_m;
void setGeom(const double dist);
......
......@@ -7,8 +7,8 @@
#include "AbstractObjects/OpalData.h"
#include "Ippl.h"
PeakFinder::PeakFinder(std::string elem, double min, double max, bool singlemode):
element_m(elem), binWidth_m(1.0 /*mm*/),
PeakFinder::PeakFinder(std::string elem, double min, double max, double binWidth, bool singlemode):
element_m(elem), binWidth_m(binWidth),
min_m(min), max_m(max), singlemode_m(singlemode)
{
if (min_m > max_m) {
......
......@@ -30,7 +30,7 @@ public:
PeakFinder() = delete;
PeakFinder(std::string elem, double min, double max, bool singlemode);
PeakFinder(std::string elem, double min, double max, double binwidth, bool singlemode);
/*!
* Append the particle coordinates to the container
......
......@@ -30,20 +30,22 @@
OpalProbe::OpalProbe():
OpalElement(SIZE, "PROBE",
"The \"PROBE\" element defines a Probe."),
owk_m(NULL) {
owk_m(nullptr) {
itsAttr[XSTART] = Attributes::makeReal
("XSTART", " Start of x coordinate ");
("XSTART", " Start of x coordinate [mm]");
itsAttr[XEND] = Attributes::makeReal
("XEND", " End of x coordinate");
("XEND", " End of x coordinate [mm]");
itsAttr[YSTART] = Attributes::makeReal
("YSTART", "Start of y coordinate");
("YSTART", "Start of y coordinate [mm]");
itsAttr[YEND1] = Attributes::makeReal
("YEND1", "Not used now");
itsAttr[YEND] = Attributes::makeReal
("YEND", "End of y coordinate");
("YEND", "End of y coordinate [mm]");
itsAttr[WIDTH] = Attributes::makeReal
("WIDTH", "Width of the probe");
("WIDTH", "Width of the probe, not used.");
itsAttr[STEP] = Attributes::makeReal
("STEP", "Step size of the probe [mm]", 1.0);
registerRealAttribute("XSTART");
registerRealAttribute("XEND");
......@@ -51,6 +53,7 @@ OpalProbe::OpalProbe():
registerRealAttribute("YEND1");
registerRealAttribute("YEND");
registerRealAttribute("WIDTH");
registerRealAttribute("STEP");
registerOwnership();
......@@ -60,13 +63,12 @@ OpalProbe::OpalProbe():
OpalProbe::OpalProbe(const std::string &name, OpalProbe *parent):
OpalElement(name, parent),
owk_m(NULL) {
owk_m(nullptr) {
setElement((new ProbeRep(name))->makeAlignWrapper());
}
OpalProbe::~OpalProbe() {
if(owk_m)
delete owk_m;
}
......@@ -94,8 +96,9 @@ void OpalProbe::update() {
double yend1 = Attributes::getReal(itsAttr[YEND1]);
double yend = Attributes::getReal(itsAttr[YEND]);
double width = Attributes::getReal(itsAttr[WIDTH]);
double step = Attributes::getReal(itsAttr[STEP]);
if(itsAttr[WAKEF] && owk_m == NULL) {
if(itsAttr[WAKEF] && owk_m == nullptr) {
owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
owk_m->initWakefunction(*prob);
prob->setWake(owk_m->wf_m);
......@@ -107,6 +110,7 @@ void OpalProbe::update() {
prob->setYend(yend1);
prob->setYend(yend);
prob->setWidth(width);
prob->setStep(step);
// Transmit "unknown" attributes.
OpalElement::updateUnknown(prob);
......
......@@ -39,6 +39,7 @@ public:
YEND1, // Not used now
YEND, // End of y coordinate
WIDTH, // Width of the probe
STEP, // Step size of the probe
SIZE
};
///YEND1 is not used since it is treated as a string in the input file which should be a real argument.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment