20template <
typename type> std::string convertVectorToString(
const std::vector<type> &vector) {
21 std::string stringOfVector =
"";
22 for (
const auto &
value : vector) {
25 return stringOfVector.substr(0, stringOfVector.size() - 1);
33const std::string
DETECTOR{
"instrument/detector_1"};
35const std::string
ORIENTATON{
"instrument/detector_1/orientation"};
47const std::string
TYPE{
"type"};
54using namespace Kernel;
57using namespace HistogramData;
59using namespace DataObjects;
66 if (!isFileMultiPeriod) {
71 }
catch (std::runtime_error &) {
72 throw std::runtime_error(
"Could not load good frames data from nexus file, check Nexus file");
81 }
catch (std::runtime_error &) {
82 throw std::runtime_error(
"Could not load good frames data from nexus file, check Nexus file");
91std::optional<std::vector<detid_t>>
93 bool isFileMultiPeriod,
int periodNumber) {
103 int numLoadedDetectors =
static_cast<int>(detectorsLoaded.size());
104 std::vector<detid_t> grouping;
105 grouping.reserve(numLoadedDetectors);
109 int groupingOffset = !isFileMultiPeriod ? 0 : (numLoadedDetectors) * (periodNumber - 1);
110 std::transform(detectorsLoaded.cbegin(), detectorsLoaded.cend(), std::back_inserter(grouping),
111 [&groupingData, groupingOffset](
const auto detectorNumber) {
112 return groupingData[detectorNumber - 1 + groupingOffset];
118 std::string mainFieldDirection =
"Longitudinal";
124 mainFieldDirection =
"Transverse";
126 }
catch (std::runtime_error &) {
129 return mainFieldDirection;
134 bool isFileMultiPeriod,
int periodNumber) {
138 int numLoadedDetectors =
static_cast<int>(loadedDetectors.size());
139 std::vector<double> deadTimes;
140 deadTimes.reserve(numLoadedDetectors);
145 deadTimesData.
load();
150 int deadTimeOffset = !isFileMultiPeriod ? 0 : (numLoadedDetectors) * (periodNumber - 1);
151 std::transform(loadedDetectors.cbegin(), loadedDetectors.cend(), std::back_inserter(deadTimes),
152 [deadTimesData, deadTimeOffset](
const auto detectorNumber) {
153 return deadTimesData[detectorNumber - 1 + deadTimeOffset];
166 switch (infoResolution.
type) {
174 throw std::runtime_error(
"Unsupported data type for resolution");
176 double bin =
static_cast<double>(boost::lexical_cast<int>(firstGoodBin));
177 double bin_size = resolution / 1000000.0;
178 return bin * bin_size;
179 }
catch (std::runtime_error &) {
180 throw std::runtime_error(
"Error loading FirstGoodData, check Nexus file");
191 switch (infoResolution.
type) {
199 throw std::runtime_error(
"Unsupported data type for resolution");
201 double bin =
static_cast<double>(boost::lexical_cast<int>(lastGoodBin));
202 double bin_size = resolution / 1000000.0;
203 return bin * bin_size;
204 }
catch (std::runtime_error &) {
205 throw std::runtime_error(
"Error loading LastGoodData, check Nexus file");
214 }
catch (std::runtime_error &) {
215 throw std::runtime_error(
"Could not load time zero, check Nexus file");
223 std::vector<double> timeZeroVector = timeZeroClass.
vecBuffer();
224 if (timeZeroVector.size() == 0) {
226 timeZeroVector = std::vector<double>(numSpectra, timeZero);
227 }
else if (timeZeroVector.size() != numSpectra) {
228 throw std::runtime_error(
"Time zero list size does not match number of "
229 "spectra, check Nexus file.");
232 return timeZeroVector;
241 }
catch (std::runtime_error &) {
242 throw std::runtime_error(
"Could not load sample information (temperature "
243 "and magnetic field) from nexus entry");
245 return sampleInformation;
250 return periodClass.
getInt(
"number");
262 std::vector<int> dataVector;
264 for (
int i = 0; i < numPeriods; ++i) {
265 dataVector.push_back(dataClass[i]);
293 return convertVectorToString(countsData.
vecBuffer());
double value
The value of the point.
std::string getPeriodTotalCounts() const
std::string getPeriodTypes(const int &numPeriods) const
std::vector< int > getIntVector(const int &numPeriods, const std::string &name) const
std::string loadMainFieldDirectionFromNexus()
int getNumberOfPeriods() const
double loadLastGoodDataFromNexus()
std::vector< double > loadDeadTimesFromNexus(const std::vector< detid_t > &loadedDetectors, bool isFileMultiPeriod, int periodNumber)
MuonNexus::SampleInformation loadSampleInformationFromNexus()
double loadFirstGoodDataFromNexus()
std::optional< std::vector< detid_t > > loadDetectorGroupingFromNexus(const std::vector< detid_t > &loadedDetectors, bool isFileMultiPeriod, int periodNumber)
const Nexus::NXEntry & m_entry
std::string getPeriodFramesRequested(const int &numPeriods) const
std::string getPeriodSequenceString(const int &numPeriods) const
std::string getPeriodRawFrames(const int &numPeriods) const
LoadMuonNexusV2NexusHelper(const Nexus::NXEntry &entry)
std::vector< double > loadTimeZeroListFromNexusFile(size_t numSpectra)
Nexus::NXInt loadGoodFramesDataFromNexus(bool isFileMultiPeriod)
double loadTimeZeroFromNexusFile()
std::string getPeriodOutput(const int &numPeriods) const
std::string getPeriodLabels() const
The base class for a Nexus class (group).
float getFloat(const std::string &name) const
Returns a float.
std::string getString(const std::string &name) const
Returns a string.
NXFloat openNXFloat(const std::string &name) const
Creates and opens a float dataset.
NXClass openNXGroup(const std::string &name) const
Creates and opens an arbitrary (non-standard) class (group).
NXChar openNXChar(const std::string &name) const
Creates and opens a char dataset.
NXInt openNXInt(const std::string &name) const
Creates and opens an integer dataset.
NXDouble openNXDouble(const std::string &name) const
Creates and opens a double dataset.
NXInfo getDataSetInfo(const std::string &name) const
Returns NXInfo for a dataset.
bool containsDataSet(const std::string &query) const
Returns whether an individual dataset is present.
int32_t getInt(const std::string &name) const
Returns a int.
Templated class implementation of NXDataSet.
void load()
Read all of the datablock in.
container_T< T > & vecBuffer()
Returns a the internal buffer.
NXAttributes attributes
Attributes.
Implements NXentry Nexus class.
static unsigned short constexpr INT32
static unsigned short constexpr FLOAT32
const std::string ORIENTATON
const std::string LASTGOODBIN
const std::string MAGNETICFIELD
const std::string DEADTIME
const std::string GOODFRAMES
const std::string RAWFRAMES
const std::string RESOLUTION
const std::string PERIODOUTPUT
const std::string SEQUENCES
const std::string TEMPERATURE
const std::string TIMEZERO
const std::string REQUESTED
const std::string DETECTOR
const std::string GROUPING
const std::string FIRSTGOODBIN
const std::string PERIODCOUNTS
MANTID_GEOMETRY_DLL PolygonEdge::Orientation orientation(const PolygonEdge &focusEdge, const PolygonEdge &refEdge, double &t)
Calculate the orientation type of one edge wrt to another.
NXDataSetTyped< char > NXChar
The char dataset type.
std::string to_string(const wide_integer< Bits, Signed > &n)
Structure for keeping information about a Nexus data set, such as the dimensions and the type.
NXnumtype type
type of the data, e.g. NX_CHAR, FLOAT32; see NexusFile_fwd.h