Mantid
Loading...
Searching...
No Matches
AnvredCorrection.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include "MantidAPI/Axis.h"
10#include "MantidAPI/Run.h"
11#include "MantidAPI/Sample.h"
20#include "MantidKernel/Unit.h"
21
22/* Following A.J.Schultz's anvred, the weight factors should be:
23 *
24 * sin^2(theta) / (lamda^4 * spec * eff * trans)
25 *
26 * where theta = scattering_angle/2
27 * lamda = wavelength (in angstroms?)
28 * spec = incident spectrum correction
29 * eff = pixel efficiency
30 * trans = absorption correction
31 *
32 * The quantity:
33 *
34 * sin^2(theta) / eff
35 *
36 * depends only on the pixel and can be pre-calculated
37 * for each pixel. It could be saved in array pix_weight[].
38 * For now, pix_weight[] is calculated by the method:
39 * BuildPixWeights() and just holds the sin^2(theta) values.
40 *
41 * The wavelength dependent portion of the correction is saved in
42 * the array lamda_weight[].
43 * The time-of-flight is converted to wave length by multiplying
44 * by tof_to_lamda[id], then (int)STEPS_PER_ANGSTROM * lamda
45 * gives an index into the table lamda_weight[].
46 *
47 * The lamda_weight[] array contains values like:
48 *
49 * 1/(lamda^power * spec(lamda))
50 *
51 * which are pre-calculated for each lamda. These values are
52 * saved in the array lamda_weight[]. The optimal value to use
53 * for the power should be determined when a good incident spectrum
54 * has been determined. Currently, power=3 when used with an
55 * incident spectrum and power=2.4 when used without an incident
56 * spectrum.
57 *
58 * The pixel efficiency and incident spectrum correction are NOT CURRENTLY
59 *USED.
60 * The absorption correction, trans, depends on both lamda and the pixel,
61 * Which is a fairly expensive calulation when done for each event.
62 */
63
64namespace Mantid::Crystal {
65
66// Register the class into the algorithm factory
67DECLARE_ALGORITHM(AnvredCorrection)
68
69using namespace Kernel;
70using namespace Geometry;
71using namespace API;
72using namespace DataObjects;
73using namespace Mantid::PhysicalConstants;
74
76 : API::Algorithm(), m_smu(0.), m_amu(0.), m_radius(0.), m_power_th(0.), m_lamda_weight(),
77 m_onlySphericalAbsorption(false), m_returnTransmissionOnly(false), m_useScaleFactors(false) {}
78
80
81 // The input workspace must have an instrument and units of wavelength
82 auto wsValidator = std::make_shared<InstrumentValidator>();
83
85 std::make_unique<WorkspaceProperty<MatrixWorkspace>>("InputWorkspace", "", Direction::Input, wsValidator),
86 "The X values for the input workspace must be in units of wavelength or TOF");
87 declareProperty(std::make_unique<WorkspaceProperty<>>("OutputWorkspace", "", Direction::Output),
88 "Output workspace name");
89
90 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
91 mustBePositive->setLower(0.0);
92 declareProperty("LinearScatteringCoef", EMPTY_DBL(), mustBePositive,
93 "Linear scattering coefficient in 1/cm. "
94 "If not provided this will be calculated from the "
95 "material cross-section if present (set with SetSampleMaterial)");
96 declareProperty("LinearAbsorptionCoef", EMPTY_DBL(), mustBePositive,
97 "Linear absorption coefficient at 1.8 Angstroms in 1/cm. "
98 "If not provided this will be calculated from the "
99 "material cross-section if present (set with SetSampleMaterial)");
100 declareProperty("Radius", EMPTY_DBL(), mustBePositive,
101 "Radius of the sample in centimeters. f not provided the "
102 "radius will be taken from the sample shape if it is a sphere "
103 "(set with SetSample).");
104 declareProperty("PreserveEvents", true,
105 "Keep the output workspace as an EventWorkspace, if the "
106 "input has events (default).\n"
107 "If false, then the workspace gets converted to a "
108 "Workspace2D histogram.");
109 declareProperty("OnlySphericalAbsorption", false,
110 "All corrections done if false (default).\n"
111 "If true, only the spherical absorption correction.");
112 declareProperty("ReturnTransmissionOnly", false,
113 "Corrections applied to data if false (default).\n"
114 "If true, only return the transmission coefficient.");
115 declareProperty("PowerLambda", 4.0, "Power of lamda ");
116 declareProperty("DetectorBankScaleFactors", false,
117 "No scale factors if false (default).\n"
118 "If true, use scale factors from instrument parameter map.");
119
121}
122
123std::map<std::string, std::string> AnvredCorrection::validateInputs() {
124 std::map<std::string, std::string> result;
125
126 const double radius = getProperty("Radius");
127 if (radius == EMPTY_DBL()) {
128 // check that if radius isn't supplied that the radius can be accessed from the sample
129 Mantid::API::MatrixWorkspace_sptr inputWorkspace = this->getProperty("InputWorkspace");
130 if (!inputWorkspace) {
131 result["InputWorkspace"] = "The InputWorkspace must be a MatrixWorkspace.";
132 return result;
133 }
134
135 const auto &sampleShape = inputWorkspace->sample().getShape();
136 if (!sampleShape.hasValidShape() ||
137 sampleShape.shapeInfo().shape() != Geometry::detail::ShapeInfo::GeometryShape::SPHERE) {
138 result["Radius"] = "Please supply a radius or provide a workspace with a spherical sample set.";
139 }
140 }
141 return result;
142}
143
145 // Retrieve the input workspace
146 m_inputWS = getProperty("InputWorkspace");
147 m_onlySphericalAbsorption = getProperty("OnlySphericalAbsorption");
148 m_returnTransmissionOnly = getProperty("ReturnTransmissionOnly");
149 m_useScaleFactors = getProperty("DetectorBankScaleFactors");
151 const API::Run &run = m_inputWS->run();
152 if (run.hasProperty("LorentzCorrection")) {
153 auto lorentzDone = run.getPropertyValueAsType<bool>("LorentzCorrection");
154 if (lorentzDone) {
156 g_log.warning() << "Lorentz Correction was already done for this "
157 "workspace. OnlySphericalAbsorption was changed to "
158 "true.\n";
159 }
160 }
161 }
162
163 const std::string &unitStr = m_inputWS->getAxis(0)->unit()->unitID();
164
165 // Get the input parameters
167
170
171 eventW = std::dynamic_pointer_cast<EventWorkspace>(m_inputWS);
172 if (eventW)
173 eventW->sortAll(TOF_SORT, nullptr);
174 if ((getProperty("PreserveEvents")) && (eventW != nullptr) && !m_returnTransmissionOnly) {
175 // Input workspace is an event workspace. Use the other exec method
176 this->execEvent();
177 this->cleanup();
178 return;
179 }
180
181 MatrixWorkspace_sptr correctionFactors = WorkspaceFactory::Instance().create(m_inputWS);
182
183 // needs to be a signed because OpenMP gives an error otherwise
184 const auto numHists = static_cast<int64_t>(m_inputWS->getNumberHistograms());
185 const auto specSize = static_cast<int64_t>(m_inputWS->blocksize());
186 if (specSize < 3)
187 throw std::runtime_error("Problem in AnvredCorrection::events not binned");
188
189 // If sample not at origin, shift cached positions.
190 const auto &spectrumInfo = m_inputWS->spectrumInfo();
191 const auto &componentInfo = m_inputWS->componentInfo();
192 double L1 = spectrumInfo.l1();
193
194 Progress prog(this, 0.0, 1.0, numHists);
195 // Loop over the spectra
196 PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *correctionFactors))
197 for (int64_t i = 0; i < int64_t(numHists); ++i) {
199
200 // If no detector is found, skip onto the next spectrum
201 if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i))
202 continue;
203
204 Instrument_const_sptr inst = m_inputWS->getInstrument();
208 spectrumInfo.getDetectorValues(tof, wl, Kernel::DeltaEMode::Elastic, false, i, pmap);
209 double L2 = pmap.at(UnitParams::l2);
210 double scattering = pmap.at(UnitParams::twoTheta);
211
212 double depth = 0.2;
213
214 double pathlength = 0.0;
215
216 std::string bankName;
217 if (m_useScaleFactors) {
218 const auto &det = spectrumInfo.detector(i);
219 bankName = det.getParent()->getParent()->getName();
220 scale_init(inst, componentInfo, L2, depth, pathlength, bankName);
221 }
222
223 auto points = m_inputWS->points(i);
224
225 // share bin boundaries
226 const auto &inSpec = m_inputWS->getSpectrum(i);
227 correctionFactors->setSharedX(i, inSpec.sharedX());
228
229 // get references to input data for calculations
230 const auto &Yin = inSpec.y();
231 const auto &Ein = inSpec.x();
232
233 // Get a reference to the Y's in the output WS for storing the factors
234 auto &Y = correctionFactors->mutableY(i);
235 auto &E = correctionFactors->mutableE(i);
236 // Loop through the bins in the current spectrum
237 bool muRTooLarge = false;
238 for (int64_t j = 0; j < specSize; j++) {
239
240 double lambda = (unitStr == "TOF") ? wl.convertSingleFromTOF(points[j], L1, 0, pmap) : points[j];
241
243 Y[j] = 1.0 / this->getEventWeight(lambda, scattering, muRTooLarge);
244 } else {
245 const auto eventWeight = this->getEventWeight(lambda, scattering, muRTooLarge);
246 double scaleFactor(eventWeight);
248 scaleFactor = scale_exec(bankName, lambda, depth, inst, pathlength, eventWeight);
249
250 Y[j] = Yin[j] * scaleFactor;
251 E[j] = Ein[j] * scaleFactor;
252 }
253 }
254
255 if (muRTooLarge) {
256 g_log.warning("Absorption correction not accurate for muR > 8 which was exceeded in spectrum index " +
257 std::to_string(i));
258 }
259
260 prog.report();
261
263 }
265
266 // set the absorption correction values in the run parameters
267 API::Run &run = correctionFactors->mutableRun();
268 run.addProperty<double>("Radius", m_radius, true);
270 run.addProperty<bool>("LorentzCorrection", true, true);
271 setProperty("OutputWorkspace", correctionFactors);
272}
273
275 // Clear vectors to free up memory.
276 m_lamda_weight.clear();
277}
278
280
281 const auto numHists = static_cast<int64_t>(m_inputWS->getNumberHistograms());
282 std::string unitStr = m_inputWS->getAxis(0)->unit()->unitID();
283 auto correctionFactors = create<EventWorkspace>(*m_inputWS);
284 correctionFactors->sortAll(TOF_SORT, nullptr);
285 bool inPlace = (this->getPropertyValue("InputWorkspace") == this->getPropertyValue("OutputWorkspace"));
286 if (inPlace)
287 g_log.debug("Correcting EventWorkspace in-place.");
288
289 // If sample not at origin, shift cached positions.
290 Instrument_const_sptr inst = m_inputWS->getInstrument();
291
292 const auto &spectrumInfo = eventW->spectrumInfo();
293 const auto &componentInfo = eventW->componentInfo();
294 double L1 = spectrumInfo.l1();
295
296 Progress prog(this, 0.0, 1.0, numHists);
297 // Loop over the spectra
298 PARALLEL_FOR_IF(Kernel::threadSafe(*eventW, *correctionFactors))
299 for (int64_t i = 0; i < int64_t(numHists); ++i) {
301
302 // share bin boundaries, and leave Y and E nullptr
303 correctionFactors->setHistogram(i, eventW->binEdges(i));
304
305 // If no detector is found, skip onto the next spectrum
306 if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i))
307 continue;
308
312 spectrumInfo.getDetectorValues(tof, wl, Kernel::DeltaEMode::Elastic, false, i, pmap);
313 double L2 = pmap.at(UnitParams::l2);
314 double scattering = pmap.at(UnitParams::twoTheta);
315
316 EventList el = eventW->getSpectrum(i);
318 std::vector<WeightedEventNoTime> events = el.getWeightedEventsNoTime();
319
320 double depth = 0.2;
321 double pathlength = 0.0;
322 std::string bankName;
323 if (m_useScaleFactors) {
324 const auto &det = spectrumInfo.detector(i);
325 bankName = det.getParent()->getParent()->getName();
326 scale_init(inst, componentInfo, L2, depth, pathlength, bankName);
327 }
328
329 // multiplying an event list by a scalar value
330 bool muRTooLarge = false;
331
332 for (auto &ev : events) {
333 // get the event's TOF
334 double lambda = ev.tof();
335
336 if ("TOF" == unitStr)
338
339 double value = this->getEventWeight(lambda, scattering, muRTooLarge);
340
342 scale_exec(bankName, lambda, depth, inst, pathlength, value);
343
344 ev.m_errorSquared = static_cast<float>(ev.m_errorSquared * value * value);
345 ev.m_weight *= static_cast<float>(value);
346 }
347
348 if (muRTooLarge) {
349 g_log.warning("Absorption correction not accurate for muR > 9 cm^-1 which was exceeded in spectrum index " +
350 std::to_string(i));
351 }
352
353 correctionFactors->getSpectrum(i) += events;
354
355 // When focussing in place, you can clear out old memory from the input one!
356 if (inPlace)
357 eventW->getSpectrum(i).clear();
358
359 prog.report();
360
362 }
364
365 // set the absorption correction values in the run parameters
366 API::Run &run = correctionFactors->mutableRun();
367 run.addProperty<double>("Radius", m_radius, true);
369 run.addProperty<bool>("LorentzCorrection", true, true);
370 setProperty("OutputWorkspace", std::move(correctionFactors));
371
372 // Now do some cleaning-up since destructor may not be called immediately
373 this->cleanup();
374}
375
378 m_smu = getProperty("LinearScatteringCoef"); // in 1/cm
379 m_amu = getProperty("LinearAbsorptionCoef"); // in 1/cm
380 m_radius = getProperty("Radius"); // in cm
381 m_power_th = getProperty("PowerLambda"); // in cm
382 const Material &sampleMaterial = m_inputWS->sample().getMaterial();
383
384 const double scatterXSection = sampleMaterial.totalScatterXSection();
385
386 if (scatterXSection != 0.0) {
387 double rho = sampleMaterial.numberDensity();
388 if (m_smu == EMPTY_DBL())
389 m_smu = scatterXSection * rho;
390 if (m_amu == EMPTY_DBL())
392 if (m_radius == EMPTY_DBL())
393 m_radius =
394 m_inputWS->sample().getShape().shapeInfo().sphereGeometry().radius * 100; // convert radius from m to cm
395 } else // Save input in Sample with wrong atomic number and name
396 {
397 NeutronAtom neutron(0, 0, 0.0, 0.0, m_smu, 0.0, m_smu, m_amu);
398 auto shape = std::shared_ptr<IObject>(
399 m_inputWS->sample().getShape().cloneWithMaterial(Material("SetInAnvredCorrection", neutron, 1.0)));
400 m_inputWS->mutableSample().setShape(shape);
401 }
402 if (m_smu != EMPTY_DBL() && m_amu != EMPTY_DBL())
403 g_log.notice() << "LinearScatteringCoef = " << m_smu << " 1/cm\n"
404 << "LinearAbsorptionCoef = " << m_amu << " 1/cm\n"
405 << "Radius = " << m_radius << " cm\n"
406 << "Power Lorentz corrections = " << m_power_th << " \n";
407 // Call the virtual function for any further properties
409}
410
420double AnvredCorrection::getEventWeight(const double lamda, const double two_theta, bool &muRTooLarge) {
421 double transinv = 1;
422 if (m_radius > 0)
423 transinv = absor_sphere(two_theta, lamda, muRTooLarge);
424 // Only Spherical absorption correction
426 return transinv;
427
428 // Resolution of the lambda table
429 auto lamda_index = static_cast<size_t>(STEPS_PER_ANGSTROM * lamda);
430
431 if (lamda_index >= m_lamda_weight.size())
432 lamda_index = m_lamda_weight.size() - 1;
433
434 double lamda_w = m_lamda_weight[lamda_index];
435
436 double sin_theta = std::sin(two_theta / 2);
437 double pix_weight = sin_theta * sin_theta;
438
439 double event_weight = pix_weight * lamda_w * transinv;
440
441 return event_weight;
442}
443
465double AnvredCorrection::absor_sphere(const double twoth, const double wl, bool &muRTooLarge) {
466 // For each of the 19 theta values in (theta = 0:5:90 deg)
467 // fitted ln(1/A*) = sum_{icoef=0}^{N=7} pc[7-icoef][ith]*(muR)^icoef
468 // using A* values in Weber (1969) for 0 < muR < 8.
469 // These values are given in the static array pc[][]
470
471 double mur = (m_smu + (m_amu / 1.8f) * wl) * m_radius;
472 if (mur < 0.) {
473 throw std::runtime_error("muR cannot be negative");
474 } else if (mur > 8.0) {
475 muRTooLarge = true;
476 }
477
478 auto theta = 0.5 * twoth * radtodeg;
479 if (theta < 0. || theta > 90.) {
480 std::ostringstream s;
481 s << theta;
482 throw std::runtime_error("theta is not in allowed range :" + s.str());
483 }
484
485 // tbar = -(double)Math.log(trans)/mu; // as defined by coppens
486 // trans = exp(-mu*tbar)
487 return calc_Astar(theta, mur);
488}
489
490/*
491 * Helper function to calc Astar to be called from SaveHKL
492 * @param theta: half scattering angle (i.e. twotheta/2)
493 * @param mur: muR is the product of linenar attenuation and sphere radius
494 * @returns astar: 1/transmission
495 */
496double AnvredCorrection::calc_Astar(const double theta, const double mur) {
497 // interpolation better done on A = 1/A* = transmission
498 auto ith = static_cast<size_t>(theta / 5.); // floor
499 double lnA_1 = 0.0;
500 double lnA_2 = 0.0;
501 size_t ncoef = sizeof pc / sizeof pc[0]; // order of poly
502 for (size_t icoef = 0; icoef < ncoef; icoef++) {
503 lnA_1 = lnA_1 * mur + pc[icoef][ith]; // previous theta
504 lnA_2 = lnA_2 * mur + pc[icoef][ith + 1]; // next theta
505 }
506 double A1 = std::exp(lnA_1);
507 double sin_th1_sq = std::pow(sin((static_cast<double>(ith) * 5.0) / radtodeg), 2);
508 double A2 = std::exp(lnA_2);
509 double sin_th2_sq = std::pow(sin((static_cast<double>(ith + 1) * 5.0) / radtodeg), 2);
510 // interpolate between theta values using
511 // A(th) = L0 + L1*(sin(th)^2)
512 double L1 = (A1 - A2) / (sin_th1_sq - sin_th2_sq);
513 double L0 = A1 - L1 * sin_th1_sq;
514
515 // correction to apply (A* = 1/A = 1/transmission)
516 return 1 / (L0 + L1 * std::pow(sin(theta / radtodeg), 2));
517}
532 // Theoretically correct value 3.0;
533 // if we have an incident spectrum
534 // double power_ns = 2.4; // lower power needed to find
535 // peaks in ARCS data with no
536 // incident spectrum
537
538 // GetSpectrumWeights( spectrum_file_name, m_lamda_weight);
539
540 if (m_lamda_weight.empty()) // loading spectrum failed so use
541 { // array of 1's
542 // power = power_ns; // This is commented out, so we
543 // don't override user specified
544 // value.
546 for (int i = 0; i < NUM_WAVELENGTHS; i++) {
547 double lamda = static_cast<double>(i) / STEPS_PER_ANGSTROM;
548 m_lamda_weight.emplace_back(1 / std::pow(lamda, m_power_th));
549 }
550 }
551}
552
554 const double L2, const double depth, double &pathlength,
555 const std::string &bankName) {
556 // Distance to center of detector
557 const IComponent *det0 = inst->getComponentByName(bankName).get();
558 if ("CORELLI" == inst->getName()) // for Corelli with sixteenpack under bank
559 {
560 const size_t bankIndex = componentInfo.indexOfAny(bankName);
561 const auto children = componentInfo.children(bankIndex);
562 if (!children.empty()) {
563 det0 = componentInfo.componentID(children[0]);
564 }
565 }
566 IComponent_const_sptr sample = inst->getSample();
567 double cosA = det0->getDistance(*sample) / L2;
568 pathlength = depth / cosA;
569}
570
571double AnvredCorrection::scale_exec(std::string &bankName, const double lambda, const double depth,
572 const Instrument_const_sptr &inst, const double pathlength, double eventWeight) {
573 // correct for the slant path throught the scintillator glass
574 const double mu = (9.614 * lambda) + 0.266; // mu for GS20 glass
575 const double eff_center = 1.0 - std::exp(-mu * depth); // efficiency at center of detector
576 const double eff_R = 1.0 - exp(-mu * pathlength); // efficiency at point R
577 double scaleFactor(eventWeight * eff_center / eff_R); // slant path efficiency ratio
578 // Take out the "bank" part of the bank name
579 bankName.erase(remove_if(bankName.begin(), bankName.end(), std::not_fn(::isdigit)), bankName.end());
580 if (inst->hasParameter("detScale" + bankName))
581 scaleFactor *= static_cast<double>(inst->getNumberParameter("detScale" + bankName)[0]);
582
583 return scaleFactor;
584}
585
586} // namespace Mantid::Crystal
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
const std::vector< double > * lambda
double value
The value of the point.
Definition FitMW.cpp:51
#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.
Definition Algorithm.h:76
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Kernel::Logger & g_log
Definition Algorithm.h:422
bool hasProperty(const std::string &name) const
Does the property exist on the object.
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition LogManager.h:90
HeldType getPropertyValueAsType(const std::string &name) const
Get the value of a property as the given TYPE.
Helper class for reporting progress from algorithms.
Definition Progress.h:25
This class stores information regarding an experimental run as a series of log entries.
Definition Run.h:35
A property class for workspaces.
double m_smu
linear scattering coefficient in 1/cm
virtual void defineProperties()
A virtual function in which additional properties of an algorithm should be declared.
double m_radius
sample radius in cm
std::map< std::string, std::string > validateInputs() override
validate inputs
void execEvent()
Event execution code.
virtual void retrieveProperties()
A virtual function in which additional properties should be retrieved into member variables.
double getEventWeight(const double lamda, const double two_theta, bool &muRTooLarge)
Get the weight factor that would be used for an event occuring at the specified wavelength,...
void init() override
Initialisation code.
double m_amu
linear absoprtion coefficient in 1/cm
void exec() override
Execution code.
double absor_sphere(const double twoth, const double wl, bool &muRTooLarge)
function to calculate a spherical absorption correction and tbar.
DataObjects::EventWorkspace_sptr eventW
Shared pointer to the event workspace.
std::vector< double > m_lamda_weight
lmabda weights
double m_power_th
Power of lamda in BuildLamdaWeights.
static double calc_Astar(const double theta, const double mur)
void scale_init(const Geometry::Instrument_const_sptr &inst, const Geometry::ComponentInfo &componentInfo, const double L2, const double depth, double &pathlength, const std::string &bankName)
void BuildLamdaWeights()
Build the list of weights corresponding to different wavelengths.
API::MatrixWorkspace_sptr m_inputWS
A pointer to the input workspace.
double scale_exec(std::string &bankName, const double lambda, const double depth, const Geometry::Instrument_const_sptr &inst, const double pathlength, double eventWeight)
void retrieveBaseProperties()
Fetch the properties and set the appropriate member variables.
A class for holding :
Definition EventList.h:57
std::vector< WeightedEventNoTime > & getWeightedEventsNoTime()
Return the list of WeightedEvent contained.
void switchTo(Mantid::API::EventType newType) override
Switch the EventList to use the given EventType (TOF, WEIGHTED, or WEIGHTED_NOTIME)
ComponentInfo : Provides a component centric view on to the instrument.
size_t indexOfAny(const std::string &name) const
const std::vector< size_t > & children(size_t componentIndex) const
const IComponent * componentID(const size_t componentIndex) const
base class for Geometric IComponent
Definition IComponent.h:53
virtual double getDistance(const IComponent &) const =0
Get the distance to another IComponent.
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.
Definition Logger.cpp:145
void notice(const std::string &msg)
Logs at notice level.
Definition Logger.cpp:126
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition Material.h:50
double numberDensity() const
Get the number density.
Definition Material.cpp:189
double absorbXSection(const double lambda=PhysicalConstants::NeutronAtom::ReferenceLambda) const
Get the absorption cross section at a given wavelength in barns.
Definition Material.cpp:260
double totalScatterXSection() const
Return the total scattering cross section for a given wavelength in barns.
Definition Material.cpp:252
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
double convertSingleFromTOF(const double xvalue, const double &l1, const int &emode, const UnitParametersMap &params)
Convert from the time-of-flight to the concrete unit. TOF is in microseconds.
Definition Unit.cpp:199
Time of flight in microseconds.
Definition Unit.h:248
Wavelength in Angstrom.
Definition Unit.h:267
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
const int NUM_WAVELENGTHS
const double radtodeg
const double pc[8][19]
const double STEPS_PER_ANGSTROM
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
Definition IComponent.h:167
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
std::unordered_map< UnitParams, double > UnitParametersMap
Definition Unit.h:30
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.
A namespace containing physical constants that are required by algorithms and unit routines.
Definition Atom.h:14
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Definition EmptyValues.h:42
Generate a tableworkspace to store the calibration results.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
Definition Property.h:53
@ Output
An output workspace.
Definition Property.h:54
Structure to store neutronic scattering information for the various elements.
Definition NeutronAtom.h:22
static const double ReferenceLambda
The reference wavelength value for absorption cross sections.
Definition NeutronAtom.h:25