Skip to content

Commit

Permalink
Fixing the limits for event workspaces. Refs #3801.
Browse files Browse the repository at this point in the history
The real problem was that the contribution of each spectra was being
incorrectly calculated for an event workspace being treated as a
histogram. This works as long as bins are not marked as masked.
  • Loading branch information
peterfpeterson committed Nov 17, 2011
1 parent 5f72c91 commit 2f2cfe3
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions Code/Mantid/Framework/Algorithms/src/DiffractionFocussing2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,36 @@ void DiffractionFocussing2::exec()
// It also initializes the groupAtWorkspaceIndex[] array.
determineRebinParameters();

// determine event workspace min/max tof
double eventXMin = 0.;
double eventXMax = 0.;

eventW = boost::dynamic_pointer_cast<EventWorkspace>( matrixInputW );
if ((getProperty("PreserveEvents")) && (eventW != NULL))
if (eventW != NULL)
{
//Input workspace is an event workspace. Use the other exec method
this->execEvent();
this->cleanup();
return;
if (getProperty("PreserveEvents"))
{
//Input workspace is an event workspace. Use the other exec method
this->execEvent();
this->cleanup();
return;
}
else
{
eventXMin = std::numeric_limits<double>::max();
eventXMax = -1. * eventXMin;

double temp;
for (int64_t workspaceIndex = 0; workspaceIndex < nHist; workspaceIndex++)
{
temp = matrixInputW->dataX(workspaceIndex).front();
if (temp < eventXMin)
eventXMin = temp;
temp = matrixInputW->dataX(workspaceIndex).back();
if (temp > eventXMax)
eventXMax = temp;
}
}
}

//No problem? Then it is a normal Workspace2D
Expand Down Expand Up @@ -264,8 +287,17 @@ void DiffractionFocussing2::exec()
}
else // If no masked bins we want to add 1 to the weight of the output bins that this input covers
{
limits[0] = Xin.front();
limits[1] = Xin.back();
if (eventXMin > 0. && eventXMax > 0)
{
limits[0] = eventXMin;
limits[1] = eventXMax;
}
else
{
limits[0] = Xin.front();
limits[1] = Xin.back();
}

// Rebin the weights - note that this is a distribution
VectorHelper::rebin(limits,weights_default,emptyVec,Xout,groupWgt,EOutDummy,true,true);
}
Expand Down

0 comments on commit 2f2cfe3

Please sign in to comment.