21using namespace Kernel;
23using DataObjects::EventWorkspace;
30const std::string INT_CHARGE_NAME(
"gd_prtn_chrg");
32const std::string LOG_CHARGE_NAME(
"proton_charge");
47 "An event workspace");
49 "The name to use for the output workspace");
50 auto range = std::make_shared<BoundedValidator<double>>();
51 range->setBounds(0., 100.);
52 declareProperty(
"LowerCutoff", 95., range,
"The percentage of the average to use as the lower bound");
61 const API::Run &runlogs = inputWS->run();
67 throw std::runtime_error(
"Found no integrated charge value in " + INT_CHARGE_NAME);
70 this->
g_log.
warning() <<
"Failed to find \"" << INT_CHARGE_NAME <<
"\" in run object.\n";
75 this->
g_log.
information() <<
"Filtering pcharge outside of " << min_pcharge <<
" to " << max_pcharge <<
'\n';
76 size_t inputNumEvents = inputWS->getNumberEvents();
81 filterAlgo->setProperty(
"InputWorkspace", inputWS);
82 filterAlgo->setProperty(
"LogName", LOG_CHARGE_NAME);
83 filterAlgo->setProperty(
"MinimumValue", min_pcharge);
84 filterAlgo->setProperty(
"MaximumValue", max_pcharge);
85 filterAlgo->execute();
89 size_t outputNumEvents = outputWS->getNumberEvents();
93 double percent =
static_cast<double>(inputNumEvents - outputNumEvents) /
static_cast<double>(inputNumEvents);
96 this->
g_log.
warning() <<
"Deleted " << (inputNumEvents - outputNumEvents) <<
" of " << inputNumEvents <<
" events ("
97 <<
static_cast<int>(percent) <<
"%)\n";
99 this->
g_log.
notice() <<
"Deleted " << (inputNumEvents - outputNumEvents) <<
" of " << inputNumEvents <<
" events ("
100 <<
static_cast<float>(percent) <<
"%)"
101 <<
" by proton charge from " << min_pcharge <<
" to " << max_pcharge <<
" with mean = " << mean
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
bool hasProperty(const std::string &name) const
Does the property exist on the object.
HeldType getPropertyValueAsType(const std::string &name) const
Get the value of a property as the given TYPE.
This class stores information regarding an experimental run as a series of log entries.
std::tuple< double, double, double > getBadPulseRange(const std::string &logname="proton_charge", const double &cutoff=95.) const
determine the range of bad pulses to filter
A property class for workspaces.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
void exec() override
Executes the algorithm.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
void init() override
Initialise the properties.
int version() const override
Algorithm's version for identification overriding a virtual method.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
@ Input
An input workspace.
@ Output
An output workspace.