Unverified Commit 5c18dad3 authored by Gemma Guest's avatar Gemma Guest Committed by GitHub
Browse files

Merge pull request #29849 from mantidproject/ILL_loaders_cleanup

ILL loaders cleanup
parents b2a7f4a9 58e8b0cf
...@@ -19,6 +19,7 @@ namespace DataHandling { ...@@ -19,6 +19,7 @@ namespace DataHandling {
*/ */
class DLLExport LoadILLIndirect2 : public API::IFileLoader<Kernel::NexusDescriptor> { class DLLExport LoadILLIndirect2 : public API::IFileLoader<Kernel::NexusDescriptor> {
public: public:
LoadILLIndirect2();
/// Returns a confidence value that this algorithm can load a file /// Returns a confidence value that this algorithm can load a file
int confidence(Kernel::NexusDescriptor &descriptor) const override; int confidence(Kernel::NexusDescriptor &descriptor) const override;
...@@ -53,17 +54,17 @@ private: ...@@ -53,17 +54,17 @@ private:
std::string m_instrumentName; ///< Name of the instrument std::string m_instrumentName; ///< Name of the instrument
// Variables describing the data in the detector // Variables describing the data in the detector
size_t m_numberOfTubes{16}; // number of tubes - X size_t m_numberOfTubes; // number of tubes - X
size_t m_numberOfPixelsPerTube{128}; // number of pixels per tube - Y size_t m_numberOfPixelsPerTube; // number of pixels per tube - Y
size_t m_numberOfChannels{1024}; // time channels - Z size_t m_numberOfChannels; // time channels - Z
size_t m_numberOfSimpleDetectors{8}; // number of simple detector size_t m_numberOfSimpleDetectors; // number of simple detector
size_t m_numberOfMonitors{1}; // number of monitors size_t m_numberOfMonitors; // number of monitors
std::set<int> m_activeSDIndices; // set of Single Detector indices, std::set<int> m_activeSDIndices; // set of Single Detector indices,
// that were actually active // that were actually active
bool m_bats{false}; // A flag marking the BATS mode bool m_bats; // A flag marking the BATS mode
size_t m_firstTubeAngleRounded{251}; // A flag holding the rounded angle of the first tube size_t m_firstTubeAngleRounded; // A flag holding the rounded angle of the first tube
std::vector<std::string> m_supportedInstruments{"IN16B"}; std::vector<std::string> m_supportedInstruments;
LoadHelper m_loader; LoadHelper m_loader;
std::string m_loadOption; std::string m_loadOption;
}; };
......
...@@ -62,19 +62,19 @@ private: ...@@ -62,19 +62,19 @@ private:
API::MatrixWorkspace_sptr m_localWorkspace; API::MatrixWorkspace_sptr m_localWorkspace;
std::string m_instrumentName = ""; ///< Name of the instrument std::string m_instrumentName; ///< Name of the instrument
std::string m_instrumentPath = ""; ///< Name of the instrument path std::string m_instrumentPath; ///< Name of the instrument path
// Variables describing the data in the detector // Variables describing the data in the detector
size_t m_numberOfTubes = 0; // number of tubes - X size_t m_numberOfTubes; // number of tubes - X
size_t m_numberOfPixelsPerTube = 0; // number of pixels per tube - Y size_t m_numberOfPixelsPerTube; // number of pixels per tube - Y
size_t m_numberOfChannels = 0; // time channels - Z size_t m_numberOfChannels; // time channels - Z
size_t m_numberOfHistograms = 0; size_t m_numberOfHistograms;
/* Values parsed from the nexus file */ /* Values parsed from the nexus file */
double m_wavelength = 0; double m_wavelength;
double m_channelWidth = 0; double m_channelWidth;
double m_timeOfFlightDelay = 0; double m_timeOfFlightDelay;
std::string m_monitorName; std::string m_monitorName;
LoadHelper m_loader; LoadHelper m_loader;
......
...@@ -33,6 +33,13 @@ using namespace NeXus; ...@@ -33,6 +33,13 @@ using namespace NeXus;
// Register the algorithm into the AlgorithmFactory // Register the algorithm into the AlgorithmFactory
DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadILLIndirect2) DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadILLIndirect2)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
LoadILLIndirect2::LoadILLIndirect2()
: m_numberOfTubes{16}, m_numberOfChannels{1024}, m_numberOfSimpleDetectors{8}, m_numberOfMonitors{1}, m_bats{false},
m_firstTubeAngleRounded{251}, m_supportedInstruments{"IN16B"} {}
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name /// Algorithm's name for identification. @see Algorithm::name
const std::string LoadILLIndirect2::name() const { return "LoadILLIndirect"; } const std::string LoadILLIndirect2::name() const { return "LoadILLIndirect"; }
...@@ -217,7 +224,8 @@ void LoadILLIndirect2::loadDataDetails(NeXus::NXEntry &entry) { ...@@ -217,7 +224,8 @@ void LoadILLIndirect2::loadDataDetails(NeXus::NXEntry &entry) {
firstTubeAngle.load(); firstTubeAngle.load();
m_firstTubeAngleRounded = static_cast<size_t>(std::round(10 * firstTubeAngle[0])); m_firstTubeAngleRounded = static_cast<size_t>(std::round(10 * firstTubeAngle[0]));
} catch (...) { } catch (...) {
g_log.information() << "Unable to read first tube anlge, assuming 25.1"; m_firstTubeAngleRounded = 251;
g_log.information() << "Unable to read first tube angle, assuming 251";
} }
} else { } else {
m_numberOfSimpleDetectors = 0; m_numberOfSimpleDetectors = 0;
......
...@@ -36,14 +36,9 @@ using namespace NeXus; ...@@ -36,14 +36,9 @@ using namespace NeXus;
using Types::Core::DateAndTime; using Types::Core::DateAndTime;
namespace { namespace {
// This defines the number of detector banks in D7
constexpr size_t D7_NUMBER_BANKS = 3;
// This defines the number of physical pixels in D7 // This defines the number of physical pixels in D7
constexpr size_t D7_NUMBER_PIXELS = 132; constexpr size_t D7_NUMBER_PIXELS = 132;
// This defines the number of pixels per bank in D7 // This defines the number of monitors in the instrument.
constexpr size_t D7_NUMBER_PIXELS_BANK = 44;
// This defines the number of monitors in the instrument. If there are cases
// where this is no longer one this decleration should be moved.
constexpr size_t NUMBER_MONITORS = 2; constexpr size_t NUMBER_MONITORS = 2;
// This defines Time Of Flight measurement mode switch value // This defines Time Of Flight measurement mode switch value
constexpr size_t TOF_MODE_ON = 1; constexpr size_t TOF_MODE_ON = 1;
...@@ -320,13 +315,14 @@ void LoadILLPolarizedDiffraction::loadInstrument(const API::MatrixWorkspace_sptr ...@@ -320,13 +315,14 @@ void LoadILLPolarizedDiffraction::loadInstrument(const API::MatrixWorkspace_sptr
std::vector<double> LoadILLPolarizedDiffraction::loadTwoThetaDetectors(const API::MatrixWorkspace_sptr &workspace, std::vector<double> LoadILLPolarizedDiffraction::loadTwoThetaDetectors(const API::MatrixWorkspace_sptr &workspace,
const NXEntry &entry, const int bankId) { const NXEntry &entry, const int bankId) {
std::vector<double> twoTheta(static_cast<int>(D7_NUMBER_PIXELS_BANK)); auto const nPixelsPerBank = workspace->getInstrument()->getIntParameter("number_pixels_per_bank")[0];
std::vector<double> twoTheta(static_cast<int>(nPixelsPerBank));
if (getPropertyValue("PositionCalibration") == "Nexus") { if (getPropertyValue("PositionCalibration") == "Nexus") {
NXFloat twoThetaPixels = entry.openNXFloat("D7/Detector/bank" + std::to_string(bankId) + "_offset"); NXFloat twoThetaPixels = entry.openNXFloat("D7/Detector/bank" + std::to_string(bankId) + "_offset");
twoThetaPixels.load(); twoThetaPixels.load();
float *twoThetaDataStart = twoThetaPixels(); float *twoThetaDataStart = twoThetaPixels();
float *twoThetaDataEnd = twoThetaDataStart + D7_NUMBER_PIXELS_BANK; float *twoThetaDataEnd = twoThetaDataStart + nPixelsPerBank;
twoTheta.assign(twoThetaDataStart, twoThetaDataEnd); twoTheta.assign(twoThetaDataStart, twoThetaDataEnd);
} else { } else {
auto loadIpf = createChildAlgorithm("LoadParameterFile"); auto loadIpf = createChildAlgorithm("LoadParameterFile");
...@@ -339,7 +335,7 @@ std::vector<double> LoadILLPolarizedDiffraction::loadTwoThetaDetectors(const API ...@@ -339,7 +335,7 @@ std::vector<double> LoadILLPolarizedDiffraction::loadTwoThetaDetectors(const API
m_wavelength = currentBank->getNumberParameter("wavelength")[0]; m_wavelength = currentBank->getNumberParameter("wavelength")[0];
for (auto pixel_no = 0; pixel_no < static_cast<int>(D7_NUMBER_PIXELS_BANK); pixel_no++) { for (auto pixel_no = 0; pixel_no < static_cast<int>(nPixelsPerBank); pixel_no++) {
twoTheta[pixel_no] = currentBank->getNumberParameter("twoTheta_pixel_" + std::to_string(pixel_no + 1))[0]; twoTheta[pixel_no] = currentBank->getNumberParameter("twoTheta_pixel_" + std::to_string(pixel_no + 1))[0];
} }
} }
...@@ -375,9 +371,11 @@ std::vector<double> LoadILLPolarizedDiffraction::loadBankParameters(const API::M ...@@ -375,9 +371,11 @@ std::vector<double> LoadILLPolarizedDiffraction::loadBankParameters(const API::M
void LoadILLPolarizedDiffraction::moveTwoTheta(const NXEntry &entry, const API::MatrixWorkspace_sptr &workspace) { void LoadILLPolarizedDiffraction::moveTwoTheta(const NXEntry &entry, const API::MatrixWorkspace_sptr &workspace) {
Instrument_const_sptr instrument = workspace->getInstrument(); Instrument_const_sptr instrument = workspace->getInstrument();
auto const nBanks = instrument->getIntParameter("number_banks")[0];
auto const nPixelsPerBank = instrument->getIntParameter("number_pixels_per_bank")[0];
auto &componentInfo = workspace->mutableComponentInfo(); auto &componentInfo = workspace->mutableComponentInfo();
for (auto bank_no = 0; bank_no < static_cast<int>(D7_NUMBER_BANKS); ++bank_no) { for (auto bank_no = 0; bank_no < static_cast<int>(nBanks); ++bank_no) {
NXFloat twoThetaBank = NXFloat twoThetaBank =
entry.openNXFloat("D7/2theta/actual_bank" + std::to_string(bank_no + 2)); // detector bank IDs start at 2 entry.openNXFloat("D7/2theta/actual_bank" + std::to_string(bank_no + 2)); // detector bank IDs start at 2
twoThetaBank.load(); twoThetaBank.load();
...@@ -393,8 +391,8 @@ void LoadILLPolarizedDiffraction::moveTwoTheta(const NXEntry &entry, const API:: ...@@ -393,8 +391,8 @@ void LoadILLPolarizedDiffraction::moveTwoTheta(const NXEntry &entry, const API::
if (getPropertyValue("PositionCalibration") == "YIGFile") { if (getPropertyValue("PositionCalibration") == "YIGFile") {
bankParameters = loadBankParameters(workspace, bank_no + 2); bankParameters = loadBankParameters(workspace, bank_no + 2);
} }
for (auto pixel_no = 0; pixel_no < static_cast<int>(D7_NUMBER_PIXELS_BANK); ++pixel_no) { for (auto pixel_no = 0; pixel_no < static_cast<int>(nPixelsPerBank); ++pixel_no) {
auto const pixelIndex = bank_no * static_cast<int>(D7_NUMBER_PIXELS_BANK) + pixel_no; auto const pixelIndex = bank_no * static_cast<int>(nPixelsPerBank) + pixel_no;
auto const pixel = componentInfo.componentID(pixelIndex); auto const pixel = componentInfo.componentID(pixelIndex);
V3D position = pixel->getPos(); V3D position = pixel->getPos();
double radius, theta, phi; double radius, theta, phi;
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<parameter-file instrument="D20" valid-from="1900-01-31 23:59:59"> <parameter-file instrument="D20" valid-from="1900-01-31 23:59:59">
<component-link name="D20"> <component-link name="D20">
<!-- The detector name for the height axis used in SumOverlappingTubes --> <!-- The detector name for the height axis used in SumOverlappingTubes -->
<parameter name="detector_for_height_axis" type="string" visible="false"> <parameter name="detector_for_height_axis" type="string" visible="false">
<value val="panel_1" /> <value val="panel_1" />
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
<parameter-file instrument="D7" valid-from="1900-01-01T00:00:00"> <parameter-file instrument="D7" valid-from="1900-01-01T00:00:00">
<component-link name="D7"> <component-link name="D7">
<parameter name="number_banks" type="int" visible="false">
<value val="3" />
</parameter>
<parameter name="number_pixels_per_bank" type="int" visible="false">
<value val="44" />
</parameter>
<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser <!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser
See http://muparser.sourceforge.net/mup_features.html#idDef2 for available See http://muparser.sourceforge.net/mup_features.html#idDef2 for available
operators --> operators -->
...@@ -39,4 +46,3 @@ ...@@ -39,4 +46,3 @@
</component-link> </component-link>
</parameter-file> </parameter-file>
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