77 std::string instrumentName;
80 std::vector<std::string> monitorFilenames;
81 std::vector<int> monitorIDs;
88 std::filesystem::path runinfoPath(runinfo_filename);
90 std::filesystem::path dirPath(runinfoPath.parent_path());
95 std::ifstream in(runinfo_filename.c_str());
96 Poco::XML::InputSource src(in);
98 Poco::XML::DOMParser parser;
99 Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&src);
101 Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT);
102 Poco::XML::Node *pNode = it.nextNode();
106 if (pNode->nodeName() ==
"RunInfo") {
107 auto *pRunInfoElement =
static_cast<Poco::XML::Element *
>(pNode);
108 instrumentName = pRunInfoElement->getAttribute(
"instrument");
115 if (pNode->nodeName() ==
"BeamMonitorInfo") {
119 auto *pE =
static_cast<Poco::XML::Element *
>(pNode);
120 g_log.
debug() <<
"Beam Monitor " << pE->getAttribute(
"id") <<
'\n';
121 g_log.
debug() <<
"\tname: " << pE->getAttribute(
"name") <<
'\n';
122 g_log.
debug() <<
"\tdescription: " << pE->getAttribute(
"description") <<
'\n';
125 Poco::XML::Element *pTimeChannels = pE->getChildElement(
"NumTimeChannels");
126 tmin = boost::lexical_cast<double>(pTimeChannels->getAttribute(
"startbin"));
127 tstep = boost::lexical_cast<double>(pTimeChannels->getAttribute(
"width"));
132 if (pNode->nodeName() ==
"DataList") {
134 Poco::AutoPtr<Poco::XML::NodeList> pDataListChildren = pNode->childNodes();
135 for (
unsigned long i = 0; i < pDataListChildren->length(); ++i) {
137 if (pDataListChildren->item(i)->nodeName() ==
"monitor") {
138 auto *element =
static_cast<Poco::XML::Element *
>(pDataListChildren->item(i));
139 monitorIDs.emplace_back(boost::lexical_cast<int>(element->getAttribute(
"id")));
140 monitorFilenames.emplace_back(element->getAttribute(
"name"));
146 if (pNode->nodeName() ==
"FileFormats") {
148 Poco::AutoPtr<Poco::XML::NodeList> pDataListChildren = pNode->childNodes();
149 for (
unsigned long i = 0; i < pDataListChildren->length(); ++i) {
151 if (pDataListChildren->item(i)->nodeName() ==
"monitor") {
152 std::string dims =
static_cast<Poco::XML::Element *
>(pDataListChildren->item(i))->getAttribute(
"dims");
153 tchannels = boost::lexical_cast<int>(dims);
158 pNode = it.nextNode();
166 const int numberTimeBins = tchannels + 1;
168 for (
int i = 0; i < numberTimeBins; ++i) {
169 time_bins[i] = tmin + (i)*tstep;
176 BinEdges edges(time_bins);
179 std::filesystem::path pMonitorFilename = dirPath / monitorFilenames[i];
181 g_log.
debug() <<
"Loading monitor file :" << pMonitorFilename.string() <<
'\n';
187 localWorkspace->setHistogram(i, edges, Counts(buffer.begin(), buffer.end()));
190 auto &spectrum = localWorkspace->getSpectrum(i);
191 spectrum.setSpectrumNo(monitorIDs[i]);
192 spectrum.setDetectorID(-monitorIDs[i]);
195 g_log.
debug() <<
"Setting axis zero to TOF\n";
198 localWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create(
"TOF");
199 localWorkspace->setYUnit(
"Counts");
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.