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