本文整理汇总了C++中api::MatrixWorkspace_sptr::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_sptr::getName方法的具体用法?C++ MatrixWorkspace_sptr::getName怎么用?C++ MatrixWorkspace_sptr::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::MatrixWorkspace_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_sptr::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
/** Initialization method:
@param bkgWS -- shared pointer to the workspace which contains background
@param sourceWS -- shared pointer to the workspace to remove background from
@param emode -- energy conversion mode used during internal units conversion
(0 -- elastic, 1-direct, 2 indirect, as defined in Units conversion
@param pLog -- pointer to the logger class which would report errors
@param nThreads -- number of threads to be used for background removal
@param inPlace -- if the background removal occurs from the existing workspace
or target workspace has to be cloned.
*/
void BackgroundHelper::initialize(const API::MatrixWorkspace_const_sptr &bkgWS,
const API::MatrixWorkspace_sptr &sourceWS,
int emode, Kernel::Logger *pLog, int nThreads,
bool inPlace) {
m_bgWs = bkgWS;
m_wkWS = sourceWS;
m_Emode = emode;
m_pgLog = pLog;
m_inPlace = inPlace;
std::string bgUnits = bkgWS->getAxis(0)->unit()->unitID();
if (bgUnits != "TOF")
throw std::invalid_argument(" Background Workspace: " + bkgWS->getName() +
" should be in the units of TOF");
if (!(bkgWS->getNumberHistograms() == 1 ||
sourceWS->getNumberHistograms() == bkgWS->getNumberHistograms()))
throw std::invalid_argument(" Background Workspace: " + bkgWS->getName() +
" should have the same number of spectra as "
"source workspace or be a single histogram "
"workspace");
auto WSUnit = sourceWS->getAxis(0)->unit();
if (!WSUnit)
throw std::invalid_argument(" Source Workspace: " + sourceWS->getName() +
" should have units");
Geometry::IComponent_const_sptr source =
sourceWS->getInstrument()->getSource();
m_Sample = sourceWS->getInstrument()->getSample();
if ((!source) || (!m_Sample))
throw std::invalid_argument(
"Instrument on Source workspace:" + sourceWS->getName() +
"is not sufficiently defined: failed to get source and/or sample");
m_L1 = source->getDistance(*m_Sample);
// just in case.
this->deleteUnitsConverters();
// allocate the array of units converters to avoid units reallocation within a
// loop
m_WSUnit.assign(nThreads, NULL);
for (int i = 0; i < nThreads; i++) {
m_WSUnit[i] = WSUnit->clone();
}
m_singleValueBackground = false;
if (bkgWS->getNumberHistograms() == 0)
m_singleValueBackground = true;
const MantidVec &dataX = bkgWS->dataX(0);
const MantidVec &dataY = bkgWS->dataY(0);
// const MantidVec& dataE = bkgWS->dataE(0);
m_NBg = dataY[0];
m_dtBg = dataX[1] - dataX[0];
// m_ErrSq = dataE[0]*dataE[0]; // needs further clarification
m_Efix = this->getEi(sourceWS);
}
示例2:
/** Uses the Minus algorithm to subtract the background workspace from the given
* workspace.
* If the ChildAlgorithm fails (e.g. if the background workspace is the wrong
* size), then this
* entire algorithm will.
* @param ws The workspace to perform the subtraction on
* @param background The workspace containing the background values
*/
API::MatrixWorkspace_sptr
IQTransform::subtractBackgroundWS(API::MatrixWorkspace_sptr ws,
API::MatrixWorkspace_sptr background) {
g_log.debug() << "Subtracting the workspace " << background->getName()
<< " from the input workspace.\n";
return ws - background;
}
示例3: deadTimeCorrection
/** Apply dead time correction to spectra in inputWs and create temporary workspace with corrected spectra
* @param inputWs :: [input] input workspace containing spectra to correct
* @param deadTimeTable :: [input] table containing dead times
* @param tempWs :: [output] workspace containing corrected spectra
*/
void PhaseQuadMuon::deadTimeCorrection(API::MatrixWorkspace_sptr inputWs, API::ITableWorkspace_sptr deadTimeTable, API::MatrixWorkspace_sptr& tempWs)
{
// Apply correction only from t = m_tPulseOver
// To do so, we first apply corrections to the whole spectrum (ApplyDeadTimeCorr
// does not allow to select a range in the spectrum)
// Then we recover counts from 0 to m_tPulseOver
auto alg = this->createChildAlgorithm("ApplyDeadTimeCorr",-1,-1);
alg->initialize();
alg->setProperty("DeadTimeTable", deadTimeTable);
alg->setPropertyValue("InputWorkspace", inputWs->getName());
alg->setPropertyValue("OutputWorkspace", inputWs->getName()+"_deadtime");
bool sucDeadTime = alg->execute();
if (!sucDeadTime)
{
g_log.error() << "PhaseQuad: Unable to apply dead time corrections" << std::endl;
throw std::runtime_error("PhaseQuad: Unable to apply dead time corrections");
}
tempWs = alg->getProperty("OutputWorkspace");
// Now recover counts from t=0 to m_tPulseOver
// Errors are set to m_bigNumber
for (int h=0; h<m_nHist; h++)
{
auto specOld = inputWs->getSpectrum(h);
auto specNew = tempWs->getSpectrum(h);
for (int t=0; t<m_tPulseOver; t++)
{
specNew->dataY()[t] = specOld->dataY()[t];
specNew->dataE()[t] = m_bigNumber;
}
}
}
示例4:
/**
* Calls an algorithm to replace special values within the workspace
* such as NaN or Inf to 0.
* @param inputWs The workspace to process
* @return The workspace with special floating point values set to 0
*/
API::MatrixWorkspace_sptr
SumSpectra::replaceSpecialValues(API::MatrixWorkspace_sptr inputWs) {
if (!m_replaceSpecialValues) {
// Skip any additional processing
return inputWs;
}
IAlgorithm_sptr alg = this->createChildAlgorithm("ReplaceSpecialValues");
alg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", inputWs);
std::string outName = "_" + inputWs->getName() + "_clean";
alg->setProperty("OutputWorkspace", outName);
alg->setProperty("NaNValue", 0.0);
alg->setProperty("NaNError", 0.0);
alg->setProperty("InfinityValue", 0.0);
alg->setProperty("InfinityError", 0.0);
alg->executeAsChildAlg();
return alg->getProperty("OutputWorkspace");
}