Ejemplo n.º 1
0
/**
 * Update the shape cache if necessary
 * @param det :: a pointer to the detector to query
 * @param detRadius :: An output parameter that contains the detector radius
 * @param detAxis :: An output parameter that contains the detector axis vector
 */
void He3TubeEfficiency::getDetectorGeometry(const Geometry::IDetector &det,
                                            double &detRadius,
                                            Kernel::V3D &detAxis) {
  boost::shared_ptr<const Geometry::Object> shape_sptr = det.shape();
  if (!shape_sptr) {
    throw std::runtime_error(
        "Detector geometry error: detector with id: " +
        std::to_string(det.getID()) +
        " does not have shape. Is this a detectors group?\n"
        "The algorithm works for instruments with one-to-one "
        "spectra-to-detector maps only!");
  }
  std::map<const Geometry::Object *,
           std::pair<double, Kernel::V3D>>::const_iterator it =
      this->shapeCache.find(shape_sptr.get());
  if (it == this->shapeCache.end()) {
    double xDist = distToSurface(Kernel::V3D(DIST_TO_UNIVERSE_EDGE, 0, 0),
                                 shape_sptr.get());
    double zDist = distToSurface(Kernel::V3D(0, 0, DIST_TO_UNIVERSE_EDGE),
                                 shape_sptr.get());
    if (std::abs(zDist - xDist) < 1e-8) {
      detRadius = zDist / 2.0;
      detAxis = Kernel::V3D(0, 1, 0);
      // assume radii in z and x and the axis is in the y
      PARALLEL_CRITICAL(deteff_shapecachea) {
        this->shapeCache.insert(
            std::pair<const Geometry::Object *, std::pair<double, Kernel::V3D>>(
                shape_sptr.get(),
                std::pair<double, Kernel::V3D>(detRadius, detAxis)));
      }
      return;
    }
Ejemplo n.º 2
0
/** Method calculates averaged polar coordinates of the detector's group
(which may consist of one detector)
*@param det    -- reference to the Mantid Detector
*@param Observer -- sample position or the centre of the polar system of
coordinates to calculate detector's parameters.

*@param Detector  -- return Detector class containing averaged polar coordinates
of the detector or detector's group in
                     spherical coordinate system with centre at Observer
*/
void FindDetectorsPar::calcDetPar(const Geometry::IDetector &det,
                                  const Kernel::V3D &Observer,
                                  DetParameters &Detector) {

  // get number of basic detectors within the composit detector
  size_t nDetectors = det.nDets();
  // define summator
  AvrgDetector detSum;
  // do we want spherical or linear box sizes?
  detSum.setUseSpherical(!m_SizesAreLinear);

  if (nDetectors == 1) {
    detSum.addDetInfo(det, Observer);
  } else {
    // access contributing detectors;
    auto detGroup = dynamic_cast<const Geometry::DetectorGroup *>(&det);
    if (!detGroup) {
      g_log.error() << "calc_cylDetPar: can not downcast IDetector_sptr to "
                       "detector group for det->ID: "
                    << det.getID() << '\n';
      throw(std::bad_cast());
    }
    for (const auto &det : detGroup->getDetectors()) {
      detSum.addDetInfo(*det, Observer);
    }
  }
  // calculate averages and return the detector parameters
  detSum.returnAvrgDetPar(Detector);
}