Skip to content

Commit

Permalink
Re #6494. Enable cancellation in case of erroneous input.
Browse files Browse the repository at this point in the history
If the user inputs a log with a large range, print a warning and add
progress reporting and a couple of bonus spots where the algorithm can
be cancelled.
  • Loading branch information
RussellTaylor committed Sep 25, 2013
1 parent 7aac045 commit 99c6830
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/SumEventsByLogValue.cpp
Expand Up @@ -160,10 +160,15 @@ namespace Algorithms
const int maxVal = log->maxValue();
const int xLength = maxVal - minVal + 1;

if ( xLength > 10000 )
{
g_log.warning() << "Did you really want to create a " << xLength << " row table? This will take some time!\n";
}

// Accumulate things in a local vector before transferring to the table
std::vector<int> Y(xLength);
const int numSpec = static_cast<int>(m_inputWorkspace->getNumberHistograms());
Progress prog(this,0.0,1.0,numSpec);
Progress prog(this,0.0,1.0,numSpec+xLength);
PARALLEL_FOR1(m_inputWorkspace)
for ( int spec = 0; spec < numSpec; ++spec )
{
Expand Down Expand Up @@ -245,15 +250,18 @@ namespace Algorithms
}
timeCol->cell<double>(row) = duration;

interruption_point();
// Sum up the proton charge for this log value
if ( protonChargeLog ) protonChgCol->cell<double>(row) = sumProtonCharge(protonChargeLog, filter);
interruption_point();

for ( auto log = otherLogs.begin(); log != otherLogs.end(); ++log )
{
// Calculate the average value of each 'other' log for the current value of the main log
// Have to (maybe inefficiently) fetch back column by name - move outside loop if too slow
outputWorkspace->getColumn(log->first)->cell<double>(row) = log->second->averageValueInFilter(filter);
}
prog.report();
}

setProperty("OutputWorkspace",outputWorkspace);
Expand Down

0 comments on commit 99c6830

Please sign in to comment.