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