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"
13
14#include <memory>
15#include <vector>
16
17namespace Mantid {
18namespace Types {
19namespace Core {
20class DateAndTime;
21}
22} // namespace Types
23namespace Kernel {
24template <class KEYTYPE, class VALUETYPE> class Cache;
25template <typename TYPE> class TimeSeriesProperty;
26template <typename TYPE> class TimeSeriesProperty;
28using SplittingIntervalVec = std::vector<SplittingInterval>;
29class PropertyManager;
30class LogFilter;
31class TimeROI;
33} // namespace Kernel
34
35namespace API {
36
44class MANTID_API_DLL LogManager {
45public:
46 // Gets the correct log name for the matching invalid values log for a given
47 // log name
48 static std::string getInvalidValuesFilterLogName(const std::string &logName);
49
50 LogManager();
51 LogManager(const LogManager &other);
54 virtual ~LogManager();
55 LogManager &operator=(const LogManager &other);
56
57 //-------------------------------------------------------------
59 void setStartAndEndTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &end);
61 const Types::Core::DateAndTime startTime() const;
63 const Types::Core::DateAndTime endTime() const;
65 const Types::Core::DateAndTime getFirstPulseTime() const;
67 const Types::Core::DateAndTime getLastPulseTime() const;
68 //-------------------------------------------------------------
69
71 virtual void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop);
72
74 virtual void removeDataOutsideTimeROI();
75
77 LogManager *cloneInTimeROI(const Kernel::TimeROI &timeROI);
78
80 void copyAndFilterProperties(const LogManager &other, const Kernel::TimeROI &timeROI);
81
83 void filterByLog(Mantid::Kernel::LogFilter *filter,
84 const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>());
85
87 virtual size_t getMemorySize() const;
88
91 void addProperty(Kernel::Property *prop, bool overwrite = false) {
92 addProperty(std::unique_ptr<Kernel::Property>(prop), overwrite);
93 };
95 void addProperty(std::unique_ptr<Kernel::Property> prop, bool overwrite = false);
97 template <class TYPE> void addProperty(const std::string &name, const TYPE &value, bool overwrite = false);
98
99 template <class TYPE>
100 void addProperty(const std::string &name, const TYPE &value, const std::string &units, bool overwrite = false);
101
103 bool hasProperty(const std::string &name) const;
105 void removeProperty(const std::string &name, bool delProperty = true);
106 const std::vector<Kernel::Property *> &getProperties() const;
107
110 template <typename T> Kernel::TimeSeriesProperty<T> *getTimeSeriesProperty(const std::string &name) const;
113 template <typename HeldType> HeldType getPropertyValueAsType(const std::string &name) const;
115 double getPropertyAsSingleValue(const std::string &name,
116 Kernel::Math::StatisticType statistic = Kernel::Math::Mean) const;
118 int getPropertyAsIntegerValue(const std::string &name) const;
120 Kernel::Property *getProperty(const std::string &name) const;
121
127 void addLogData(Kernel::Property *p) { addLogData(std::unique_ptr<Kernel::Property>(p)); }
128
134 void addLogData(std::unique_ptr<Kernel::Property> p, bool overwrite = false) { addProperty(std::move(p), overwrite); }
135
141 Kernel::Property *getLogData(const std::string &name) const { return getProperty(name); }
146 const std::vector<Kernel::Property *> &getLogData() const { return getProperties(); }
152 void removeLogData(const std::string &name, const bool delproperty = true) {
153 return removeProperty(name, delproperty);
154 }
161 double getLogAsSingleValue(const std::string &name,
162 Kernel::Math::StatisticType statistic = Kernel::Math::Mean) const {
163 return getPropertyAsSingleValue(name, statistic);
164 }
165
167 double getTimeAveragedStd(const std::string &name) const;
169 double getTimeAveragedValue(const std::string &name) const;
170
173
175 void clearTimeSeriesLogs();
177 void clearOutdatedTimeSeriesLogValues();
178
179 const Kernel::TimeROI &getTimeROI() const;
180 virtual void setTimeROI(const Kernel::TimeROI &timeroi);
181
183 virtual void saveNexus(Nexus::File *file, const std::string &group, bool keepOpen = false) const;
184
186 virtual void loadNexus(Nexus::File *file, const std::string &group, const Mantid::Nexus::NexusDescriptor &fileInfo,
187 const std::string &prefix, bool keepOpen = false);
189 virtual void loadNexus(Nexus::File *file, const std::string &group, bool keepOpen = false);
191 void clearLogs();
192
194 void clearSingleValueCache();
195
196 // returns true if the log has a matching invalid values log filter
197 bool hasInvalidValuesFilter(const std::string &logName) const;
198
199 // returns the invalid values log if the log has a matching invalid values log filter
200 Kernel::TimeSeriesProperty<bool> *getInvalidValuesFilter(const std::string &logName) const;
201
202 bool operator==(const LogManager &other) const;
203 bool operator!=(const LogManager &other) const;
204
205 const std::string &getProtonChargeLogName() const { return PROTON_CHARGE_LOG_NAME; }
206 const std::string &getProtonChargeUnfilteredName() const { return PROTON_CHARGE_UNFILTERED_LOG_NAME; }
207
208protected:
209 bool hasStartTime() const;
210 bool hasEndTime() const;
211 bool hasValidProtonChargeLog(std::string &error) const;
212
213 void loadNexus(Nexus::File *file, const Mantid::Nexus::NexusDescriptor &fileInfo, const std::string &prefix);
215 void loadNexus(Nexus::File *file, const std::map<std::string, std::string> &entries);
217 std::unique_ptr<Kernel::PropertyManager> m_manager;
218 std::unique_ptr<Kernel::TimeROI> m_timeroi;
221 static const std::string PROTON_CHARGE_LOG_NAME;
223 static const std::string PROTON_CHARGE_UNFILTERED_LOG_NAME;
224
225private:
227 mutable std::unique_ptr<Kernel::Cache<std::pair<std::string, Kernel::Math::StatisticType>, double>>
229};
231using LogManager_sptr = std::shared_ptr<LogManager>;
233using LogManager_const_sptr = std::shared_ptr<const LogManager>;
234
242template <class TYPE> void LogManager::addProperty(const std::string &name, const TYPE &value, bool overwrite) {
243 addProperty(std::make_unique<Kernel::PropertyWithValue<TYPE>>(name, value), overwrite);
244}
245
255template <class TYPE>
256void LogManager::addProperty(const std::string &name, const TYPE &value, const std::string &units, bool overwrite) {
257 auto newProp = std::make_unique<Kernel::PropertyWithValue<TYPE>>(name, value);
258 newProp->setUnits(units);
259 addProperty(std::move(newProp), overwrite);
260}
261} // namespace API
262} // 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:44
void addLogData(Kernel::Property *p)
Add a log entry.
Definition LogManager.h:127
const std::vector< Kernel::Property * > & getLogData() const
Access all log entries.
Definition LogManager.h:146
const std::string & getProtonChargeLogName() const
Definition LogManager.h:205
std::unique_ptr< Kernel::PropertyManager > m_manager
A pointer to a property manager.
Definition LogManager.h:217
const std::string & getProtonChargeUnfilteredName() const
Definition LogManager.h:206
virtual ~LogManager()
Destructor.
Kernel::Property * getLogData(const std::string &name) const
Access a single log entry.
Definition LogManager.h:141
std::unique_ptr< Kernel::Cache< std::pair< std::string, Kernel::Math::StatisticType >, double > > m_singleValueCache
Cache for the retrieved single values.
Definition LogManager.h:228
static const std::string PROTON_CHARGE_LOG_NAME
Name of the log entry containing the proton charge when retrieved using getProtonCharge.
Definition LogManager.h:221
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition LogManager.h:91
std::unique_ptr< Kernel::TimeROI > m_timeroi
Definition LogManager.h:218
void addLogData(std::unique_ptr< Kernel::Property > p, bool overwrite=false)
Add a log entry.
Definition LogManager.h:134
double getLogAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Definition LogManager.h:161
void removeLogData(const std::string &name, const bool delproperty=true)
Remove a named log entry.
Definition LogManager.h:152
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:223
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:233
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
Definition LogManager.h:231
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:28
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.