31#include "MantidBeamline/ComponentInfo.h"
32#include "MantidBeamline/DetectorInfo.h"
33#include "MantidBeamline/SpectrumInfo.h"
45#include "MantidTypes/SpectrumDefinition.h"
47#include <boost/algorithm/string.hpp>
48#include <boost/lexical_cast.hpp>
49#include <boost/regex.hpp>
101 m_run = other->m_run;
120 }
catch (std::exception &) {
125 std::ostringstream out;
128 const auto instName = inst->getName();
129 out <<
"Instrument: ";
130 if (!instName.empty()) {
131 out << instName <<
" (" << inst->getValidFromDate().toFormattedString(
"%Y-%b-%d") <<
" to "
132 << inst->getValidToDate().toFormattedString(
"%Y-%b-%d") <<
")";
133 const auto instFilename = inst->getFilename();
134 if (!instFilename.empty()) {
135 out <<
"Instrument from: " << instFilename;
145 for (
auto const &itFilename : paramFileVector) {
146 out <<
"Parameters from: " << itFilename;
152 std::string msgNA =
"not available";
153 if (runStart.empty())
157 out <<
"Run start: " << runStart <<
"\n";
158 out <<
"Run end: " << runEnd <<
"\n";
160 if (this->
sample().hasOrientedLattice()) {
162 out <<
"Sample: a " << std::fixed << std::setprecision(1) << latt.
a() <<
", b " << latt.
b() <<
", c " << latt.
c();
163 out <<
"; alpha " << std::fixed << std::setprecision(0) << latt.
alpha() <<
", beta " << latt.
beta() <<
", gamma "
174 if (numDets != detInfo.
size())
175 throw std::runtime_error(
"ExperimentInfo: size mismatch between "
176 "DetectorInfo and number of detectors in "
197 if (
sptr_instrument != (instr->isParametrized() ? instr->baseInstrument() : instr)) {
200 if (instr->isParametrized()) {
205 const auto &source = *instr->getParameterMap();
206 m_parmap = std::make_shared<ParameterMap>(source);
211 m_parmap->rebuildBeamlineFrom(source);
214 m_parmap = std::make_shared<ParameterMap>();
268 RTP() : radius(0.0), haveRadius(false), theta(0.0), phi(0.0) {}
275struct ParameterValue {
277 : info(paramInfo), runData(run) {}
280 if (info.m_logfileID.empty())
281 return boost::lexical_cast<double>(info.m_value);
283 const TimeROI *roi = &runData.getTimeROI();
284 return info.createParamValue(runData.getTimeSeriesProperty<
double>(info.m_logfileID), roi);
287 operator int() {
return boost::lexical_cast<int>(info.m_value); }
289 if (boost::iequals(info.m_value,
"true"))
291 else if (boost::iequals(info.m_value,
"yes"))
307bool isScaleParameter(
const std::string &
name) {
return (
name ==
"scalex" ||
name ==
"scaley"); }
309bool isRedundantPosOrRot(
const std::string &
name) {
311 return (
name.size() == 4) &&
315template <
class T> T getParam(
const std::string ¶mType,
const std::string ¶mValue) {
316 const std::string
name =
"dummy";
318 param->fromString(paramValue);
319 return param->value<T>();
322void updatePosition(
ComponentInfo &componentInfo,
const size_t compIndex,
const V3D &newRelPos) {
324 if (componentInfo.
hasParent(compIndex)) {
325 const auto parentIndex = componentInfo.
parent(compIndex);
332void updateRotation(
ComponentInfo &componentInfo,
const size_t compIndex,
const Quat &newRelRot) {
334 if (componentInfo.
hasParent(compIndex)) {
335 const auto parentIndex = componentInfo.
parent(compIndex);
341void adjustPositionsFromScaleFactor(
ComponentInfo &componentInfo,
const size_t compIndex,
const std::string ¶mName,
345 if (paramName ==
"scalex")
363 const auto &runData =
run();
374 const auto ¶mInfoFromIDF = compInfo.logfileParameters();
376 std::map<size_t, RTP> rtpParams;
386 for (
const auto &[key, paramInfo] : paramInfoFromIDF) {
387 const auto compIndex = key.first;
391 const std::string ¶mN = paramInfo->m_paramName;
397 if (paramN.compare(1, 9,
"-position") == 0) {
398 auto &rtpValues = rtpParams[compIndex];
399 double value = ParameterValue(*paramInfo, runData);
400 if (paramN.compare(0, 1,
"r") == 0) {
401 rtpValues.radius =
value;
402 rtpValues.haveRadius =
true;
403 }
else if (paramN.compare(0, 1,
"t") == 0)
404 rtpValues.theta =
value;
405 else if (paramN.compare(0, 1,
"p") == 0)
406 rtpValues.phi =
value;
407 if (rtpValues.haveRadius) {
409 pos.
spherical(rtpValues.radius, rtpValues.theta, rtpValues.phi);
415 }
catch (std::exception &exc) {
416 g_log.
information() <<
"Unable to add component parameter '" << paramN <<
"'. Error: " << exc.what();
423 for (
const auto &[compIndex, newRelPos] : posAndRot.
positions()) {
424 updatePosition(compInfo, compIndex, newRelPos);
426 for (
const auto &[compIndex, newRelRot] : posAndRot.
rotations()) {
427 updateRotation(compInfo, compIndex, newRelRot);
431 for (
const auto &item : paramMap.
entries()) {
432 if (isScaleParameter(item.second->name())) {
433 adjustPositionsFromScaleFactor(compInfo, item.first, item.second->name(), item.second->value<
double>());
466 SpectrumDefinition specDef;
467 for (
const auto detID : detIDs) {
470 specDef.add(detIndex);
471 }
catch (std::out_of_range &) {
487 throw std::runtime_error(
"ExperimentInfo::updateCachedDetectorGrouping: "
488 "Cannot update -- grouping information not "
525 return m_run.access();
556 const std::string logName = compInfo.getParameterAsString(compInfo.root(), log,
false);
557 if (logName.empty()) {
558 throw std::invalid_argument(
"ExperimentInfo::getLog - No instrument parameter named \"" + log +
559 "\". Cannot access full log name");
582 const std::string logName = compInfo.getParameterAsString(compInfo.root(), log,
false);
583 if (logName.empty()) {
584 throw std::invalid_argument(
"ExperimentInfo::getLog - No instrument parameter named \"" + log +
585 "\". Cannot access full log name");
596 const Run &thisRun =
run();
625 static const char *emodeTag =
"deltaE-mode";
626 std::string emodeStr;
627 if (
run().hasProperty(emodeTag)) {
665 const std::vector<std::string> ¶meterNames)
const {
667 for (
auto ¶meterName : parameterNames) {
670 efixed = par->value<
double>();
672 std::vector<double> efixedVec = detector->getNumberParameter(parameterName);
673 if (efixedVec.empty()) {
674 int detid = detector->getID();
676 efixedVec = detectorSingle->getNumberParameter(parameterName);
678 if (!efixedVec.empty()) {
684 std::ostringstream os;
685 os <<
"ExperimentInfo::getEFixed - Indirect mode efixed requested but "
686 "detector has no Efixed parameter attached. ID="
687 << detector->getID();
688 throw std::runtime_error(os.str());
704 for (
auto ¶meterName : {
"Ei",
"EnergyRequested",
"EnergyEstimate"}) {
711 throw std::runtime_error(
"Experiment logs do not contain an Ei "
712 "value. Have you run GetEi?");
717 throw std::runtime_error(
"ExperimentInfo::getEFixed - Indirect mode "
718 "efixed requested without a valid detector.");
721 throw std::runtime_error(
"ExperimentInfo::getEFixed - EFixed requested for "
722 "elastic mode, don't know what to do!");
731 }
catch (
const std::out_of_range &) {
751 }
catch (std::runtime_error &) {
754 date = Types::Core::DateAndTime::getCurrentTime().toISO8601String();
770 }
catch (std::runtime_error &) {
787 }
catch (std::runtime_error &) {
803 throw std::runtime_error(
"Cannot return reference to NULL DetectorInfo");
812 throw std::runtime_error(
"Cannot return reference to NULL DetectorInfo");
851 [](
char i) { return i == 1; })) {
854 [](
char i) { return i == 1; })) {
856#pragma omp parallel for
857 for (int64_t i = 0; i < size; ++i) {
874 throw std::runtime_error(
"Cannot return reference to NULL ComponentInfo");
882 throw std::runtime_error(
"Cannot return reference to NULL ComponentInfo");
908 throw std::runtime_error(
"Cannot return reference to NULL InstrumentMetadata");
915 if (spectrumDefinitions) {
916 m_spectrumInfo = std::make_unique<Beamline::SpectrumInfo>(std::move(spectrumDefinitions));
931 return compInfo.
name(compInfo.
root());
960 size_t specIndex = 0;
961 for (
const auto detID : detIDs) {
964 SpectrumDefinition specDef;
965 specDef.add(detIndex);
967 m_spectrumInfo->setSpectrumDefinition(specIndex, std::move(specDef));
985 if (saveLegacyInstrument) {
986 instrument->saveNexus(file,
"instrument");
999 bool saveLogs)
const {
1003 instrument->saveNexus(file,
"instrument");
1017 if (sampleVersion == 0) {
1020 file->openGroup(
"sample",
"NXsample");
1035 if (sampleVersion == 0) {
1038 file->openGroup(
"sample",
"NXsample");
1048 std::string ¶meterStr,
const std::string &prefix) {
1065 std::string ¶meterStr) {
1083 std::string ¶meterStr) {
1086 file->openGroup(
"instrument",
"NXinstrument");
1089 std::string instrumentName;
1090 std::string instrumentXml;
1115 file->openGroup(
"instrument",
"NXinstrument");
1118 std::string instrumentName;
1119 std::string instrumentXml;
1136 std::string &instrumentXml) {
1138 file->readData(
"name", instrumentName);
1141 file->openGroup(
"instrument_xml",
"NXnote");
1142 file->readData(
"data", instrumentXml);
1145 g_log.
debug(std::string(
"Unable to load instrument_xml: ") + ex.what());
1159 std::string &instrumentXml) {
1163 std::string instrumentFilename;
1164 if (!instrumentXml.empty()) {
1168 instrumentFilename = nxFilename;
1169 g_log.
debug() <<
"Using instrument IDF XML text contained in nexus file.\n";
1179 if (!instrumentXml.empty() && !instrumentName.empty()) {
1185 if (InstrumentDataService::Instance().doesExist(instrumentNameMangled)) {
1187 instr = InstrumentDataService::Instance().retrieve(instrumentNameMangled);
1197 instr->parseTreeAndCacheBeamline();
1200 InstrumentDataService::Instance().add(instrumentNameMangled, instr);
1216 }
catch (std::exception &e) {
1217 g_log.
error() <<
"Error loading instrument IDF file: " << filename <<
".\n";
1231 file->openGroup(
"instrument_parameter_map",
"NXnote");
1232 file->readData(
"data", parameterStr);
1235 g_log.
debug(std::string(
"Unable to load instrument_parameter_map: ") + ex.what());
1236 g_log.
information(
"Parameter map entry missing from NeXus file. Continuing without it.");
1258 const std::string visibilityKey =
"visible:";
1260 for (
auto itr = splitter.
begin(); itr !=
iend; ++itr) {
1262 if (tokens.
count() < 4)
1264 std::string comp_name = tokens[0];
1272 if (comp_name.find(
"detID:") != std::string::npos) {
1273 const auto detID =
static_cast<detid_t>(std::stoi(comp_name.substr(6)));
1277 compIndex = detInfo.
indexOf(detID);
1278 }
catch (std::out_of_range &) {
1279 g_log.
warning() <<
"Cannot find detector " << detID <<
'\n';
1283 compIndex = compInfo.indexOfFullName(comp_name);
1289 const auto *comp =
sptr_instrument->getComponentByName(comp_name).get();
1291 compIndex = compInfo.indexOfOrInvalid(comp->getComponentID());
1294 g_log.
warning() <<
"Cannot find component " << comp_name <<
'\n';
1302 std::string paramValue = tokens[3];
1303 auto size =
static_cast<int>(tokens.
count());
1304 for (
int i = 4; i < size; i++)
1305 paramValue +=
";" + tokens[i];
1306 const auto ¶mType = tokens[1];
1307 const auto ¶mName = tokens[2];
1308 auto ¶mVisibility = tokens[size - 1];
1309 if (paramVisibility.find(visibilityKey) > paramVisibility.size())
1310 paramVisibility =
"true";
1313 paramVisibility.substr(paramVisibility.find(visibilityKey) + visibilityKey.size(), paramVisibility.size());
1314 paramValue.erase(paramValue.find(visibilityKey) - 1, paramValue.size());
1316 const auto paramDescr = std::string(
"");
1317 if (paramName ==
"masked") {
1318 auto value = getParam<bool>(paramType, paramValue);
1321 const auto componentIndex = compIndex;
1322 if (!compInfo.isDetector(componentIndex)) {
1323 throw std::runtime_error(
"Found masking for a non-detector "
1324 "component. This is not possible");
1330 }
else if (isPositionParameter(paramName)) {
1335 const auto newRelPos = getParam<V3D>(paramType, paramValue);
1336 updatePosition(compInfo, compIndex, newRelPos);
1337 }
else if (isRotationParameter(paramName)) {
1342 const auto newRelRot = getParam<Quat>(paramType, paramValue);
1343 updateRotation(compInfo, compIndex, newRelRot);
1344 }
else if (!isRedundantPosOrRot(paramName)) {
1347 if (isScaleParameter(paramName))
1348 adjustPositionsFromScaleFactor(compInfo, compIndex, paramName, getParam<double>(paramType, paramValue));
1359 if (paramType ==
"fitting") {
1360 std::string fittingFunction;
1364 const auto firstComma = paramValue.find(
',');
1365 if (firstComma != std::string::npos) {
1366 const auto secondComma = paramValue.find(
',', firstComma + 1);
1367 if (secondComma != std::string::npos) {
1369 fittingFunction = paramValue.substr(firstComma + 1, secondComma - firstComma - 1);
1371 const auto firstNonSpace = fittingFunction.find_first_not_of(
" \t");
1372 if (firstNonSpace != std::string::npos) {
1373 const auto lastNonSpace = fittingFunction.find_last_not_of(
" \t");
1374 fittingFunction = fittingFunction.substr(firstNonSpace, lastNonSpace - firstNonSpace + 1);
1377 fittingFunction.clear();
1380 if (!fittingFunction.empty()) {
1381 pmap.addFittingParameter(compIndex, paramName, fittingFunction, paramValue, ¶mDescr, paramVisibility);
1383 pmap.add(paramType, compIndex, paramName, paramValue, ¶mDescr, paramVisibility);
1386 pmap.add(paramType, compIndex, paramName, paramValue, ¶mDescr, paramVisibility);
1406 const Run &runData) {
1407 const std::string &category = paramInfo.
m_type;
1408 ParameterValue paramValue(paramInfo,
1411 const std::string *pDescription =
nullptr;
1414 std::string pVisible =
"true";
1419 if (
name ==
"masked") {
1420 bool value(paramValue);
1424 throw std::runtime_error(
"Found masking for a non-detector component. This is not possible");
1430 }
else if (
name ==
"x" ||
name ==
"y" ||
name ==
"z") {
1436 }
else if (
name ==
"rot" ||
name ==
"rotx" ||
name ==
"roty" ||
name ==
"rotz") {
1439 g_log.
warning() <<
"Ignoring instrument parameter '" <<
name <<
"': it does not name a rotation axis.\n";
1441 }
else if (category ==
"fitting") {
1442 std::ostringstream str;
1452 }
else if (category ==
"string") {
1454 }
else if (category ==
"bool") {
1455 compInfo.
addBool(compIndex,
name, paramValue, pDescription, pVisible);
1456 }
else if (category ==
"int") {
1457 compInfo.
addInt(compIndex,
name, paramValue, pDescription, pVisible);
1459 compInfo.
addDouble(compIndex,
name, paramValue, pDescription, pVisible);
1474IPropertyManager::getValue<Mantid::API::ExperimentInfo_sptr>(
const std::string &
name)
const {
1479 std::string message =
1480 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<ExperimentInfo>.";
1481 throw std::runtime_error(message);
1487IPropertyManager::getValue<Mantid::API::ExperimentInfo_const_sptr>(
const std::string &
name)
const {
1490 return prop->operator()();
1492 std::string message =
1493 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<ExperimentInfo>.";
1494 throw std::runtime_error(message);
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
This class is shared by a few Workspace types and holds information related to a particular experimen...
void loadEmbeddedInstrumentInfoNexus(Nexus::File *file, std::string &instrumentName, std::string &instrumentXml)
Attempt to load instrument embedded in Nexus file. *file must have instrument group open.
Geometry::DetectorInfo & mutableDetectorInfo()
Return a non-const reference to the DetectorInfo object.
Run & mutableRun()
Writable version of the run object.
Kernel::cow_ptr< Sample > m_sample
The information on the sample environment.
const SpectrumInfo & spectrumInfo() const
Return a reference to the SpectrumInfo object.
Geometry::InstrumentMetadata const & instrumentMetadata() const
std::mutex m_baseComponentInfoMutex
std::shared_ptr< Geometry::ParameterMap > m_parmap
Parameters modifying the base instrument.
ExperimentInfo()
Default constructor.
void setInstumentFromXML(const std::string &nxFilename, std::string &instrumentName, std::string &instrumentXml)
Set the instrument given the name and XML leading from IDF file if XML string is empty.
std::shared_ptr< Geometry::InstrumentMetadata > m_instrumentMetadata
Geometry::ComponentInfo & mutableComponentInfo()
std::unique_ptr< Geometry::ComponentInfo > m_baseComponentInfo
const Geometry::DetectorInfo & detectorInfo() const
Return a const reference to the DetectorInfo object.
virtual ExperimentInfo * cloneExperimentInfo() const
Clone us.
std::unordered_map< detid_t, size_t > m_det2group
Detector grouping information.
std::shared_ptr< Geometry::DetectorInfo > m_detectorInfo
double getEFixed(const detid_t detID) const
Easy access to the efixed value for this run & detector ID.
void readParameterMap(const std::string ¶meterStr)
Populate the parameter map given a string.
virtual void populateIfNotLoaded() const
Called as the first operation of most public methods.
void invalidateSpectrumDefinition(const size_t index)
Notifies the ExperimentInfo that a spectrum definition has changed.
void saveExperimentInfoNexus(Nexus::File *file, bool saveLegacyInstrument=true) const
Saves this experiment description to the open NeXus file.
size_t numberOfDetectorGroups() const
Returns the number of detector groups.
void updateSpectrumDefinitionIfNecessary(const size_t index) const
std::string getAvailableWorkspaceStartDate() const
Return workspace start date as a formatted string (strftime, as returned by Types::Core::DateAndTime)...
std::unique_ptr< Geometry::DetectorInfo > m_baseDetectorInfo
Lazily-built 2.0 layers of the base instrument, reset whenever the instrument is set.
std::string loadInstrumentXML(const std::string &filename)
Loads the contents of a file and returns the string The file is assumed to be an IDF,...
virtual ~ExperimentInfo()
Virtual destructor.
std::shared_ptr< Geometry::ComponentInfo > m_componentInfo
The 2.0 instrument layers, of which this object is the primary owner.
virtual void updateCachedDetectorGrouping(const size_t index) const
Update detector grouping for spectrum with given index.
void cacheDefaultDetectorGrouping() const
Sets up a default detector grouping.
std::mutex m_spectrumInfoMutex
void copyExperimentInfoFrom(const ExperimentInfo *other)
Copy everything from the given experiment object.
const Run & run() const
Run details object access.
Geometry::ComponentInfo const & baseComponentInfo() const
Returns a ComponentInfo for the base (unparametrized) instrument, i.e.
std::string getInstrumentName() const
Return the name of the instrument from the ComponentInfo object.
void loadSampleAndLogInfoNexus(Nexus::File *file, std::string const &prefix)
Load the sample and log info from an open NeXus file.
const Geometry::ParameterMap & constInstrumentParameters() const
Const version.
Geometry::Instrument_const_sptr getInstrument() const
Returns the parameterized instrument.
Kernel::DeltaEMode::Type getEMode() const
Returns the emode for this run.
std::unique_ptr< Beamline::SpectrumInfo > m_spectrumInfo
void loadExperimentInfoNexus(std::string const &nxFilename, Nexus::File *file, std::string ¶meterStr, std::string const &prefix)
const Sample & sample() const
Sample accessors.
void setEFixed(const detid_t detID, const double value)
Set the efixed value for a given detector ID.
double getEFixedGivenEMode(const std::shared_ptr< const Geometry::IDetector > &detector, const Kernel::DeltaEMode::Type emode) const
Easy access to the efixed value for this run & detector.
double getEFixedForIndirect(const std::shared_ptr< const Geometry::IDetector > &detector, const std::vector< std::string > ¶meterNames) const
const std::string toString() const
Returns a string description of the object.
const Geometry::ParameterMap & instrumentParameters() const
Returns the set of parameters modifying the base instrument (const-version)
int getRunNumber() const
Utility method to get the run number.
std::string getAvailableWorkspaceEndDate() const
Return workspace end date as a formatted string (strftime style, as returned by Kernel::DateAdnTime) ...
const Geometry::ComponentInfo & componentInfo() const
std::string getWorkspaceStartDate() const
Returns the start date for this experiment (or current time if no info available)
void setInstrument(const Geometry::Instrument_const_sptr &instr)
Instrument accessors.
std::unique_ptr< SpectrumInfo > m_spectrumInfoWrapper
void setSharedRun(Kernel::cow_ptr< Run > run)
Set the run object. Use in particular to clear run without copying old run.
void setDetectorGrouping(const size_t index, const std::set< detid_t > &detIDs) const
Sets the detector grouping for the spectrum with the given index.
Kernel::cow_ptr< Run > sharedRun()
Return the cow ptr of the run.
ExperimentInfo & operator=(const ExperimentInfo &)
Implements the copy assignment operator.
void setSpectrumDefinitions(Kernel::cow_ptr< std::vector< SpectrumDefinition > > spectrumDefinitions)
Sets the SpectrumDefinition for all spectra.
std::vector< char > m_spectrumDefinitionNeedsUpdate
double getLogAsSingleValue(const std::string &log) const
Access a single value from a log for this experiment.
SpectrumInfo & mutableSpectrumInfo()
Return a non-const reference to the SpectrumInfo object.
void adoptBeamline()
Take co-ownership of whatever m_parmap currently holds.
void loadInstrumentParametersNexus(Nexus::File *file, std::string ¶meterStr)
Load instrument parameters from an open Nexus file in Instrument group if found there.
void setNumberOfDetectorGroups(const size_t count) const
Sets the number of detector groups.
Sample & mutableSample()
Writable version of the sample object.
Geometry::Instrument_const_sptr sptr_instrument
The base (unparametrized) instrument.
void loadInstrumentInfoNexus(const std::string &nxFilename, Nexus::File *file, std::string ¶meterStr)
Load the instrument from an open NeXus file.
void populateInstrumentParameters()
Add parameters to the instrument parameter map that are defined in instrument definition file or para...
Kernel::Property * getLog(const std::string &log) const
Access a log for this experiment.
void invalidateAllSpectrumDefinitions()
Sets flags for all spectrum definitions indicating that they need to be updated.
Kernel::cow_ptr< Run > m_run
The run information.
void populateWithParameter(Geometry::ComponentInfo &compInfo, Geometry::PositionAndRotationAccumulator &posAndRot, const size_t compIndex, const std::string &name, const Geometry::XMLInstrumentParameter ¶mInfo, const Run &runData)
Fill with given instrument parameter.
static std::string getInstrumentFilename(const std::string &instrumentName, const std::string &date="")
Get the IDF using the instrument name and date.
const Types::Core::DateAndTime endTime() const
Return the run end time.
bool hasProperty(const std::string &name) const
Does the property exist on the object.
const Types::Core::DateAndTime startTime() const
Return the run start time.
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
double getPropertyAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Returns a property as a single double value from its name.
HeldType getPropertyValueAsType(const std::string &name) const
Get the value of a property as the given TYPE.
This class stores information regarding an experimental run as a series of log entries.
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.
void loadNexus(Nexus::File *file, const std::string &group, const std::string &prefix, bool keepOpen=false) override
Load the run from a NeXus file with a given group name.
This class stores information about the sample used in particular run.
int loadNexus(Nexus::File *file, const std::string &group)
Load the object from an open NeXus file.
void saveNexus(Nexus::File *file, const std::string &group) const
Save the object to an open NeXus file.
const Geometry::OrientedLattice & getOrientedLattice() const
Get a reference to the sample's OrientedLattice.
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
const Kernel::cow_ptr< std::vector< SpectrumDefinition > > & sharedSpectrumDefinitions() const
ComponentInfo : Provides a component centric view on to the instrument.
bool hasParent(const size_t componentIndex) const
void setRotation(size_t componentIndex, const Kernel::Quat &newRotation)
void addFittingParameter(const size_t componentIndex, const std::string &name, const std::string &fittingFunction, const std::string &value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Add a fitting parameter.
size_t parent(const size_t componentIndex) const
Kernel::Quat rotation(const size_t componentIndex) const
Kernel::V3D position(const size_t componentIndex) const
bool hasParameter(const size_t componentIndex, const std::string &name, bool recursive=true) const
Returns empty (or false) if the ComponentInfo was built without parameters or the parameter is unset.
void addString(const size_t componentIndex, const std::string &name, const std::string &value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Add or replace a named string parameter at a specific component index.
bool isDetector(const size_t componentIndex) const
std::string getParameterAsString(size_t const componentIndex, std::string const &name, bool const recursive=true) const
The value of the named parameter as a string, whatever its type, or an empty string if it is unset.
void addInt(const size_t componentIndex, const std::string &name, int value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Add or replace a named integer parameter at a specific component index.
Kernel::V3D relativePosition(const size_t componentIndex) const
const std::string & name(const size_t componentIndex) const
void setPosition(size_t componentIndex, const Kernel::V3D &newPosition)
void addDouble(const size_t componentIndex, const std::string &name, double value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Add or replace a named double parameter at a specific component index.
static constexpr size_t invalidIndex
Returned by indexOfOrInvalid() for a component ID that is not part of this instrument.
void addBool(const size_t componentIndex, const std::string &name, bool value, const std::string *const pDescription=nullptr, const std::string &pVisible="true")
Add or replace a named boolean parameter at a specific component index.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
void setMasked(const size_t index, bool masked)
Set the mask flag of the detector with given index. Not thread safe.
size_t indexOf(const detid_t id) const
Returns the index of the detector with the given detector ID.
size_t size() const
Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument.
Creates an instrument data from a XML instrument description file.
std::shared_ptr< Instrument > parseXML(Kernel::ProgressBase *progressReporter)
Parse XML contents.
std::string getMangledName()
Handle used in the singleton constructor for instrument file should append the value file sha-1 check...
std::pair< std::unique_ptr< ComponentInfo >, std::unique_ptr< DetectorInfo > > makeWrappers() const
Make the wrappers from the data collected by walkInstrument(), which must be called first.
std::size_t getNumberDetectors(bool skipMonitors=false) const
Class to implement UB matrix.
static std::shared_ptr< Instrument > createInstrument(const std::shared_ptr< const Instrument > &base, const std::shared_ptr< ParameterMap > &map)
Create a parameterized instrument from the given base and ParameterMap.
static std::shared_ptr< Parameter > create(const std::string &className, const std::string &name, const std::string &visible="true")
Creates an instance of a parameter.
Parameter map iterator typedef.
const std::vector< std::string > & getParameterFilenames() const
Returns a list of all the parameter files loaded.
std::shared_ptr< Parameter > getRecursive(const IComponent *comp, const std::string &name, const std::string &type="") const
Use get() recursively to see if can find param in all parents of comp and given type (std::string ver...
static const std::string & rot()
std::vector< Entry > entries() const
Every stored parameter with its component's index in the instrument this map belongs to,...
static const std::string & pos()
Return string to be used in the map.
Collects the position and rotation an instrument definition specifies piecemeal, so that each can be ...
void setCoordinate(const size_t componentIndex, const std::string &axis, const double value, const Kernel::V3D ¤tPosition)
Set one coordinate.
void setPosition(const size_t componentIndex, const Kernel::V3D &position)
Set the whole position at once, discarding any coordinates accumulated so far.
std::map< size_t, Kernel::V3D > positions() const
The accumulated position for each component that had any coordinate set.
bool setRotationAngle(const size_t componentIndex, const std::string &axis, const double degrees)
Set one rotation angle, in degrees.
std::map< size_t, Kernel::Quat > rotations() const
The composed rotation for each component that had any angle set.
double alpha() const
Get lattice parameter.
double a(int nd) const
Get lattice parameter a1-a3 as function of index (0-2)
double c() const
Get lattice parameter.
double beta() const
Get lattice parameter.
double b() const
Get lattice parameter.
double gamma() const
Get lattice parameter.
This class is used to store information about parameters in XML instrument definition files and instr...
const std::string m_value
rather then extracting value from logfile,
const std::string m_type
type of the data, e.g. int, double or string
const std::string m_description
if present, contains help string, describing the parameter
const std::string m_visible
if present, describes whether the parameter shall be visible in InstrumentViewer
std::shared_ptr< Kernel::Interpolation > m_interpolation
evaluating the formula
const std::string m_fittingFunction
specific to fitting parameter
std::string m_penaltyFactor
parameter specify lower and upper bound in that order
const std::string m_formula
specify fitting function
const std::string m_resultUnit
expected result (output) unit from
const std::vector< std::string > m_constraint
specific to fitting
const std::string m_tie
specific to fitting parameter specify any tie
const std::string m_formulaUnit
formula to use for setting this parameter
Exception for when an item is not found in a collection.
The Logger class is in charge of the publishing messages from the framework through various channels.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
The concrete, templated class for properties.
Base class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
void rotate(V3D &) const
Rotate a vector.
Iterator begin()
Iterator referring to first element in the container.
@ TOK_IGNORE_EMPTY
ignore empty tokens
@ TOK_TRIM
remove leading and trailing whitespace from tokens
Iterator end()
Iterator referring to the past-the-end element in the container.
std::size_t count() const
Get the total number of tokens.
TimeROI : Object that holds information about when the time measurement was active.
void spherical(const double R, const double theta, const double phi) noexcept
Sets the vector position based on spherical coordinates.
Implements a copy on write data template.
Class that provides for a standard Nexus exception.
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, const size_t componentIndex, const double scaleX, const double scaleY)
Helpers for resizing RectangularDetectors.
std::shared_ptr< const ExperimentInfo > ExperimentInfo_const_sptr
Shared pointer to const ExperimentInfo.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< Parameter > Parameter_sptr
Typedef for the shared pointer.
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
MANTID_KERNEL_DLL std::string strip(const std::string &A)
strip pre/post spaces
MANTID_KERNEL_DLL std::string loadFile(const std::string &filename)
Loads the entire contents of a text file into a string.
int convert(const std::string &A, T &out)
Convert a string into a number.
int32_t detid_t
Typedef for a detector ID.
Generate a tableworkspace to store the calibration results.
std::string to_string(const wide_integer< Bits, Signed > &n)
static Type fromString(const std::string &modeStr)
Returns the emode from the given string.
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...