本文整理汇总了C++中EventWorkspace_const_sptr::getLastPulseTime方法的典型用法代码示例。如果您正苦于以下问题:C++ EventWorkspace_const_sptr::getLastPulseTime方法的具体用法?C++ EventWorkspace_const_sptr::getLastPulseTime怎么用?C++ EventWorkspace_const_sptr::getLastPulseTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventWorkspace_const_sptr
的用法示例。
在下文中一共展示了EventWorkspace_const_sptr::getLastPulseTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
/** Executes the algorithm
*/
void FilterByTime::exec()
{
EventWorkspace_const_sptr inputWS = this->getProperty("InputWorkspace");
// ---- Find the start/end times ----
DateAndTime start, stop;
double start_dbl, stop_dbl;
start_dbl = getProperty("StartTime");
stop_dbl = getProperty("StopTime");
std::string start_str, stop_str;
start_str = getPropertyValue("AbsoluteStartTime");
stop_str = getPropertyValue("AbsoluteStopTime");
if ( (start_str != "") && (stop_str != "") && (start_dbl <= 0.0) && (stop_dbl <= 0.0) )
{
// Use the absolute string
start = DateAndTime( start_str );
stop = DateAndTime( stop_str );
}
else if ( (start_str == "") && (stop_str == "") && ((start_dbl > 0.0) || (stop_dbl > 0.0)) )
{
// Use the relative times in seconds.
DateAndTime first = inputWS->getFirstPulseTime();
DateAndTime last = inputWS->getLastPulseTime();
start = first + start_dbl;
if (stop_dbl > 0.0)
{
stop = first + stop_dbl;
}
else
{
this->getLogger().debug() << "No end filter time specified - assuming last pulse" << std::endl;
stop = last + 10000.0; // so we get all events - needs to be past last pulse
}
}
else
{
//Either both or none were specified
throw std::invalid_argument("You need to specify either the StartTime or StopTime parameters; or both the AbsoluteStartTime and AbsoluteStopTime parameters; but not other combinations.");
}
if (stop <= start)
throw std::invalid_argument("The stop time should be larger than the start time.");
// Make a brand new EventWorkspace
EventWorkspace_sptr outputWS = boost::dynamic_pointer_cast<EventWorkspace>(
API::WorkspaceFactory::Instance().create("EventWorkspace", inputWS->getNumberHistograms(), 2, 1));
// Copy geometry over.
API::WorkspaceFactory::Instance().initializeFromParent(inputWS, outputWS, false);
// But we don't copy the data.
setProperty("OutputWorkspace", outputWS);
size_t numberOfSpectra = inputWS->getNumberHistograms();
// Initialise the progress reporting object
Progress prog(this,0.0,1.0,numberOfSpectra);
// Loop over the histograms (detector spectra)
PARALLEL_FOR_NO_WSP_CHECK()
for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i)
{
PARALLEL_START_INTERUPT_REGION
//Get the output event list (should be empty)
EventList& output_el = outputWS->getEventList(i);
//and this is the input event list
const EventList& input_el = inputWS->getEventList(i);
//Perform the filtering
input_el.filterByPulseTime(start, stop, output_el);
prog.report();
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
//Now filter out the run, using the DateAndTime type.
outputWS->mutableRun().filterByTime(start, stop);
}