/** Execute the algorithm. */ void LoadILLReflectometry::exec() { // Retrieve filename std::string filenameData = getPropertyValue("Filename"); // open the root node NeXus::NXRoot dataRoot(filenameData); NXEntry firstEntry = dataRoot.openFirstEntry(); // Load Monitor details: n. monitors x monitor contents std::vector<std::vector<int>> monitorsData = loadMonitors(firstEntry); // Load Data details (number of tubes, channels, etc) loadDataDetails(firstEntry); std::string instrumentPath = m_loader.findInstrumentNexusPath(firstEntry); setInstrumentName(firstEntry, instrumentPath); initWorkSpace(firstEntry, monitorsData); g_log.debug("Building properties..."); loadNexusEntriesIntoProperties(filenameData); g_log.debug("Loading data..."); loadDataIntoTheWorkSpace(firstEntry, monitorsData); // load the instrument from the IDF if it exists g_log.debug("Loading instrument definition..."); runLoadInstrument(); // 1) Move // Get distance and tilt angle stored in nexus file // Mantid way //// auto angleProp = /// dynamic_cast<PropertyWithValue<double>*>(m_localWorkspace->run().getProperty("dan.value")); // Nexus way double angle = firstEntry.getFloat("instrument/dan/value"); // detector angle in degrees double distance = firstEntry.getFloat( "instrument/det/value"); // detector distance in millimeter distance /= 1000.0; // convert to meter g_log.debug() << "Moving detector at angle " << angle << " and distance " << distance << std::endl; placeDetector(distance, angle); // Set the channel width property auto channel_width = dynamic_cast<PropertyWithValue<double> *>( m_localWorkspace->run().getProperty("monitor1.time_of_flight_0")); m_localWorkspace->mutableRun().addProperty<double>( "channel_width", *channel_width, true); // overwrite // Set the output workspace property setProperty("OutputWorkspace", m_localWorkspace); }
void MainWindow::refreshInstruments() { FtmDocument *d = m_dinfo->doc(); int current = m_dinfo->currentInstrument(); instruments->clear(); int instc = d->GetInstrumentCount(); instrumentName->clear(); instrumentName->setEnabled(instc > 0); for (int i = 0; i < 64; i++) { if (!d->IsInstrumentUsed(i)) continue; CInstrument *inst = d->GetInstrument(i); QListWidgetItem *item = new QListWidgetItem; const char *res; switch (inst->GetType()) { case INST_NONE: case INST_2A03: res = ":/inst/2a03"; break; case INST_VRC6: res = ":/inst/vrc6"; break; case INST_VRC7: res = ":/inst/vrc7"; break; case INST_FDS: res = ":/inst/fds"; break; default: res = NULL; break; } if (res != NULL) item->setIcon(QIcon(res)); setInstrumentName(item, i, inst->GetName()); item->setData(Qt::UserRole, qVariantFromValue(i)); instruments->addItem(item); if (i == current) { instruments->setCurrentItem(item); instrumentName->setText(inst->GetName()); } } }
void MainWindow::instrumentNameChange(QString s) { QModelIndex idx = instruments->currentIndex(); if (idx.row() < 0) return; int i = idx.data(Qt::UserRole).value<int>(); FtmDocument *doc = m_dinfo->doc(); doc->lock(); CInstrument *inst = doc->GetInstrument(i); inst->SetName(s.toAscii()); doc->unlock(); setInstrumentName(instruments->currentItem(), idx.row(), s.toAscii()); }
bool RunData::decodeMessage(const uint8_t *buf) { auto runData = GetRunInfo(buf); if (runData->info_type_type() == InfoTypes_RunStart) { auto runStartData = static_cast<const RunStart *>(runData->info_type()); setStartTimeInNanoseconds(runStartData->start_time()); setInstrumentName(runStartData->instrument_name()->str()); setRunNumber(runStartData->run_number()); setNumberOfPeriods(runStartData->n_periods()); return true; } if (runData->info_type_type() == InfoTypes_RunStop) { auto runStopData = static_cast<const RunStop *>(runData->info_type()); setStopTime(runStopData->stop_time()); return true; } return false; // this is not a RunData message }