Skip to content

Commit

Permalink
refs #6449 Other syntax differences
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts authored and martyngigg committed Apr 10, 2013
1 parent 7468db3 commit 2c3666a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "MantidGeometry/MDGeometry/MDTypes.h"
#include "MantidKernel/System.h"
#include <limits>
#include <boost/lexical_cast.hpp>

namespace Mantid
{
Expand Down Expand Up @@ -49,9 +50,7 @@ namespace Geometry
//
std::string extentsStr()const
{
std::stringstream mess;
mess<< min << "-"<< max;
return mess.str();
return (boost::lexical_cast<std::string>(min)+"-"+boost::lexical_cast<std::string>(max));
}
T getMin()const{return min;}
T getMax()const{return max;}
Expand Down
13 changes: 2 additions & 11 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,6 @@ namespace MDEvents
return "MDEvent";
}

/**The function returns number of data fields present in an Lean event.
For lean event it is nd+4 where nd describes the events coordinates, 2 goes for signal and error, and 2 for DetID and RunID*/
template<size_t nd>
static inline size_t getNumFields()
{
return nd+4;
}


/* static method used to convert vector of lean events into vector of their coordinates & signal and error
@param events -- vector of events
@return data -- vector of events data, namely, their signal and error casted to coord_t type
Expand All @@ -219,7 +210,7 @@ namespace MDEvents
template<size_t nd>
static inline void eventsToData(const std::vector<MDEvent<nd> > & events,std::vector<coord_t> &data,size_t &ncols,double &totalSignal,double &totalErrSq )
{
ncols = getNumFields<nd>();
ncols = (nd+4);
size_t nEvents=events.size();
data.resize(nEvents*ncols);

Expand Down Expand Up @@ -257,7 +248,7 @@ namespace MDEvents
static inline void dataToEvents(const std::vector<coord_t> &data, std::vector<MDEvent<nd> > & events, bool reserveMemory=true)
{
// Number of columns = number of dimensions + 4 (signal/error)+detId+runID
size_t numColumns = getNumFields<nd>();
size_t numColumns = (nd+4);
size_t numEvents = data.size()/numColumns;
if(numEvents*numColumns!=data.size())
throw(std::invalid_argument("wrong input array of data to convert to lean events, suspected column data for different dimensions/(type of) events "));
Expand Down
12 changes: 3 additions & 9 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDLeanEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,7 @@ namespace MDEvents
{
return 0;
}
/**The function returns number of data fields present in an Lean event.
For lean event it is nd+2 where nd describes the events coordinates and 2 goes for signal and error*/
template<size_t nd>
static inline size_t getNumFields()
{
return nd+2;
}


/* static method used to convert vector of lean events into vector of their coordinates & signal and error
@param events -- vector of events
Expand All @@ -297,7 +291,7 @@ namespace MDEvents
template<size_t nd>
static inline void eventsToData(const std::vector<MDLeanEvent<nd> > & events,std::vector<coord_t> &data,size_t &ncols,double &totalSignal,double &totalErrSq )
{
ncols = getNumFields<nd>();
ncols = nd+2;
size_t nEvents=events.size();
data.resize(nEvents*ncols);

Expand Down Expand Up @@ -333,7 +327,7 @@ namespace MDEvents
static inline void dataToEvents(const std::vector<coord_t> &coord, std::vector<MDLeanEvent<nd> > & events, bool reserveMemory=true)
{
// Number of columns = number of dimensions + 2 (signal/error)
size_t numColumns = getNumFields<nd>();
size_t numColumns = (nd+2);
size_t numEvents = coord.size()/numColumns;
if(numEvents*numColumns!=coord.size())
throw(std::invalid_argument("wrong input array of data to convert to lean events, suspected column data for different dimensions/(type of) events "));
Expand Down

0 comments on commit 2c3666a

Please sign in to comment.