46 in.open(filename.c_str(), std::ios::in);
55 std::string convention = ConfigService::Instance().getString(
"Q.convention");
56 if (convention ==
"Crystallography")
60 detector->
setPos(0.0, 0.0, 0.0);
62 inst->markAsDetector(detector);
65 inst->markAsSamplePos(sample);
67 source->
setPos(0.0, 0.0, -1.0);
69 inst->markAsSource(source);
73 double mu1 = 0.0, mu2 = 0.0, wl1 = 0.0, wl2 = 0.0, sc1 = 0.0, astar1 = 0.0;
76 double h = 0.0, k = 0.0, l = 0.0,
m = 0.0,
n = 0.0, p = 0.0;
79 if (line.length() < 95) {
82 }
else if (line.length() == 101) {
85 }
else if (line.length() == 157) {
93 h = std::stod(line.substr(0, 4));
94 k = std::stod(line.substr(4, 4));
95 l = std::stod(line.substr(8, 4));
96 if (
h == 0.0 && k == 0.0 && l == 0.0) {
103 m = std::stod(line.substr(12, 4));
104 n = std::stod(line.substr(16, 4));
105 p = std::stod(line.substr(20, 4));
109 double Inti = std::stod(line.substr(12 + offset, 8));
110 double SigI = std::stod(line.substr(20 + offset, 8));
111 double wl = std::stod(line.substr(32 + offset, 8));
112 double tbar, trans, scattering;
116 tbar = std::stod(line.substr(40 + offset, 8));
122 run = std::stoi(line.substr(48 + offset, 6));
123 seqNum = std::stoi(line.substr(54 + offset, 7));
124 trans = std::stod(line.substr(61 + offset, 7));
125 bank = std::stoi(line.substr(68 + offset, 4));
126 scattering = std::stod(line.substr(72 + offset, 9));
129 mu1 = -std::log(trans) / tbar;
132 astar1 = 1.0 / trans;
135 mu2 = -std::log(trans) / tbar;
139 Peak peak(inst, scattering, wl);
140 peak.
setHKL(qSign *
h, qSign * k, qSign * l);
147 std::ostringstream oss;
148 oss <<
"bank" << bank;
149 std::string bankName = oss.str();
153 int col = std::stoi(line.substr(142, 7));
154 int row = std::stoi(line.substr(149, 7));
164 double amu = (mu2 - 1.0 * mu1) / (-1.0 * wl1 + wl2);
165 double smu = mu1 - wl1 * amu;
166 double theta = sc1 *
radtodeg * 0.5;
170 if (std::isfinite(astar1) && astar1 >= 1) {
171 const size_t ndeg =
sizeof pc /
sizeof pc[0];
173 std::vector<double> murs;
175 auto ith_lo =
static_cast<size_t>(theta / 5.);
176 for (
size_t ith = ith_lo; ith < ith_lo + 2; ith++) {
177 for (
size_t ideg = 0; ideg < ndeg; ideg++) {
178 coefs[ideg] =
pc[ndeg - 1 - ideg][ith];
180 coefs[0] = coefs[0] - std::log(1.0 / astar1);
181 double roots[2 * (ndeg - 1)];
182 gsl_poly_complex_workspace *w = gsl_poly_complex_workspace_alloc(ndeg);
183 gsl_poly_complex_solve(coefs, ndeg, w, roots);
184 gsl_poly_complex_workspace_free(w);
186 for (
size_t irt = 0; irt < ndeg - 1; irt++) {
187 if (roots[2 * irt] > 0 && roots[2 * irt] < 9 && std::abs(roots[2 * irt + 1]) < 1e-15) {
188 murs.emplace_back(roots[2 * irt]);
192 if (murs.size() == 2) {
193 double frac = (theta -
static_cast<double>(ith_lo) * 5.0) / 5.0;
194 radius = (murs[0] * (1 - frac) + murs[1] * frac) / mu1;
195 g_log.
notice() <<
"LinearScatteringCoef = " << smu <<
" LinearAbsorptionCoef = " << amu <<
" Radius = " << radius
196 <<
" calculated from tbar and transmission of 2 peaks\n";
198 g_log.
warning() <<
"Radius set to 0.0 cm - failed to find physical root to polynomial in AnvredCorrections\n";
201 g_log.
warning() <<
"Radius set to 0.0 cm - non-physical transmission supplied.\n";
206 NeutronAtom neutron(0, 0, 0.0, 0.0, smu, 0.0, smu, amu);
208 std::shared_ptr<IObject>(ws->sample().getShape().cloneWithMaterial(
Material(
"SetInLoadHKL", neutron, 1.0)));
209 ws->mutableSample().setShape(shape);
211 setProperty(
"OutputWorkspace", std::dynamic_pointer_cast<PeaksWorkspace>(ws));