Skip to content

Commit

Permalink
refs #6449 intermediate commit for rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 5, 2013
1 parent 8460896 commit 347c776
Show file tree
Hide file tree
Showing 19 changed files with 178 additions and 198 deletions.
3 changes: 1 addition & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ class IMDNode
virtual void splitAllIfNeeded(Mantid::Kernel::ThreadScheduler * /*ts*/ = NULL)=0;
/** Recalculate signal etc. */
virtual void refreshCache(Kernel::ThreadScheduler * /*ts*/ = NULL)=0;
/** Cache the centroid of this box and all sub-boxes. */
virtual void refreshCentroid(Kernel::ThreadScheduler * /*ts*/ = NULL)= 0;
/** Calculate the centroid of this box and all sub-boxes. */
virtual void calculateCentroid(coord_t * /*centroid*/) const=0;
//----------------------------------------------------------------------------------------------------------------------------------
// MDBoxBase interface, related to average signals/box parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ConvertToMDEventsWS<ConvertToMD::EventWSType,Q,MODE,CONV,Sample>: public C
pWSWrapper->pWorkspace()->splitAllIfNeeded(NULL);
// Recount totals at the end.
pWSWrapper->pWorkspace()->refreshCache();
pWSWrapper->refreshCentroid();

pProg->report();
}
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class ConvertToMDEventsWS<ConvertToMD::Ws2DHistoType,Q,MODE,CONV,Sample>: public

pWSWrapper->pWorkspace()->splitAllIfNeeded(NULL);
pWSWrapper->pWorkspace()->refreshCache();
pWSWrapper->refreshCentroid();
pProg->report();
}
};
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDAlgorithms/src/FindPeaksMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ namespace MDAlgorithms

// TODO: This might be slow, progress report?
// Make sure all centroids are fresh
ws->getBox()->refreshCentroid();
//ws->getBox()->refreshCentroid();

if (ws->getNumExperimentInfo() == 0)
throw std::runtime_error("No instrument was found in the MDEventWorkspace. Cannot find peaks.");
Expand Down
44 changes: 11 additions & 33 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ namespace MDEvents
uint64_t getTotalDataSize()const{return getNPoints();}

size_t getNumDims() const;

size_t getNumMDBoxes() const;

/// Get the # of children MDBoxBase'es (non-recursive)
Expand All @@ -81,19 +80,11 @@ namespace MDEvents
void setChildren(const std::vector<API::IMDNode *> & /*boxes*/, const size_t /*indexStart*/, const size_t /*indexEnd*/)
{ throw std::runtime_error("MDBox cannot have children."); }


/// @return true if events were added to the box (using addEvent()) while the rest of the event list is cached to disk
bool isDataAdded() const;


/* Getter to determine if masking is applied.
@return true if masking is applied.
*/
virtual bool getIsMasked() const
{
return m_bIsMasked;
}
/**Get vector of events to change. Beware, that calling this funtion for file-based workspace sets both dataChanged and dataBusy flags
/**Get vector of events to change. Beware, that calling this funtion for file-based workspace sets both dataChanged and dataBusy flags
first forces disk buffer to write the object contents to HDD when disk buffer is full and the second one prevents DB
from clearing object from memory untill the events are released. One HAS TO call releaseEvents when finished using data on file-based WS */
std::vector< MDE > & getEvents();
Expand All @@ -103,7 +94,6 @@ namespace MDEvents
const std::vector<MDE> & getConstEvents()const ;
// the same as getConstEvents above,
const std::vector< MDE > & getEvents()const;

void releaseEvents() ;

std::vector< MDE > * getEventsCopy();
Expand Down Expand Up @@ -131,54 +121,42 @@ namespace MDEvents
//---------------------------------------------------------------------------------------------------------------------------------
void centerpointBin(MDBin<MDE,nd> & bin, bool * fullyContained) const;
void generalBin(MDBin<MDE,nd> & bin, Mantid::Geometry::MDImplicitFunction & function) const;

//---------------------------------------------------------------------------------------------------------------------------------
void splitAllIfNeeded(Mantid::Kernel::ThreadScheduler * /*ts*/ = NULL)
{ /* Do nothing with a box default. */ }

/** Recalculate signal etc. */
//---------------------------------------------------------------------------------------------------------------------------------
/** Recalculate signal and various averages dependent on signal and the signal coordinates */
void refreshCache(Kernel::ThreadScheduler * /*ts*/ = NULL);
/** Calculate the centroid of this box. */
void refreshCentroid(Kernel::ThreadScheduler * /*ts*/ = NULL)
{};
void calculateCentroid(coord_t * centroid) const;

void calculateDimensionStats(MDDimensionStats * stats) const;

void integrateSphere(Mantid::API::CoordTransform & radiusTransform, const coord_t radiusSquared, signal_t & signal, signal_t & errorSquared) const;

void centroidSphere(Mantid::API::CoordTransform & radiusTransform, const coord_t radiusSquared, coord_t * centroid, signal_t & signal) const;

//------------------------------------------------------------------------------------------------------------------------------------
//void saveNexus(::NeXus::File * file) const;

//void loadNexus(::NeXus::File * file, bool setLoaded=true);

void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t /*maxDepth*/, bool /*leafOnly*/);
void getBoxes(std::vector<API::IMDNode *> & boxes, size_t /*maxDepth*/, bool /*leafOnly*/);

void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function);
void getBoxes(std::vector<API::IMDNode *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function);

