Mantid
Loading...
Searching...
No Matches
GridDetectorPixel.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include <utility>
8
11#include "MantidKernel/V3D.h"
12
13using namespace Mantid::Kernel;
14
15namespace Mantid::Geometry {
16
22 : Detector(base, map), m_panel(base->m_panel), m_col(base->m_col), m_row(base->m_row), m_layer(base->m_layer) {}
23
36GridDetectorPixel::GridDetectorPixel(const std::string &name, int id, const std::shared_ptr<IObject> &shape,
37 IComponent *parent, const GridDetector *panel, size_t col, size_t row,
38 size_t layer)
39 : Detector(name, id, shape, parent), m_panel(panel), m_col(col), m_row(row), m_layer(layer) {
40 if (!m_panel)
41 throw std::runtime_error("GridDetectorPixel::ctor(): pixel " + name + " has no valid GridDetector parent.");
42}
43
44//----------------------------------------------------------------------------------------------
51 if (m_map && hasDetectorInfo())
53
54 // Calculate the x,y position
55 double x = m_panel->xstart() + double(m_col) * m_panel->xstep();
56 double y = m_panel->ystart() + double(m_row) * m_panel->ystep();
57 double z = m_panel->zstart() + double(m_layer) * m_panel->zstep();
58 // The parent m_panel is always the unparametrized version,
59 // so the xstep() etc. returned are the UNSCALED one.
60 if (m_map) {
61 // Apply the scaling factors
62 if (auto scalex = m_map->get(m_panel, "scalex"))
63 x *= scalex->value<double>();
64 if (auto scaley = m_map->get(m_panel, "scaley"))
65 y *= scaley->value<double>();
66 // Apply the scaling factors
67 if (auto scalez = m_map->get(m_panel, "scalez"))
68 z *= scalez->value<double>();
69 }
70 return V3D(x, y, z);
71}
72
73} // namespace Mantid::Geometry
std::string name
Definition Run.cpp:60
const ParameterMap * m_map
A pointer to const ParameterMap containing the parameters.
Definition Component.h:316
This class represents a detector - i.e.
Definition Detector.h:30
GridrDetectorPixel: a sub-class of Detector that is one pixel inside a GridDetector.
const GridDetector * m_panel
GridDetector that is the parent of this pixel.
Kernel::V3D getRelativePos() const override
Get the position relative to the parent IComponent (absolute if no parent) This is calculated on-the-...
size_t m_row
Column of the pixel in the panel (y/row index)
GridDetectorPixel(const std::string &name, int id, const std::shared_ptr< IObject > &shape, IComponent *parent, const GridDetector *panel, size_t col, size_t row, size_t layer)
Constructor.
size_t m_col
Row of the pixel in the panel (x/col index)
size_t m_layer
Plane of the pixel in the panel (z/layer index)
GridDetector is a type of CompAssembly, an assembly of components.
double ystart() const
Returns the start position in the Y direction.
double ystep() const
Returns the step size in the Y direction.
double xstep() const
Returns the step size in the X direction.
double xstart() const
Returns the start position in the X direction.
double zstart() const
Returns the start position in the Z direction.
double zstep() const
Returns the step size in the Z direction.
base class for Geometric IComponent
Definition IComponent.h:53
virtual Kernel::V3D getRelativePos() const =0
Get the position relative to the parent IComponent (absolute if no parent)
std::shared_ptr< Parameter > get(const IComponent *comp, const std::string &name, const std::string &type="") const
Get a parameter with a given name and type (std::string version)
Class for 3D vectors.
Definition V3D.h:34
adjust instrument component position and orientation
: detector size scale at y-direction