31 declareProperty(std::make_unique<FileProperty>(
"Filename",
"",
FileProperty::Load,
".hkl"),
32 "Path to an hkl file to save.");
35 "Name of the output workspace.");
47 in.open(filename.c_str(), std::ios::in);
57 if (convention ==
"Crystallography")
61 detector->
setPos(0.0, 0.0, 0.0);
63 inst->markAsDetector(detector);
66 inst->markAsSamplePos(sample);
68 source->
setPos(0.0, 0.0, -1.0);
70 inst->markAsSource(source);
74 double mu1 = 0.0, mu2 = 0.0, wl1 = 0.0, wl2 = 0.0, sc1 = 0.0, astar1 = 0.0;
77 if (line.length() > 125)
79 double h = std::stod(line.substr(0, 4));
80 double k = std::stod(line.substr(4, 4));
81 double l = std::stod(line.substr(8, 4));
82 if (
h == 0.0 && k == 0 && l == 0)
84 double Inti = std::stod(line.substr(12, 8));
85 double SigI = std::stod(line.substr(20, 8));
86 double wl = std::stod(line.substr(32, 8));
87 double tbar, trans, scattering;
91 tbar = std::stod(line.substr(40, 8));
92 run = std::stoi(line.substr(102, 6));
93 trans = std::stod(line.substr(114, 7));
94 seqNum = std::stoi(line.substr(109, 7));
95 bank = std::stoi(line.substr(121, 4));
96 scattering = std::stod(line.substr(125, 9));
98 tbar = std::stod(line.substr(40, 7));
99 run = std::stoi(line.substr(47, 7));
100 trans = std::stod(line.substr(61, 7));
101 seqNum = std::stoi(line.substr(54, 7));
102 bank = std::stoi(line.substr(68, 4));
103 scattering = std::stod(line.substr(72, 9));
107 mu1 = -std::log(trans) / tbar;
110 astar1 = 1.0 / trans;
113 mu2 = -std::log(trans) / tbar;
117 Peak peak(inst, scattering, wl);
118 peak.
setHKL(qSign *
h, qSign * k, qSign * l);
123 std::ostringstream oss;
124 oss <<
"bank" << bank;
125 std::string bankName = oss.str();
129 int col = std::stoi(line.substr(142, 7));
130 int row = std::stoi(line.substr(149, 7));
140 double amu = (mu2 - 1.0 * mu1) / (-1.0 * wl1 + wl2);
141 double smu = mu1 - wl1 * amu;
142 double theta = sc1 *
radtodeg * 0.5;
146 if (std::isfinite(astar1) && astar1 >= 1) {
147 const size_t ndeg =
sizeof pc /
sizeof pc[0];
149 std::vector<double> murs;
151 auto ith_lo =
static_cast<size_t>(theta / 5.);
152 for (
size_t ith = ith_lo; ith < ith_lo + 2; ith++) {
153 for (
size_t ideg = 0; ideg < ndeg; ideg++) {
154 coefs[ideg] =
pc[ndeg - 1 - ideg][ith];
156 coefs[0] = coefs[0] - std::log(1.0 / astar1);
157 double roots[2 * (ndeg - 1)];
158 gsl_poly_complex_workspace *w = gsl_poly_complex_workspace_alloc(ndeg);
159 gsl_poly_complex_solve(coefs, ndeg, w, roots);
160 gsl_poly_complex_workspace_free(w);
162 for (
size_t irt = 0; irt < ndeg - 1; irt++) {
163 if (roots[2 * irt] > 0 && roots[2 * irt] < 9 && std::abs(roots[2 * irt + 1]) < 1e-15) {
164 murs.emplace_back(roots[2 * irt]);
168 if (murs.size() == 2) {
169 double frac = (theta -
static_cast<double>(ith_lo) * 5.0) / 5.0;
170 radius = (murs[0] * (1 - frac) + murs[1] * frac) / mu1;
171 g_log.
notice() <<
"LinearScatteringCoef = " << smu <<
" LinearAbsorptionCoef = " << amu <<
" Radius = " <<
radius
172 <<
" calculated from tbar and transmission of 2 peaks\n";
174 g_log.
warning() <<
"Radius set to 0.0 cm - failed to find physical root to polynomial in AnvredCorrections\n";
177 g_log.
warning() <<
"Radius set to 0.0 cm - non-physical transmission supplied.\n";
182 NeutronAtom neutron(0, 0, 0.0, 0.0, smu, 0.0, smu, amu);
184 std::shared_ptr<IObject>(ws->sample().getShape().cloneWithMaterial(
Material(
"SetInLoadHKL", neutron, 1.0)));
185 ws->mutableSample().setShape(shape);
187 setProperty(
"OutputWorkspace", std::dynamic_pointer_cast<PeaksWorkspace>(ws));
#define DECLARE_ALGORITHM(classname)
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
@ Load
allowed here which will be passed to the algorithm
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
LoadHKL : Load an ISAW-style .hkl file into a PeaksWorkspace.
void exec() override
Run the algorithm.
void setSigmaIntensity(double m_sigmaIntensity) override
Set the error on the integrated peak intensity.
void setRunNumber(int m_runNumber) override
Set the run number that measured this peak.
void setPeakNumber(int m_peakNumber) override
Sets the unique peak number.
void setIntensity(double m_intensity) override
Set the integrated peak intensity.
void setHKL(double H, double K, double L) override
Set all three H,K,L indices of the peak.
Structure describing a single-crystal peak.
void setRow(int row)
For RectangularDetectors only, sets the row (y) of the pixel of the detector.
void setBankName(std::string bankName)
Set the BankName of this peak.
void setCol(int col)
For RectangularDetectors only, sets the column (x) of the pixel of the detector.
The class PeaksWorkspace stores information about a set of SCD peaks.
Component is a wrapper for a Component which can modify some of its parameters, e....
void setPos(double, double, double) override
Set the IComponent position, x, y, z respective to parent (if present)
This class represents a detector - i.e.
Object Component class, this class brings together the physical attributes of the component to the po...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
void warning(const std::string &msg)
Logs at warning level.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
A namespace containing physical constants that are required by algorithms and unit routines.
static constexpr double h
Planck constant in J*s.
@ Output
An output workspace.
Structure to store neutronic scattering information for the various elements.