本文整理汇总了C++中geometry::IComponent_const_sptr::getDistance方法的典型用法代码示例。如果您正苦于以下问题:C++ IComponent_const_sptr::getDistance方法的具体用法?C++ IComponent_const_sptr::getDistance怎么用?C++ IComponent_const_sptr::getDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geometry::IComponent_const_sptr
的用法示例。
在下文中一共展示了IComponent_const_sptr::getDistance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: sizeBanks
void SaveIsawDetCal::sizeBanks(std::string bankName, int &NCOLS, int &NROWS,
double &xsize, double &ysize) {
if (bankName.compare("None") == 0)
return;
boost::shared_ptr<const IComponent> parent =
inst->getComponentByName(bankName);
if (parent->type().compare("RectangularDetector") == 0) {
boost::shared_ptr<const RectangularDetector> RDet =
boost::dynamic_pointer_cast<const RectangularDetector>(parent);
NCOLS = RDet->xpixels();
NROWS = RDet->ypixels();
xsize = RDet->xsize();
ysize = RDet->ysize();
} else {
std::vector<Geometry::IComponent_const_sptr> children;
boost::shared_ptr<const Geometry::ICompAssembly> asmb =
boost::dynamic_pointer_cast<const Geometry::ICompAssembly>(parent);
asmb->getChildren(children, false);
if (children[0]->getName().compare("sixteenpack") == 0) {
asmb = boost::dynamic_pointer_cast<const Geometry::ICompAssembly>(
children[0]);
children.clear();
asmb->getChildren(children, false);
}
boost::shared_ptr<const Geometry::ICompAssembly> asmb2 =
boost::dynamic_pointer_cast<const Geometry::ICompAssembly>(children[0]);
std::vector<Geometry::IComponent_const_sptr> grandchildren;
asmb2->getChildren(grandchildren, false);
NROWS = static_cast<int>(grandchildren.size());
NCOLS = static_cast<int>(children.size());
Geometry::IComponent_const_sptr first = children[0];
Geometry::IComponent_const_sptr last = children[NCOLS - 1];
xsize = first->getDistance(*last);
first = grandchildren[0];
last = grandchildren[NROWS - 1];
ysize = first->getDistance(*last);
}
}
示例3: processDetectorsPositions
/** method does preliminary calculations of the detectors positions to convert
results into k-dE space ;
and places the results into static cash to be used in subsequent calls to this
algorithm */
void PreprocessDetectorsToMD::processDetectorsPositions(
const API::MatrixWorkspace_const_sptr &inputWS,
DataObjects::TableWorkspace_sptr &targWS) {
g_log.information()
<< "Preprocessing detector locations in a target reciprocal space\n";
//
Geometry::Instrument_const_sptr instrument = inputWS->getInstrument();
// this->pBaseInstr = instrument->baseInstrument();
//
Geometry::IComponent_const_sptr source = instrument->getSource();
Geometry::IComponent_const_sptr sample = instrument->getSample();
if ((!source) || (!sample)) {
g_log.error() << " Instrument is not fully defined. Can not identify "
"source or sample\n";
throw Kernel::Exception::InstrumentDefinitionError(
"Instrument not sufficiently defined: failed to get source and/or "
"sample");
}
// L1
try {
double L1 = source->getDistance(*sample);
targWS->logs()->addProperty<double>("L1", L1, true);
g_log.debug() << "Source-sample distance: " << L1 << '\n';
} catch (Kernel::Exception::NotFoundError &) {
throw Kernel::Exception::InstrumentDefinitionError(
"Unable to calculate source-sample distance for workspace",
inputWS->getTitle());
}
// Instrument name
std::string InstrName = instrument->getName();
targWS->logs()->addProperty<std::string>(
"InstrumentName", InstrName,
true); // "The name which should unique identify current instrument");
targWS->logs()->addProperty<bool>("FakeDetectors", false, true);
// get access to the workspace memory
auto &sp2detMap = targWS->getColVector<size_t>("spec2detMap");
auto &detId = targWS->getColVector<int32_t>("DetectorID");
auto &detIDMap = targWS->getColVector<size_t>("detIDMap");
auto &L2 = targWS->getColVector<double>("L2");
auto &TwoTheta = targWS->getColVector<double>("TwoTheta");
auto &Azimuthal = targWS->getColVector<double>("Azimuthal");
auto &detDir = targWS->getColVector<Kernel::V3D>("DetDirections");
// Efixed; do we need one and does one exist?
double Efi = targWS->getLogs()->getPropertyValueAsType<double>("Ei");
float *pEfixedArray(nullptr);
const Geometry::ParameterMap &pmap = inputWS->constInstrumentParameters();
if (m_getEFixed)
pEfixedArray = targWS->getColDataArray<float>("eFixed");
// check if one needs to generate masked detectors column.
int *pMasksArray(nullptr);
if (m_getIsMasked)
pMasksArray = targWS->getColDataArray<int>("detMask");
//// progress message appearance
size_t div = 100;
size_t nHist = targWS->rowCount();
Mantid::API::Progress theProgress(this, 0, 1, nHist);
//// Loop over the spectra
uint32_t liveDetectorsCount(0);
const auto &spectrumInfo = inputWS->spectrumInfo();
for (size_t i = 0; i < nHist; i++) {
sp2detMap[i] = std::numeric_limits<uint64_t>::quiet_NaN();
detId[i] = std::numeric_limits<int32_t>::quiet_NaN();
detIDMap[i] = std::numeric_limits<uint64_t>::quiet_NaN();
L2[i] = std::numeric_limits<double>::quiet_NaN();
TwoTheta[i] = std::numeric_limits<double>::quiet_NaN();
Azimuthal[i] = std::numeric_limits<double>::quiet_NaN();
// detMask[i] = true;
if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i))
continue;
// if masked detectors state is not used, masked detectors just ignored;
bool maskDetector = spectrumInfo.isMasked(i);
if (m_getIsMasked)
*(pMasksArray + liveDetectorsCount) = maskDetector ? 1 : 0;
else if (maskDetector)
continue;
const auto &spDet = spectrumInfo.detector(i);
// calculate the requested values;
sp2detMap[i] = liveDetectorsCount;
detId[liveDetectorsCount] = int32_t(spDet.getID());
detIDMap[liveDetectorsCount] = i;
L2[liveDetectorsCount] = spectrumInfo.l2(i);
double polar = spectrumInfo.twoTheta(i);
double azim = spDet.getPhi();
TwoTheta[liveDetectorsCount] = polar;
Azimuthal[liveDetectorsCount] = azim;
//.........这里部分代码省略.........