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