28using Kernel::Direction;
50 return "Corrects the input data for the effects of attenuation & multiple "
61 "Input workspace with X units in TOF. The workspace must "
62 "also have a sample with a cylindrical shape and an "
63 "instrument with a defined source and sample position.");
65 "If True then also correct for the effects of multiple scattering."
66 "Please note that the MS correction assumes the scattering is elastic.",
69 "Controls the number of second-scatter "
70 "events generated. Only applicable where "
71 "MultipleScattering=True.",
74 "Controls the number of simulations, each containing "
75 "MSEvents, performed. The final MS correction is "
76 "computed as the average over the runs. Only applicable"
77 "where MultipleScattering=True.",
81 "An output workspace.");
89 const bool mscatOn =
getProperty(
"MultipleScattering");
95 auto instrument = inputWS->getInstrument();
96 const auto frame = instrument->getReferenceFrame();
99 const auto &sampleShape = inputWS->sample().getShape();
102 const double big(100.);
103 double minX(-big), maxX(big), minY(-big), maxY(big), minZ(-big), maxZ(big);
104 sampleShape.getBoundingBox(maxX, maxY, maxZ, minX, minY, minZ);
105 V3D boxWidth(maxX - minX, maxY - minY, maxZ - minZ);
106 const double radius(0.5 * boxWidth[frame->pointingHorizontal()]),
height(boxWidth[frame->pointingUp()]);
107 const auto &sampleMaterial = sampleShape.material();
109 const size_t nhist(inputWS->getNumberHistograms());
110 Progress prog(
this, 0.0, 1.0, nhist);
113 const auto &spectrumInfo = inputWS->spectrumInfo();
116 for (int64_t i = 0; i < static_cast<int64_t>(nhist); ++i) {
119 if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i) || spectrumInfo.isMasked(i) ||
120 spectrumInfo.l2(i) == 0) {
125 params.
mscat = mscatOn;
126 params.
l1 = spectrumInfo.l1();
127 params.
l2 = spectrumInfo.l2(i);
128 params.
twoTheta = spectrumInfo.twoTheta(i);
131 const auto pos = spectrumInfo.position(i);
134 double _(0.0), theta(0.0), phi(0.0);
135 pos.getSpherical(_, theta, phi);
136 params.
azimuth = asin(sin(theta) * sin(phi));
137 params.
rho = sampleMaterial.numberDensityEffective();
138 params.
sigmaAbs = sampleMaterial.absorbXSection();
139 params.
sigmaSc = sampleMaterial.totalScatterXSection();
142 params.
msNEvents =
static_cast<size_t>(msEvents);
143 params.
msNRuns =
static_cast<size_t>(msRuns);
167 auto validator = std::make_shared<CompositeValidator>();
#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.
Base class from which all concrete algorithm classes should be derived.
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 validator which checks that sample has the required properties.
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
void setNotifyStep(double notifyStepPct)
Override the frequency at which notifications are sent out.
Manage the lifetime of a class intended to be a singleton.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
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.
@ Input
An input workspace.
@ Output
An output workspace.