Skip to content

Commit

Permalink
Re #11292 Merge branch 'master' into 11292_LET_cycle2015_1_changes
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/Testing/SystemTests/tests/analysis/ISIS_LETReduction.py
	Code/Mantid/scripts/Inelastic/Direct/DirectEnergyConversion.py
  • Loading branch information
abuts committed Mar 10, 2015
2 parents 870d551 + 40e5686 commit 4834942
Show file tree
Hide file tree
Showing 199 changed files with 7,425 additions and 6,878 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h
Expand Up @@ -87,7 +87,7 @@ class MANTID_API_DLL IPeak {
virtual double getL1() const = 0;
virtual double getL2() const = 0;

virtual const Mantid::Geometry::PeakShape& getPeakShape() = 0;
virtual const Mantid::Geometry::PeakShape& getPeakShape() const = 0;
};

} // namespace Mantid
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/MockObjects.h
Expand Up @@ -156,7 +156,7 @@ namespace
Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getDetectorPositionNoCheck,
Mantid::Kernel::V3D());
MOCK_METHOD0(getPeakShape, const Mantid::Geometry::PeakShape&());
MOCK_CONST_METHOD0(getPeakShape, const Mantid::Geometry::PeakShape&());
};


Expand Down
17 changes: 10 additions & 7 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -21,6 +21,7 @@ set ( SRC_FILES
src/BinaryOperateMasks.cpp
src/BinaryOperation.cpp
src/CalMuonDeadTime.cpp
src/CalculateDIFC.cpp
src/CalculateEfficiency.cpp
src/CalculateFlatBackground.cpp
src/CalculateResolution.cpp
Expand Down Expand Up @@ -277,6 +278,7 @@ set ( INC_FILES
inc/MantidAlgorithms/BinaryOperateMasks.h
inc/MantidAlgorithms/BinaryOperation.h
inc/MantidAlgorithms/CalMuonDeadTime.h
inc/MantidAlgorithms/CalculateDIFC.h
inc/MantidAlgorithms/CalculateEfficiency.h
inc/MantidAlgorithms/CalculateFlatBackground.h
inc/MantidAlgorithms/CalculateResolution.h
Expand Down Expand Up @@ -524,7 +526,6 @@ if(UNITY_BUILD)
endif(UNITY_BUILD)

set ( TEST_FILES
CalMuonDeadTimeTest.h
# CountEventsInPulsesTest.h
# UpdatePeakParameterTableTest.h
AddLogDerivativeTest.h
Expand All @@ -544,6 +545,8 @@ set ( TEST_FILES
AverageLogDataTest.h
BinaryOperateMasksTest.h
BinaryOperationTest.h
CalMuonDeadTimeTest.h
CalculateDIFCTest.h
CalculateEfficiencyTest.h
CalculateFlatBackgroundTest.h
CalculateResolutionTest.h
Expand Down Expand Up @@ -575,7 +578,7 @@ set ( TEST_FILES
ConvertToMatrixWorkspaceTest.h
ConvertToPointDataTest.h
ConvertUnitsTest.h
CopyDetectorMappingTest.h
CopyDetectorMappingTest.h
CopyInstrumentParametersTest.h
CopyLogsTest.h
CopySampleTest.h
Expand Down Expand Up @@ -609,7 +612,7 @@ set ( TEST_FILES
DiffractionFocussingTest.h
DivideTest.h
EditInstrumentGeometryTest.h
ElasticWindowTest.h
ElasticWindowTest.h
EstimateResolutionDiffractionTest.h
ExponentialCorrectionTest.h
ExponentialTest.h
Expand Down Expand Up @@ -674,7 +677,7 @@ set ( TEST_FILES
PDFFourierTransformTest.h
PauseTest.h
PerformIndexOperationsTest.h
PhaseQuadMuonTest.h
PhaseQuadMuonTest.h
PlotAsymmetryByLogValueTest.h
PlusTest.h
PointByPointVCorrectionTest.h
Expand All @@ -686,6 +689,7 @@ set ( TEST_FILES
Q1D2Test.h
Q1DWeightedTest.h
QxyTest.h
RRFMuonTest.h
RadiusSumTest.h
RayTracerTesterTest.h
ReadGroupsFromFileTest.h
Expand All @@ -699,7 +703,7 @@ set ( TEST_FILES
ReflectometryReductionOneAutoTest.h
ReflectometryReductionOneTest.h
RegroupTest.h
RemoveBackgroundTest.h
RemoveBackgroundTest.h
RemoveBinsTest.h
RemoveExpDecayTest.h
RemoveLowResTOFTest.h
Expand All @@ -712,7 +716,6 @@ set ( TEST_FILES
ResetNegativesTest.h
ResizeRectangularDetectorTest.h
RingProfileTest.h
RRFMuonTest.h
SassenaFFTTest.h
SaveGSASInstrumentFileTest.h
ScaleTest.h
Expand All @@ -739,7 +742,7 @@ set ( TEST_FILES
SumNeighboursTest.h
SumRowColumnTest.h
SumSpectraTest.h
TOFSANSResolutionByPixelTest.h
TOFSANSResolutionByPixelTest.h
TransposeTest.h
UnGroupWorkspaceTest.h
UnaryOperationTest.h
Expand Down
@@ -0,0 +1,67 @@
#ifndef MANTID_ALGORITHMS_CALCULATEDIFC_H_
#define MANTID_ALGORITHMS_CALCULATEDIFC_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/OffsetsWorkspace.h"

namespace Mantid {
namespace Algorithms {

/** CalculateDIFC : Calculate the DIFC for every pixel
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport CalculateDIFC : public API::Algorithm {
public:
CalculateDIFC();
virtual ~CalculateDIFC();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();

/// Create output workspace
void createOutputWorkspace();

/// Calculate the DIFC for every pixel
void calculate();

/// Input workspace
API::MatrixWorkspace_sptr m_inputWS;

/// Offsets workspace
DataObjects::OffsetsWorkspace_sptr m_offsetsWS;

/// Output workspace
API::MatrixWorkspace_sptr m_outputWS;
};

} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_CALCULATEDIFC_H_ */
Expand Up @@ -64,7 +64,7 @@ class DLLExport CreateSampleWorkspace : public API::Algorithm {
const std::string &functionString, bool isRandom);
Geometry::Instrument_sptr
createTestInstrumentRectangular(int num_banks, int pixels,
double pixelSpacing = 0.008);
double pixelSpacing, const double bankDistanceFromSample);
Geometry::Object_sptr createCappedCylinder(double radius, double height,
const Kernel::V3D &baseCentre,
const Kernel::V3D &axis,
Expand All @@ -85,4 +85,4 @@ class DLLExport CreateSampleWorkspace : public API::Algorithm {
} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_CREATESAMPLEWORKSPACE_H_ */
#endif /* MANTID_ALGORITHMS_CREATESAMPLEWORKSPACE_H_ */
126 changes: 126 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/CalculateDIFC.cpp
@@ -0,0 +1,126 @@
#include "MantidAlgorithms/CalculateDIFC.h"
#include "MantidDataObjects/SpecialWorkspace2D.h"
#include "MantidGeometry/IDetector.h"

namespace Mantid {
namespace Algorithms {

using Mantid::API::MatrixWorkspace;
using Mantid::API::WorkspaceProperty;
using Mantid::DataObjects::OffsetsWorkspace;
using Mantid::DataObjects::OffsetsWorkspace_sptr;
using Mantid::DataObjects::SpecialWorkspace2D;
using Mantid::DataObjects::SpecialWorkspace2D_sptr;
using Mantid::Geometry::Instrument_const_sptr;
using Mantid::Kernel::Direction;

// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(CalculateDIFC)

//----------------------------------------------------------------------------------------------
/** Constructor
*/
CalculateDIFC::CalculateDIFC() {}

//----------------------------------------------------------------------------------------------
/** Destructor
*/
CalculateDIFC::~CalculateDIFC() {}

//----------------------------------------------------------------------------------------------

/// Algorithms name for identification. @see Algorithm::name
const std::string CalculateDIFC::name() const { return "CalculateDIFC"; }

/// Algorithm's version for identification. @see Algorithm::version
int CalculateDIFC::version() const {
return 1;
};

/// Algorithm's category for identification. @see Algorithm::category
const std::string CalculateDIFC::category() const {
return "Diffraction";
}

/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string CalculateDIFC::summary() const {
return "Calculate the DIFC for every pixel";
};

//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void CalculateDIFC::init() {
declareProperty(
new WorkspaceProperty<MatrixWorkspace>("InputWorkspace", "", Direction::Input),
"Name of the workspace to have DIFC calculated from");
declareProperty(
new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace", "", Direction::Output),
"Workspace containing DIFC for each pixel");
declareProperty(
new WorkspaceProperty<OffsetsWorkspace>(
"OffsetsWorkspace", "", Direction::Input, Mantid::API::PropertyMode::Optional),
"Optional: A OffsetsWorkspace containing the calibration offsets. Either "
"this or CalibrationFile needs to be specified.");
}

//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void CalculateDIFC::exec() {
m_offsetsWS = getProperty("OffsetsWorkspace");

createOutputWorkspace();

calculate();

setProperty("OutputWorkspace", m_outputWS);
}

void CalculateDIFC::createOutputWorkspace() {
m_inputWS = getProperty("InputWorkspace");

m_outputWS =
boost::dynamic_pointer_cast<MatrixWorkspace>(SpecialWorkspace2D_sptr(
new SpecialWorkspace2D(m_inputWS->getInstrument())));
m_outputWS->setTitle("DIFC workspace");

return;
}

void CalculateDIFC::calculate() {
Instrument_const_sptr instrument = m_inputWS->getInstrument();

SpecialWorkspace2D_sptr localWS =
boost::dynamic_pointer_cast<SpecialWorkspace2D>(m_outputWS);

double l1;
Kernel::V3D beamline, samplePos;
double beamline_norm;
instrument->getInstrumentParameters(l1, beamline, beamline_norm, samplePos);

// To get all the detector ID's
detid2det_map allDetectors;
instrument->getDetectors(allDetectors);

// Now go through all
detid2det_map::const_iterator it = allDetectors.begin();
for (; it != allDetectors.end(); ++it) {
Geometry::IDetector_const_sptr det = it->second;
if ((!det->isMasked()) && (!det->isMonitor())) {
const detid_t detID = it->first;
double offset = 0.;
if (m_offsetsWS)
offset = m_offsetsWS->getValue(detID, 0.);

double difc = Geometry::Instrument::calcConversion(
l1, beamline, beamline_norm, samplePos, det, offset);
difc = 1. / difc; // calcConversion gives 1/DIFC
localWS->setValue(detID, difc);
}
}

}

} // namespace Algorithms
} // namespace Mantid
25 changes: 21 additions & 4 deletions Code/Mantid/Framework/Algorithms/src/CreateSampleWorkspace.cpp
Expand Up @@ -122,6 +122,13 @@ void CreateSampleWorkspace::init() {
declareProperty("BinWidth", 200.0,
boost::make_shared<BoundedValidator<double>>(0, 100000, true),
"The bin width of the X axis (default:200).");
declareProperty("PixelSpacing", 0.008,
boost::make_shared<BoundedValidator<double>>(0, 100000, true),
"The spacing between detector pixels in M (default:0.008)");
declareProperty("BankDistanceFromSample", 5.0,
boost::make_shared<BoundedValidator<double>>(0, 1000, true),
"The distance along the beam direction from the sample to "
"bank in M (default:5.0)");
}

//----------------------------------------------------------------------------------------------
Expand All @@ -139,6 +146,8 @@ void CreateSampleWorkspace::exec() {
const double xMin = getProperty("XMin");
const double xMax = getProperty("XMax");
double binWidth = getProperty("BinWidth");
const double pixelSpacing = getProperty("PixelSpacing");
const double bankDistanceFromSample = getProperty("BankDistanceFromSample");

if (xMax <= xMin) {
throw std::invalid_argument("XMax must be larger than XMin");
Expand Down Expand Up @@ -170,8 +179,10 @@ void CreateSampleWorkspace::exec() {
m_randGen = new Kernel::MersenneTwister(seedValue);
}

Instrument_sptr inst =
createTestInstrumentRectangular(numBanks, bankPixelWidth);
// Create an instrument with one or more rectangular banks.
Instrument_sptr inst = createTestInstrumentRectangular(
numBanks, bankPixelWidth, pixelSpacing, bankDistanceFromSample);

int num_bins = static_cast<int>((xMax - xMin) / binWidth);
MatrixWorkspace_sptr ws;
if (wsType == "Event") {
Expand Down Expand Up @@ -391,10 +402,15 @@ void CreateSampleWorkspace::replaceAll(std::string &str,
* @param num_banks :: number of rectangular banks to create
* @param pixels :: number of pixels in each direction.
* @param pixelSpacing :: padding between pixels
* @param bankDistanceFromSample :: Distance of first bank from sample (defaults
*to 5.0m)
*/
Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
int num_banks, int pixels, double pixelSpacing) {
int num_banks, int pixels, double pixelSpacing,
const double bankDistanceFromSample) {
boost::shared_ptr<Instrument> testInst(new Instrument("basic_rect"));
// The instrument is going to be set up with z as the beam axis and y as the
// vertical axis.
testInst->setReferenceFrame(
boost::shared_ptr<ReferenceFrame>(new ReferenceFrame(Y, Z, Left, "")));

Expand Down Expand Up @@ -424,7 +440,8 @@ Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
}

testInst->add(bank);
bank->setPos(V3D(0.0, 0.0, 5.0 * banknum));
// Set the bank along the z-axis of the instrument. (beam direction).
bank->setPos(V3D(0.0, 0.0, bankDistanceFromSample * banknum));
}

// Define a source component
Expand Down

0 comments on commit 4834942

Please sign in to comment.