// 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; }