File indexing completed on 2025-02-22 09:36:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <DDSegmentation/CartesianGridXY.h>
0019
0020 namespace dd4hep {
0021 namespace DDSegmentation {
0022
0023
0024 CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) :
0025 CartesianGrid(cellEncoding) {
0026
0027 _type = "CartesianGridXY";
0028 _description = "Cartesian segmentation in the local XY-plane";
0029
0030
0031 registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0032 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0033 registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0034 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0035 registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0036 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0037 }
0038
0039
0040 CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) :
0041 CartesianGrid(decode)
0042 {
0043
0044 _type = "CartesianGridXY";
0045 _description = "Cartesian segmentation in the local XY-plane";
0046
0047
0048 registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0049 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0050 registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0051 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0052 registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0053 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0054 }
0055
0056
0057 CartesianGridXY::~CartesianGridXY() {
0058
0059 }
0060
0061
0062 Vector3D CartesianGridXY::position(const CellID& cID) const {
0063 Vector3D cellPosition;
0064 cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX);
0065 cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY);
0066 return cellPosition;
0067 }
0068
0069
0070 CellID CartesianGridXY::cellID(const Vector3D& localPosition,
0071 const Vector3D& ,
0072 const VolumeID& vID) const {
0073 CellID cID = vID;
0074 _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) );
0075 _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) );
0076 return cID;
0077 }
0078
0079 std::vector<double> CartesianGridXY::cellDimensions(const CellID& ) const {
0080 #if __cplusplus >= 201103L
0081 return {_gridSizeX, _gridSizeY};
0082 #else
0083 std::vector<double> cellDims(2,0.0);
0084 cellDims[0] = _gridSizeX;
0085 cellDims[1] = _gridSizeY;
0086 return cellDims;
0087 #endif
0088 }
0089
0090
0091 }
0092 }
0093
0094
0095
0096