Mantid
Loading...
Searching...
No Matches
LoadMcStas.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 +
19#include "MantidKernel/Unit.h"
21
22#include <boost/algorithm/string.hpp>
23// clang-format off
24#include <nexus/NeXusFile.hpp>
25#include <nexus/NeXusException.hpp>
26// clang-format on
27
28namespace Mantid::DataHandling {
29using namespace Kernel;
30using namespace API;
31using namespace DataObjects;
32
33// Register the algorithm into the AlgorithmFactory
35
36//----------------------------------------------------------------------------------------------
37// Algorithm's name for identification. @see Algorithm::name
38const std::string LoadMcStas::name() const { return "LoadMcStas"; }
39
40// Algorithm's version for identification. @see Algorithm::version
41int LoadMcStas::version() const { return 1; }
42
43// Algorithm's category for identification. @see Algorithm::category
44const std::string LoadMcStas::category() const { return "DataHandling\\Nexus"; }
45
46//----------------------------------------------------------------------------------------------
47
48//----------------------------------------------------------------------------------------------
52 const std::vector<std::string> exts{".h5", ".nxs"};
53 declareProperty(std::make_unique<FileProperty>("Filename", "", FileProperty::Load, exts),
54 "The name of the Nexus file to load");
55
56 declareProperty(std::make_unique<WorkspaceProperty<Workspace>>("OutputWorkspace", "", Direction::Output),
57 "An output workspace.");
58
59 declareProperty("ErrorBarsSetTo1", false,
60 "When this property is set to false errors are set equal to data values, "
61 "and when set to true all errors are set equal to one. This property "
62 "defaults to false");
63
64 declareProperty("OutputOnlySummedEventWorkspace", true,
65 "When true the algorithm only outputs the sum of all event data into "
66 "one eventworkspace EventData + _ + name of the OutputWorkspace. "
67 "If false eventworkspaces are also returned for each individual "
68 "McStas components storing event data");
69}
70
71//----------------------------------------------------------------------------------------------
75
76 std::string filename = getPropertyValue("Filename");
77 g_log.debug() << "Opening file " << filename << '\n';
78
79 ::NeXus::File nxFile(filename);
80 auto entries = nxFile.getEntries();
81
82 // McStas Nexus only ever have one top level entry
83 auto entry = entries.begin();
84 std::string name = entry->first;
85 std::string type = entry->second;
86
87 // open top entry - open data entry
88 nxFile.openGroup(name, type);
89 nxFile.openGroup("data", "NXdetector");
90
91 auto dataEntries = nxFile.getEntries();
92
93 std::map<std::string, std::string> eventEntries;
94 std::map<std::string, std::string> histogramEntries;
95
96 // populate eventEntries and histogramEntries
97 for (auto &dataEntry : dataEntries) {
98 std::string dataName = dataEntry.first;
99 std::string dataType = dataEntry.second;
100 if (dataName == "content_nxs" || dataType != "NXdata")
101 continue; // can be removed if sure no Nexus files contains
102 // "content_nxs"
103 g_log.debug() << "Opening " << dataName << " " << dataType << '\n';
104
105 // open second level entry
106 nxFile.openGroup(dataName, dataType);
107
108 // Find the Neutron_ID tag from McStas event data
109 // Each event detector has the nexus attribute:
110 // @long_name = data ' Intensity Position Position Neutron_ID Velocity
111 // Time_Of_Flight Monitor (Square)'
112 // if Neutron_ID present we have event data
113
114 auto nxdataEntries = nxFile.getEntries();
115
116 for (auto &nxdataEntry : nxdataEntries) {
117 if (nxdataEntry.second == "NXparameters")
118 continue;
119 nxFile.openData(nxdataEntry.first);
120 if (nxFile.hasAttr("long_name")) {
121 std::string nameAttrValue;
122 nxFile.getAttr("long_name", nameAttrValue);
123
124 if (nameAttrValue.find("Neutron_ID") != std::string::npos) {
125 eventEntries[dataEntry.first] = dataEntry.second;
126 } else {
127 histogramEntries[dataEntry.first] = dataEntry.second;
128 }
129 }
130 nxFile.closeData();
131 }
132 // close second entry
133 nxFile.closeGroup();
134 }
135 std::vector<std::string> scatteringWSNames;
136 std::vector<std::string> histoWSNames;
137 if (!eventEntries.empty()) {
138 scatteringWSNames = readEventData(eventEntries, nxFile);
139 }
140 histoWSNames = readHistogramData(histogramEntries, nxFile);
141
142 // join two vectors together
143 scatteringWSNames.insert(scatteringWSNames.end(), histoWSNames.begin(), histoWSNames.end());
144
145 // close top entry
146 nxFile.closeGroup(); // corresponds to nxFile.openGroup("data", "NXdetector");
147 nxFile.closeGroup();
148
149 setProperty("OutputWorkspace", groupWorkspaces(scatteringWSNames));
150} // LoadMcStas::exec()
151
157API::WorkspaceGroup_sptr LoadMcStas::groupWorkspaces(const std::vector<std::string> &workspaces) const {
158 auto groupAlgorithm = API::AlgorithmManager::Instance().createUnmanaged("GroupWorkspaces");
159 groupAlgorithm->setChild(true);
160 groupAlgorithm->setLogging(false);
161 groupAlgorithm->initialize();
162 groupAlgorithm->setProperty("InputWorkspaces", workspaces);
163 groupAlgorithm->setProperty("OutputWorkspace", "__grouped");
164 groupAlgorithm->execute();
165 return groupAlgorithm->getProperty("OutputWorkspace");
166}
167
174std::vector<std::string> LoadMcStas::readEventData(const std::map<std::string, std::string> &eventEntries,
175 ::NeXus::File &nxFile) {
176
177 // vector to store output workspaces
178 std::vector<std::string> scatteringWSNames;
179
180 std::string filename = getPropertyValue("Filename");
181 auto entries = nxFile.getEntries();
182 const bool errorBarsSetTo1 = getProperty("ErrorBarsSetTo1");
183
184 // will assume that each top level entry contain one mcstas
185 // generated IDF and any event data entries within this top level
186 // entry are data collected for that instrument
187 // This code for loading the instrument is for now adjusted code from
188 // ExperimentalInfo.
189
190 // Close data folder and go back to top level. Then read and close the
191 // Instrument folder.
192 nxFile.closeGroup();
193
194 Geometry::Instrument_sptr instrument;
195
196 // Initialize progress reporting
197 int reports = 2;
198 const double progressFractionInitial = 0.1;
199 Progress progInitial(this, 0.0, progressFractionInitial, reports);
200
201 std::string instrumentXML;
202 progInitial.report("Loading instrument");
203 try {
204 nxFile.openGroup("instrument", "NXinstrument");
205 nxFile.openGroup("instrument_xml", "NXnote");
206 nxFile.readData("data", instrumentXML);
207 nxFile.closeGroup();
208 nxFile.closeGroup();
209 } catch (...) {
210 g_log.warning() << "\nCould not find the instrument description in the Nexus file:" << filename
211 << " Ignore eventdata from the Nexus file\n";
212 return scatteringWSNames;
213 ;
214 }
215
216 try {
217 std::string instrumentName = "McStas";
218 Geometry::InstrumentDefinitionParser parser(filename, instrumentName, instrumentXML);
219 std::string instrumentNameMangled = parser.getMangledName();
220
221 // Check whether the instrument is already in the InstrumentDataService
222 if (InstrumentDataService::Instance().doesExist(instrumentNameMangled)) {
223 // If it does, just use the one from the one stored there
224 instrument = InstrumentDataService::Instance().retrieve(instrumentNameMangled);
225 } else {
226 // Really create the instrument
227 instrument = parser.parseXML(nullptr);
228 // Add to data service for later retrieval
229 InstrumentDataService::Instance().add(instrumentNameMangled, instrument);
230 }
232 g_log.warning() << "When trying to read the instrument description in the Nexus file: " << filename
233 << " the following error is reported: " << e.what() << " Ignore eventdata from the Nexus file\n";
234 return scatteringWSNames;
235 ;
236 } catch (...) {
237 g_log.warning() << "Could not parse instrument description in the Nexus file: " << filename
238 << " Ignore eventdata from the Nexus file\n";
239 return scatteringWSNames;
240 ;
241 }
242 // Finished reading Instrument. Then open new data folder again
243 nxFile.openGroup("data", "NXdetector");
244
245 // create and prepare an event workspace ready to receive the mcstas events
246 progInitial.report("Set up EventWorkspace");
247 EventWorkspace_sptr eventWS(new EventWorkspace());
248 // initialize, where create up front number of eventlists = number of
249 // detectors
250 eventWS->initialize(instrument->getNumberDetectors(), 1, 1);
251 // Set the units
252 eventWS->getAxis(0)->unit() = UnitFactory::Instance().create("TOF");
253 eventWS->setYUnit("Counts");
254 // set the instrument
255 eventWS->setInstrument(instrument);
256 // assign detector ID to eventlists
257
258 std::vector<detid_t> detIDs = instrument->getDetectorIDs();
259
260 for (size_t i = 0; i < instrument->getNumberDetectors(); i++) {
261 eventWS->getSpectrum(i).addDetectorID(detIDs[i]);
262 // spectrum number are treated as equal to detector IDs for McStas data
263 eventWS->getSpectrum(i).setSpectrumNo(detIDs[i]);
264 }
265 // the one is here for the moment for backward compatibility
266 eventWS->rebuildSpectraMapping(true);
267
268 bool isAnyNeutrons = false;
269 // to store shortest and longest recorded TOF
270 double shortestTOF(0.0);
271 double longestTOF(0.0);
272
273 // create vector container all the event output workspaces needed
274 const size_t numEventEntries = eventEntries.size();
275 std::string nameOfGroupWS = getProperty("OutputWorkspace");
276 const auto eventDataTotalName = "EventData_" + nameOfGroupWS;
277 std::vector<std::pair<EventWorkspace_sptr, std::string>> allEventWS = {{eventWS, eventDataTotalName}};
278 // if numEventEntries > 1 also create separate event workspaces
279 const bool onlySummedEventWorkspace = getProperty("OutputOnlySummedEventWorkspace");
280 if (!onlySummedEventWorkspace && numEventEntries > 1) {
281 for (const auto &eventEntry : eventEntries) {
282 const std::string &dataName = eventEntry.first;
283 // create container to hold partial event data
284 // plus the name users will see for it
285 const auto ws_name = dataName + "_" + nameOfGroupWS;
286 allEventWS.emplace_back(eventWS->clone(), ws_name);
287 }
288 }
289
290 Progress progEntries(this, progressFractionInitial, 1.0, numEventEntries * 2);
291
292 // Refer to entry in allEventWS. The first non-summed workspace index is 1
293 auto eventWSIndex = 1u;
294 // Loop over McStas event data components
295 for (const auto &eventEntry : eventEntries) {
296 const std::string &dataName = eventEntry.first;
297 const std::string &dataType = eventEntry.second;
298
299 // open second level entry
300 nxFile.openGroup(dataName, dataType);
301 std::vector<double> data;
302 nxFile.openData("events");
303 progEntries.report("read event data from nexus");
304
305 // Need to take into account that the nexus readData method reads a
306 // multi-column data entry
307 // into a vector
308 // The number of data column for each neutron is here hardcoded to (p, x,
309 // y, n, id, t)
310 // Thus we have
311 // column 0 : p neutron wight
312 // column 1 : x x coordinate
313 // column 2 : y y coordinate
314 // column 3 : n accumulated number of neutrons
315 // column 4 : id pixel id
316 // column 5 : t time
317
318 // get info about event data
319 ::NeXus::Info id_info = nxFile.getInfo();
320 if (id_info.dims.size() != 2) {
321 g_log.error() << "Event data in McStas nexus file not loaded. Expected "
322 "event data block to be two dimensional\n";
323 return scatteringWSNames;
324 ;
325 }
326 int64_t nNeutrons = id_info.dims[0];
327 int64_t numberOfDataColumn = id_info.dims[1];
328 if (nNeutrons && numberOfDataColumn != 6) {
329 g_log.error() << "Event data in McStas nexus file expecting 6 columns\n";
330 return scatteringWSNames;
331 ;
332 }
333 if (!isAnyNeutrons && nNeutrons > 0)
334 isAnyNeutrons = true;
335
336 std::vector<int64_t> start(2);
337 std::vector<int64_t> step(2);
338
339 // read the event data in blocks. 1 million event is 1000000*6*8 doubles
340 // about 50Mb
341 int64_t nNeutronsInBlock = 1000000;
342 int64_t nOfFullBlocks = nNeutrons / nNeutronsInBlock;
343 int64_t nRemainingNeutrons = nNeutrons - nOfFullBlocks * nNeutronsInBlock;
344 // sum over number of blocks + 1 to cover the remainder
345 for (int64_t iBlock = 0; iBlock < nOfFullBlocks + 1; iBlock++) {
346 if (iBlock == nOfFullBlocks) {
347 // read remaining neutrons
348 start[0] = nOfFullBlocks * nNeutronsInBlock;
349 start[1] = 0;
350 step[0] = nRemainingNeutrons;
351 step[1] = numberOfDataColumn;
352 } else {
353 // read neutrons in a full block
354 start[0] = iBlock * nNeutronsInBlock;
355 start[1] = 0;
356 step[0] = nNeutronsInBlock;
357 step[1] = numberOfDataColumn;
358 }
359 const int64_t nNeutronsForthisBlock = step[0]; // number of neutrons read for this block
360 data.resize(nNeutronsForthisBlock * numberOfDataColumn);
361
362 // Check that the type is what it is supposed to be
363 if (id_info.type == ::NeXus::FLOAT64) {
364 nxFile.getSlab(&data[0], start, step);
365 } else {
366 g_log.warning() << "Entry event field is not FLOAT64! It will be skipped.\n";
367 continue;
368 }
369
370 // populate workspace with McStas events
371 const detid2index_map detIDtoWSindex_map = allEventWS[0].first->getDetectorIDToWorkspaceIndexMap(true);
372
373 progEntries.report("read event data into workspace");
374 for (int64_t in = 0; in < nNeutronsForthisBlock; in++) {
375 const auto detectorID = static_cast<int>(data[4 + numberOfDataColumn * in]);
376 const double detector_time = data[5 + numberOfDataColumn * in] * 1.0e6; // convert to microseconds
377 if (in == 0 && iBlock == 0) {
378 shortestTOF = detector_time;
379 longestTOF = detector_time;
380 } else {
381 if (detector_time < shortestTOF)
382 shortestTOF = detector_time;
383 if (detector_time > longestTOF)
384 longestTOF = detector_time;
385 }
386
387 const size_t workspaceIndex = detIDtoWSindex_map.find(detectorID)->second;
388
389 int64_t pulse_time = 0;
390 WeightedEvent weightedEvent;
391 if (errorBarsSetTo1) {
392 weightedEvent = WeightedEvent(detector_time, pulse_time, data[numberOfDataColumn * in], 1.0);
393 } else {
394 weightedEvent = WeightedEvent(detector_time, pulse_time, data[numberOfDataColumn * in],
395 data[numberOfDataColumn * in] * data[numberOfDataColumn * in]);
396 }
397 allEventWS[0].first->getSpectrum(workspaceIndex) += weightedEvent;
398 if (!onlySummedEventWorkspace && numEventEntries > 1) {
399 allEventWS[eventWSIndex].first->getSpectrum(workspaceIndex) += weightedEvent;
400 }
401 }
402 eventWSIndex++;
403 } // end reading over number of blocks of an event dataset
404
405 nxFile.closeData();
406 nxFile.closeGroup();
407
408 } // end reading over number of event datasets
409
410 // Create a default TOF-vector for histogramming, for now just 2 bins
411 // 2 bins is the standard. However for McStas simulation data it may make
412 // sense to
413 // increase this number for better initial visual effect
414
415 auto axis = HistogramData::BinEdges{shortestTOF - 1, longestTOF + 1};
416
417 // ensure that specified name is given to workspace (eventWS) when added to
418 // outputGroup
419 for (const auto &wsAndName : allEventWS) {
420 const auto ws = wsAndName.first;
421 ws->setAllX(axis);
422 AnalysisDataService::Instance().addOrReplace(wsAndName.second, ws);
423 scatteringWSNames.emplace_back(wsAndName.second);
424 }
425 return scatteringWSNames;
426}
427
434std::vector<std::string> LoadMcStas::readHistogramData(const std::map<std::string, std::string> &histogramEntries,
435 ::NeXus::File &nxFile) {
436
437 std::string nameAttrValueYLABEL;
438 std::vector<std::string> histoWSNames;
439
440 for (const auto &histogramEntry : histogramEntries) {
441 const std::string &dataName = histogramEntry.first;
442 const std::string &dataType = histogramEntry.second;
443
444 // open second level entry
445 nxFile.openGroup(dataName, dataType);
446
447 // grap title to use to e.g. create workspace name
448 std::string nameAttrValueTITLE;
449 nxFile.getAttr("filename", nameAttrValueTITLE);
450
451 if (nxFile.hasAttr("ylabel")) {
452 nxFile.getAttr("ylabel", nameAttrValueYLABEL);
453 }
454
455 // Find the axis names
456 auto nxdataEntries = nxFile.getEntries();
457 std::string axis1Name, axis2Name;
458 for (auto &nxdataEntry : nxdataEntries) {
459 if (nxdataEntry.second == "NXparameters")
460 continue;
461 if (nxdataEntry.first == "ncount")
462 continue;
463 nxFile.openData(nxdataEntry.first);
464
465 if (nxFile.hasAttr("axis")) {
466 int axisNo(0);
467 nxFile.getAttr("axis", axisNo);
468 if (axisNo == 1)
469 axis1Name = nxdataEntry.first;
470 else if (axisNo == 2)
471 axis2Name = nxdataEntry.first;
472 else
473 throw std::invalid_argument("Unknown axis number");
474 }
475 nxFile.closeData();
476 }
477
478 std::vector<double> axis1Values;
479 std::vector<double> axis2Values;
480 nxFile.readData<double>(axis1Name, axis1Values);
481 if (axis2Name.length() == 0) {
482 axis2Name = nameAttrValueYLABEL;
483 axis2Values.emplace_back(0.0);
484 } else {
485 nxFile.readData<double>(axis2Name, axis2Values);
486 }
487
488 const size_t axis1Length = axis1Values.size();
489 const size_t axis2Length = axis2Values.size();
490 g_log.debug() << "Axis lengths=" << axis1Length << " " << axis2Length << '\n';
491
492 // Require "data" field
493 std::vector<double> data;
494 nxFile.readData<double>("data", data);
495
496 // Optional errors field
497 std::vector<double> errors;
498 try {
499 nxFile.readData<double>("errors", errors);
500 } catch (::NeXus::Exception &) {
501 g_log.information() << "Field " << dataName << " contains no error information.\n";
502 }
503
504 // close second level entry
505 nxFile.closeGroup();
506
507 MatrixWorkspace_sptr ws = WorkspaceFactory::Instance().create("Workspace2D", axis2Length, axis1Length, axis1Length);
508 Axis *axis1 = ws->getAxis(0);
509 axis1->title() = axis1Name;
510 // Set caption
511 auto lblUnit = std::make_shared<Units::Label>();
512 lblUnit->setLabel(axis1Name, "");
513 axis1->unit() = lblUnit;
514
515 auto axis2 = std::make_unique<NumericAxis>(axis2Length);
516 auto axis2Raw = axis2.get();
517 axis2->title() = axis2Name;
518 // Set caption
519 lblUnit = std::make_shared<Units::Label>();
520 lblUnit->setLabel(axis2Name, "");
521 axis2->unit() = lblUnit;
522
523 ws->setYUnit(axis2Name);
524 ws->replaceAxis(1, std::move(axis2));
525
526 for (size_t wsIndex = 0; wsIndex < axis2Length; ++wsIndex) {
527 auto &dataX = ws->mutableX(wsIndex);
528 auto &dataY = ws->mutableY(wsIndex);
529 auto &dataE = ws->mutableE(wsIndex);
530
531 for (size_t j = 0; j < axis1Length; ++j) {
532 // Data is stored in column-major order so we are translating to
533 // row major for Mantid
534 const size_t fileDataIndex = j * axis2Length + wsIndex;
535
536 dataX[j] = axis1Values[j];
537 dataY[j] = data[fileDataIndex];
538 if (!errors.empty())
539 dataE[j] = errors[fileDataIndex];
540 }
541 axis2Raw->setValue(wsIndex, axis2Values[wsIndex]);
542 }
543
544 // set the workspace title
545 ws->setTitle(nameAttrValueTITLE);
546
547 // use the workspace title to create the workspace name
548 std::replace(nameAttrValueTITLE.begin(), nameAttrValueTITLE.end(), ' ', '_');
549
550 // ensure that specified name is given to workspace (eventWS) when added to
551 // outputGroup
552 const std::string outputWS = getProperty("OutputWorkspace");
553 const std::string nameUserSee = nameAttrValueTITLE + "_" + outputWS;
554 AnalysisDataService::Instance().addOrReplace(nameUserSee, ws);
555
556 histoWSNames.emplace_back(ws->getName());
557 }
558 nxFile.closeGroup();
559 return histoWSNames;
560
561} // finish
562
570 using namespace ::NeXus;
571 // look at to see if entry1/simulation/name exist first and then
572 // if its value = mccode
573 int confidence(0);
574 if (descriptor.pathExists("/entry1/simulation/name")) {
575 try {
576 // need to look inside file to check value of entry1/simulation/name
577 ::NeXus::File file = ::NeXus::File(descriptor.filename());
578 file.openGroup(descriptor.firstEntryNameType().first, descriptor.firstEntryNameType().second);
579 file.openGroup("simulation", "NXnote");
580 std::string value;
581 // check if entry1/simulation/name equals mccode
582 file.readData("name", value);
583 if (boost::iequals(value, "mccode"))
584 confidence = 98;
585 file.closeGroup();
586 file.closeGroup();
587 } catch (::NeXus::Exception &) {
588 }
589 }
590 return confidence;
591}
592
593} // namespace Mantid::DataHandling
double value
The value of the point.
Definition: FitMW.cpp:51
#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro wh...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
Class to represent the axis of a workspace.
Definition: Axis.h:30
const std::string & title() const
Returns the user-defined title for this axis.
Definition: Axis.cpp:20
const std::shared_ptr< Kernel::Unit > & unit() const
The unit for this axis.
Definition: Axis.cpp:28
@ Load
allowed here which will be passed to the algorithm
Definition: FileProperty.h:52
Helper class for reporting progress from algorithms.
Definition: Progress.h:25
A property class for workspaces.
LoadMcStas : TODO: DESCRIPTION.
Definition: LoadMcStas.h:22
void init() override
Initialize the algorithm's properties.
Definition: LoadMcStas.cpp:51
int confidence(Kernel::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
Definition: LoadMcStas.cpp:569
API::WorkspaceGroup_sptr groupWorkspaces(const std::vector< std::string > &workspaces) const
Group workspaces.
Definition: LoadMcStas.cpp:157
void exec() override
Execute the algorithm.
Definition: LoadMcStas.cpp:74
const std::string name() const override
function to return a name of the algorithm, must be overridden in all algorithms
Definition: LoadMcStas.cpp:38
const std::string category() const override
function to return a category of the algorithm.
Definition: LoadMcStas.cpp:44
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
Definition: LoadMcStas.cpp:41
std::vector< std::string > readEventData(const std::map< std::string, std::string > &eventEntries, ::NeXus::File &nxFile)
Read Event Data.
Definition: LoadMcStas.cpp:174
std::vector< std::string > readHistogramData(const std::map< std::string, std::string > &histogramEntries, ::NeXus::File &nxFile)
Read histogram data.
Definition: LoadMcStas.cpp:434
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
Info about a single neutron detection event, including a weight and error value:
Definition: Events.h:39
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...
Exception for errors associated with the instrument definition.
Definition: Exception.h:220
const char * what() const noexcept override
Writes out the range and limits.
Definition: Exception.cpp:172
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
Definition: Logger.cpp:114
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
void information(const std::string &msg)
Logs at information level.
Definition: Logger.cpp:105
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
const std::pair< std::string, std::string > & firstEntryNameType() const
Returns the name & type of the first entry in the file.
bool pathExists(const std::string &path) const
Query if a path exists.
const std::string & filename() const
Access the filename.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
Definition: ProgressBase.h:51
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
std::unordered_map< detid_t, size_t > detid2index_map
Map with key = detector ID, value = workspace index.
STL namespace.
@ Output
An output workspace.
Definition: Property.h:54