18template <
typename type> std::string convertVectorToString(
const std::vector<type> &vector) {
19 std::string stringOfVector =
"";
20 for (
const auto &
value : vector) {
23 return stringOfVector.substr(0, stringOfVector.size() - 1);
31const std::string
DETECTOR{
"instrument/detector_1"};
33const std::string
ORIENTATON{
"instrument/detector_1/orientation"};
44const std::string
RAWDATA{
"/raw_data_1"};
46const 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");
93 bool isFileMultiPeriod,
int periodNumber) {
97 int numLoadedDetectors =
static_cast<int>(detectorsLoaded.size());
98 std::vector<detid_t> grouping;
99 grouping.reserve(numLoadedDetectors);
105 int groupingOffset = !isFileMultiPeriod ? 0 : (numLoadedDetectors) * (periodNumber - 1);
106 std::transform(detectorsLoaded.cbegin(), detectorsLoaded.cend(), std::back_inserter(grouping),
107 [&groupingData, groupingOffset](
const auto detectorNumber) {
108 return groupingData[detectorNumber - 1 + groupingOffset];
114 std::string mainFieldDirection =
"Longitudinal";
120 mainFieldDirection =
"Transverse";
122 }
catch (std::runtime_error &) {
125 return mainFieldDirection;
130 bool isFileMultiPeriod,
int periodNumber) {
134 int numLoadedDetectors =
static_cast<int>(loadedDetectors.size());
135 std::vector<double> deadTimes;
136 deadTimes.reserve(numLoadedDetectors);
141 deadTimesData.
load();
146 int deadTimeOffset = !isFileMultiPeriod ? 0 : (numLoadedDetectors) * (periodNumber - 1);
147 std::transform(loadedDetectors.cbegin(), loadedDetectors.cend(), std::back_inserter(deadTimes),
148 [deadTimesData, deadTimeOffset](
const auto detectorNumber) {
149 return deadTimesData[detectorNumber - 1 + deadTimeOffset];
162 switch (infoResolution.
type) {
170 throw std::runtime_error(
"Unsupported data type for resolution");
172 double bin =
static_cast<double>(boost::lexical_cast<int>(firstGoodBin));
173 double bin_size = resolution / 1000000.0;
174 return bin * bin_size;
175 }
catch (std::runtime_error &) {
176 throw std::runtime_error(
"Error loading FirstGoodData, check Nexus file");
187 switch (infoResolution.
type) {
195 throw std::runtime_error(
"Unsupported data type for resolution");
197 double bin =
static_cast<double>(boost::lexical_cast<int>(lastGoodBin));
198 double bin_size = resolution / 1000000.0;
199 return bin * bin_size;
200 }
catch (std::runtime_error &) {
201 throw std::runtime_error(
"Error loading LastGoodData, check Nexus file");
210 }
catch (std::runtime_error &) {
211 throw std::runtime_error(
"Could not load time zero, check Nexus file");
219 std::vector<double> timeZeroVector = timeZeroClass.
vecBuffer();
220 if (timeZeroVector.size() == 0) {
222 timeZeroVector = std::vector<double>(numSpectra, timeZero);
223 }
else if (timeZeroVector.size() != numSpectra) {
224 throw std::runtime_error(
"Time zero list size does not match number of "
225 "spectra, check Nexus file.");
228 return timeZeroVector;
237 }
catch (std::runtime_error &) {
238 throw std::runtime_error(
"Could not load sample information (temperature "
239 "and magnetic field) from nexus entry");
241 return sampleInformation;
246 return periodClass.
getInt(
"number");
258 std::vector<int> dataVector;
260 for (
int i = 0; i < numPeriods; ++i) {
261 dataVector.push_back(dataClass[i]);
288 std::vector<double> countsVector;
290 for (
int i = 0; i < numPeriods; ++i) {
291 countsVector.push_back(countsData[i]);
293 return convertVectorToString(countsVector);
double value
The value of the point.
std::string getPeriodTotalCounts(const int &numPeriods) 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::string getPeriodFramesRequested(const int &numPeriods) const
std::string getPeriodSequenceString(const int &numPeriods) const
std::string getPeriodRawFrames(const int &numPeriods) const
const NeXus::NXEntry & m_entry
std::vector< detid_t > loadDetectorGroupingFromNexus(const std::vector< detid_t > &loadedDetectors, bool isFileMultiPeriod, int periodNumber)
std::vector< double > loadTimeZeroListFromNexusFile(size_t numSpectra)
NeXus::NXInt loadGoodFramesDataFromNexus(bool isFileMultiPeriod)
double loadTimeZeroFromNexusFile()
LoadMuonNexusV2NexusHelper(const NeXus::NXEntry &entry)
std::string getPeriodOutput(const int &numPeriods) const
std::string getPeriodLabels() const
The base class for a Nexus class (group).
int getInt(const std::string &name) const
Returns a int.
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.
NXClass openNXGroup(const std::string &name) const
Creates and opens an arbitrary (non-standard) class (group).
bool containsDataSet(const std::string &query) const
Returns whether an individual dataset is present.
NXInfo getDataSetInfo(const std::string &name) const
Returns NXInfo for a dataset.
float getFloat(const std::string &name) const
Returns a float.
NXFloat openNXFloat(const std::string &name) const
Creates and opens a float dataset.
NXChar openNXChar(const std::string &name) const
Creates and opens a char dataset.
std::string getString(const std::string &name) const
Returns a string.
Templated class implementation of NXDataSet.
container_T< T > & vecBuffer()
Returns a the internal buffer.
void load(const int blocksize=1, int i=-1, int j=-1, int k=-1, int l=-1) override
Implementation of the virtual NXDataSet::load(...) method.
Implements NXentry Nexus class.
NXAttributes attributes
Attributes.
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 RAWDATA
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.
std::string to_string(const wide_integer< Bits, Signed > &n)
C++ implementation of NeXus classes.
int type
type of the data, e.g. NX_CHAR, NX_FLOAT32, see napi.h