/** Extract mask information from a workspace containing instrument
  * @return vector of detector IDs of detectors that are masked
  */
std::vector<detid_t> ExtractMaskToTable::extractMaskFromMatrixWorkspace() {
  // Clear input
  std::vector<detid_t> maskeddetids;

  // Get on hold of instrument
  Instrument_const_sptr instrument = m_dataWS->getInstrument();
  if (!instrument)
    throw runtime_error("There is no instrument in input workspace.");

  // Extract
  size_t numdets = instrument->getNumberDetectors();
  vector<detid_t> detids = instrument->getDetectorIDs();

  for (size_t i = 0; i < numdets; ++i) {
    detid_t tmpdetid = detids[i];
    IDetector_const_sptr tmpdetector = instrument->getDetector(tmpdetid);
    bool masked = tmpdetector->isMasked();
    if (masked) {
      maskeddetids.push_back(tmpdetid);
    }
    g_log.debug() << "[DB] Detector No. " << i << ":  ID = " << tmpdetid
                  << ", Masked = " << masked << ".\n";
  }

  g_log.notice() << "Extract mask:  There are " << maskeddetids.size()
                 << " detectors that"
                    " are masked."
                 << ".\n";

  return maskeddetids;
}
Esempio n. 2
0
PoldiDeadWireDecorator::PoldiDeadWireDecorator(Instrument_const_sptr poldiInstrument, boost::shared_ptr<PoldiAbstractDetector> detector) :
    PoldiDetectorDecorator(detector),
    m_deadWireSet(),
    m_goodElements()
{
    setDecoratedDetector(detector);

    std::vector<detid_t> allDetectorIds = poldiInstrument->getDetectorIDs();
    std::vector<detid_t> deadDetectorIds(allDetectorIds.size());

    std::vector<detid_t>::iterator endIterator = std::remove_copy_if(allDetectorIds.begin(), allDetectorIds.end(), deadDetectorIds.begin(), boost::bind<bool>(&PoldiDeadWireDecorator::detectorIsNotMasked, poldiInstrument, _1));
    deadDetectorIds.resize(std::distance(deadDetectorIds.begin(), endIterator));

    setDeadWires(std::set<int>(deadDetectorIds.begin(), deadDetectorIds.end()));
}