Mantid
Loading...
Searching...
No Matches
MuonNexusReader.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
11#include "MantidNexus/DllConfig.h"
12#include <boost/date_time/posix_time/posix_time.hpp>
13#include <climits>
14#include <nexus/NeXusFile.hpp>
15
16// class MuonNexusReader - based on ISISRAW this class implements a simple
17// reader for Nexus Muon data files.
18class MANTID_NEXUS_DLL MuonNexusReader {
34private:
36 std::string m_nexusSampleName;
37 int m_nexusLogCount = 0;
38 std::vector<bool> m_logType;
39 std::vector<std::string> m_logNames;
40 std::vector<std::string> m_logUnits;
41
42 void openFirstNXentry(NeXus::File &handle);
43 bool readMuonLogData(NeXus::File &handle);
44 std::vector<std::vector<float>> m_logValues,
46 std::vector<std::vector<std::string>> m_logStringValues;
47 std::string m_startTime;
49 std::time_t m_startTime_time_t = 0;
50 std::time_t to_time_t(const boost::posix_time::ptime &t)
51 {
58 if (t == boost::posix_time::neg_infin)
59 return 0;
60 else if (t == boost::posix_time::pos_infin)
61 return LONG_MAX;
62 boost::posix_time::ptime start(boost::gregorian::date(1970, 1, 1));
63 return (t - start).total_seconds();
64 }
65 void readPeriodInfo(NeXus::File &handle);
66
67public:
69 MuonNexusReader() = default;
71 ~MuonNexusReader() = default;
72
73 void readFromFile(const std::string &filename);
74 void readLogData(const std::string &filename);
75 void getTimeChannels(float *timebnds,
76 const int &nbnds) const;
78 std::string getSampleName() const { return m_nexusSampleName; };
79 int numberOfLogs() const;
80 int getLogLength(const int i) const;
81 std::string getLogName(const int i) const;
82 void getLogValues(const int &logNumber, const int &logSequence, std::time_t &logTime,
83 double &value);
84 void getLogStringValues(const int &logNumber, const int &logSequence, std::time_t &logTime,
85 std::string &value);
86 bool logTypeNumeric(const int i) const;
87 std::string logUnits(const int i) const;
88 // following ISISRAW.h
89 int t_nsp1 = 0;
90 int t_ntc1 = 0;
91 int t_nper = 0;
92 // for nexus histogram data
93 std::vector<float> m_correctedTimes;
94 std::vector<int> m_counts;
95 std::vector<int> m_detectorGroupings;
96 int m_numDetectors = 0;
97 std::string getInstrumentName() const;
98 int m_numPeriodSequences = 0;
99 std::string m_periodNames;
100 std::string m_periodTypes;
103 std::string m_periodsOutput;
104 std::string m_periodsCounts;
105};
double value
The value of the point.
Definition: FitMW.cpp:51
MuunNexusReader opens a Nexus file and reads certain fields expected for a ISIS Muon data file (old f...
std::string m_framesPeriodsRaw
std::vector< std::string > m_logNames
stores name read from file
std::vector< std::vector< std::string > > m_logStringValues
array of string values for i'th NXlog section
std::string m_periodsOutput
std::string m_nexusSampleName
sample name read from Nexus
std::string m_framesPeriodsRequested
std::vector< std::vector< float > > m_logTimes
arrys of times for i'th NXlog section
std::time_t to_time_t(const boost::posix_time::ptime &t)
std::string m_periodNames
std::vector< float > m_correctedTimes
temp store for corrected times
std::string getSampleName() const
std::vector< bool > m_logType
true if i'th log is numeric
std::vector< int > m_detectorGroupings
detector grouping info
std::string m_periodTypes
std::vector< std::string > m_logUnits
std::string m_nexusInstrumentName
name read from nexus file
~MuonNexusReader()=default
Default Destructor.
std::string m_startTime
string startTime which must be read from Nexus
std::string m_periodsCounts
std::vector< int > m_counts
temp store of histogram data
std::vector< std::vector< float > > m_logValues
array of values for i'th NXlog section
MuonNexusReader()=default
Default constructor.