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
0019 #include <DDSegmentation/CartesianGridUV.h>
0020
0021 namespace dd4hep {
0022 namespace DDSegmentation {
0023
0024
0025 CartesianGridUV::CartesianGridUV(const std::string& cellEncoding) :
0026 CartesianGrid(cellEncoding) {
0027
0028 _type = "CartesianGridUV";
0029 _description = "Cartesian segmentation along U,V rotated some angle from local X,Y axes";
0030
0031
0032 registerParameter("grid_size_u", "Cell size in U", _gridSizeU, 1., SegmentationParameter::LengthUnit);
0033 registerParameter("grid_size_v", "Cell size in V", _gridSizeV, 1., SegmentationParameter::LengthUnit);
0034 registerParameter("offset_u", "Cell offset in U", _offsetU, 0., SegmentationParameter::LengthUnit, true);
0035 registerParameter("offset_v", "Cell offset in V", _offsetV, 0., SegmentationParameter::LengthUnit, true);
0036 registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u");
0037 registerIdentifier("identifier_v", "Cell ID identifier for V", _vId, "v");
0038 registerParameter("grid_angle", "Angle of U measurement axis in X,Y frame", _gridAngle, 0., SegmentationParameter::AngleUnit);
0039 };
0040
0041
0042 CartesianGridUV::CartesianGridUV(const BitFieldCoder* decode) :
0043 CartesianGrid(decode)
0044 {
0045
0046 _type = "CartesianGridUV";
0047 _description = "Cartesian segmentation along U,V rotated some angle from local X,Y axes";
0048
0049
0050 registerParameter("grid_size_u", "Cell size in U", _gridSizeU, 1., SegmentationParameter::LengthUnit);
0051 registerParameter("grid_size_v", "Cell size in V", _gridSizeV, 1., SegmentationParameter::LengthUnit);
0052 registerParameter("offset_u", "Cell offset in U", _offsetU, 0., SegmentationParameter::LengthUnit, true);
0053 registerParameter("offset_v", "Cell offset in V", _offsetV, 0., SegmentationParameter::LengthUnit, true);
0054 registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u");
0055 registerIdentifier("identifier_v", "Cell ID identifier for V", _vId, "v");
0056 registerParameter("grid_angle", "Angle of U measurement axis in X,Y frame", _gridAngle, 0., SegmentationParameter::AngleUnit);
0057 };
0058
0059
0060 CartesianGridUV::~CartesianGridUV() {
0061
0062 }
0063
0064
0065 Vector3D CartesianGridUV::position(const CellID& cID) const {
0066 Vector3D cellPosition;
0067 cellPosition.X = binToPosition( _decoder->get(cID,_uId ), _gridSizeU, _offsetU);
0068 cellPosition.Y = binToPosition( _decoder->get(cID,_vId ), _gridSizeV, _offsetV);
0069 cellPosition = RotationZ(-_gridAngle)*cellPosition;
0070 return cellPosition;
0071 }
0072
0073
0074 CellID CartesianGridUV::cellID(const Vector3D& localPosition,
0075 const Vector3D& ,
0076 const VolumeID& vID) const {
0077 CellID cID = vID;
0078 const Vector3D& localUV = RotationZ(_gridAngle)*localPosition;
0079 _decoder->set( cID,_uId, positionToBin(localUV.X, _gridSizeU, _offsetU) );
0080 _decoder->set( cID,_vId, positionToBin(localUV.Y, _gridSizeV, _offsetV) );
0081 return cID;
0082 }
0083
0084 std::vector<double> CartesianGridUV::cellDimensions(const CellID& ) const {
0085 return {_gridSizeU, _gridSizeV};
0086 }
0087
0088
0089 }
0090 }
0091
0092
0093
0094