//------------------------------------------------------------------------------------------------------------------------------------
void transformDimensions(std::vector<double> & scaling, std::vector<double> & offset);

//------------------------------------------------------------------------------------------------------------------------------------
/* Getter to determine if masking is applied.
@return true if masking is applied. */
virtual bool getIsMasked() const { return m_bIsMasked; }
///Setter for masking the box
void mask();

///Setter for unmasking the box
void unmask();

protected:
// the pointer to the class, responsible for saving/restoring this class to the hdd
mutable MDBoxSaveable *m_Saveable;
/// Mutex for modifying the event list
Mantid::Kernel::Mutex dataMutex;

/** Vector of MDLeanEvent's, in no particular order.
* */
Mantid::Kernel::Mutex dataMutex;
/** Vector of MDLeanEvent's, in no particular order. */
mutable std::vector< MDE > data;


/// Flag indicating that masking has been applied.
bool m_bIsMasked;
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,7 @@ namespace MDEvents
virtual Mantid::API::BoxController *const getBoxController()
{ return m_BoxController; }

/** Set the box controller used.
* @param controller :: Mantid::API::BoxController *
*/
//virtual void setBoxController(Mantid::API::BoxController *controller)
//{ m_BoxController = controller; }



// -------------------------------- Geometry/vertexes-Related -------------------------------------------

std::vector<Mantid::Kernel::VMD> getVertexes() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Mantid
/// get access to the internal workspace
API::IMDEventWorkspace_sptr pWorkspace(){return m_Workspace;}
// should it be moved to the IMDEvents?
void refreshCentroid(){ (this->*(mdCalCentroid[m_NDimensions]))(); };
//void refreshCentroid(){ (this->*(mdCalCentroid[m_NDimensions]))(); };
/** initiate the class with pointer to existing MD workspace */
void setMDWS(API::IMDEventWorkspace_sptr spWS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ namespace MDEvents
virtual void setMinRecursionDepth(size_t minDepth);

//------------------------ (END) IMDEventWorkspace Methods -----------------------------------------
// TODO: The meaning of boxes have changed
//Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num);
Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num);

virtual void getBoxes(std::vector<API::IMDNode *> & boxes, size_t maxDepth, bool leafOnly)
{
Expand Down
12 changes: 3 additions & 9 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,7 @@ namespace MDEvents

size_t getChildIndexFromID(size_t childId) const;
API::IMDNode * getChild(size_t index);
//void setChild(size_t index,MDGridBox<MDE,nd> * newChild)
//{
// // Delete the old box (supposetly ungridded);
// delete this->boxes[index];
// // set new box, supposetly gridded
// this->boxes[index]=newChild;
//}
void setChild(size_t index,MDGridBox<MDE,nd> * newChild);

void setChildren(const std::vector<API::IMDNode *> & boxes, const size_t indexStart, const size_t indexEnd);

Expand Down Expand Up @@ -130,7 +124,7 @@ namespace MDEvents

void refreshCache(Kernel::ThreadScheduler * ts = NULL);

void refreshCentroid(Kernel::ThreadScheduler * ts = NULL);
//void refreshCentroid(Kernel::ThreadScheduler * ts = NULL);

// Set the box controller overrriden.
//virtual void setBoxController(Mantid::API::BoxController *controller);
Expand Down Expand Up @@ -192,7 +186,7 @@ namespace MDEvents

size_t computeSizesFromSplit();
void fillBoxShell(const size_t tot,const coord_t inverseVolume);

/**private default copy constructor as the only correct constructor is the one with box controller */
MDGridBox(const MDGridBox<MDE, nd> & box);
public:

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDEvents/src/ConvToMDEventsWS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace Mantid

// Recount totals at the end.
m_OutWSWrapper->pWorkspace()->refreshCache();
m_OutWSWrapper->refreshCentroid();
//m_OutWSWrapper->refreshCentroid();
pProgress->report();

/// Set the special coordinate system flag on the output workspace.
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDEvents/src/ConvToMDHistoWS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace Mantid
m_OutWSWrapper->pWorkspace()->splitAllIfNeeded(NULL);
}
m_OutWSWrapper->pWorkspace()->refreshCache();
m_OutWSWrapper->refreshCentroid();
//m_OutWSWrapper->refreshCentroid();
pProgress->report();

/// Set the special coordinate system flag on the output workspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ namespace MDEvents
if (DODEBUG) g_log.information() << cputim << ": Performing the refreshCache().\n";

//TODO: Centroid in parallel, maybe?
ws->getBox()->refreshCentroid(NULL);
if (DODEBUG) g_log.information() << cputim << ": Performing the refreshCentroid().\n";
//ws->getBox()->refreshCentroid(NULL);
//if (DODEBUG) g_log.information() << cputim << ": Performing the refreshCentroid().\n";


if (DODEBUG)
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDEvents/src/MDEventWSWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void MDEventWSWrapper::calcCentroidND(void)
MDEvents::MDEventWorkspace<MDEvents::MDEvent<nd>,nd> *const pWs = dynamic_cast<MDEvents::MDEventWorkspace<MDEvents::MDEvent<nd>,nd> *>(this->m_Workspace.get());
if(!pWs) throw(std::bad_cast());

pWs->getBox()->refreshCentroid(NULL);
//pWs->getBox()->refreshCentroid(NULL);
}
/// the function used in template metaloop termination on 0 dimensions and as the function which will throw the error on undefined MDWorkspaceWrapper
template<>
Expand Down

0 comments on commit 347c776

Please sign in to comment.