Skip to content

Commit

Permalink
refs #4509. Fix error bars and a crash on Debug Win64
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Feb 3, 2012
1 parent e687029 commit 18ceedf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
41 changes: 25 additions & 16 deletions Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,27 +640,36 @@ namespace MDEvents
outOfBounds = true;
}



//TODO: make the logic/reuse in the following nicer.
if (!outOfBounds)
{
// The point is in the workspace.
box = data->getBoxAtCoord(coord.getBareArray());
// What is our normalization factor?
signal_t normalizer = 1.0;
switch (normalize)
if(box != NULL)
{
// What is our normalization factor?
signal_t normalizer = 1.0;
switch (normalize)
{
case NoNormalization:
break;
case VolumeNormalization:
normalizer = box->getInverseVolume();
break;
case NumEventsNormalization:
normalizer = double(box->getNPoints());
break;
}

// And add the normalized signal/error to the list
y.push_back( box->getSignal() * normalizer );
e.push_back( box->getError() * normalizer );
}
else
{
case NoNormalization:
break;
case VolumeNormalization:
normalizer = box->getInverseVolume();
break;
case NumEventsNormalization:
normalizer = double(box->getNPoints());
break;
y.push_back(std::numeric_limits<double>::quiet_NaN());
e.push_back(std::numeric_limits<double>::quiet_NaN());
}
// And add the normalized signal/error to the list
y.push_back( box->getSignal() * normalizer );
e.push_back( box->getError() * normalizer );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/API/src/MantidQwtIMDWorkspaceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ double MantidQwtIMDWorkspaceData::y(size_t i) const
/// Returns the x position of the error bar for the i-th data point (bin)
double MantidQwtIMDWorkspaceData::ex(size_t i) const
{
return (this->x(i) + this->x(i+1)) / 2.0;
return this->x(i);
}

/// Returns the error of the i-th data point
Expand Down

0 comments on commit 18ceedf

Please sign in to comment.