Warning, file /DD4hep/DDCore/src/segmentations/CartesianGridXY.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <DDSegmentation/CartesianGridXY.h>
0017
0018 namespace dd4hep {
0019
0020 namespace DDSegmentation {
0021
0022
0023 CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) :
0024 CartesianGrid(cellEncoding) {
0025
0026 _type = "CartesianGridXY";
0027 _description = "Cartesian segmentation in the local XY-plane";
0028
0029
0030 registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0031 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0032 registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0033 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0034 registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0035 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0036 }
0037
0038
0039 CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) :
0040 CartesianGrid(decode)
0041 {
0042
0043 _type = "CartesianGridXY";
0044 _description = "Cartesian segmentation in the local XY-plane";
0045
0046
0047 registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0048 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0049 registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0050 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0051 registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0052 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0053 }
0054
0055
0056 CartesianGridXY::~CartesianGridXY() {
0057
0058 }
0059
0060
0061 Vector3D CartesianGridXY::position(const CellID& cID) const {
0062 Vector3D cellPosition;
0063 cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX);
0064 cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY);
0065 return cellPosition;
0066 }
0067
0068
0069 CellID CartesianGridXY::cellID(const Vector3D& localPosition,
0070 const Vector3D& ,
0071 const VolumeID& vID) const {
0072 CellID cID = vID;
0073 _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) );
0074 _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) );
0075 return cID;
0076 }
0077
0078 std::vector<double> CartesianGridXY::cellDimensions(const CellID& ) const {
0079 return {_gridSizeX, _gridSizeY};
0080 }
0081
0082
0083 }
0084 }
0085
0086
0087
0088