23using namespace DataObjects;
38 return "CorrectionFunctions\\SpecialCorrections; Inelastic\\Corrections";
43 return "Apply polarization factor as part of getting the spin incoherent "
51 auto wsValidator = std::make_shared<Mantid::Kernel::CompositeValidator>();
56 "An input workspace in units of energy transfer.");
58 auto angleValidator = std::make_shared<Mantid::Kernel::BoundedValidator<double>>();
59 angleValidator->setLower(-180.0);
60 angleValidator->setUpper(180.0);
62 "In plane angle between polatrization and incident beam"
63 "Must be between -180 and +180 degrees");
64 auto precisionValidator = std::make_shared<Mantid::Kernel::BoundedValidator<double>>();
65 precisionValidator->setLower(0.0);
66 precisionValidator->setUpper(1.0);
68 "If cosine of twice the "
69 "Scharpf angle is closer to 0 than the precision, the intensities "
70 "and errors will be set to 0");
72 "An output workspace.");
88 throw std::invalid_argument(
"No Ei value has been set or stored within the run information.");
103 const auto &spectrumInfo =
m_inputWS->spectrumInfo();
106 const auto numberOfSpectra =
static_cast<int64_t
>(
m_inputWS->getNumberHistograms());
108 const auto refFrame =
m_inputWS->getInstrument()->getReferenceFrame();
111 for (int64_t i = 0; i < numberOfSpectra; ++i) {
124 if ((!spectrumInfo.hasDetectors(i)) || spectrumInfo.isMonitor(i) || spectrumInfo.isMasked(i)) {
129 const auto l2 = detPos - samplePos;
130 const double thPlane = std::atan2(
l2[refFrame->pointingHorizontal()],
l2[refFrame->pointingAlongBeam()]);
131 size_t spectrumSize = xIn.size();
132 for (
size_t j = 0; j < spectrumSize; ++j) {
135 double kfki = std::sqrt(1. - xIn[j] /
m_Ei);
138 yOut[j] = yIn[j] * factor;
139 eOut[j] = eIn[j] * factor;
160 std::dynamic_pointer_cast<Mantid::DataObjects::EventWorkspace>(
m_outputWS);
162 const auto &spectrumInfo =
m_inputWS->spectrumInfo();
165 const auto numberOfSpectra =
static_cast<int64_t
>(
m_inputWS->getNumberHistograms());
167 const auto refFrame =
m_inputWS->getInstrument()->getReferenceFrame();
170 for (int64_t i = 0; i < numberOfSpectra; ++i) {
174 if ((!spectrumInfo.hasDetectors(i)) || spectrumInfo.isMonitor(i) || spectrumInfo.isMasked(i)) {
178 const auto l2 = detPos - samplePos;
179 const double thPlane = std::atan2(
l2[refFrame->pointingHorizontal()],
l2[refFrame->pointingAlongBeam()]);
181 auto &evlist = eventWS->getSpectrum(i);
182 switch (evlist.getEventType()) {
203 for (
auto it = wevector.begin(); it < wevector.end();) {
204 double Ef =
m_Ei - it->tof();
206 it = wevector.erase(it);
208 double kfki = std::sqrt(Ef /
m_Ei);
212 it->m_weight *= factor;
213 it->m_errorSquared *= factor * factor;
221 const double angleQ = std::atan2(-kfki * std::sin(thPlane), 1. - kfki * std::cos(thPlane));
223 auto factor =
static_cast<float>(std::cos(2. * (
m_angle - angleQ)));
226 factor = 1.f / factor;
#define DECLARE_ALGORITHM(classname)
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
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.
A validator which checks that a workspace has a valid instrument.
Helper class for reporting progress from algorithms.
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
HyspecScharpfCorrection : Divide by cos(2alpha) where alpha is the angle between incident beam and th...
double m_Ei
Incident energy.
Mantid::API::MatrixWorkspace_const_sptr m_inputWS
The user selected (input) workspace.
void ScharpfEventHelper(std::vector< T > &wevector, double thPlane)
Execute Scharpf correction for event lists.
const std::string category() const override
Algorithm's category for identification.
void execEvent()
Execute for events.
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
double m_angle
In plane angle beween polarization and incident beam (in degrees)
int version() const override
Algorithm's version for identification.
float calculateFactor(const double kfki, const double thPlane)
calculate the Scharph angle correction factor
double m_precision
Lower limit for abs(cos(2*Scharpf angle)), below which intensities are 0.
Mantid::API::MatrixWorkspace_sptr m_outputWS
The output workspace, maybe the same as the input one.
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void information(const std::string &msg)
Logs at information level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.
@ Output
An output workspace.