/** Execute the algorithm */ void LoadEventPreNexus::exec() { // Check 'chunk' properties are valid, if set const int chunks = getProperty("TotalChunks"); if (!isEmpty(chunks) && int(getProperty("ChunkNumber")) > chunks) { throw std::out_of_range("ChunkNumber cannot be larger than TotalChunks"); } prog = new Progress(this, 0.0, 1.0, 100); // what spectra (pixel ID's) to load this->spectra_list = this->getProperty(PID_PARAM); // the event file is needed in case the pulseid fileanme is empty string event_filename = this->getPropertyValue(EVENT_PARAM); string pulseid_filename = this->getPropertyValue(PULSEID_PARAM); bool throwError = true; if (pulseid_filename.empty()) { pulseid_filename = generatePulseidName(event_filename); if (!pulseid_filename.empty()) { if (Poco::File(pulseid_filename).exists()) { this->g_log.information() << "Found pulseid file " << pulseid_filename << std::endl; throwError = false; } else { pulseid_filename = ""; } } } prog->report("Loading Pulse ID file"); this->readPulseidFile(pulseid_filename, throwError); this->openEventFile(event_filename); prog->report("Creating output workspace"); // prep the output workspace EventWorkspace_sptr localWorkspace = EventWorkspace_sptr(new EventWorkspace()); // Make sure to initialize. // We can use dummy numbers for arguments, for event workspace it doesn't // matter localWorkspace->initialize(1, 1, 1); // Set the units localWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create("TOF"); localWorkspace->setYUnit("Counts"); // TODO localWorkspace->setTitle(title); // Add the run_start property // Use the first pulse as the run_start time. if (this->num_pulses > 0) { // add the start of the run as a ISO8601 date/time string. The start = the // first pulse. // (this is used in LoadInstrument to find the right instrument file to // use). localWorkspace->mutableRun().addProperty( "run_start", pulsetimes[0].toISO8601String(), true); } // determine the run number and add it to the run object localWorkspace->mutableRun().addProperty("run_number", getRunnumber(event_filename)); // Get the instrument! prog->report("Loading Instrument"); this->runLoadInstrument(event_filename, localWorkspace); // load the mapping file prog->report("Loading Mapping File"); string mapping_filename = this->getPropertyValue(MAP_PARAM); if (mapping_filename.empty()) { mapping_filename = generateMappingfileName(localWorkspace); if (!mapping_filename.empty()) this->g_log.information() << "Found mapping file \"" << mapping_filename << "\"" << std::endl; } this->loadPixelMap(mapping_filename); // Process the events into pixels this->procEvents(localWorkspace); // Save output this->setProperty<IEventWorkspace_sptr>(OUT_PARAM, localWorkspace); // Cleanup delete prog; }
/** Execute the algorithm * Procedure: * 1. check all the inputs * 2. create an EventWorkspace object * 3. process events * 4. set out output */ void LoadEventPreNexus2::exec() { g_log.information("Executing LoadEventPreNexus Ver 2.0"); // Process input properties // a. Check 'chunk' properties are valid, if set const int chunks = getProperty("TotalChunks"); if (!isEmpty(chunks) && int(getProperty("ChunkNumber")) > chunks) { throw std::out_of_range("ChunkNumber cannot be larger than TotalChunks"); } prog = make_unique<Progress>(this, 0.0, 1.0, 100); // b. what spectra (pixel ID's) to load this->spectra_list = this->getProperty(PID_PARAM); // c. the event file is needed in case the pulseid fileanme is empty string event_filename = this->getPropertyValue(EVENT_PARAM); string pulseid_filename = this->getPropertyValue(PULSEID_PARAM); bool throwError = true; if (pulseid_filename.empty()) { pulseid_filename = generatePulseidName(event_filename); if (!pulseid_filename.empty()) { if (Poco::File(pulseid_filename).exists()) { this->g_log.information() << "Found pulseid file " << pulseid_filename << '\n'; throwError = false; } else { pulseid_filename = ""; } } } processInvestigationInputs(); // Read input files prog->report("Loading Pulse ID file"); this->readPulseidFile(pulseid_filename, throwError); prog->report("Loading Event File"); this->openEventFile(event_filename); // Correct event indexes mased by veto flag unmaskVetoEventIndex(); // Optinally output event number / pulse file std::string diswsname = getPropertyValue("EventNumberWorkspace"); if (!diswsname.empty()) { MatrixWorkspace_sptr disws = generateEventDistribtionWorkspace(); setProperty("EventNumberWorkspace", disws); } // Create otuput Workspace prog->report("Creating output workspace"); createOutputWorkspace(event_filename); // Process the events into pixels procEvents(localWorkspace); // Set output this->setProperty<IEventWorkspace_sptr>(OUT_PARAM, localWorkspace); // Fast frequency sample environment data this->processImbedLogs(); } // exec()