Mantid
Loading...
Searching...
No Matches
AnvredCorrection.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13#include "MantidCrystal/DllConfig.h"
15
16namespace Mantid {
17namespace Crystal {
18
19// fit to ln(1/A*) = sum_{icoef=0}^{N=7} pc[7-icoef][ith]*(muR)^icoef
20// A*(muR=0) = 1 so pc[7][ith] = 0 (fixed not fitted)
21// Fit performed in MATLAB using least-squares minimisation
22// after Dwiggins, jr., acta cryst. A, 31, 146 (1975) - (but for sphere instread of cylinder)
23const double pc[8][19] = {{-6.4910e-07, -6.8938e-07, -7.8149e-07, 8.1682e-08, 1.8008e-06, 3.3916e-06, 4.5095e-06,
24 4.7970e-06, 4.4934e-06, 3.6700e-06, 2.5881e-06, 1.5007e-06, 3.7669e-07, -7.9487e-07,
25 -1.7935e-06, -2.5563e-06, -3.1113e-06, -3.3993e-06, -3.5091e-06},
26 {1.0839e-05, 1.1582e-05, 1.1004e-05, -2.2848e-05, -8.1974e-05, -1.3268e-04, -1.6486e-04,
27 -1.6839e-04, -1.5242e-04, -1.1949e-04, -7.8682e-05, -3.7973e-05, 2.9117e-06, 4.4823e-05,
28 8.0464e-05, 1.0769e-04, 1.2753e-04, 1.3800e-04, 1.4190e-04},
29 {8.7140e-05, 9.0870e-05, 1.6706e-04, 6.9008e-04, 1.4781e-03, 2.0818e-03, 2.3973e-03,
30 2.3209e-03, 1.9935e-03, 1.4508e-03, 8.1903e-04, 1.9608e-04, -4.1128e-04, -1.0205e-03,
31 -1.5374e-03, -1.9329e-03, -2.2212e-03, -2.3760e-03, -2.4324e-03},
32 {-2.9549e-03, -3.1360e-03, -4.2431e-03, -8.1103e-03, -1.2989e-02, -1.6012e-02, -1.6815e-02,
33 -1.4962e-02, -1.1563e-02, -6.8581e-03, -1.7302e-03, 3.2400e-03, 7.9409e-03, 1.2528e-02,
34 1.6414e-02, 1.9394e-02, 2.1568e-02, 2.2758e-02, 2.3182e-02},
35 {1.7934e-02, 1.9304e-02, 2.4706e-02, 3.6759e-02, 4.8351e-02, 5.1049e-02, 4.5368e-02,
36 3.0864e-02, 1.2086e-02, -1.0254e-02, -3.2992e-02, -5.4495e-02, -7.4205e-02, -9.2818e-02,
37 -1.0855e-01, -1.2068e-01, -1.2954e-01, -1.3451e-01, -1.3623e-01},
38 {6.2799e-02, 6.3892e-02, 6.4943e-02, 6.4881e-02, 7.2169e-02, 9.5669e-02, 1.3082e-01,
39 1.7694e-01, 2.2559e-01, 2.7655e-01, 3.2483e-01, 3.6888e-01, 4.0783e-01, 4.4330e-01,
40 4.7317e-01, 4.9631e-01, 5.1334e-01, 5.2318e-01, 5.2651e-01},
41 {-1.4949e+00, -1.4952e+00, -1.4925e+00, -1.4889e+00, -1.4867e+00, -1.4897e+00, -1.4948e+00,
42 -1.5025e+00, -1.5084e+00, -1.5142e+00, -1.5176e+00, -1.5191e+00, -1.5187e+00, -1.5180e+00,
43 -1.5169e+00, -1.5153e+00, -1.5138e+00, -1.5125e+00, -1.5120e+00},
44 {0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
45 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
46 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00}};
47
48const double MAX_WAVELENGTH = 50.0; // max in lamda_weight table
49
50const double STEPS_PER_ANGSTROM = 100; // resolution of lamda table
51
52const int NUM_WAVELENGTHS = static_cast<int>(std::ceil(MAX_WAVELENGTH * STEPS_PER_ANGSTROM));
53
54const double radtodeg = 180.0 / M_PI;
76class MANTID_CRYSTAL_DLL AnvredCorrection final : public API::Algorithm {
77public:
81 const std::string name() const override { return "AnvredCorrection"; }
83 const std::string summary() const override {
84 return "Calculates anvred correction factors for attenuation due to "
85 "absorption and scattering in a spherical sample";
86 }
87
89 int version() const override { return 1; }
90 const std::vector<std::string> seeAlso() const override { return {"LorentzCorrection"}; }
92 const std::string category() const override {
93 return "Crystal\\Corrections;CorrectionFunctions\\AbsorptionCorrections";
94 }
95 static double calc_Astar(const double theta, const double mur);
96
97protected:
102 virtual void defineProperties() { /*Empty in base class*/
103 }
106 virtual void retrieveProperties() { /*Empty in base class*/
107 }
108
112
113private:
115 void init() override;
117 void exec() override;
119 void execEvent();
121 void cleanup();
123 std::map<std::string, std::string> validateInputs() override;
124
125 void retrieveBaseProperties();
126 // void constructSample(API::Sample& sample);
127 double getEventWeight(const double lamda, const double two_theta, bool &muRTooLarge);
128 void BuildLamdaWeights();
129 double absor_sphere(const double twoth, const double wl, bool &muRTooLarge);
130 void scale_init(const Geometry::Instrument_const_sptr &inst, const double L2, const double depth, double &pathlength,
131 const std::string &bankName);
132 double scale_exec(std::string &bankName, const double lambda, const double depth,
133 const Geometry::Instrument_const_sptr &inst, const double pathlength, double eventWeight);
134
135 double m_smu;
136 double m_amu;
137 double m_radius;
138 double m_power_th;
139 std::vector<double> m_lamda_weight;
143};
144
145} // namespace Crystal
146} // namespace Mantid
const std::vector< double > * lambda
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
Calculates anvred correction factors for attenuation due to absorption and scattering in a spherical ...
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.
const std::string summary() const override
Summary of algorithms purpose.
double m_radius
sample radius in cm
int version() const override
Algorithm's version for identification overriding a virtual method.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
virtual void retrieveProperties()
A virtual function in which additional properties should be retrieved into member variables.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
double m_amu
linear absoprtion coefficient in 1/cm
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.
API::MatrixWorkspace_sptr m_inputWS
A pointer to the input workspace.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
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 MAX_WAVELENGTH
const double STEPS_PER_ANGSTROM
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
Helper class which provides the Collimation Length for SANS instruments.