Skip to content

Commit

Permalink
refs #4201 fixing crash caused by negative size_t
Browse files Browse the repository at this point in the history
was in EventsToEvents branch
  • Loading branch information
abuts committed Jan 6, 2012
1 parent 922a084 commit cadc635
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDEventWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ namespace API

/// Set the number of bins in each dimension to something corresponding to the estimated resolution of the finest binning
virtual void estimateResolution() = 0;
/// get number of dimensions contained in initialized MD workspace
virtual size_t getNumDims()const=0;

/// Split all boxes that exceed the split threshold.
virtual void splitAllIfNeeded(Kernel::ThreadScheduler * ts) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void ConvertToMDEvents::processQNDEWS()
int32_t det_id = det_loc.det_id[wi];

const DataObjects::EventList & el = pEventWS->getEventList(ic);
size_t numEvents = el.getNumberEvents();
size_t numEvents = (int64_t)el.getNumberEvents();


const MantidVec& X = el.dataX();
Expand All @@ -190,7 +190,7 @@ void ConvertToMDEvents::processQNDEWS()
if(!trn.calcYDepCoordinates(Coord,ic))continue; // skip y outsize of the range;

//=> START INTERNAL LOOP OVER THE "TIME"
for (size_t j = 0; j < numEvents-1; ++j)
for (size_t j = 0; j < Signal.size(); ++j)
{
// drop emtpy histohrams
if(Signal[j]<FLT_EPSILON)continue;
Expand Down
12 changes: 6 additions & 6 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ void ConvertToMDEvents::exec()
}
else
{
n_activated_dimensions = spws->getNumDims();
dim_min.assign(n_activated_dimensions,-1);
dim_max.assign(n_activated_dimensions,1);
throw(Kernel::Exception::NotImplementedError("Adding to existing MD workspace not Yet Implemented"));
Expand Down Expand Up @@ -666,20 +667,19 @@ ConvertToMDEvents::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,const std
convert_log.error()<<"Can not currently deal with more then: "<<pWSWrapper->getMaxNDim()<< " dimesnions, but requested: "<<nDims<<std::endl;
throw(std::invalid_argument(" Too many dimensions requested "));
}

// get emode
int emode;
// any inelastic mode or unit conversion involing TOF needs Ei to be among the input workspace properties
if (!Q_mode_req.empty()){
emode = getEMode(this);
}else{
emode = -1;
emode = -1; // no coordinate conversion
}
//if((emode == 1)||(emode == 2)||(the_algID.find("TOF")!=std::string::npos))
// any inelastic mode needs Ei to be among the input workspace properties
if((emode == 1)||(emode == 2))
{
if(!inWS->run().hasProperty("Ei")){
convert_log.error()<<" Conversion sub-algorithm with ID: "<<the_algID<<" needs input energy to be present among run properties\n";
throw(std::invalid_argument(" Needs Input energy to be present "));
convert_log.error()<<" Conversion sub-algorithm with ID: "<<the_algID<<" (inelastic) needs input energy to be present among run properties\n";
throw(std::invalid_argument(" Needs Input energy to be present for inelastic modes"));
}
}

Expand Down

0 comments on commit cadc635

Please sign in to comment.