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
0019 #include <DDSegmentation/CartesianGridYZ.h>
0020
0021 namespace dd4hep {
0022 namespace DDSegmentation {
0023
0024
0025 CartesianGridYZ::CartesianGridYZ(const std::string& cellEncoding) :
0026 CartesianGrid(cellEncoding) {
0027
0028 _type = "CartesianGridYZ";
0029 _description = "Cartesian segmentation in the local YZ-plane";
0030
0031
0032 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0033 registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0034 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0035 registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0036 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0037 registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0038 }
0039
0040
0041
0042 CartesianGridYZ::CartesianGridYZ(const BitFieldCoder* decode) : CartesianGrid(decode)
0043 {
0044
0045 _type = "CartesianGridYZ";
0046 _description = "Cartesian segmentation in the local YZ-plane";
0047
0048
0049 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0050 registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0051 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0052 registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0053 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0054 registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0055 }
0056
0057
0058 CartesianGridYZ::~CartesianGridYZ() {
0059
0060 }
0061
0062
0063 Vector3D CartesianGridYZ::position(const CellID& cID) const {
0064 Vector3D cellPosition;
0065 cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY);
0066 cellPosition.Z = binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ);
0067 return cellPosition;
0068 }
0069
0070
0071 CellID CartesianGridYZ::cellID(const Vector3D& localPosition, const Vector3D& , const VolumeID& vID) const {
0072 CellID cID = vID ;
0073 _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) );
0074 _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) );
0075 return cID ;
0076 }
0077
0078 std::vector<double> CartesianGridYZ::cellDimensions(const CellID&) const {
0079 #if __cplusplus >= 201103L
0080 return {_gridSizeY, _gridSizeZ};
0081 #else
0082 std::vector<double> cellDims(2,0.0);
0083 cellDims[0] = _gridSizeY;
0084 cellDims[1] = _gridSizeZ;
0085 return cellDims;
0086 #endif
0087 }
0088
0089
0090 }
0091 }