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/CylindricalGridPhiZ.h>
0019
0020 namespace dd4hep {
0021 namespace DDSegmentation {
0022
0023 using std::make_pair;
0024 using std::vector;
0025
0026
0027 CylindricalGridPhiZ::CylindricalGridPhiZ(const std::string& cellEncoding) :
0028 CylindricalSegmentation(cellEncoding) {
0029
0030 _type = "CylindricalGridPhiZ";
0031 _description = "Cylindrical segmentation in the local PhiZ-cylinder";
0032
0033
0034 registerParameter("grid_size_phi", "Cell size in phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit);
0035 registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0036 registerParameter("offset_phi", "Cell offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0037 registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0038 registerParameter("radius", "Radius of Cylinder", _radius, 0., SegmentationParameter::LengthUnit);
0039 registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiId, "phi");
0040 registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0041 }
0042
0043
0044 CylindricalGridPhiZ::CylindricalGridPhiZ(const BitFieldCoder* decode) :
0045 CylindricalSegmentation(decode) {
0046
0047 _type = "CylindricalGridPhiZ";
0048 _description = "Cylindrical segmentation in the local PhiZ-cylinder";
0049
0050
0051 registerParameter("grid_size_phi", "Cell size in phi", _gridSizePhi, 1., SegmentationParameter::AngleUnit);
0052 registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0053 registerParameter("offset_phi", "Cell offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0054 registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0055 registerParameter("radius", "Radius of Cylinder", _radius, 0., SegmentationParameter::LengthUnit);
0056 registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiId, "phi");
0057 registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0058 }
0059
0060
0061 CylindricalGridPhiZ::~CylindricalGridPhiZ() {
0062
0063 }
0064
0065
0066 void CylindricalGridPhiZ::setDecoder(const BitFieldCoder* newDecoder) {
0067 this->Segmentation::setDecoder(newDecoder);
0068 const BitFieldElement* m_phi = &((*_decoder)[_phiId]);
0069 _phiIsSigned = m_phi->isSigned();
0070 }
0071
0072
0073 Vector3D CylindricalGridPhiZ::position(const CellID& cID) const {
0074 vector<double> localPosition(3);
0075 Vector3D cellPosition;
0076 double phi =
0077 binToPosition( _decoder->get(cID,_phiId ), _gridSizePhi, _offsetPhi);
0078 cellPosition.Z =
0079 binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ);
0080 const double &R = _radius;
0081 cellPosition.X = R*cos(phi); cellPosition.Y = R*sin(phi);
0082
0083 return cellPosition;
0084 }
0085
0086
0087 CellID CylindricalGridPhiZ::cellID(const Vector3D& localPosition, const Vector3D& , const VolumeID& vID) const {
0088 double phi = atan2(localPosition.Y,localPosition.X);
0089 double Z = localPosition.Z;
0090 if (!_phiIsSigned && phi < _offsetPhi) {
0091 phi += 2*M_PI;
0092 }
0093 CellID cID = vID ;
0094 _decoder->set( cID,_phiId, positionToBin(phi, _gridSizePhi, _offsetPhi) );
0095 _decoder->set( cID,_zId, positionToBin(Z, _gridSizeZ, _offsetZ) );
0096
0097 return cID ;
0098 }
0099
0100 std::vector<double> CylindricalGridPhiZ::cellDimensions(const CellID&) const {
0101 return {_radius*_gridSizePhi, _gridSizeZ};
0102 }
0103
0104
0105 }
0106 }