Skip to content

Commit

Permalink
refs #4201 Allow the elastic mode without incident energy
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Jan 6, 2012
1 parent 9f3c7a4 commit c5fb5e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ ConvertToMDEvents::getEi(ConvertToMDEvents const *const pHost)
convert_log.error()<<"getEi: invoked when input workspace is undefined\n";
throw(std::logic_error(" should not call this function when input workpace is undefined"));
}
Kernel::PropertyWithValue<double> *pProp =dynamic_cast<Kernel::PropertyWithValue<double> *>(pHost->inWS2D->run().getProperty("Ei"));
Kernel::PropertyWithValue<double> *pProp(NULL);
try{
pProp =dynamic_cast<Kernel::PropertyWithValue<double> *>(pHost->inWS2D->run().getProperty("Ei"));
}catch(...){
}
if(!pProp){
convert_log.error()<<"getEi: can not obtain incident energy of neutrons\n";
throw(std::logic_error(" should not call this function when incident energy is undefined"));
//convert_log.error()<<"getEi: can not obtain incident energy of neutrons\n";
//throw(std::logic_error(" should not call this function when incident energy is undefined"));
return std::numeric_limits<double>::quiet_NaN();
}
return (*pProp);
}
Expand Down Expand Up @@ -669,7 +674,8 @@ ConvertToMDEvents::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,const std
}else{
emode = -1;
}
if((emode == 1)||(emode == 2)||(the_algID.find("TOF")!=std::string::npos))
//if((emode == 1)||(emode == 2)||(the_algID.find("TOF")!=std::string::npos))
if((emode == 1)||(emode == 2))
{
if(!inWS->run().hasProperty("Ei")){
convert_log.error()<<" Conversion sub-algorithm with ID: "<<the_algID<<" needs input energy to be present among run properties\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ConvertEventsToMDEventsTest(){
Mantid::API::MatrixWorkspace_sptr wsEv = boost::dynamic_pointer_cast<MatrixWorkspace>(WorkspaceCreationHelper::CreateRandomEventWorkspace(100, numHist, 0.1));
wsEv->setInstrument( ComponentCreationHelper::createTestInstrumentCylindrical(numHist) );
// any inelastic units or unit conversion using TOF needs Ei to be present among properties.
wsEv->mutableRun().addProperty("Ei",13.,"meV",true);
// wsEv->mutableRun().addProperty("Ei",13.,"meV",true);

AnalysisDataService::Instance().addOrReplace("testEvWS", wsEv);

Expand Down

0 comments on commit c5fb5e5

Please sign in to comment.