From dd6d71b51cf13a0b30f097443b2c486d1f4e48f6 Mon Sep 17 00:00:00 2001 From: Alex Buts <Alex.Buts@stfc.ac.uk> Date: Tue, 2 Apr 2013 17:39:52 +0100 Subject: [PATCH] refs #6449 finishing touches for MDEvents project only MDBoxFlatTree may still need to be modified for this ticket. --- .../API/inc/MantidAPI/BoxController.h | 9 +- .../Framework/API/src/BoxController.cpp | 19 +- .../Algorithms/src/BinaryOperation.cpp | 40 ++-- .../inc/MantidMDEvents/MDEventWorkspace.h | 3 +- .../MDEvents/src/ConvToMDEventsWS.cpp | 2 +- .../Framework/MDEvents/src/MDBoxFlatTree.cpp | 37 ++-- .../Framework/MDEvents/src/MDBoxSaveable.cpp | 195 +----------------- .../MDEvents/src/MDEventWorkspace.cpp | 10 +- .../Framework/MDEvents/src/MDTransfModQ.cpp | 17 +- .../MDEvents/src/UnitsConversionHelper.cpp | 8 +- .../Framework/MDEvents/test/MDBoxBaseTest.h | 1 + .../mantid/api/src/Exports/BoxController.cpp | 3 +- .../TestHelpers/src/BoxControllerDummyIO.cpp | 20 +- 13 files changed, 120 insertions(+), 244 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h b/Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h index 5db2d235d7e..6e8a457f4f3 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h @@ -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() @@ -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: diff --git a/Code/Mantid/Framework/API/src/BoxController.cpp b/Code/Mantid/Framework/API/src/BoxController.cpp index 316ba6d6d5b..2003a8b54bd 100644 --- a/Code/Mantid/Framework/API/src/BoxController.cpp +++ b/Code/Mantid/Framework/API/src/BoxController.cpp @@ -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 diff --git a/Code/Mantid/Framework/Algorithms/src/BinaryOperation.cpp b/Code/Mantid/Framework/Algorithms/src/BinaryOperation.cpp index 138bd89c31d..17b807b8ba3 100644 --- a/Code/Mantid/Framework/Algorithms/src/BinaryOperation.cpp +++ b/Code/Mantid/Framework/Algorithms/src/BinaryOperation.cpp @@ -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 diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h index 6f5add8ca18..4a12dcc955b 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h @@ -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. */ diff --git a/Code/Mantid/Framework/MDEvents/src/ConvToMDEventsWS.cpp b/Code/Mantid/Framework/MDEvents/src/ConvToMDEventsWS.cpp index fe146cadf21..29bb15a1cb1 100644 --- a/Code/Mantid/Framework/MDEvents/src/ConvToMDEventsWS.cpp +++ b/Code/Mantid/Framework/MDEvents/src/ConvToMDEventsWS.cpp @@ -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) { diff --git a/Code/Mantid/Framework/MDEvents/src/MDBoxFlatTree.cpp b/Code/Mantid/Framework/MDEvents/src/MDBoxFlatTree.cpp index 452c4fd25d9..2ef57738a15 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDBoxFlatTree.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDBoxFlatTree.cpp @@ -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? @@ -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); } } @@ -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)); @@ -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); diff --git a/Code/Mantid/Framework/MDEvents/src/MDBoxSaveable.cpp b/Code/Mantid/Framework/MDEvents/src/MDBoxSaveable.cpp index 47e1c35a362..3b885c0f6b4 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDBoxSaveable.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDBoxSaveable.cpp @@ -5,7 +5,6 @@ namespace Mantid { namespace MDEvents { - //using Mantid::Kernel::DiskBuffer; MDBoxSaveable::MDBoxSaveable(API::IMDNode *const Host): m_MDNode(Host) @@ -19,8 +18,8 @@ namespace MDEvents } //----------------------------------------------------------------------------------------------- - /** Physical save the whole data. Tries to load any previous data from HDD - * Called from the DiskBuffer. + /** Physically save the box data. Tries to load any previous data from HDD + * Private function called from the DiskBuffer. */ void MDBoxSaveable::save()const { @@ -37,7 +36,9 @@ namespace MDEvents } -/** Loads the data from HDD if these data were not loaded before. */ +/** Loads the data from HDD if these data has not been loaded before. + * private function called from the DiskBuffer + */ void MDBoxSaveable::load() { API::IBoxControllerIO *fileIO = m_MDNode->getBoxController()->getFileIO(); @@ -52,39 +53,7 @@ namespace MDEvents } // old save parts -// // std::cout << "MDBox ID " << this->getId() << " being saved." << std::endl; -// -// -// // this aslo indirectly checks if the object knows its place (may be wrong place but no checks for that here) -// if (this->wasSaved()) -// { -// //TODO: redesighn const_cast -// -// MDBox<MDE,nd> *loader = const_cast<MDBox<MDE,nd> *>(this); -// loader->load(); -// -// -// // This is the new size of the event list, possibly appended (if used AddEvent) or changed otherwise (non-const access) -// if (data.size() > 0) -// { -// -// // Save at the ISaveable specified place -// this->saveNexus(this->m_BoxController->getFile()); -// } -// } -// else -// if(data.size()>0) throw std::runtime_error(" Attempt to save undefined event"); -// -// - -// -// //--------------------------------------------------------------------------------------------- -// /** Do any final clean up of NXS event data blocks -// * -// * @param file :: open NXS file. -// */ -// // // //--------------------------------------------------------------------------------------------- // /** Put a slab of MDEvent data into the nexus file. @@ -161,52 +130,6 @@ namespace MDEvents // // } // -// //--------------------------------------------------------------------------------------------- -// /** Static method to save a vector of MDEvents of this type to a nexus file -// * open to the right group. -// * This method plops the events as a slab at a particular point in an already created array. -// * The data block MUST be already open. -// * -// * This will be re-implemented by any other MDLeanEvent-like type. -// * -// * @param events :: reference to the vector of events to save. -// * @param file :: open NXS file. -// * @param startIndex :: index in the array to start saving to -// * @param[out] totalSignal :: returns the integrated signal of all events -// * @param[out] totalErrorSquared :: returns the integrated squared error of all events -// * */ -// static void saveVectorToNexusSlab(const std::vector<MDLeanEvent<nd> > & events, ::NeXus::File * file, const uint64_t startIndex, -// signal_t & totalSignal, signal_t & totalErrorSquared) -// { -// size_t numEvents = events.size(); -// size_t numColumns = nd+2; -// coord_t * data = new coord_t[numEvents*numColumns]; -// -// totalSignal = 0; -// totalErrorSquared = 0; -// -// size_t index = 0; -// typename std::vector<MDLeanEvent<nd> >::const_iterator it = events.begin(); -// typename std::vector<MDLeanEvent<nd> >::const_iterator it_end = events.end(); -// for (; it != it_end; ++it) -// { -// const MDLeanEvent<nd> & event = *it; -// float signal = event.signal; -// float errorSquared = event.errorSquared; -// data[index++] = static_cast<coord_t>(signal); -// data[index++] = static_cast<coord_t>(errorSquared); -// for(size_t d=0; d<nd; d++) -// data[index++] = event.center[d]; -// // Track the total signal -// totalSignal += signal_t(signal); -// totalErrorSquared += signal_t(errorSquared); -// } -// -// putDataInNexus(file, data, startIndex, numEvents, numColumns); -// -// } -// -// //--------------------------------------------------------------------------------------------- // /** Get a slab of MDEvent data out of the nexus file. // * This is reused by both MDEvent and MDLeanEvent // * @@ -267,46 +190,6 @@ namespace MDEvents // file->getSlab(data, start, size); //#endif // return data; -// } -// -// //--------------------------------------------------------------------------------------------- -// /** Static method to load part of a HDF block into a vector of MDEvents. -// * The data block MUST be already open, using e.g. openNexusData() -// * -// * This will be re-implemented by any other MDLeanEvent-like type. -// * -// * @param events :: reference to the vector of events to load. This is NOT cleared by the method before loading. -// * @param file :: open NXS file. -// * @param indexStart :: index (in events) in the data field to start at -// * @param numEvents :: number of events to load. -// * */ -// static void loadVectorFromNexusSlab(std::vector<MDLeanEvent<nd> > & events, ::NeXus::File * file, -// uint64_t indexStart, uint64_t numEvents) -// { -// if (numEvents == 0) -// return; -// -// // Number of columns = number of dimensions + 2 (signal/error) -// size_t numColumns = nd+2; -// // Load the data -// coord_t * data = getDataFromNexus(file, indexStart, numEvents, numColumns); -// -// // Reserve the amount of space needed. Significant speed up (~30% thanks to this) -// events.reserve( events.size() + numEvents); -// for (size_t i=0; i<numEvents; i++) -// { -// // Index into the data array -// size_t ii = i*numColumns; -// -// // Point directly into the data block for the centers. -// coord_t * centers = data + ii+2; -// -// // Create the event with signal, error squared, and the centers -// events.push_back( MDLeanEvent<nd>(float(data[ii]), float(data[ii + 1]), centers) ); -// } -// -// // Release the memory (all has been COPIED into MDLeanEvent's) -// delete [] data; // } ////----------------------------------------------------------------------------------- @@ -388,74 +271,6 @@ namespace MDEvents // // } // -// //--------------------------------------------------------------------------------------------- -// /** Open the NXS data blocks for loading. -// * The data should have been created before. -// * -// * @param file :: open NXS file. -// * @return the number of events currently in the data field. -// */ -// uint64_t BoxController::openEventNexusData(::NeXus::File * file) -// { -// // Open the data -// file->openData("event_data"); -// // Return the size of dimension 0 = the number of events in the field -// return uint64_t(file->getInfo().dims[0]); -// } -// void BoxController::closeNexusData(::NeXus::File * file) -// { -// file->closeData(); -// } - -///**TODO: this should not be here, refactor out*/ -// void MDBoxFlatTree::initEventFileStorage(::NeXus::File *hFile,API::BoxController_sptr bc,bool setFileBacked,const std::string &EventType) -// { -// bool update=true; -//// Start the event Data group, TODO: should be better way of checking existing group -// try -// { -// hFile->openGroup("event_data", "NXdata"); -// } -// catch(...) -// { -// update=false; -// hFile->makeGroup("event_data", "NXdata",true); -// } -// hFile->putAttr("version", "1.0"); -// -// -// // Prepare the data chunk storage. -// size_t chunkSize = bc->getDataChunk(); -// size_t nDim = bc->getNDims(); -// uint64_t NumOldEvents(0); -// if (update) -// NumOldEvents= API::BoxController::openEventNexusData(hFile); -// else -// { -// std::string descr; -// size_t nColumns; -// if(EventType=="MDEvent") -// { -// nColumns = nDim+4; -// descr="signal, errorSquared, runIndex, detectorId, center (each dim.)"; -// } -// else if(EventType=="MDLeanEvent") -// { -// nColumns = nDim+2; -// descr="signal, errorsquared, center (each dim.)"; -// } -// else -// throw std::runtime_error("unknown event type encontered"); -// -// API::BoxController::prepareEventNexusData(hFile, chunkSize,nColumns,descr); -// } -// // Initialize the file-backing -// if (setFileBacked) // Set it back to the new file handle -// bc->setFile(hFile, m_FileName, NumOldEvents); -// -// -// } -// } } \ No newline at end of file diff --git a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp index 842dae76056..06ce5317004 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp @@ -44,6 +44,7 @@ namespace MDEvents data = new MDBox<MDE, nd>(m_BoxController.get(), 0); } + //----------------------------------------------------------------------------------------------- /** Copy constructor */ @@ -78,7 +79,14 @@ namespace MDEvents { delete data; } - + /**Make workspace file backed if it has not been already file backed + * @param fileName -- short or full file name of the file, which should be used as the file back end + */ + TMDE( + void MDEventWorkspace)::setFileBacked(const std::string &fileName) + { + throw Kernel::Exception::NotImplementedError(" Not yet implemented"); + } //----------------------------------------------------------------------------------------------- /** Perform initialization after m_dimensions (and others) have been set. diff --git a/Code/Mantid/Framework/MDEvents/src/MDTransfModQ.cpp b/Code/Mantid/Framework/MDEvents/src/MDTransfModQ.cpp index abf0697a74d..e4e773c5650 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDTransfModQ.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDTransfModQ.cpp @@ -8,8 +8,10 @@ namespace Mantid // register the class, whith conversion factory under ModQ name DECLARE_MD_TRANSFID(MDTransfModQ,|Q|); - /** method calculates the unigs, the transformation expects input ws to be in. If input ws is in different units, - the WS data will be converted into the units requested on-fly. + /**method calculates the units, the transformation expects the input ws to be in. If the input ws is in different units, + the WS data will be converted into the requested units on the fly. + @param dEmode -- energy conversion mode requested by the user for the transfromation + @param inWS -- imput matrix workspace, the subject of transformation. */ const std::string MDTransfModQ::inputUnitID(Kernel::DeltaEMode::Type dEmode, API::MatrixWorkspace_const_sptr inWS)const { @@ -24,7 +26,10 @@ namespace Mantid } } /** method returns number of matrix dimensions calculated by this class - * as function of energy analysis mode */ + * as function of the energy analysis (conversion) mode + @param dEmode -- energy conversion mode requested by the user for the transfromation + @param inWS -- imput matrix workspace, the subject of transformation. + */ unsigned int MDTransfModQ::getNMatrixDimensions(Kernel::DeltaEMode::Type mode,API::MatrixWorkspace_const_sptr inWS)const { UNUSED_ARG(inWS); @@ -38,7 +43,13 @@ namespace Mantid } + /**Convert single point of matrix workspacd into reciprocal space and (optionally) modify signal and error + as function of reciprocal space (e.g. Lorents corrections) + @param x -- the x-coordinate of matix workspace. Often can be a time of flight though the unit conversion is availible + @return Coord -- converted MD coordinates of the point x calculated for particular workspace position (detector) + no signal or error transformation is performed by this particular method. + */ bool MDTransfModQ::calcMatrixCoord(const double& x,std::vector<coord_t> &Coord, double & /*signal*/,double &/*ErrSq*/)const { if(m_Emode == Kernel::DeltaEMode::Elastic) diff --git a/Code/Mantid/Framework/MDEvents/src/UnitsConversionHelper.cpp b/Code/Mantid/Framework/MDEvents/src/UnitsConversionHelper.cpp index afe25e5398a..ca2c0cdc73e 100644 --- a/Code/Mantid/Framework/MDEvents/src/UnitsConversionHelper.cpp +++ b/Code/Mantid/Framework/MDEvents/src/UnitsConversionHelper.cpp @@ -12,7 +12,8 @@ namespace MDEvents @param UnitsFrom -- the ID of the units, which have to be converted from @param UnitsTo -- the ID of the units to converted to -@returns kind of the initiated conversion, e.g. no conversion (unitsFrom == UnitsTo, fastConversion, convFromTOF or convViaTOF +@return kind of the initiated conversion, e.g. no conversion (unitsFrom == UnitsTo, fastConversion, convFromTOF or convViaTOF. + See ConvertUnits for the details of this transformations if necessary, also sets up the proper units convertor pointers which do the actual conversion. */ @@ -136,7 +137,10 @@ void UnitsConversionHelper::updateConversion(size_t i) } } -/** Convert units for the input data */ +/** do actual unit conversion from input to oputput data +@param val -- the input value which has to be converted +@return the input value converted into the units requested. +*/ double UnitsConversionHelper::convertUnits(double val) { switch(m_UnitCnvrsn) diff --git a/Code/Mantid/Framework/MDEvents/test/MDBoxBaseTest.h b/Code/Mantid/Framework/MDEvents/test/MDBoxBaseTest.h index c4ff0d14cd0..1146ec334ef 100644 --- a/Code/Mantid/Framework/MDEvents/test/MDBoxBaseTest.h +++ b/Code/Mantid/Framework/MDEvents/test/MDBoxBaseTest.h @@ -125,6 +125,7 @@ public: virtual void getBoxes(std::vector<API::IMDNode *>& /*boxes*/, size_t /*maxDepth*/, bool, Mantid::Geometry::MDImplicitFunction *) {}; virtual void generalBin(MDBin<MDE,nd> & /*bin*/, Mantid::Geometry::MDImplicitFunction & /*function*/) const {} + virtual void clearDataFromMemory(){}; virtual bool getIsMasked() const { diff --git a/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/BoxController.cpp b/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/BoxController.cpp index f093241434f..97829d73999 100644 --- a/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/BoxController.cpp +++ b/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/BoxController.cpp @@ -22,8 +22,7 @@ void export_BoxController() .def("getTotalNumMDGridBoxes", &BoxController::getTotalNumMDGridBoxes, "Return the total number of MDGridBox'es, irrespective of depth") .def("getAverageDepth", &BoxController::getAverageDepth, "Return the average recursion depth of gridding.") .def("isFileBacked", &BoxController::isFileBacked, "Return True if the MDEventWorkspace is backed by a file ") - .def("getFilename", &BoxController::getFilename, return_value_policy< copy_const_reference >(), - "Return the full path to the file open as the file-based back end.") + .def("getFilename", &BoxController::getFilename, "Return the full path to the file open as the file-based back or empty string if no file back-end is initiated") .def("useWriteBuffer", &BoxController::useWriteBuffer, "Return true if the MRU should be used") ; } diff --git a/Code/Mantid/Framework/TestHelpers/src/BoxControllerDummyIO.cpp b/Code/Mantid/Framework/TestHelpers/src/BoxControllerDummyIO.cpp index 12412e81d1f..1602ecdbf71 100644 --- a/Code/Mantid/Framework/TestHelpers/src/BoxControllerDummyIO.cpp +++ b/Code/Mantid/Framework/TestHelpers/src/BoxControllerDummyIO.cpp @@ -6,7 +6,7 @@ namespace MantidTestHelpers { /**Constructor - @param nDim -- number of dimensions within the data to write + @param bc shared pointer to the box controller which will use this IO operations */ BoxControllerDummyIO::BoxControllerDummyIO(Mantid::API::BoxController_sptr bc) : m_bc(bc), @@ -42,7 +42,7 @@ namespace MantidTestHelpers } else if (m_TypeName == "MDLeanEvent") { -m_EventSize = static_cast<unsigned int>(m_bc->getNDims()+2); + m_EventSize = static_cast<unsigned int>(m_bc->getNDims()+2); } else { throw std::invalid_argument("unsupported event type");} @@ -67,8 +67,6 @@ m_EventSize = static_cast<unsigned int>(m_bc->getNDims()+2); if file name has word exist, the file is opened as existing with 100 floats equal 2. othewise if assumed to be new and size 0 *@more opening mode (read or read/write) - * - * */ bool BoxControllerDummyIO::openFile(const std::string &fileName,const std::string &mode) { @@ -107,7 +105,10 @@ m_EventSize = static_cast<unsigned int>(m_bc->getNDims()+2); return true; } - + /**Save block of data into properly opened and initiated direct access data file + @param DataBlock -- the vector with the data to write + @param blockPosision -- the position of the data block within the data file itself + */ void BoxControllerDummyIO::saveBlock(const std::vector<float> & DataBlock, const uint64_t blockPosition)const { size_t nEvents = DataBlock.size()/m_EventSize; @@ -129,7 +130,14 @@ m_EventSize = static_cast<unsigned int>(m_bc->getNDims()+2); } - + /**Load a block of data from properly prepared direct access data file + @param DataBlock -- the vector for data to place into. If the size of the block is smaller then the requested size, the vector will be realocated. + The data are placed at the beginnign of the block. + @param blockPosision -- the position of the data block within the data file + @param nPoints -- number of data points to read from the file. The datapoint size is defined when opened file or by calling the setDataType directrly + + *Thros if attempted to read data outside of the file. + */ void BoxControllerDummyIO::loadBlock(std::vector<float> & Block, const uint64_t blockPosition,const size_t nPoints)const { m_fileMutex.lock(); -- GitLab