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/ProjectiveCylinder.h>
0019 #include <DDSegmentation/SegmentationUtil.h>
0020
0021 #define _USE_MATH_DEFINES
0022 #include <cmath>
0023
0024 namespace dd4hep {
0025 namespace DDSegmentation {
0026
0027 using Util::thetaFromXYZ;
0028 using Util::phiFromXYZ;
0029
0030
0031 ProjectiveCylinder::ProjectiveCylinder(const std::string& cellEncoding) :
0032 CylindricalSegmentation(cellEncoding) {
0033
0034 _type = "ProjectiveCylinder";
0035 _description = "Projective segmentation in the global coordinates";
0036
0037
0038 registerParameter("theta_bins", "Number of bins theta", _thetaBins, 1);
0039 registerParameter("phi_bins", "Number of bins phi", _phiBins, 1);
0040 registerParameter("offset_theta", "Angular offset in theta", _offsetTheta, 0., SegmentationParameter::AngleUnit, true);
0041 registerParameter("offset_phi", "Angular offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0042 registerIdentifier("identifier_theta", "Cell ID identifier for theta", _thetaID, "theta");
0043 registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiID, "phi");
0044 }
0045
0046
0047
0048 ProjectiveCylinder::ProjectiveCylinder(const BitFieldCoder* decode) : CylindricalSegmentation(decode) {
0049
0050 _type = "ProjectiveCylinder";
0051 _description = "Projective segmentation in the global coordinates";
0052
0053
0054 registerParameter("theta_bins", "Number of bins theta", _thetaBins, 1);
0055 registerParameter("phi_bins", "Number of bins phi", _phiBins, 1);
0056 registerParameter("offset_theta", "Angular offset in theta", _offsetTheta, 0., SegmentationParameter::AngleUnit, true);
0057 registerParameter("offset_phi", "Angular offset in phi", _offsetPhi, 0., SegmentationParameter::AngleUnit, true);
0058 registerIdentifier("identifier_theta", "Cell ID identifier for theta", _thetaID, "theta");
0059 registerIdentifier("identifier_phi", "Cell ID identifier for phi", _phiID, "phi");
0060 }
0061
0062
0063 ProjectiveCylinder::~ProjectiveCylinder() {
0064
0065 }
0066
0067
0068 Vector3D ProjectiveCylinder::position(const CellID& cID) const {
0069 return Util::positionFromRThetaPhi(1.0, theta(cID), phi(cID));
0070 }
0071
0072
0073 CellID ProjectiveCylinder::cellID(const Vector3D& , const Vector3D& globalPosition, const VolumeID& vID) const {
0074 CellID cID = vID ;
0075 double lTheta = thetaFromXYZ(globalPosition);
0076 double lPhi = phiFromXYZ(globalPosition);
0077 _decoder->set(cID,_thetaID, positionToBin(lTheta, M_PI / (double) _thetaBins, _offsetTheta));
0078 _decoder->set(cID,_phiID , positionToBin(lPhi, 2 * M_PI / (double) _phiBins, _offsetPhi));
0079 return cID;
0080 }
0081
0082
0083 double ProjectiveCylinder::theta(const CellID& cID) const {
0084 CellID thetaIndex = _decoder->get(cID,_thetaID);
0085 return M_PI * ((double) thetaIndex + 0.5) / (double) _thetaBins;
0086 }
0087
0088 double ProjectiveCylinder::phi(const CellID& cID) const {
0089 CellID phiIndex = _decoder->get(cID,_phiID);
0090 return 2. * M_PI * ((double) phiIndex + 0.5) / (double) _phiBins;
0091 }
0092
0093
0094 }
0095 }
0096