File indexing completed on 2025-02-22 09:36:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <DDSegmentation/WaferGridXY.h>
0019
0020 namespace dd4hep {
0021 namespace DDSegmentation {
0022
0023
0024 WaferGridXY::WaferGridXY(const std::string& cellEncoding) :
0025 CartesianGrid(cellEncoding) {
0026
0027 _type = "WaferGridXY";
0028 _description = "Cartesian segmentation in the local XY-plane for both Normal wafer and Magic wafer(depending on the layer dimensions)";
0029
0030
0031 registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0032 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0033 registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0034 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0035 registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0036 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0037 registerParameter("identifier_groupMGWafer", "Cell encoding identifier for Magic Wafer group", _identifierMGWaferGroup, std::string("layer"),
0038 SegmentationParameter::NoUnit, true);
0039 registerParameter("identifier_wafer", "Cell encoding identifier for wafer", _identifierWafer, std::string("wafer"),
0040 SegmentationParameter::NoUnit, true);
0041 }
0042
0043
0044 WaferGridXY::WaferGridXY(const BitFieldCoder* decode) : CartesianGrid(decode) {
0045
0046 _type = "WaferGridXY";
0047 _description = "Cartesian segmentation in the local XY-plane for both Normal wafer and Magic wafer(depending on the layer dimensions)";
0048
0049
0050 registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0051 registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0052 registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0053 registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0054 registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0055 registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0056 registerParameter("identifier_groupMGWafer", "Cell encoding identifier for Magic Wafer group", _identifierMGWaferGroup, std::string("layer"),
0057 SegmentationParameter::NoUnit, true);
0058 registerParameter("identifier_wafer", "Cell encoding identifier for wafer", _identifierWafer, std::string("wafer"),
0059 SegmentationParameter::NoUnit, true);
0060 }
0061
0062
0063 WaferGridXY::~WaferGridXY() {
0064
0065 }
0066
0067
0068 Vector3D WaferGridXY::position(const CellID& cID) const {
0069 unsigned int _groupMGWaferIndex;
0070 unsigned int _waferIndex;
0071 Vector3D cellPosition;
0072
0073 _groupMGWaferIndex = _decoder->get(cID,_identifierMGWaferGroup);
0074 _waferIndex = _decoder->get(cID,_identifierWafer);
0075
0076 if ( _waferOffsetX[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetX[_groupMGWaferIndex][_waferIndex] < 0 )
0077 {
0078 cellPosition.X = binToPosition(_decoder->get(cID,_xId), _gridSizeX, _offsetX+_waferOffsetX[_groupMGWaferIndex][_waferIndex]);
0079 }
0080 else
0081 {
0082 cellPosition.X = binToPosition(_decoder->get(cID,_xId), _gridSizeX, _offsetX);
0083 }
0084
0085 if ( _waferOffsetY[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetY[_groupMGWaferIndex][_waferIndex] < 0 )
0086 {
0087 cellPosition.Y = binToPosition(_decoder->get(cID,_yId), _gridSizeY, _offsetY+_waferOffsetY[_groupMGWaferIndex][_waferIndex]);
0088 }
0089 else
0090 {
0091 cellPosition.Y = binToPosition(_decoder->get(cID,_yId), _gridSizeY, _offsetY);
0092 }
0093
0094 return cellPosition;
0095 }
0096
0097
0098 CellID WaferGridXY::cellID(const Vector3D& localPosition, const Vector3D& , const VolumeID& vID) const {
0099 unsigned int _groupMGWaferIndex;
0100 unsigned int _waferIndex;
0101
0102 CellID cID = vID ;
0103
0104 _groupMGWaferIndex = _decoder->get(cID,_identifierMGWaferGroup);
0105 _waferIndex = _decoder->get(cID,_identifierWafer);
0106
0107 if ( _waferOffsetX[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetX[_groupMGWaferIndex][_waferIndex] < 0 )
0108 {
0109 _decoder->set(cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_waferOffsetX[_groupMGWaferIndex][_waferIndex]));
0110 }
0111 else
0112 {
0113 _decoder->set(cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX));
0114 }
0115
0116 if ( _waferOffsetY[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetY[_groupMGWaferIndex][_waferIndex] < 0)
0117 {
0118 _decoder->set(cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_waferOffsetY[_groupMGWaferIndex][_waferIndex]));
0119 }
0120 else
0121 {
0122 _decoder->set(cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY));
0123 }
0124
0125 return cID;
0126 }
0127
0128 std::vector<double> WaferGridXY::cellDimensions(const CellID&) const {
0129 #if __cplusplus >= 201103L
0130 return {_gridSizeX, _gridSizeY};
0131 #else
0132 std::vector<double> cellDims(2,0.0);
0133 cellDims[0] = _gridSizeX;
0134 cellDims[1] = _gridSizeY;
0135 return cellDims;
0136 #endif
0137 }
0138
0139 }
0140 }