21 std::string commonHelp(
"\nYou can only specify the relative or absolute "
22 "start/stop times, not both.");
26 "An input event workspace");
30 "The name to use for the output workspace");
32 auto min = std::make_shared<BoundedValidator<double>>();
35 "The start time, in seconds, since the start of the run. "
36 "Events before this time are filtered out. \nThe time of the "
37 "first pulse (i.e. the first entry in the ProtonCharge "
38 "sample log) is used as the zero. " +
42 "The stop time, in seconds, since the start of the run. "
43 "Events at or after this time are filtered out. \nThe time "
44 "of the first pulse (i.e. the first entry in the "
45 "ProtonCharge sample log) is used as the zero. " +
48 std::string absoluteHelp(
"Specify date and UTC time in ISO8601 format, e.g. 2010-09-14T04:20:12." + commonHelp);
50 "Absolute start time; events before this time are filtered out. " + absoluteHelp);
53 "Absolute stop time; events at of after this time are filtered out. " + absoluteHelp);
62 g_log.
error() <<
"Input is not EventWorkspace\n";
63 throw std::invalid_argument(
"Input is not EventWorksapce");
65 g_log.
debug() <<
"DB5244 InputWorkspace Name = " << inWS->getName() <<
'\n';
70 std::string absstarttime = this->
getProperty(
"AbsoluteStartTime");
71 std::string absstoptime = this->
getProperty(
"AbsoluteStopTime");
73 std::string start, stop;
74 if ((!absstarttime.empty()) && (!absstoptime.empty()) && (starttime <= 0.0) && (stoptime <= 0.0)) {
78 }
else if ((!absstarttime.empty() || !absstoptime.empty()) && (starttime > 0.0 || stoptime > 0.0)) {
79 throw std::invalid_argument(
"It is not allowed to provide both absolute time and relative time.");
85 std::stringstream ss2;
91 g_log.
debug() <<
"\nDB441: About to generate Filter. StartTime = " << starttime <<
" StopTime = " << stoptime
95 genfilter->initialize();
96 genfilter->setPropertyValue(
"InputWorkspace", inWS->getName());
97 genfilter->setPropertyValue(
"OutputWorkspace",
"FilterWS");
98 genfilter->setProperty(
"StartTime", start);
99 genfilter->setProperty(
"StopTime", stop);
100 genfilter->setProperty(
"UnitOfTime",
"Seconds");
101 genfilter->setProperty(
"FastLog",
false);
103 bool sucgen = genfilter->execute();
105 g_log.
error() <<
"Unable to generate event filters\n";
106 throw std::runtime_error(
"Unable to generate event filters");
113 g_log.
error() <<
"Unable to retrieve generated SplittersWorkspace object "
114 "from AnalysisDataService.\n";
115 throw std::runtime_error(
"Unable to retrieve Splittersworkspace. ");
123 filter->initialize();
124 filter->setPropertyValue(
"InputWorkspace", inWS->getName());
125 filter->setPropertyValue(
"OutputWorkspaceBaseName",
"ResultWS");
126 filter->setProperty(
"SplitterWorkspace", filterWS);
127 filter->setProperty(
"FilterByPulseTime",
true);
129 bool sucfilt = filter->execute();
132 throw std::runtime_error(
"Unable to filter events");
134 g_log.
debug() <<
"Filter events is successful. \n";
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.
A property class for workspaces.
void exec() override
Executes the algorithm.
void init() override
Sets documentation strings for this algorithm.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
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.