27using namespace Kernel;
30using namespace HistogramData;
38 : m_supportedInstruments{
"MIBEMOL"}, m_numberOfTubes{0}, m_numberOfPixelsPerTube{0}, m_numberOfChannels{0},
39 m_numberOfHistograms{0}, m_wavelength{0.0}, m_channelWidth{0.0} {}
59 if (descriptor.
pathExists(
"/nxentry/program_name") && descriptor.
pathExists(
"/nxentry/subrun_number") &&
60 descriptor.
pathExists(
"/nxentry/total_subruns")) {
73 const std::vector<std::string> exts{
".nxs",
".hdf"};
75 "The name of the Nexus file to load");
77 "The name to use for the output workspace");
109 throw std::runtime_error(
"Cannot read the instrument name from the Nexus file!");
173 float *data_p = &data(
static_cast<int>(i),
static_cast<int>(j));
180 g_log.
debug() <<
"Data loading inti WS done....\n";
187 const float *data_p = &data(
static_cast<int>(i), 0);
188 float currentSpec = 0;
191 currentSpec += data_p[j];
194 cumulatedSumOfSpectras[i] = cumulatedSumOfSpectras[i - 1] +
static_cast<int>(currentSpec);
196 cumulatedSumOfSpectras[i] =
static_cast<int>(currentSpec);
199 auto it = std::max_element(cumulatedSumOfSpectras.begin(), cumulatedSumOfSpectras.end());
201 int calculatedDetectorElasticPeakPosition;
202 if (it == cumulatedSumOfSpectras.end()) {
203 throw std::runtime_error(
"No Elastic peak position found while analyzing the data!");
206 calculatedDetectorElasticPeakPosition =
static_cast<int>(std::distance(cumulatedSumOfSpectras.begin(), it));
208 if (calculatedDetectorElasticPeakPosition == 0) {
209 throw std::runtime_error(
"No Elastic peak position found while analyzing "
210 "the data. Elastic peak position is ZERO!");
212 g_log.
debug() <<
"Calculated Detector EPP: " << calculatedDetectorElasticPeakPosition <<
'\n';
215 return calculatedDetectorElasticPeakPosition;
223 double theoreticalElasticTOF =
226 g_log.
debug() <<
"elasticPeakPosition : " <<
static_cast<float>(elasticPeakPosition) <<
'\n';
229 g_log.
debug() <<
"theoreticalElasticTOF : " << theoreticalElasticTOF <<
'\n';
232 histX[i] = theoreticalElasticTOF + channelWidth *
static_cast<double>(
static_cast<int>(i) - elasticPeakPosition) -
245 std::string start_time = entry.
getString(
"start_time");
249 std::string end_time = entry.
getString(
"end_time");
253 double wavelength = entry.
getFloat(
"nxbeam/incident_wavelength");
254 runDetails.
addProperty<
double>(
"wavelength", wavelength);
259 std::string title = entry.
getString(
"title");
#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.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
@ Load
allowed here which will be passed to the algorithm
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Helper class for reporting progress from algorithms.
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
LoadLLB : Loads an LLB MIBEMOL TOF NeXus file into a Workspace2D with the given name.
size_t m_numberOfHistograms
void exec() override
Execute the algorithm.
int getDetectorElasticPeakPosition(const NeXus::NXFloat &)
size_t m_numberOfPixelsPerTube
size_t m_numberOfChannels
void initWorkSpace(NeXus::NXEntry &)
std::string m_instrumentName
void setTimeBinning(HistogramData::HistogramX &histX, int, double)
int version() const override
Algorithm's version for identification.
const std::string category() const override
Algorithm's category for identification.
void loadTimeDetails(const NeXus::NXEntry &entry)
void loadRunDetails(const NeXus::NXEntry &)
std::string m_instrumentPath
Name of the instrument path.
const std::string name() const override
Algorithm's name for identification.
int confidence(Kernel::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
void loadDataIntoTheWorkSpace(NeXus::NXEntry &)
void init() override
Initialize the algorithm's properties.
void setInstrumentName(const NeXus::NXEntry &entry)
API::MatrixWorkspace_sptr m_localWorkspace
void runLoadInstrument()
Run the Child Algorithm LoadInstrument.
void loadExperimentDetails(NeXus::NXEntry &)
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.
void information(const std::string &msg)
Logs at information level.
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
bool pathExists(const std::string &path) const
Query if a path exists.
OptionalBool : Tri-state bool.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
int getInt(const std::string &name) const
Returns a int.
float getFloat(const std::string &name) const
Returns a float.
std::string getString(const std::string &name) const
Returns a string.
Templated class implementation of NXDataSet.
void load(const int blocksize=1, int i=-1, int j=-1, int k=-1, int l=-1) override
Implementation of the virtual NXDataSet::load(...) method.
int dim0() const
Returns the number of elements along the first dimension.
int dim1() const
Returns the number of elements along the second dimension.
Implements NXdata Nexus class.
NXFloat openFloatData()
Opens data of float type.
NXInt openIntData()
Opens data of int type.
Implements NXentry Nexus class.
NXData openNXData(const std::string &name) const
Opens a NXData.
Implements NXroot Nexus class.
NXEntry openFirstEntry()
Open the first NXentry in the file.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
double calculateEnergy(double)
Calculate Neutron Energy from wavelength: .
std::string getStringFromNexusPath(const Mantid::NeXus::NXEntry &, const std::string &)
double calculateTOF(double, double)
Calculate TOF from distance.
@ Output
An output workspace.