Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
2062d0ef
Commit
2062d0ef
authored
May 18, 2020
by
Stephen
Browse files
Rename algorithm to LoadMuonNexusV2
parent
f388655a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Framework/DataHandling/CMakeLists.txt
View file @
2062d0ef
...
...
@@ -86,8 +86,8 @@ set(SRC_FILES
src/LoadMuonNexus.cpp
src/LoadMuonNexus1.cpp
src/LoadMuonNexus2.cpp
src/LoadMuonNexus
3
.cpp
src/LoadMuonNexus
3
Helper.cpp
src/LoadMuonNexus
V2
.cpp
src/LoadMuonNexus
V2
Helper.cpp
src/LoadMuonStrategy.cpp
src/SinglePeriodLoadMuonStrategy.cpp
src/LoadNXSPE.cpp
...
...
@@ -300,8 +300,8 @@ set(INC_FILES
inc/MantidDataHandling/LoadMuonNexus.h
inc/MantidDataHandling/LoadMuonNexus1.h
inc/MantidDataHandling/LoadMuonNexus2.h
inc/MantidDataHandling/LoadMuonNexus
3
.h
inc/MantidDataHandling/LoadMuonNexus
3
Helper.h
inc/MantidDataHandling/LoadMuonNexus
V2
.h
inc/MantidDataHandling/LoadMuonNexus
V2
Helper.h
inc/MantidDataHandling/LoadMuonStrategy.h
inc/MantidDataHandling/SinglePeriodLoadMuonStrategy.h
inc/MantidDataHandling/LoadNXSPE.h
...
...
@@ -504,7 +504,7 @@ set(TEST_FILES
LoadMuonLogTest.h
LoadMuonNexus1Test.h
LoadMuonNexus2Test.h
LoadMuonNexus
3
Test.h
LoadMuonNexus
V2
Test.h
LoadNXSPETest.h
LoadNXcanSASTest.h
LoadNexusLogsTest.h
...
...
Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus
3
.h
→
Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus
V2
.h
View file @
2062d0ef
...
...
@@ -5,7 +5,6 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include
"MantidAPI/Algorithm.h"
#include
"MantidAPI/IFileLoader.h"
#include
"MantidAPI/NexusFileLoader.h"
...
...
@@ -25,9 +24,9 @@
namespace
Mantid
{
namespace
DataHandling
{
/** @class LoadMuonNexus
3
LoadMuonNexus
3
.h DataHandling/LoadMuonNexus
3
.h
/** @class LoadMuonNexus
V2
LoadMuonNexus
V2
.h DataHandling/LoadMuonNexus
V2
.h
Loads a file in the Nexus Muon format
version
2 and stores it in a 2D workspace
Loads a file in the Nexus Muon format
V
2 and stores it in a 2D workspace
(Workspace2D class). LoadMuonNexus is an algorithm that loads
an HDF5 file and as such inherits from API::NexusFileLoader and
the init() & execLoader() methods.
...
...
@@ -38,7 +37,7 @@ Required Properties:
data
(a multiperiod file will store higher periods in workspaces called
OutputWorkspace_PeriodNo)
[ not yet implemented for Muon Nexus 2 ]</LI>
[ not yet implemented for Muon Nexus
V
2 ]</LI>
</UL>
Optional Properties: (note that these options are not available if reading a
...
...
@@ -51,12 +50,12 @@ multiperiod file)
@author Stephen Smith, ISIS
*/
class
DLLExport
LoadMuonNexus
3
:
public
API
::
NexusFileLoader
{
class
DLLExport
LoadMuonNexus
V2
:
public
API
::
NexusFileLoader
{
public:
// Default constructor
LoadMuonNexus
3
();
LoadMuonNexus
V2
();
/// Algorithm's name for identification overriding a virtual method
const
std
::
string
name
()
const
override
{
return
"LoadMuonNexus
3
"
;
}
const
std
::
string
name
()
const
override
{
return
"LoadMuonNexus
V2
"
;
}
/// Summary of algorithms purpose
const
std
::
string
summary
()
const
override
{
return
"Loads a Muon Nexus V2 data file and stores it in a 2D "
...
...
@@ -83,8 +82,6 @@ private:
void
loadMuonProperties
(
const
NeXus
::
NXEntry
&
entry
);
/// The name and path of the input file
std
::
string
m_filename
;
/// The sample name read from Nexus
std
::
string
m_sampleName
;
/// The number of the input entry
int64_t
m_entrynumber
;
/// The number of periods in the raw file
...
...
@@ -93,8 +90,6 @@ private:
bool
m_isFileMultiPeriod
;
// Are multi periods loaded
bool
m_multiPeriodsLoaded
;
/// The group which each detector belongs to in order
std
::
vector
<
specnum_t
>
m_groupings
;
// The loading strategy used
std
::
unique_ptr
<
LoadMuonStrategy
>
m_loadMuonStrategy
;
};
...
...
Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus
3
Helper.h
→
Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus
V2
Helper.h
View file @
2062d0ef
...
...
@@ -19,7 +19,7 @@
namespace
Mantid
{
namespace
DataHandling
{
namespace
LoadMuonNexus
3
Helper
{
namespace
LoadMuonNexus
V2
Helper
{
// Loads the good frame data from the nexus file
NeXus
::
NXInt
loadGoodFramesDataFromNexus
(
const
NeXus
::
NXEntry
&
entry
,
...
...
Framework/DataHandling/inc/MantidDataHandling/LoadMuonStrategy.h
View file @
2062d0ef
...
...
@@ -46,8 +46,8 @@ protected:
const
std
::
vector
<
double
>
&
deadTimes
)
const
;
// Logger
Kernel
::
Logger
&
m_logger
;
// File
name, used for running child algorithms
std
::
string
m_filename
;
// Filename, used for running child algorithms
const
std
::
string
&
m_filename
;
};
}
// namespace DataHandling
}
// namespace Mantid
Framework/DataHandling/src/LoadMuonNexus
3
.cpp
→
Framework/DataHandling/src/LoadMuonNexus
V2
.cpp
View file @
2062d0ef
...
...
@@ -4,14 +4,14 @@
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include
"MantidDataHandling/LoadMuonNexus
3
.h"
#include
"MantidDataHandling/LoadMuonNexus
V2
.h"
#include
"MantidAPI/FileProperty.h"
#include
"MantidAPI/GroupingLoader.h"
#include
"MantidAPI/RegisterFileLoader.h"
#include
"MantidAPI/WorkspaceFactory.h"
#include
"MantidAPI/WorkspaceGroup.h"
#include
"MantidDataHandling/LoadISISNexus2.h"
#include
"MantidDataHandling/LoadMuonNexus
3
Helper.h"
#include
"MantidDataHandling/LoadMuonNexus
V2
Helper.h"
#include
"MantidDataHandling/SinglePeriodLoadMuonStrategy.h"
#include
"MantidDataObjects/Workspace2D.h"
#include
"MantidGeometry/Instrument.h"
...
...
@@ -26,7 +26,7 @@
namespace
Mantid
{
namespace
DataHandling
{
DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM
(
LoadMuonNexus
3
)
DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM
(
LoadMuonNexus
V2
)
using
namespace
Kernel
;
using
namespace
API
;
...
...
@@ -36,9 +36,8 @@ using std::size_t;
using
namespace
DataObjects
;
/// Empty default constructor
LoadMuonNexus3
::
LoadMuonNexus3
()
:
m_filename
(),
m_sampleName
(),
m_isFileMultiPeriod
(
false
),
m_multiPeriodsLoaded
(
false
)
{}
LoadMuonNexusV2
::
LoadMuonNexusV2
()
:
m_filename
(),
m_isFileMultiPeriod
(
false
),
m_multiPeriodsLoaded
(
false
)
{}
/**
* Return the confidence criteria for this algorithm can load the file
...
...
@@ -46,27 +45,27 @@ LoadMuonNexus3::LoadMuonNexus3()
* @returns An integer specifying the confidence level. 0 indicates it will not
* be used
*/
int
LoadMuonNexus
3
::
confidence
(
NexusHDF5Descriptor
&
descriptor
)
const
{
int
LoadMuonNexus
V2
::
confidence
(
NexusHDF5Descriptor
&
descriptor
)
const
{
// Without this entry we cannot use LoadISISNexus
if
(
!
descriptor
.
isEntry
(
"/raw_data_1"
,
"NXentry"
))
{
return
0
;
}
const
std
::
string
root
=
"/raw_data_1"
;
// Check if Muon source in defin
t
iion entry
// Check if Muon source in defini
t
ion entry
if
(
!
descriptor
.
isEntry
(
root
+
"/definition"
))
return
0
;
::
NeXus
::
File
file
(
descriptor
.
getFilename
());
file
.
openPath
(
root
+
"/definition"
);
std
::
string
def
=
file
.
getStrData
();
if
(
def
==
"muonTD"
||
def
==
"pulsedTD"
)
{
return
82
;
// have to return 82 to "beat" the LoadMuonNexus
V
2 algorithm,
return
82
;
// have to return 82 to "beat" the LoadMuonNexus2 algorithm,
// which returns 81 for this file as well
}
else
{
return
0
;
}
}
/// Initialization method.
void
LoadMuonNexus
3
::
init
()
{
void
LoadMuonNexus
V2
::
init
()
{
declareProperty
(
std
::
make_unique
<
FileProperty
>
(
"Filename"
,
""
,
FileProperty
::
Load
,
".nxs"
),
"The name of the Nexus file to load"
);
...
...
@@ -88,14 +87,14 @@ void LoadMuonNexus3::init() {
"0 indicates that every entry is loaded, into a separate "
"workspace within a group. "
"A positive number identifies one entry to be loaded, into "
"one wor
s
kspace"
);
"one workspace"
);
std
::
vector
<
std
::
string
>
FieldOptions
{
"Transverse"
,
"Longitudinal"
};
declareProperty
(
"MainFieldDirection"
,
"Transverse"
,
std
::
make_shared
<
StringListValidator
>
(
FieldOptions
),
"Output the main field direction if specified in Nexus file "
"(run/instrument/detector/orientation, default "
"longitudinal).
Version 1 only.
"
,
"longitudinal)."
,
Direction
::
Output
);
declareProperty
(
"TimeZero"
,
0.0
,
...
...
@@ -108,17 +107,15 @@ void LoadMuonNexus3::init() {
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
Workspace
>>
(
"DeadTimeTable"
,
""
,
Direction
::
Output
,
PropertyMode
::
Optional
),
"Table or a group of tables containing detector dead times. Version 1 "
"only."
);
"Table or a group of tables containing detector dead times."
);
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
Workspace
>>
(
"DetectorGroupingTable"
,
""
,
Direction
::
Output
,
PropertyMode
::
Optional
),
"Table or a group of tables with information about the "
"detector grouping stored in the file (if any). Version 1 only."
);
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
Workspace
>>
(
"DetectorGroupingTable"
,
""
,
Direction
::
Output
,
PropertyMode
::
Optional
),
"Table or a group of tables with information about the "
"detector grouping stored in the file (if any)."
);
}
void
LoadMuonNexus
3
::
execLoader
()
{
void
LoadMuonNexus
V2
::
execLoader
()
{
// prepare nexus entry
m_entrynumber
=
getProperty
(
"EntryNumber"
);
...
...
@@ -149,8 +146,8 @@ void LoadMuonNexus3::execLoader() {
m_loadMuonStrategy
->
loadGoodFrames
();
m_loadMuonStrategy
->
applyTimeZeroCorrection
();
// Grouping info should be returned if user has set the property
auto
loadedGrouping
=
m_loadMuonStrategy
->
loadDetectorGrouping
();
if
(
!
getPropertyValue
(
"DetectorGroupingTable"
).
empty
())
{
auto
loadedGrouping
=
m_loadMuonStrategy
->
loadDetectorGrouping
();
setProperty
(
"DetectorGroupingTable"
,
loadedGrouping
);
};
// Deadtime table should be returned if user has set the property
...
...
@@ -164,7 +161,7 @@ void LoadMuonNexus3::execLoader() {
* Determines whether the file is multi period
* If multi period the function determines whether multi periods are loaded
*/
void
LoadMuonNexus
3
::
isEntryMultiPeriod
(
const
NXEntry
&
entry
)
{
void
LoadMuonNexus
V2
::
isEntryMultiPeriod
(
const
NXEntry
&
entry
)
{
NXClass
periodClass
=
entry
.
openNXGroup
(
"periods"
);
int
numberOfPeriods
=
periodClass
.
getInt
(
"number"
);
if
(
numberOfPeriods
>
1
)
{
...
...
@@ -181,7 +178,7 @@ void LoadMuonNexus3::isEntryMultiPeriod(const NXEntry &entry) {
* Runs the child algorithm LoadISISNexus, which loads data into an output
* workspace
*/
void
LoadMuonNexus
3
::
runLoadISISNexus
()
{
void
LoadMuonNexus
V2
::
runLoadISISNexus
()
{
IAlgorithm_sptr
childAlg
=
createChildAlgorithm
(
"LoadISISNexus"
,
0
,
1
,
true
,
2
);
declareProperty
(
"LoadMonitors"
,
"Exclude"
);
// we need to set this property
...
...
@@ -194,16 +191,16 @@ void LoadMuonNexus3::runLoadISISNexus() {
* Loads Muon specific data from the nexus entry
* and sets the appropriate output properties
*/
void
LoadMuonNexus
3
::
loadMuonProperties
(
const
NXEntry
&
entry
)
{
void
LoadMuonNexus
V2
::
loadMuonProperties
(
const
NXEntry
&
entry
)
{
std
::
string
mainFieldDirection
=
LoadMuonNexus
3
Helper
::
loadMainFieldDirectionFromNexus
(
entry
);
LoadMuonNexus
V2
Helper
::
loadMainFieldDirectionFromNexus
(
entry
);
setProperty
(
"MainFieldDirection"
,
mainFieldDirection
);
double
timeZero
=
LoadMuonNexus
3
Helper
::
loadTimeZeroFromNexusFile
(
entry
);
double
timeZero
=
LoadMuonNexus
V2
Helper
::
loadTimeZeroFromNexusFile
(
entry
);
setProperty
(
"timeZero"
,
timeZero
);
auto
firstGoodData
=
LoadMuonNexus
3
Helper
::
loadFirstGoodDataFromNexus
(
entry
);
auto
firstGoodData
=
LoadMuonNexus
V2
Helper
::
loadFirstGoodDataFromNexus
(
entry
);
setProperty
(
"FirstGoodData"
,
firstGoodData
);
}
}
// namespace DataHandling
...
...
Framework/DataHandling/src/LoadMuonNexus
3
Helper.cpp
→
Framework/DataHandling/src/LoadMuonNexus
V2
Helper.cpp
View file @
2062d0ef
...
...
@@ -8,13 +8,13 @@
// These functions handle the nexus operations needed to load
// the information from the Muon Nexus V2 file
#include
"MantidDataHandling/LoadMuonNexus
3
Helper.h"
#include
"MantidDataHandling/LoadMuonNexus
V2
Helper.h"
#include
"MantidAPI/TableRow.h"
#include
"MantidAPI/WorkspaceFactory.h"
namespace
Mantid
{
namespace
DataHandling
{
namespace
LoadMuonNexus
3
Helper
{
namespace
LoadMuonNexus
V2
Helper
{
using
namespace
NeXus
;
using
namespace
Kernel
;
...
...
@@ -157,6 +157,6 @@ getLoadedDetectors(const DataObjects::Workspace2D_sptr &localWorkspace) {
return
loadedDetectors
;
}
}
// namespace LoadMuonNexus
3
Helper
}
// namespace LoadMuonNexus
V2
Helper
}
// namespace DataHandling
}
// namespace Mantid
Framework/DataHandling/src/SinglePeriodLoadMuonStrategy.cpp
View file @
2062d0ef
...
...
@@ -12,7 +12,7 @@
#include
"MantidAPI/WorkspaceFactory.h"
#include
"MantidDataHandling/ISISRunLogs.h"
#include
"MantidDataHandling/LoadMuonLog.h"
#include
"MantidDataHandling/LoadMuonNexus
3
Helper.h"
#include
"MantidDataHandling/LoadMuonNexus
V2
Helper.h"
#include
"MantidKernel/UnitFactory.h"
#include
"MantidKernel/UnitLabelTypes.h"
...
...
@@ -50,7 +50,7 @@ void SinglePeriodLoadMuonStrategy::loadMuonLogData() {
m_logger
.
error
(
"Unable to successfully run LoadMuonLog Child Algorithm"
);
}
std
::
string
mainFieldDirection
=
LoadMuonNexus
3
Helper
::
loadMainFieldDirectionFromNexus
(
m_entry
);
LoadMuonNexus
V2
Helper
::
loadMainFieldDirectionFromNexus
(
m_entry
);
// set output property and add to workspace logs
auto
&
run
=
m_workspace
->
mutableRun
();
run
.
addProperty
(
"main_field_direction"
,
mainFieldDirection
);
...
...
@@ -64,7 +64,7 @@ void SinglePeriodLoadMuonStrategy::loadGoodFrames() {
auto
&
run
=
m_workspace
->
mutableRun
();
run
.
removeProperty
(
"goodfrm"
);
NXInt
goodframes
=
LoadMuonNexus
3
Helper
::
loadGoodFramesDataFromNexus
(
NXInt
goodframes
=
LoadMuonNexus
V2
Helper
::
loadGoodFramesDataFromNexus
(
m_entry
,
m_isFileMultiPeriod
);
if
(
m_isFileMultiPeriod
)
{
...
...
@@ -82,7 +82,7 @@ void SinglePeriodLoadMuonStrategy::loadGoodFrames() {
*/
Workspace_sptr
SinglePeriodLoadMuonStrategy
::
loadDetectorGrouping
()
const
{
auto
grouping
=
LoadMuonNexus
3
Helper
::
loadDetectorGroupingFromNexus
(
auto
grouping
=
LoadMuonNexus
V2
Helper
::
loadDetectorGroupingFromNexus
(
m_entry
,
m_detectors
,
m_isFileMultiPeriod
);
DataObjects
::
TableWorkspace_sptr
table
=
createDetectorGroupingTable
(
m_detectors
,
grouping
);
...
...
@@ -133,7 +133,7 @@ SinglePeriodLoadMuonStrategy::loadDefaultDetectorGrouping() const {
*/
Workspace_sptr
SinglePeriodLoadMuonStrategy
::
loadDeadTimeTable
()
const
{
auto
deadTimes
=
LoadMuonNexus
3
Helper
::
loadDeadTimesFromNexus
(
auto
deadTimes
=
LoadMuonNexus
V2
Helper
::
loadDeadTimesFromNexus
(
m_entry
,
m_detectors
,
m_isFileMultiPeriod
);
auto
deadTimeTable
=
createDeadTimeTable
(
m_detectors
,
deadTimes
);
...
...
@@ -149,7 +149,7 @@ Workspace_sptr SinglePeriodLoadMuonStrategy::loadDeadTimeTable() const {
*/
void
SinglePeriodLoadMuonStrategy
::
applyTimeZeroCorrection
()
{
double
timeZero
=
LoadMuonNexus
3
Helper
::
loadTimeZeroFromNexusFile
(
m_entry
);
double
timeZero
=
LoadMuonNexus
V2
Helper
::
loadTimeZeroFromNexusFile
(
m_entry
);
auto
newUnit
=
std
::
dynamic_pointer_cast
<
Kernel
::
Units
::
Label
>
(
Kernel
::
UnitFactory
::
Instance
().
create
(
"Label"
));
newUnit
->
setLabel
(
"Time"
,
Kernel
::
Units
::
Symbol
::
Microsecond
);
...
...
Framework/DataHandling/test/LoadMuonNexus
3
Test.h
→
Framework/DataHandling/test/LoadMuonNexus
V2
Test.h
View file @
2062d0ef
...
...
@@ -12,7 +12,7 @@
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/Run.h"
#include
"MantidAPI/WorkspaceGroup.h"
#include
"MantidDataHandling/LoadMuonNexus
3
.h"
#include
"MantidDataHandling/LoadMuonNexus
V2
.h"
#include
"MantidDataObjects/Workspace2D.h"
#include
<cmath>
...
...
@@ -27,7 +27,7 @@ private:
// helper methods
public:
void
testExec
()
{
LoadMuonNexus
3
ld
;
LoadMuonNexus
V2
ld
;
ld
.
initialize
();
ld
.
setPropertyValue
(
"Filename"
,
"EMU00103638.nxs_v2"
);
ld
.
setPropertyValue
(
"OutputWorkspace"
,
"outWS"
);
...
...
@@ -73,5 +73,5 @@ public:
void
testDefaultLoad
()
{
loader
.
execute
();
}
private:
LoadMuonNexus
3
loader
;
LoadMuonNexus
V2
loader
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment