17using namespace Kernel;
19using namespace DataObjects;
23 "Name of the input workspace");
25 "Name of the output workspace");
28 "Re-integrates the proton charge. This will modify the "
29 "gd_prtn_chrg. Does nothing for multi-period data");
44 const bool integratePCharge)
const {
47 const Run &run = inputWS->run();
54 "data, then you will be normalising against the "
62 int periodNumber = std::stoi(currentPeriodNumberProperty->
value());
67 if (chargePropertyArray) {
68 charge = chargePropertyArray->operator()()[periodNumber - 1];
71 "multiperiod data workspace (" +
72 inputWS->getName() +
")",
73 "proton_charge_by_period");
77 throw std::domain_error(
"The proton charge found for period number " +
std::to_string(periodNumber) +
78 " in the input workspace (" + inputWS->getName() +
79 ") run information is zero. When applying "
80 "NormaliseByCurrent on multiperiod data, a "
81 "non-zero value is required for every period in "
82 "the proton_charge_by_period log.");
87 if (integratePCharge) {
88 inputWS->run().integrateProtonCharge();
90 charge = inputWS->run().getProtonCharge();
92 g_log.
error() <<
"The proton charge is not set for the run attached to "
94 inputWS->getName() +
")\n";
99 throw std::domain_error(
"The proton charge found in the input workspace (" + inputWS->getName() +
100 ") run information is zero");
110 const bool integratePCharge =
getProperty(
"RecalculatePCharge");
117 double invcharge = 1.0 / charge;
121 if (inputWS != outputWS) {
122 outputWS = inputWS * invcharge;
125 inputWS *= invcharge;
128 outputWS->setYUnitLabel(
"Counts per microAmp.hour");
#define DECLARE_ALGORITHM(classname)
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.
Kernel::Property * getLogData(const std::string &name) const
Access a single log entry.
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.
A property class for workspaces.
void init() override
Virtual method - must be overridden by concrete algorithm.
void exec() override
Virtual method - must be overridden by concrete algorithm.
double extractCharge(const std::shared_ptr< Mantid::API::MatrixWorkspace > &inputWS, const bool integratePCharge) const
Extract a value for the charge from the input workspace.
Support for a property that holds an array of values.
Exception for when an item is not found in a collection.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
void information(const std::string &msg)
Logs at information level.
The concrete, templated class for properties.
Base class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.