Skip to content

Commit

Permalink
refs #6852 Should solve the ticket
Browse files Browse the repository at this point in the history
in theory. Test are still needed.
  • Loading branch information
abuts committed Apr 22, 2013
1 parent a20cb78 commit 10eb402
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ namespace MDAlgorithms

bool buildTargetWSDescription(API::IMDEventWorkspace_sptr spws,const std::string &Q_mod_req,const std::string &dEModeRequested,const std::vector<std::string> &other_dim_names,
const std::string &convert_to_,MDEvents::MDWSDescription &targWSDescr);
/// Store metadata
uint16_t copyMetaData(API::IMDEventWorkspace_sptr mdEventWS) const;
/// Store metadata and set some methadata, needed for plugin to run on the target workspace description
void copyMetaData(API::IMDEventWorkspace_sptr mdEventWS,MDEvents::MDWSDescription &targWSDescr) const;

//
DataObjects::TableWorkspace_const_sptr preprocessDetectorsPositions( Mantid::API::MatrixWorkspace_const_sptr InWS2D,const std::string &dEModeRequested,bool updateMasks);
Expand Down
23 changes: 14 additions & 9 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,9 @@ void ConvertToMD::exec()
else // setup existing MD workspace as workspace target.
m_OutWSWrapper->setMDWS(spws);

// get the unique number, that identifies the run, the source workspace came from
uint16_t numExperiment= copyMetaData(spws);
targWSDescr.setProperty<uint16_t>("RUN_INDEX",numExperiment);
// preprocess detectors;
// copy the necessary methadata and get the unique number, that identifies the run, the source workspace came from.
copyMetaData(spws,targWSDescr);
// preprocess detectors;
targWSDescr.m_PreprDetTable = this->preprocessDetectorsPositions(m_InWS2D,dEModReq,getProperty("UpdateMasks"));


Expand Down Expand Up @@ -403,26 +402,32 @@ void ConvertToMD::exec()
/**
* Copy over the metadata from the input matrix workspace to output MDEventWorkspace
* @param mdEventWS :: The output MDEventWorkspace
* @param targWSDescr :: The descrition of the target workspace, used in the algorithm
*
* @return :: the number of experiment info added from the current MD workspace
*/
uint16_t ConvertToMD::copyMetaData(API::IMDEventWorkspace_sptr mdEventWS) const
void ConvertToMD::copyMetaData(API::IMDEventWorkspace_sptr mdEventWS, MDEvents::MDWSDescription &targWSDescr) const
{
// Copy ExperimentInfo (instrument, run, sample) to the output WS
API::ExperimentInfo_sptr ei(m_InWS2D->cloneExperimentInfo());

ei->mutableRun().addProperty("W_MATRIX",targWSDescr.m_Wtransf,true);
uint16_t runIndex = mdEventWS->addExperimentInfo(ei);

const MantidVec & binBoundaries = m_InWS2D->readX(0);
auto mapping = m_InWS2D->spectraMap().createIDGroupsMap();


uint16_t nexpts = mdEventWS->getNumExperimentInfo();
for(uint16_t i = 0; i < nexpts; ++i)
{
ExperimentInfo_sptr expt = mdEventWS->getExperimentInfo(i);
expt->mutableRun().storeHistogramBinBoundaries(binBoundaries);
expt->cacheDetectorGroupings(*mapping);
}
// Copy ExperimentInfo (instrument, run, sample) to the output WS
API::ExperimentInfo_sptr ei(m_InWS2D->cloneExperimentInfo());
mdEventWS->addExperimentInfo(ei);


// and add it to the target workspace description for further usage as identifier for the workspaces, which come from this run.
targWSDescr.setProperty<uint16_t>("RUN_INDEX",runIndex);

}

Expand Down

0 comments on commit 10eb402

Please sign in to comment.