本文整理汇总了C++中geometry::Instrument_const_sptr::getMonitors方法的典型用法代码示例。如果您正苦于以下问题:C++ Instrument_const_sptr::getMonitors方法的具体用法?C++ Instrument_const_sptr::getMonitors怎么用?C++ Instrument_const_sptr::getMonitors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geometry::Instrument_const_sptr
的用法示例。
在下文中一共展示了Instrument_const_sptr::getMonitors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: monitorIdReader
// read the monitors list from the workspace and try to do it once for any
// particular ws;
bool MonIDPropChanger::monitorIdReader(
API::MatrixWorkspace_const_sptr inputWS) const {
// no workspace
if (!inputWS)
return false;
// no instrument
Geometry::Instrument_const_sptr pInstr = inputWS->getInstrument();
if (!pInstr)
return false;
std::vector<detid_t> mon = pInstr->getMonitors();
if (mon.empty()) {
if (iExistingAllowedValues.empty()) {
return false;
} else {
iExistingAllowedValues.clear();
return true;
}
}
// are these monitors really there?
// got the index of correspondent spectra.
std::vector<size_t> indexList = inputWS->getIndicesFromDetectorIDs(mon);
if (indexList.empty()) {
if (iExistingAllowedValues.empty()) {
return false;
} else {
iExistingAllowedValues.clear();
return true;
}
}
// index list can be less or equal to the mon list size (some monitors do not
// have spectra)
size_t mon_count =
(mon.size() < indexList.size()) ? mon.size() : indexList.size();
std::vector<int> allowed_values(mon_count);
for (size_t i = 0; i < mon_count; i++) {
allowed_values[i] = mon[i];
}
// are known values the same as the values we have just identified?
if (iExistingAllowedValues.size() != mon_count) {
iExistingAllowedValues.clear();
iExistingAllowedValues.assign(allowed_values.begin(), allowed_values.end());
return true;
}
// the monitor list has the same size as before. Is it equivalent to the
// existing one?
bool values_redefined = false;
for (size_t i = 0; i < mon_count; i++) {
if (iExistingAllowedValues[i] != allowed_values[i]) {
values_redefined = true;
iExistingAllowedValues[i] = allowed_values[i];
}
}
return values_redefined;
}
示例2: monitorIdReader
// read the monitors list from the workspace and try to do it once for any
// particular ws;
bool MonIDPropChanger::monitorIdReader(
MatrixWorkspace_const_sptr inputWS) const {
// no workspace
if (!inputWS)
return false;
// no instrument
Geometry::Instrument_const_sptr pInstr = inputWS->getInstrument();
if (!pInstr)
return false;
// are these monitors really there?
std::vector<detid_t> monitorIDList = pInstr->getMonitors();
{
const auto &specInfo = inputWS->spectrumInfo();
std::set<detid_t> idsInWorkspace;
size_t i = 0;
// Loop over spectra, but finish early if we find everything
while (i < specInfo.size() &&
idsInWorkspace.size() < monitorIDList.size()) {
if (specInfo.isMonitor(i))
idsInWorkspace.insert(specInfo.detector(i).getID());
++i;
}
monitorIDList =
std::vector<detid_t>(idsInWorkspace.begin(), idsInWorkspace.end());
}
if (monitorIDList.empty()) {
if (iExistingAllowedValues.empty()) {
return false;
} else {
iExistingAllowedValues.clear();
return true;
}
}
// are known values the same as the values we have just identified?
if (iExistingAllowedValues.size() != monitorIDList.size()) {
iExistingAllowedValues.clear();
iExistingAllowedValues.assign(monitorIDList.begin(), monitorIDList.end());
return true;
}
// the monitor list has the same size as before. Is it equivalent to the
// existing one?
bool values_redefined = false;
for (size_t i = 0; i < monitorIDList.size(); i++) {
if (iExistingAllowedValues[i] != monitorIDList[i]) {
values_redefined = true;
iExistingAllowedValues[i] = monitorIDList[i];
}
}
return values_redefined;
}