Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re #11292 Merge branch 'master' into 11292_LET_cycle2015_1_changes
Conflicts: Code/Mantid/Testing/SystemTests/tests/analysis/ISIS_LETReduction.py Code/Mantid/scripts/Inelastic/Direct/DirectEnergyConversion.py
- Loading branch information
Showing
199 changed files
with
7,425 additions
and
6,878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/CalculateDIFC.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.