Commit ad494764 authored by Danny Hindson's avatar Danny Hindson
Browse files

Various changes to address review comments

Update file headers to use correct year in copyright statement
Add progress reporting to the AddAbsorptionWeightedPathLengths algorithm
Remove commented out line from AddAbsorptionWeightedPathLengths.cpp
parent ada92701
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
// Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
......@@ -19,8 +19,8 @@ class Instrument;
}
namespace Algorithms {
/** Takes an existing sample log, and calculates its first or second
* derivative, and adds it as a new log.
/** Calculates the absorption weighted path length for each peak
* in a peaks workspace and saves it to the tbar column in the workspace.
@author Danny Hindson
@date 2020-05-07
......
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
......@@ -95,9 +95,14 @@ void AddAbsorptionWeightedPathLengths::exec() {
auto instrument = inputWS->getInstrument();
auto beamProfile = createBeamProfile(*instrument, inputWS->sample());
const auto npeaks = inputWS->getNumberPeaks();
// Configure progress
Progress prog(this, 0.0, 1.0, npeaks);
prog.setNotifyStep(0.01);
const std::string reportMsg = "Computing path lengths";
// Configure strategy
/*MCAbsorptionWeightedPathStrategy strategy(
*beamProfile, inputWS->sample(), nevents, maxScatterPtAttempts, g_log);*/
const int nlambda = 1;
MCAbsorptionStrategy strategy(*beamProfile, inputWS->sample(),
DeltaEMode::Elastic, nevents,
......@@ -106,7 +111,7 @@ void AddAbsorptionWeightedPathLengths::exec() {
const int seed = getProperty("SeedValue");
MersenneTwister rng(seed);
for (int i = 0; i < inputWS->getNumberPeaks(); ++i) {
for (int i = 0; i < npeaks; ++i) {
IPeak &peak = inputWS->getPeak(i);
auto peakWavelength = peak.getWavelength();
......@@ -119,6 +124,8 @@ void AddAbsorptionWeightedPathLengths::exec() {
peakWavelength); // m-1
double absWeightedPathLength = -log(absFactors[0]) / mu; // metres
peak.setAbsorptionWeightedPathLength(absWeightedPathLength * 100); // cm
prog.report(reportMsg);
}
}
......
......@@ -68,7 +68,7 @@ void MCAbsorptionStrategy::calculate(Kernel::PseudoRandomNumberGenerator &rng,
for (size_t i = 0; i < m_nevents; ++i) {
Geometry::Track beforeScatter;
Geometry::Track afterScatter;
for (int j = 0; j < nbins; j++) {
for (int j = 0; j < nbins; ++j) {
size_t attempts(0);
do {
bool success = false;
......
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory UKRI,
// Copyright &copy; 2020 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
......
......@@ -13,6 +13,7 @@
#include "MantidDataHandling/LoadBinaryStl.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadSampleShape.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidGeometry/Instrument/Goniometer.h"
#include "MantidGeometry/Objects/MeshObject.h"
#include "MantidKernel/OptionalBool.h"
......@@ -99,6 +100,22 @@ public:
TS_ASSERT_DELTA(cube->volume(), 0.000001, 0.000001);
}
void test_peak_workspace() {
LoadSampleShape alg;
alg.initialize();
const int npeaks(10);
PeaksWorkspace_sptr inputWS =
WorkspaceCreationHelper::createPeaksWorkspace(npeaks);
alg.setChild(true);
alg.setProperty("InputWorkspace", inputWS);
alg.setPropertyValue("OutputWorkspace", "__dummy_unused");
alg.setProperty("OutputWorkspace", inputWS);
alg.setPropertyValue("Filename", "cube.stl");
TS_ASSERT_THROWS_NOTHING(alg.execute());
TS_ASSERT(alg.isExecuted());
getMeshObject(alg);
}
void test_fail_off_invalid_first_line() {
LoadSampleShape alg;
loadFailureTest(alg, "invalid_first_line.off");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment