Mantid
Loading...
Searching...
No Matches
Run.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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#include "MantidAPI/Run.h"
10#include "MantidKernel/Matrix.h"
14
15#include <nexus/NeXusFile.hpp>
16
17#include <boost/lexical_cast.hpp>
18#include <memory>
19
20#include <algorithm>
21#include <numeric>
22
23namespace Mantid::API {
24
25using namespace Kernel;
26
27namespace {
29const int ADDABLES = 12;
31const std::string ADDABLE[ADDABLES] = {"tot_prtn_chrg", "rawfrm", "goodfrm", "dur",
32 "gd_prtn_chrg", "uA.hour", "monitor0_counts", "monitor1_counts",
33 "monitor2_counts", "monitor3_counts", "monitor4_counts", "monitor5_counts"};
35const char *GONIOMETER_LOG_NAME = "goniometer";
36const char *GONIOMETERS_LOG_NAME = "goniometers";
38const char *HISTO_BINS_LOG_NAME = "processed_histogram_bins";
39const char *PEAK_RADIUS_GROUP = "peak_radius";
40const char *INNER_BKG_RADIUS_GROUP = "inner_bkg_radius";
41const char *OUTER_BKG_RADIUS_GROUP = "outer_bkg_radius";
42
44Kernel::Logger g_log("Run");
45} // namespace
46
48 m_goniometers.clear();
49 m_goniometers.push_back(std::make_unique<Geometry::Goniometer>());
50}
51
52Run::Run(const Run &other) : LogManager(other), m_histoBins(other.m_histoBins) { this->copyGoniometers(other); }
53
54// Defined as default in source for forward declaration with std::unique_ptr.
55Run::~Run() = default;
56
57Run &Run::operator=(const Run &other) {
58 if (this == &other)
59 return *this;
61 copyGoniometers(other);
62 m_histoBins = other.m_histoBins;
63 return *this;
64}
65
66bool Run::operator==(const Run &other) {
67 if (m_goniometers.size() != other.m_goniometers.size())
68 return false;
69 for (size_t i = 0; i < m_goniometers.size(); i++) {
70 if (*m_goniometers[i] != *other.m_goniometers[i])
71 return false;
72 }
73 return LogManager::operator==(other) && this->m_histoBins == other.m_histoBins;
74}
75
76bool Run::operator!=(const Run &other) { return !this->operator==(other); }
77
78std::shared_ptr<Run> Run::clone() {
79 auto clone = std::make_shared<Run>();
80 for (auto property : this->m_manager->getProperties()) {
81 clone->addProperty(property->clone());
82 }
83 clone->copyGoniometers(const_cast<Run &>(*this));
84 clone->m_histoBins = this->m_histoBins;
85 return clone;
86}
87
88//-----------------------------------------------------------------------------------------------
101void Run::filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop) {
102 LogManager::filterByTime(start, stop);
103 // Re-integrate proton charge
104 this->integrateProtonCharge();
105}
106
114 // merge and copy properties where there is no risk of corrupting data
115 mergeMergables(*m_manager, *rhs.m_manager);
116
117 // Other properties are added together if they are on the approved list
118 for (const auto &name : ADDABLE) {
119 if (rhs.m_manager->existsProperty(name)) {
120 // get a pointer to the property on the right-hand side workspace
121 Property *right = rhs.m_manager->getProperty(name);
122
123 // now deal with the left-hand side
124 if (m_manager->existsProperty(name)) {
125 Property *left = m_manager->getProperty(name);
126 left->operator+=(right);
127 } else
128 // no property on the left-hand side, create one and copy the
129 // right-hand side across verbatim
130 m_manager->declareProperty(std::unique_ptr<Property>(right->clone()), "");
131 }
132 }
133 return *this;
134}
135
136//-----------------------------------------------------------------------------------------------
145void Run::splitByTime(TimeSplitterType &splitter, std::vector<LogManager *> outputs) const {
146
147 // std::vector<LogManager *> outputsBase(outputs.begin(),outputs.end());
148 LogManager::splitByTime(splitter, outputs);
149
150 // Re-integrate proton charge of all outputs
151 for (auto output : outputs) {
152 if (output) {
153 auto run = dynamic_cast<Run *>(output);
154 if (run)
156 }
157 }
158}
159
160//-----------------------------------------------------------------------------------------------
165void Run::setProtonCharge(const double charge) {
166 const std::string PROTON_CHARGE_UNITS("uA.hour");
168 addProperty(PROTON_CHARGE_LOG_NAME, charge, PROTON_CHARGE_UNITS);
169 } else {
171 charge_prop->setValue(boost::lexical_cast<std::string>(charge));
172 charge_prop->setUnits(PROTON_CHARGE_UNITS);
173 }
174}
175
176//-----------------------------------------------------------------------------------------------
182double Run::getProtonCharge() const {
183 double charge = 0.0;
184
185 if (!m_manager->existsProperty(PROTON_CHARGE_LOG_NAME) && !this->hasProperty("proton_charge")) {
186 g_log.notice() << "There is no proton charge associated with this workspace" << std::endl;
187 return charge;
188 }
189
190 if (!m_manager->existsProperty(PROTON_CHARGE_LOG_NAME)) {
192 }
193 if (m_manager->existsProperty(PROTON_CHARGE_LOG_NAME)) {
194 charge = m_manager->getProperty(PROTON_CHARGE_LOG_NAME);
195 } else {
196 g_log.warning() << PROTON_CHARGE_LOG_NAME << " log was not found. Proton Charge set to 0.0\n";
197 }
198 return charge;
199}
200
201//-----------------------------------------------------------------------------------------------
208void Run::integrateProtonCharge(const std::string &logname) const {
210
211 if (this->hasProperty(logname)) {
212 try {
213 log = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(this->getProperty(logname));
214 } catch (Exception::NotFoundError &) {
215 g_log.warning(logname + " log was not found. The value of the total proton "
216 "charge has not been set");
217 return;
218 }
219 }
220
221 if (log) {
222 const std::vector<double> logValues = log->valuesAsVector();
223 double total = std::accumulate(logValues.begin(), logValues.end(), 0.0);
224 const std::string &unit = log->units();
225 // Do we need to take account of a unit
226 if (unit.find("picoCoulomb") != std::string::npos) {
228 const double currentConversion = 1.e-6 / 3600.;
229 total *= currentConversion;
230 } else if (!unit.empty() && unit != "uAh") {
231 g_log.warning(logname + " log has units other than uAh or "
232 "picoCoulombs. The value of the total proton charge has "
233 "been left at the sum of the log values.");
234 }
235 const_cast<Run *>(this)->setProtonCharge(total);
236 } else {
237 g_log.warning(logname + " log was not a time series property. The value of the total proton "
238 "charge has not been set");
239 }
240}
241
242//-----------------------------------------------------------------------------------------------
243
251void Run::storeHistogramBinBoundaries(const std::vector<double> &histoBins) {
252 if (histoBins.size() < 2) {
253 std::ostringstream os;
254 os << "Run::storeEnergyBinBoundaries - Fewer than 2 values given, size=" << histoBins.size()
255 << ". Cannot interpret values as bin boundaries.";
256 throw std::invalid_argument(os.str());
257 }
258 if (histoBins.front() >= histoBins.back()) {
259 std::ostringstream os;
260 os << "Run::storeEnergyBinBoundaries - Inconsistent start & end values "
261 "given, size="
262 << histoBins.size() << ". Cannot interpret values as bin boundaries.";
263 throw std::out_of_range(os.str());
264 }
265 m_histoBins = histoBins;
266}
267
275std::pair<double, double> Run::histogramBinBoundaries(const double value) const {
276 if (m_histoBins.empty()) {
277 throw std::runtime_error("Run::histogramBoundaries - No energy bins have "
278 "been stored for this run");
279 }
280
281 if (value < m_histoBins.front()) {
282 std::ostringstream os;
283 os << "Run::histogramBinBoundaries- Value lower than first bin boundary. "
284 "Value= "
285 << value << ", first boundary=" << m_histoBins.front();
286 throw std::out_of_range(os.str());
287 }
288 if (value > m_histoBins.back()) {
289 std::ostringstream os;
290 os << "Run::histogramBinBoundaries- Value greater than last bin boundary. "
291 "Value= "
292 << value << ", last boundary=" << m_histoBins.back();
293 throw std::out_of_range(os.str());
294 }
296 return std::make_pair(m_histoBins[index], m_histoBins[index + 1]);
297}
298
304std::vector<double> Run::getBinBoundaries() const {
305 if (m_histoBins.empty()) {
306 throw std::runtime_error("Run::histogramBoundaries - No energy bins have "
307 "been stored for this run");
308 }
309
310 return m_histoBins;
311}
312
313//-----------------------------------------------------------------------------------------------
316size_t Run::getMemorySize() const {
317 size_t total = LogManager::getMemorySize();
318 total += sizeof(Geometry::Goniometer) * m_goniometers.size();
319 total += m_histoBins.size() * sizeof(double);
320 return total;
321}
322
325
328
329//-----------------------------------------------------------------------------------------------
336void Run::setGoniometer(const Geometry::Goniometer &goniometer, const bool useLogValues) {
337 auto old = std::move(m_goniometers);
338 try {
339 m_goniometers.emplace_back(std::make_unique<Geometry::Goniometer>(goniometer));
340 if (useLogValues)
342 } catch (std::runtime_error &) {
343 m_goniometers = std::move(old);
344 throw;
345 }
346}
347
348//-----------------------------------------------------------------------------------------------
354 auto old = std::move(m_goniometers);
355 try {
356 calculateGoniometerMatrices(goniometer);
357 } catch (std::runtime_error &) {
358 m_goniometers = std::move(old);
359 throw;
360 }
361}
362
370
371//-----------------------------------------------------------------------------------------------
373size_t Run::getNumGoniometers() const { return m_goniometers.size(); }
374
375//-----------------------------------------------------------------------------------------------
381size_t Run::addGoniometer(const Geometry::Goniometer &goniometer) {
382 m_goniometers.emplace_back(std::make_unique<Geometry::Goniometer>(goniometer));
383 return m_goniometers.size() - 1;
384}
385
386//-----------------------------------------------------------------------------------------------
389
390//-----------------------------------------------------------------------------------------------
397 if (index >= m_goniometers.size())
398 throw std::out_of_range("Run::getGoniometer() const: index is out of range.");
399 return *m_goniometers[index];
400}
401
402//-----------------------------------------------------------------------------------------------
409 if (index >= m_goniometers.size())
410 throw std::out_of_range("Run::getGoniometer() const: index is out of range.");
411 return *m_goniometers[index];
412}
413
422 if (index >= m_goniometers.size())
423 throw std::out_of_range("Run::getGoniometer() const: index is out of range.");
424 return m_goniometers[index]->getR();
425}
426
431const std::vector<Kernel::Matrix<double>> Run::getGoniometerMatrices() const {
432 std::vector<Kernel::Matrix<double>> goniometers;
433 goniometers.reserve(m_goniometers.size());
434 for (auto it = m_goniometers.begin(); it != m_goniometers.end(); ++it) {
435 goniometers.emplace_back((*it)->getR());
436 }
437 return goniometers;
438}
439
440//--------------------------------------------------------------------------------------------
446void Run::saveNexus(::NeXus::File *file, const std::string &group, bool keepOpen) const {
447 LogManager::saveNexus(file, group, true);
448
449 // write the goniometer
450 if (m_goniometers.size() == 1)
451 m_goniometers[0]->saveNexus(file, GONIOMETER_LOG_NAME);
452 else if (m_goniometers.size() > 1) {
453 file->makeGroup(GONIOMETERS_LOG_NAME, "NXcollection", true);
454 file->writeData("num_goniometer", int(m_goniometers.size()));
455 for (size_t i = 0; i < m_goniometers.size(); i++) {
456 m_goniometers[i]->saveNexus(file, "goniometer" + std::to_string(i));
457 }
458 file->closeGroup();
459 }
460
461 // write the histogram bins, if there are any
462 if (!m_histoBins.empty()) {
463 file->makeGroup(HISTO_BINS_LOG_NAME, "NXdata", true);
464 file->writeData("value", m_histoBins);
465 file->closeGroup();
466 }
467 if (this->hasProperty("PeakRadius")) {
468 const std::vector<double> &values = this->getPropertyValueAsType<std::vector<double>>("PeakRadius");
469
470 file->makeGroup(PEAK_RADIUS_GROUP, "NXdata", true);
471 file->writeData("value", values);
472 file->closeGroup();
473 }
474 if (this->hasProperty("BackgroundInnerRadius")) {
475 file->makeGroup(INNER_BKG_RADIUS_GROUP, "NXdata", true);
476 const std::vector<double> &values = this->getPropertyValueAsType<std::vector<double>>("BackgroundInnerRadius");
477 file->writeData("value", values);
478 file->closeGroup();
479 }
480 if (this->hasProperty("BackgroundOuterRadius")) {
481 file->makeGroup(OUTER_BKG_RADIUS_GROUP, "NXdata", true);
482 const std::vector<double> &values = this->getPropertyValueAsType<std::vector<double>>("BackgroundOuterRadius");
483 file->writeData("value", values);
484 file->closeGroup();
485 }
486 if (!keepOpen)
487 file->closeGroup();
488}
489
490//--------------------------------------------------------------------------------------------
498void Run::loadNexus(::NeXus::File *file, const std::string &group, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo,
499 const std::string &prefix, bool keepOpen) {
500
501 if (!group.empty()) {
502 file->openGroup(group, "NXgroup");
503 }
504
505 // Example: /MDEventWorkspace/experiment4 + / + logs
506 const std::string absoluteGroupName = prefix + "/" + group;
507 LogManager::loadNexus(file, fileInfo, absoluteGroupName);
508
509 // group hierarchy levels
510 const auto levels = std::count(absoluteGroupName.begin(), absoluteGroupName.end(), '/');
511
512 const auto &allEntries = fileInfo.getAllEntries();
513 // loop through nxClass sets
514 for (const auto &nxClassPair : allEntries) {
515 const std::set<std::string> &nxClassEntries = nxClassPair.second;
516
517 // since std::set is ordered, just find the iterators
518 // for the bounds of the current experiment number
519 // take advantage of the fact that std::set is sorted, find by prefix bounds
520 auto itLower = nxClassEntries.lower_bound(absoluteGroupName);
521 // not prefixed
522 if (itLower == nxClassEntries.end()) {
523 continue;
524 }
525 if (itLower->compare(0, absoluteGroupName.size(), absoluteGroupName) != 0) {
526 continue;
527 }
528
529 // loop through the set with prefix absoluteGroupName
530 for (auto it = itLower;
531 it != nxClassEntries.end() && it->compare(0, absoluteGroupName.size(), absoluteGroupName) == 0; ++it) {
532
533 // only next level entries
534 const std::string &absoluteEntryName = *it;
535 if (std::count(absoluteEntryName.begin(), absoluteEntryName.end(), '/') != levels + 1) {
536 continue;
537 }
538 const std::string nameClass = absoluteEntryName.substr(absoluteEntryName.find_last_of('/') + 1);
539 loadNexusCommon(file, nameClass);
540 }
541 }
542
543 if (!(group.empty() || keepOpen))
544 file->closeGroup();
545
546 if (this->hasProperty("proton_charge")) {
547 // Old files may have a proton_charge field, single value.
548 // Modern files (e.g. SNS) have a proton_charge TimeSeriesProperty.
549 PropertyWithValue<double> *charge_log =
550 dynamic_cast<PropertyWithValue<double> *>(this->getProperty("proton_charge"));
551 if (charge_log) {
552 this->setProtonCharge(boost::lexical_cast<double>(charge_log->value()));
553 }
554 }
555}
556
557//--------------------------------------------------------------------------------------------
565void Run::loadNexus(::NeXus::File *file, const std::string &group, bool keepOpen) {
566
567 if (!group.empty()) {
568 file->openGroup(group, "NXgroup");
569 }
570 std::map<std::string, std::string> entries;
571 file->getEntries(entries);
572 LogManager::loadNexus(file, entries);
573 for (const auto &name_class : entries) {
574 loadNexusCommon(file, name_class.first);
575 }
576 if (!(group.empty() || keepOpen))
577 file->closeGroup();
578
579 if (this->hasProperty("proton_charge")) {
580 // Old files may have a proton_charge field, single value.
581 // Modern files (e.g. SNS) have a proton_charge TimeSeriesProperty.
582 PropertyWithValue<double> *charge_log =
583 dynamic_cast<PropertyWithValue<double> *>(this->getProperty("proton_charge"));
584 if (charge_log) {
585 this->setProtonCharge(boost::lexical_cast<double>(charge_log->value()));
586 }
587 }
588}
589
590//-----------------------------------------------------------------------------------------------------------------------
591// Private methods
592//-----------------------------------------------------------------------------------------------------------------------
593
598 for (size_t i = 0; i < m_goniometers[0]->getNumberAxes(); ++i) {
599 const std::string axisName = m_goniometers[0]->getAxis(i).name;
600 const double minAngle = getLogAsSingleValue(axisName, Kernel::Math::Minimum);
601 const double maxAngle = getLogAsSingleValue(axisName, Kernel::Math::Maximum);
602 const double angle = getLogAsSingleValue(axisName, Kernel::Math::TimeAveragedMean);
603
604 if (minAngle != maxAngle && !(std::isnan(minAngle) && std::isnan(maxAngle))) {
605 const double lastAngle = getLogAsSingleValue(axisName, Kernel::Math::LastValue);
606 g_log.warning("Goniometer angle changed in " + axisName + " log from " +
607 boost::lexical_cast<std::string>(minAngle) + " to " + boost::lexical_cast<std::string>(maxAngle) +
608 ". Used time averaged value = " + boost::lexical_cast<std::string>(angle) + ".");
609 if (axisName == "omega") {
610 g_log.warning("To set to last angle, replace omega with " + boost::lexical_cast<std::string>(lastAngle) +
611 ": "
612 "SetGoniometer(Workspace=\'workspace\',Axis0=omega,0,1,0,"
613 "1\',Axis1='chi,0,0,1,1',Axis2='phi,0,1,0,1')");
614 } else if (axisName == "chi") {
615 g_log.warning("To set to last angle, replace chi with " + boost::lexical_cast<std::string>(lastAngle) +
616 ": "
617 "SetGoniometer(Workspace=\'workspace\',Axis0=omega,0,1,0,"
618 "1\',Axis1='chi,0,0,1,1',Axis2='phi,0,1,0,1')");
619 } else if (axisName == "phi") {
620 g_log.warning("To set to last angle, replace phi with " + boost::lexical_cast<std::string>(lastAngle) +
621 ": "
622 "SetGoniometer(Workspace=\'workspace\',Axis0=omega,0,1,0,"
623 "1\',Axis1='chi,0,0,1,1',Axis2='phi,0,1,0,1')");
624 }
625 }
626 m_goniometers[0]->setRotationAngle(i, angle);
627 }
628}
629
635 if (goniometer.getNumberAxes() == 0)
636 throw std::runtime_error("Run::calculateGoniometerMatrices must include axes for goniometer");
637
638 const size_t num_log_values = getTimeSeriesProperty<double>(goniometer.getAxis(0).name)->size();
639
640 m_goniometers.clear();
641 m_goniometers.reserve(num_log_values);
642
643 for (size_t i = 0; i < num_log_values; ++i)
644 m_goniometers.emplace_back(std::make_unique<Geometry::Goniometer>(goniometer));
645
646 for (size_t i = 0; i < goniometer.getNumberAxes(); ++i) {
647 const auto angles = getTimeSeriesProperty<double>(goniometer.getAxis(i).name)->valuesAsVector();
648 if (angles.size() != num_log_values)
649 throw std::runtime_error("Run::calculateGoniometerMatrices different "
650 "number of log entries between axes");
651
652 for (size_t j = 0; j < num_log_values; ++j) {
653 m_goniometers[j]->setRotationAngle(i, angles[j]);
654 }
655 }
656}
657
664 // get pointers to all the properties on the right-handside and prepare to
665 // loop through them
666 const std::vector<Property *> &inc = toAdd.getProperties();
667 for (auto ptr : inc) {
668 const std::string &rhs_name = ptr->name();
669 try {
670 // now get pointers to the same properties on the left-handside
671 Property *lhs_prop(sum.getProperty(rhs_name));
672 lhs_prop->merge(ptr);
673 } catch (Exception::NotFoundError &) {
674 // copy any properties that aren't already on the left hand side
675 auto copy = std::unique_ptr<Property>(ptr->clone());
676 // And we add a copy of that property to *this
677 sum.declareProperty(std::move(copy), "");
678 }
679 }
680}
681
682//-----------------------------------------------------------------------------------------------
685void Run::copyGoniometers(const Run &other) {
686 m_goniometers.clear();
687 m_goniometers.reserve(other.m_goniometers.size());
688 for (const auto &goniometer : other.m_goniometers) {
689 auto new_goniometer = std::make_unique<Geometry::Goniometer>(*goniometer);
690 m_goniometers.emplace_back(std::move(new_goniometer));
691 }
692}
693
694void Run::loadNexusCommon(::NeXus::File *file, const std::string &nameClass) {
695 if (nameClass == GONIOMETER_LOG_NAME) {
696 // Goniometer class
697 m_goniometers[0]->loadNexus(file, nameClass);
698 } else if (nameClass == GONIOMETERS_LOG_NAME) {
699 file->openGroup(nameClass, "NXcollection");
700 int num_goniometer;
701 file->readData("num_goniometer", num_goniometer);
702 m_goniometers.clear();
703 m_goniometers.reserve(num_goniometer);
704 for (int i = 0; i < num_goniometer; i++) {
705 m_goniometers.emplace_back(std::make_unique<Geometry::Goniometer>());
706 m_goniometers[i]->loadNexus(file, "goniometer" + std::to_string(i));
707 }
708 file->closeGroup();
709 } else if (nameClass == HISTO_BINS_LOG_NAME) {
710 file->openGroup(nameClass, "NXdata");
711 file->readData("value", m_histoBins);
712 file->closeGroup();
713 } else if (nameClass == PEAK_RADIUS_GROUP) {
714 file->openGroup(nameClass, "NXdata");
715 std::vector<double> values;
716 file->readData("value", values);
717 file->closeGroup();
718 this->addProperty("PeakRadius", values, true);
719 } else if (nameClass == INNER_BKG_RADIUS_GROUP) {
720 file->openGroup(nameClass, "NXdata");
721 std::vector<double> values;
722 file->readData("value", values);
723 file->closeGroup();
724 this->addProperty("BackgroundInnerRadius", values, true);
725 } else if (nameClass == OUTER_BKG_RADIUS_GROUP) {
726 file->openGroup(nameClass, "NXdata");
727 std::vector<double> values;
728 file->readData("value", values);
729 file->closeGroup();
730 this->addProperty("BackgroundOuterRadius", values, true);
731 } else if (nameClass == "proton_charge" && !this->hasProperty("proton_charge")) {
732 // Old files may have a proton_charge field, single value (not even NXlog)
733 double charge;
734 file->readData("proton_charge", charge);
735 this->setProtonCharge(charge);
736 }
737}
738
739} // namespace Mantid::API
const std::vector< double > & rhs
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
double left
Definition: LineProfile.cpp:80
double right
Definition: LineProfile.cpp:81
This class contains the information about the log entries.
Definition: LogManager.h:44
virtual size_t getMemorySize() const
Return an approximate memory size for the object in bytes.
Definition: LogManager.cpp:292
bool hasProperty(const std::string &name) const
Does the property exist on the object.
Definition: LogManager.cpp:265
virtual void loadNexus(::NeXus::File *file, const std::string &group, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &prefix, bool keepOpen=false)
Load the run from a NeXus file with a given group name.
Definition: LogManager.cpp:471
std::unique_ptr< Kernel::PropertyManager > m_manager
A pointer to a property manager.
Definition: LogManager.h:198
virtual void saveNexus(::NeXus::File *file, const std::string &group, bool keepOpen=false) const
Save the run to a NeXus file with a given group name.
Definition: LogManager.cpp:445
static const char * PROTON_CHARGE_LOG_NAME
Name of the log entry containing the proton charge when retrieved using getProtonCharge.
Definition: LogManager.h:201
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
Definition: LogManager.cpp:404
virtual void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop)
Filter the logs by time.
Definition: LogManager.cpp:196
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition: LogManager.h:79
LogManager & operator=(const LogManager &other)
Definition: LogManager.cpp:109
bool operator==(const LogManager &other) const
Definition: LogManager.cpp:588
double getLogAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Definition: LogManager.h:149
virtual void splitByTime(Kernel::TimeSplitterType &splitter, std::vector< LogManager * > outputs) const
Split the logs based on the given intervals.
Definition: LogManager.cpp:209
This class stores information regarding an experimental run as a series of log entries.
Definition: Run.h:38
void splitByTime(Kernel::TimeSplitterType &splitter, std::vector< LogManager * > outputs) const override
Split the logs based on the given intervals.
Definition: Run.cpp:145
void storeHistogramBinBoundaries(const std::vector< double > &histoBins)
Store the given values as a set of histogram bin boundaries.
Definition: Run.cpp:251
bool operator!=(const Run &other)
Definition: Run.cpp:76
void setProtonCharge(const double charge)
Set the proton charge.
Definition: Run.cpp:165
bool operator==(const Run &other)
Definition: Run.cpp:66
Run & operator+=(const Run &rhs)
Addition.
Definition: Run.cpp:113
void integrateProtonCharge(const std::string &logname="proton_charge") const
Integrate the proton charge over the whole run time - default log proton_charge.
Definition: Run.cpp:208
void copyGoniometers(const Run &other)
Copy the goniometers from another.
Definition: Run.cpp:685
std::vector< double > getBinBoundaries() const
Returns the vector of bin boundaries.
Definition: Run.cpp:304
std::vector< std::unique_ptr< Geometry::Goniometer > > m_goniometers
Goniometer for this run.
Definition: Run.h:130
size_t getNumGoniometers() const
Get the number of goniometers in the Run.
Definition: Run.cpp:373
void clearGoniometers()
Clear all goniometers on the Run.
Definition: Run.cpp:388
void calculateGoniometerMatrices(const Geometry::Goniometer &goniometer)
Calculate the gonoimeter matrices from logs.
Definition: Run.cpp:634
void setGoniometer(const Geometry::Goniometer &goniometer, const bool useLogValues)
Set a single gonoimeter & read the average values from the logs if told to do so.
Definition: Run.cpp:336
void calculateAverageGoniometerMatrix()
Calculate the average gonoimeter matrix.
Definition: Run.cpp:597
Geometry::Goniometer & mutableGoniometer()
Return reference to the first non-const Goniometer object for this run.
Definition: Run.cpp:327
const Geometry::Goniometer & getGoniometer() const
Return reference to the first const Goniometer object for this run.
Definition: Run.cpp:324
size_t getMemorySize() const override
Return an approximate memory size for the object in bytes.
Definition: Run.cpp:316
const Kernel::Matrix< double > & getGoniometerMatrix() const
Retrieve the first goniometer rotation matrix.
Definition: Run.cpp:369
void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop) override
Filter the logs by time.
Definition: Run.cpp:101
size_t addGoniometer(const Geometry::Goniometer &goniometer)
Append a goniometer to the run.
Definition: Run.cpp:381
std::shared_ptr< Run > clone()
Clone.
Definition: Run.cpp:78
double getProtonCharge() const
Get the proton charge.
Definition: Run.cpp:182
void saveNexus(::NeXus::File *file, const std::string &group, bool keepOpen=false) const override
Save the run to a NeXus file with a given group name.
Definition: Run.cpp:446
void loadNexusCommon(::NeXus::File *file, const std::string &nameClass)
Definition: Run.cpp:694
void loadNexus(::NeXus::File *file, const std::string &group, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &prefix, bool keepOpen=false) override
Load the run from a NeXus file with a given group name.
Definition: Run.cpp:498
void mergeMergables(Mantid::Kernel::PropertyManager &sum, const Mantid::Kernel::PropertyManager &toAdd)
Adds all the time series in from one property manager into another.
Definition: Run.cpp:663
std::pair< double, double > histogramBinBoundaries(const double value) const
Returns the bin boundaries for a given value.
Definition: Run.cpp:275
void setGoniometers(const Geometry::Goniometer &goniometer)
Set the gonoimeters using the individual values.
Definition: Run.cpp:353
Run & operator=(const Run &other)
Definition: Run.cpp:57
const std::vector< Kernel::Matrix< double > > getGoniometerMatrices() const
Get vector of all goniometer matrices in the Run.
Definition: Run.cpp:431
std::vector< double > m_histoBins
A set of histograms that can be stored here for future reference.
Definition: Run.h:132
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Definition: Goniometer.h:55
const GoniometerAxis & getAxis(size_t axisnumber) const
Get GoniometerAxis obfject using motor number.
Definition: Goniometer.cpp:245
Exception for when an item is not found in a collection.
Definition: Exception.h:145
void notice(const std::string &msg)
Logs at notice level.
Definition: Logger.cpp:95
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
const std::map< std::string, std::set< std::string > > & getAllEntries() const noexcept
Returns a const reference of the internal map holding all entries in the NeXus HDF5 file.
Property manager helper class.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void declareProperty(std::unique_ptr< Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
const std::vector< Property * > & getProperties() const override
Get the list of managed properties.
The concrete, templated class for properties.
std::string value() const override
Returns the value of the property as a string.
Base class for properties.
Definition: Property.h:94
virtual const std::string & units() const
Returns the units of the property, if any, as a string.
Definition: Property.cpp:179
virtual std::string setValue(const std::string &)=0
Set the value of the property via a string.
virtual void setUnits(const std::string &unit)
Sets the units of the property, as a string.
Definition: Property.cpp:186
virtual Property & merge(Property *)
Just returns the property (*this) unless overridden.
Definition: Property.h:191
A specialised Property class for holding a series of time-value pairs.
std::vector< TYPE > valuesAsVector() const
Return the time series's values (unfiltered) as a vector<TYPE>
Kernel::Logger g_log("ExperimentInfo")
static logger object
MANTID_KERNEL_DLL int getBinIndex(const std::vector< double > &bins, const double value)
Return the index into a vector of bin boundaries for a particular X value.
std::vector< SplittingInterval > TimeSplitterType
A typedef for splitting events according their pulse time.
Definition: LogManager.h:31
std::string to_string(const wide_integer< Bits, Signed > &n)