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