Skip to content

Commit

Permalink
refs #6449 finishing touches for MDEvents project
Browse files Browse the repository at this point in the history
only MDBoxFlatTree may still need to be modified for this ticket.
  • Loading branch information
abuts committed Apr 16, 2013
1 parent b6b6b3a commit dd6d71b
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 244 deletions.
9 changes: 6 additions & 3 deletions Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ namespace API
{return m_numEventsAtMax;}
/// get range of id-s and increment box ID by this range;
size_t claimIDRange(size_t range);

/// the function left for compartibility with the previous bc python interface.
std::string getFilename()const;
/// the compartibility function -- the write buffer is always used for file based workspaces
bool useWriteBuffer()const;
private:
/// When you split a MDBox, it becomes this many sub-boxes
void calcNumSplit()
Expand Down Expand Up @@ -447,9 +452,7 @@ namespace API
/// Instance of the disk-caching MRU list.
// mutable Mantid::Kernel::DiskBuffer m_diskBuffer;

/// Do we use the DiskBuffer at all? Always use WB
// bool m_useWriteBuffer;


/// Number of bytes in a single MDLeanEvent<> of the workspace.
//size_t m_bytesPerEvent;
public:
Expand Down
19 changes: 18 additions & 1 deletion Code/Mantid/Framework/API/src/BoxController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,24 @@ namespace API

return xmlstream.str().c_str();
}

/** the function left for compartibility with the previous bc python interface.
@return -- the file name of the file used for backup if file backup mode is enabled or emtpy sting if the workspace is not file backed */
std::string BoxController::getFilename()const
{
if(m_fileIO)
return m_fileIO->getFileName();
else
return "";
}
/** the function left for compartibility with the previous bc python interface.
@return true if the workspace is file based and false otherwise */
bool BoxController::useWriteBuffer()const
{
if(m_fileIO)
return true;
else
return false;
}

//------------------------------------------------------------------------------------------------------
/** Static method that sets the data inside this BoxController from an XML string
Expand Down
40 changes: 20 additions & 20 deletions Code/Mantid/Framework/Algorithms/src/BinaryOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,34 +823,34 @@ namespace Mantid
PARALLEL_FOR1(out)
for(int64_t i = 0; i < nindices; ++i)
{
if (!m_parallelException && !m_cancel)
{
if (!m_parallelException && !m_cancel)
{
try
{
IDetector_const_sptr det_out = out->getDetector(m_indicesToMask[i]);
PARALLEL_CRITICAL(BinaryOperation_masking)
{
pmap.addBool(det_out.get(), "masked", true);
}
} /* End of try block in PARALLEL_START_INTERUPT_REGION */
catch(Kernel::Exception::NotFoundError )
{ // detector not found, do nothing, go further
}
catch(std::runtime_error &ex)
{
{
IDetector_const_sptr det_out = out->getDetector(m_indicesToMask[i]);
PARALLEL_CRITICAL(BinaryOperation_masking)
{
pmap.addBool(det_out.get(), "masked", true);
}
} /* End of try block in PARALLEL_START_INTERUPT_REGION */
catch(Kernel::Exception::NotFoundError )
{ // detector not found, do nothing, go further
}
catch(std::runtime_error &ex)
{
if (!m_parallelException)
{
m_parallelException = true;
g_log.error() << this->name() << ": " << ex.what() << "\n";
}
}
}
catch(...)
{
m_parallelException = true;
}
{
m_parallelException = true;
}

} // End of if block in PARALLEL_START_INTERUPT_REGION
} // End of if block in PARALLEL_START_INTERUPT_REGION

}
PARALLEL_CHECK_INTERUPT_REGION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ namespace MDEvents

/// Set the special coordinate system.
void setCoordinateSystem(const Mantid::API::SpecialCoordinateSystem coordinateSystem);

/// make the workspace file backed if it has not been already file backed;
void setFileBacked(const std::string &fileName);
protected:

/** MDBox containing all of the events in the workspace. */
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 @@ -6,7 +6,7 @@ namespace Mantid
{
namespace MDEvents
{
/**function converts particular list of events of type T into MD workspace space and adds these events to the workspace itself */
/**function converts particular list of events of type T into MD workspace and adds these events to the workspace itself */
template <class T>
size_t ConvToMDEventsWS::convertEventList(size_t workspaceIndex)
{
Expand Down
37 changes: 23 additions & 14 deletions Code/Mantid/Framework/MDEvents/src/MDBoxFlatTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ namespace Mantid
}

}

/*** this function tries to set file positions of the boxes to
make data physiclly located close to each otger to be as close as possible on the HDD
@param setFileBacked -- initiate the boxes to be fileBacked.
*/
void MDBoxFlatTree::setBoxesFilePositions(bool setFileBacked)
{
// this will preserve file-backed workspace and information in it as we are not loading old box data and not?
Expand All @@ -146,7 +149,7 @@ namespace Mantid
// m_BoxEventIndex[ID*2] = 0; should we do this for the boxes without events?

if(setFileBacked)
mdBox->setFileBacked(eventsStart,nEvents,true);
mdBox->setFileBacked(eventsStart,nEvents,false);
}
}

Expand Down Expand Up @@ -184,19 +187,26 @@ namespace Mantid
size_t maxBoxes = this->getNBoxes();
if(maxBoxes==0)return;

bool update=true;
std::map<std::string, std::string> groupEntries;
hFile->getEntries(groupEntries);


bool update(false);
if(groupEntries.find("box_structure")!=groupEntries.end()) //dimesnions dataset exist
update = true;

// Start the box data group
try
if(update)
{
hFile->openGroup("box_structure", "NXdata");
}catch(...)
{
update = false;
hFile->makeGroup("box_structure", "NXdata",true);
hFile->putAttr("version", "1.0");
// Add box controller info to this group
hFile->putAttr("box_controller_xml", m_bcXMLDescr);

}
hFile->putAttr("version", "1.0");
// Add box controller info to this group
hFile->putAttr("box_controller_xml", m_bcXMLDescr);
else
hFile->openGroup("box_structure", "NXdata");


std::vector<int64_t> exents_dims(2,0);
exents_dims[0] = (int64_t(maxBoxes));
Expand Down Expand Up @@ -419,9 +429,8 @@ namespace Mantid



// TODO: Get rid of this --> create the box generator and move it into MDBoxFactory!


// TODO: Get rid of this --> create the box generator and move all below into MDBoxFactory!

template DLLExport uint64_t MDBoxFlatTree::restoreBoxTree<MDLeanEvent<1>, 1>(std::vector<API::IMDNode * >&Boxes,API::BoxController_sptr bc, bool FileBackEnd,bool BoxStructureOnly);
template DLLExport uint64_t MDBoxFlatTree::restoreBoxTree<MDLeanEvent<2>, 2>(std::vector<API::IMDNode * >&Boxes,API::BoxController_sptr bc, bool FileBackEnd,bool BoxStructureOnly);
template DLLExport uint64_t MDBoxFlatTree::restoreBoxTree<MDLeanEvent<3>, 3>(std::vector<API::IMDNode * >&Boxes,API::BoxController_sptr bc, bool FileBackEnd,bool BoxStructureOnly);
Expand Down

0 comments on commit dd6d71b

Please sign in to comment.