本文整理汇总了C++中PeaksWorkspace_sptr::setInstrument方法的典型用法代码示例。如果您正苦于以下问题:C++ PeaksWorkspace_sptr::setInstrument方法的具体用法?C++ PeaksWorkspace_sptr::setInstrument怎么用?C++ PeaksWorkspace_sptr::setInstrument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PeaksWorkspace_sptr
的用法示例。
在下文中一共展示了PeaksWorkspace_sptr::setInstrument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readHeader
/** Reads the header of a .peaks file
* @param outWS :: the workspace in which to place the information
* @param in :: stream of the input file
* @param T0 :: Time offset
* @return the first word on the next line
*/
std::string LoadIsawPeaks::readHeader( PeaksWorkspace_sptr outWS, std::ifstream& in, double &T0 )
{
std::string tag;
std::string r = getWord( in , false );
if( r.length() < 1 )
throw std::logic_error( std::string( "No first line of Peaks file" ) );
if( r.compare( std::string( "Version:" ) ) != 0 )
throw std::logic_error(
std::string( "No Version: on first line of Peaks file" ) );
std::string C_version = getWord( in , false );
if( C_version.length() < 1 )
throw std::logic_error( std::string( "No Version for Peaks file" ) );
getWord( in , false ); //tag
// cppcheck-suppress unreadVariable
std::string C_Facility = getWord( in , false );
getWord( in , false ); //tag
std::string C_Instrument = getWord( in , false );
if( C_Instrument.length() < 1 )
throw std::logic_error(
std::string( "No Instrument for Peaks file" ) );
// Date: use the current date/time if not found
Kernel::DateAndTime C_experimentDate;
std::string date;
tag = getWord( in , false );
if(tag.empty())
date = Kernel::DateAndTime::getCurrentTime().toISO8601String();
else if(tag == "Date:")
date = getWord( in , false );
readToEndOfLine( in , true );
// Now we load the instrument using the name and date
MatrixWorkspace_sptr tempWS = WorkspaceFactory::Instance().create("Workspace2D", 1, 1, 1);
tempWS->mutableRun().addProperty<std::string>("run_start", date);
IAlgorithm_sptr loadInst= createChildAlgorithm("LoadInstrument");
loadInst->setPropertyValue("InstrumentName", C_Instrument);
loadInst->setProperty<MatrixWorkspace_sptr> ("Workspace", tempWS);
loadInst->executeAsChildAlg();
// Populate the instrument parameters in this workspace - this works around a bug
tempWS->populateInstrumentParameters();
Geometry::Instrument_const_sptr instr_old = tempWS->getInstrument() ;
boost::shared_ptr< ParameterMap > map(new ParameterMap());
Geometry::Instrument_const_sptr instr ( new Geometry::Instrument(instr_old->baseInstrument(), map ));
//std::string s;
std::string s = ApplyCalibInfo(in, "", instr_old, instr, T0);
outWS->setInstrument( instr);
// Now skip all lines on L1, detector banks, etc. until we get to a block of peaks. They start with 0.
// readToEndOfLine( in , true );
// readToEndOfLine( in , true );
// s = getWord(in, false);
while (s != "0" && in.good())
{
readToEndOfLine( in , true );
s = getWord(in, false);
}
return s;
}