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/System.h"
12#include "MantidKernel/V3D.h"
13
14using namespace Mantid::Kernel;
15
16namespace Mantid::Geometry {
17
23 : Detector(base, map), m_panel(base->m_panel), m_col(base->m_col), m_row(base->m_row), m_layer(base->m_layer) {}
24
37GridDetectorPixel::GridDetectorPixel(const std::string &name, int id, const std::shared_ptr<IObject> &shape,
38 IComponent *parent, const GridDetector *panel, size_t col, size_t row,
39 size_t layer)
40 : Detector(name, id, shape, parent), m_panel(panel), m_col(col), m_row(row), m_layer(layer) {
41 if (!m_panel)
42 throw std::runtime_error("GridDetectorPixel::ctor(): pixel " + name + " has no valid GridDetector parent.");
43}
44
45//----------------------------------------------------------------------------------------------
52 if (m_map && hasDetectorInfo())
54
55 // Calculate the x,y position
56 double x = m_panel->xstart() + double(m_col) * m_panel->xstep();
57 double y = m_panel->ystart() + double(m_row) * m_panel->ystep();
58 double z = m_panel->zstart() + double(m_layer) * m_panel->zstep();
59 // The parent m_panel is always the unparametrized version,
60 // so the xstep() etc. returned are the UNSCALED one.
61 if (m_map) {
62 // Apply the scaling factors
63 if (auto scalex = m_map->get(m_panel, "scalex"))
64 x *= scalex->value<double>();
65 if (auto scaley = m_map->get(m_panel, "scaley"))
66 y *= scaley->value<double>();
67 // Apply the scaling factors
68 if (auto scalez = m_map->get(m_panel, "scalez"))
69 z *= scalez->value<double>();
70 }
71 return V3D(x, y, z);
72}
73
74} // namespace Mantid::Geometry
const ParameterMap * m_map
A pointer to const ParameterMap containing the parameters.
Definition: Component.h:307
This class represents a detector - i.e.
Definition: Detector.h:30
bool hasDetectorInfo() const
Definition: Detector.cpp:135
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.
Definition: GridDetector.h:34
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:51
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