Mantid
Loading...
Searching...
No Matches
LogManager.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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
9#include "MantidAPI/DllConfig.h"
12
13#include <memory>
14#include <vector>
15
16namespace Mantid {
17namespace Types {
18namespace Core {
19class DateAndTime;
20}
21} // namespace Types
22namespace Kernel {
23template <class KEYTYPE, class VALUETYPE> class Cache;
24template <typename TYPE> class TimeSeriesProperty;
25template <typename TYPE> class TimeSeriesProperty;
27using SplittingIntervalVec = std::vector<SplittingInterval>;
28class PropertyManager;
29class LogFilter;
30class TimeROI;
32} // namespace Kernel
33
34namespace API {
35
43class MANTID_API_DLL LogManager {
44public:
45 // Gets the correct log name for the matching invalid values log for a given
46 // log name
47 static std::string getInvalidValuesFilterLogName(const std::string &logName);
48
49 LogManager();
50 LogManager(const LogManager &other);
53 virtual ~LogManager();
54 LogManager &operator=(const LogManager &other);
55
56 //-------------------------------------------------------------
58 void setStartAndEndTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &end);
60 const Types::Core::DateAndTime startTime() const;
62 const Types::Core::DateAndTime endTime() const;
64 const Types::Core::DateAndTime getFirstPulseTime() const;
66 const Types::Core::DateAndTime getLastPulseTime() const;
67 //-------------------------------------------------------------
68
70 virtual void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop);
71
73 virtual void removeDataOutsideTimeROI();
74
76 LogManager *cloneInTimeROI(const Kernel::TimeROI &timeROI);
77
79 void copyAndFilterProperties(const LogManager &other, const Kernel::TimeROI &timeROI);
80
82 void filterByLog(Mantid::Kernel::LogFilter *filter,
83 const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>());
84
86 virtual size_t getMemorySize() const;
87
90 void addProperty(Kernel::Property *prop, bool overwrite = false) {
91 addProperty(std::unique_ptr<Kernel::Property>(prop), overwrite);
92 };
94 void addProperty(std::unique_ptr<Kernel::Property> prop, bool overwrite = false);
96 template <class TYPE> void addProperty(const std::string &name, const TYPE &value, bool overwrite = false);
97
98 template <class TYPE>
99 void addProperty(const std::string &name, const TYPE &value, const std::string &units, bool overwrite = false);
100
102 bool hasProperty(const std::string &name) const;
104 void removeProperty(const std::string &name, bool delProperty = true);
105 const std::vector<Kernel::Property *> &getProperties() const;
106
109 template <typename T> Kernel::TimeSeriesProperty<T> *getTimeSeriesProperty(const std::string &name) const;
112 template <typename HeldType> HeldType getPropertyValueAsType(const std::string &name) const;
114 double getPropertyAsSingleValue(const std::string &name,
115 Kernel::Math::StatisticType statistic = Kernel::Math::Mean) const;
117 int getPropertyAsIntegerValue(const std::string &name) const;
119 Kernel::Property *getProperty(const std::string &name) const;
120
126 void addLogData(Kernel::Property *p) { addLogData(std::unique_ptr<Kernel::Property>(p)); }
127
133 void addLogData(std::unique_ptr<Kernel::Property> p, bool overwrite = false) { addProperty(std::move(p), overwrite); }
134
140 Kernel::Property *getLogData(const std::string &name) const { return getProperty(name); }
145 const std::vector<Kernel::Property *> &getLogData() const { return getProperties(); }
151 void removeLogData(const std::string &name, const bool delproperty = true) {
152 return removeProperty(name, delproperty);
153 }
160 double getLogAsSingleValue(const std::string &name,
161 Kernel::Math::StatisticType statistic = Kernel::Math::Mean) const {
162 return getPropertyAsSingleValue(name, statistic);
163 }
164
166 double getTimeAveragedStd(const std::string &name) const;
168 double getTimeAveragedValue(const std::string &name) const;
169
172
174 void clearTimeSeriesLogs();
176 void clearOutdatedTimeSeriesLogValues();
177
178 const Kernel::TimeROI &getTimeROI() const;
179 virtual void setTimeROI(const Kernel::TimeROI &timeroi);
180
182 virtual void saveNexus(Nexus::File *file, const std::string &group, bool keepOpen = false) const;
183
185 virtual void loadNexus(Nexus::File *file, std::string const &group, std::string const &prefix, bool keepOpen = false);
187 virtual void loadNexus(Nexus::File *file, std::string const &group, bool keepOpen);
189 void clearLogs();
190
192 void clearSingleValueCache();
193
194 // returns true if the log has a matching invalid values log filter
195 bool hasInvalidValuesFilter(const std::string &logName) const;
196
197 // returns the invalid values log if the log has a matching invalid values log filter
198 Kernel::TimeSeriesProperty<bool> *getInvalidValuesFilter(const std::string &logName) const;
199
200 bool operator==(const LogManager &other) const;
201 bool operator!=(const LogManager &other) const;
202
203 const std::string &getProtonChargeLogName() const { return PROTON_CHARGE_LOG_NAME; }
204 const std::string &getProtonChargeUnfilteredName() const { return PROTON_CHARGE_UNFILTERED_LOG_NAME; }
205
206protected:
207 bool hasStartTime() const;
208 bool hasEndTime() const;
209 bool hasValidProtonChargeLog(std::string &error) const;
210
211 void loadNexus(Nexus::File *file, const std::string &prefix);
213 void loadNexus(Nexus::File *file, const std::map<std::string, std::string> &entries);
215 std::unique_ptr<Kernel::PropertyManager> m_manager;
216 std::unique_ptr<Kernel::TimeROI> m_timeroi;
219 static const std::string PROTON_CHARGE_LOG_NAME;
221 static const std::string PROTON_CHARGE_UNFILTERED_LOG_NAME;
222
223private:
225 mutable std::unique_ptr<Kernel::Cache<std::pair<std::string, Kernel::Math::StatisticType>, double>>
227};
229using LogManager_sptr = std::shared_ptr<LogManager>;
231using LogManager_const_sptr = std::shared_ptr<const LogManager>;
232
240template <class TYPE> void LogManager::addProperty(const std::string &name, const TYPE &value, bool overwrite) {
241 addProperty(std::make_unique<Kernel::PropertyWithValue<TYPE>>(name, value), overwrite);
242}
243
253template <class TYPE>
254void LogManager::addProperty(const std::string &name, const TYPE &value, const std::string &units, bool overwrite) {
255 auto newProp = std::make_unique<Kernel::PropertyWithValue<TYPE>>(name, value);
256 newProp->setUnits(units);
257 addProperty(std::move(newProp), overwrite);
258}
259} // namespace API
260} // namespace Mantid
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
double error
This class contains the information about the log entries.
Definition LogManager.h:43
void addLogData(Kernel::Property *p)
Add a log entry.
Definition LogManager.h:126
const std::vector< Kernel::Property * > & getLogData() const
Access all log entries.
Definition LogManager.h:145
const std::string & getProtonChargeLogName() const
Definition LogManager.h:203
std::unique_ptr< Kernel::PropertyManager > m_manager
A pointer to a property manager.
Definition LogManager.h:215
const std::string & getProtonChargeUnfilteredName() const
Definition LogManager.h:204
virtual ~LogManager()
Destructor.
Kernel::Property * getLogData(const std::string &name) const
Access a single log entry.
Definition LogManager.h:140
std::unique_ptr< Kernel::Cache< std::pair< std::string, Kernel::Math::StatisticType >, double > > m_singleValueCache
Cache for the retrieved single values.
Definition LogManager.h:226
static const std::string PROTON_CHARGE_LOG_NAME
Name of the log entry containing the proton charge when retrieved using getProtonCharge.
Definition LogManager.h:219
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition LogManager.h:90
std::unique_ptr< Kernel::TimeROI > m_timeroi
Definition LogManager.h:216
void addLogData(std::unique_ptr< Kernel::Property > p, bool overwrite=false)
Add a log entry.
Definition LogManager.h:133
double getLogAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Definition LogManager.h:160
void removeLogData(const std::string &name, const bool delproperty=true)
Remove a named log entry.
Definition LogManager.h:151
static const std::string PROTON_CHARGE_UNFILTERED_LOG_NAME
Flag to signify if a filter has been applied to the proton charge log.
Definition LogManager.h:221
Cache is a generic caching storage class.
Definition Cache.h:27
This class is for filtering TimeSeriesProperty data.
Definition LogFilter.h:32
Property manager helper class.
The concrete, templated class for properties.
Base class for properties.
Definition Property.h:94
Class holding a start/end time and a destination for splitting event lists and logs.
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
A specialised Property class for holding a series of time-value pairs.
std::shared_ptr< const LogManager > LogManager_const_sptr
shared pointer to the logManager base class (const version)
Definition LogManager.h:231
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
Definition LogManager.h:229
StatisticType
Maps a "statistic" to a number.
Definition Statistics.h:18
Statistics getStatistics(const std::vector< TYPE > &data, const unsigned int flags=StatOptions::AllStats)
Return a statistics object for the given data set.
std::vector< SplittingInterval > SplittingIntervalVec
A typedef for splitting events according their pulse time.
Definition LogManager.h:27
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
Struct holding some useful statistics for a TimeSeriesProperty.