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) { ...@@ -110,7 +110,7 @@ void Probe::initialise(PartBunchBase<double, 3> *bunch) {
name = filename_m.substr(0, filename_m.rfind(".")); name = filename_m.substr(0, filename_m.rfind("."));
bool singlemode = (bunch->getTotalNum() == 1) ? true : false; 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)); lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(name, !Options::asciidump));
} }
...@@ -143,14 +143,17 @@ void Probe::setYstart(double ystart) { ...@@ -143,14 +143,17 @@ void Probe::setYstart(double ystart) {
ystart_m = ystart; ystart_m = ystart;
} }
void Probe::setYend(double yend) { void Probe::setYend(double yend) {
yend_m = yend; yend_m = yend;
} }
void Probe::setWidth(double width) { void Probe::setWidth(double width) {
width_m = width; width_m = width;
} }
void Probe::setStep(double step) {
step_m = step;
}
double Probe::getXstart() const { double Probe::getXstart() const {
return xstart_m; return xstart_m;
...@@ -167,10 +170,15 @@ double Probe::getYstart() const { ...@@ -167,10 +170,15 @@ double Probe::getYstart() const {
double Probe::getYend() const { double Probe::getYend() const {
return yend_m; return yend_m;
} }
double Probe::getWidth() const { double Probe::getWidth() const {
return width_m; return width_m;
} }
double Probe::getStep() const {
return step_m;
}
void Probe::setGeom(const double dist) { void Probe::setGeom(const double dist) {
double slope; double slope;
...@@ -239,6 +247,7 @@ bool Probe::checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, c ...@@ -239,6 +247,7 @@ bool Probe::checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, c
sk2 = - A_m/B_m; sk2 = - A_m/B_m;
stangle = std::abs(( sk1-sk2 )/(1 + sk1*sk2)); 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 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 ); double Swidth = lstep / sqrt( 1 + 1/stangle/stangle );
setGeom(Swidth); setGeom(Swidth);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
#include "AbsBeamline/Component.h" #include "AbsBeamline/Component.h"
#include <string>
#include <utility> #include <utility>
template <class T, unsigned Dim> template <class T, unsigned Dim>
...@@ -59,24 +60,23 @@ public: ...@@ -59,24 +60,23 @@ public:
virtual void goOffline(); virtual void goOffline();
void setXstart(double xstart); void setXstart(double xstart);
void setXend(double xend); void setXend(double xend);
void setYstart(double ystart); void setYstart(double ystart);
void setYend(double yend); void setYend(double yend);
void setWidth(double width); void setWidth(double width);
void setStep(double step);
virtual double getXstart() const; virtual double getXstart() const;
virtual double getXend() const; virtual double getXend() const;
virtual double getYstart() const; virtual double getYstart() const;
virtual double getYend() const; virtual double getYend() const;
virtual double getWidth() const; virtual double getWidth() const;
virtual double getStep() const;
bool checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, const double t, const double tstep); bool checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, const double t, const double tstep);
virtual ElementBase::ElementType getType() const; virtual ElementBase::ElementType getType() const;
...@@ -85,18 +85,20 @@ public: ...@@ -85,18 +85,20 @@ public:
private: private:
std::string filename_m; /**< The name of the inputfile*/ std::string filename_m; /**< The name of the inputfile*/
double position_m; double position_m;
///@{ input geometry positions
double xstart_m; double xstart_m;
double xend_m; double xend_m;
double ystart_m; double ystart_m;
double yend_m; double yend_m;
double width_m; ///@}
Point geom_m[5]; double width_m; ///< bin width, not used
int step_m; 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; double A_m, B_m,R_m, C_m;
void setGeom(const double dist); void setGeom(const double dist);
int checkPoint( const double & x, const double & y ); int checkPoint( const double & x, const double & y );
std::unique_ptr<PeakFinder> peakfinder_m; std::unique_ptr<PeakFinder> peakfinder_m;
std::unique_ptr<LossDataSink> lossDs_m; std::unique_ptr<LossDataSink> lossDs_m;
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Ippl.h" #include "Ippl.h"
PeakFinder::PeakFinder(std::string elem, double min, double max, bool singlemode): PeakFinder::PeakFinder(std::string elem, double min, double max, double binWidth, bool singlemode):
element_m(elem), binWidth_m(1.0 /*mm*/), element_m(elem), binWidth_m(binWidth),
min_m(min), max_m(max), singlemode_m(singlemode) min_m(min), max_m(max), singlemode_m(singlemode)
{ {
if (min_m > max_m) { if (min_m > max_m) {
...@@ -42,7 +42,7 @@ void PeakFinder::save() { ...@@ -42,7 +42,7 @@ void PeakFinder::save() {
} }
if ( found ) { if ( found ) {
fn_m = element_m + std::string(".peaks"); fn_m = element_m + std::string(".peaks");
hist_m = element_m + std::string(".hist"); hist_m = element_m + std::string(".hist");
INFOMSG("Save " << fn_m << " and " << hist_m << endl); INFOMSG("Save " << fn_m << " and " << hist_m << endl);
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
PeakFinder() = delete; 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 * Append the particle coordinates to the container
......
...@@ -30,20 +30,22 @@ ...@@ -30,20 +30,22 @@
OpalProbe::OpalProbe(): OpalProbe::OpalProbe():
OpalElement(SIZE, "PROBE", OpalElement(SIZE, "PROBE",
"The \"PROBE\" element defines a Probe."), "The \"PROBE\" element defines a Probe."),
owk_m(NULL) { owk_m(nullptr) {
itsAttr[XSTART] = Attributes::makeReal itsAttr[XSTART] = Attributes::makeReal
("XSTART", " Start of x coordinate "); ("XSTART", " Start of x coordinate [mm]");
itsAttr[XEND] = Attributes::makeReal itsAttr[XEND] = Attributes::makeReal
("XEND", " End of x coordinate"); ("XEND", " End of x coordinate [mm]");
itsAttr[YSTART] = Attributes::makeReal itsAttr[YSTART] = Attributes::makeReal
("YSTART", "Start of y coordinate"); ("YSTART", "Start of y coordinate [mm]");
itsAttr[YEND1] = Attributes::makeReal itsAttr[YEND1] = Attributes::makeReal
("YEND1", "Not used now"); ("YEND1", "Not used now");
itsAttr[YEND] = Attributes::makeReal itsAttr[YEND] = Attributes::makeReal
("YEND", "End of y coordinate"); ("YEND", "End of y coordinate [mm]");
itsAttr[WIDTH] = Attributes::makeReal 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("XSTART");
registerRealAttribute("XEND"); registerRealAttribute("XEND");
...@@ -51,6 +53,7 @@ OpalProbe::OpalProbe(): ...@@ -51,6 +53,7 @@ OpalProbe::OpalProbe():
registerRealAttribute("YEND1"); registerRealAttribute("YEND1");
registerRealAttribute("YEND"); registerRealAttribute("YEND");
registerRealAttribute("WIDTH"); registerRealAttribute("WIDTH");
registerRealAttribute("STEP");
registerOwnership(); registerOwnership();
...@@ -60,14 +63,13 @@ OpalProbe::OpalProbe(): ...@@ -60,14 +63,13 @@ OpalProbe::OpalProbe():
OpalProbe::OpalProbe(const std::string &name, OpalProbe *parent): OpalProbe::OpalProbe(const std::string &name, OpalProbe *parent):
OpalElement(name, parent), OpalElement(name, parent),
owk_m(NULL) { owk_m(nullptr) {
setElement((new ProbeRep(name))->makeAlignWrapper()); setElement((new ProbeRep(name))->makeAlignWrapper());
} }
OpalProbe::~OpalProbe() { OpalProbe::~OpalProbe() {
if(owk_m) delete owk_m;
delete owk_m;
} }
...@@ -89,13 +91,14 @@ void OpalProbe::update() { ...@@ -89,13 +91,14 @@ void OpalProbe::update() {
dynamic_cast<ProbeRep *>(getElement()->removeWrappers()); dynamic_cast<ProbeRep *>(getElement()->removeWrappers());
double length = Attributes::getReal(itsAttr[LENGTH]); double length = Attributes::getReal(itsAttr[LENGTH]);
double xstart = Attributes::getReal(itsAttr[XSTART]); double xstart = Attributes::getReal(itsAttr[XSTART]);
double xend = Attributes::getReal(itsAttr[XEND]); double xend = Attributes::getReal(itsAttr[XEND]);
double ystart = Attributes::getReal(itsAttr[YSTART]); double ystart = Attributes::getReal(itsAttr[YSTART]);
double yend1 = Attributes::getReal(itsAttr[YEND1]); double yend1 = Attributes::getReal(itsAttr[YEND1]);
double yend = Attributes::getReal(itsAttr[YEND]); double yend = Attributes::getReal(itsAttr[YEND]);
double width = Attributes::getReal(itsAttr[WIDTH]); 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 = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
owk_m->initWakefunction(*prob); owk_m->initWakefunction(*prob);
prob->setWake(owk_m->wf_m); prob->setWake(owk_m->wf_m);
...@@ -107,6 +110,7 @@ void OpalProbe::update() { ...@@ -107,6 +110,7 @@ void OpalProbe::update() {
prob->setYend(yend1); prob->setYend(yend1);
prob->setYend(yend); prob->setYend(yend);
prob->setWidth(width); prob->setWidth(width);
prob->setStep(step);
// Transmit "unknown" attributes. // Transmit "unknown" attributes.
OpalElement::updateUnknown(prob); OpalElement::updateUnknown(prob);
......
...@@ -39,6 +39,7 @@ public: ...@@ -39,6 +39,7 @@ public:
YEND1, // Not used now YEND1, // Not used now
YEND, // End of y coordinate YEND, // End of y coordinate
WIDTH, // Width of the probe WIDTH, // Width of the probe
STEP, // Step size of the probe
SIZE SIZE
}; };
///YEND1 is not used since it is treated as a string in the input file which should be a real argument. ///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