Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix in Segmentation's CylindricalGridPhiZ: phi range #1357

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion DDCore/include/DDSegmentation/CylindricalGridPhiZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ namespace dd4hep {
*/
virtual std::vector<double> cellDimensions(const CellID& cellID) const;

/// Set the underlying decoder (setting, inter alia, whether phi isSigned)
virtual void setDecoder(const BitFieldCoder* decoder);

protected:
/// the grid size in phi
double _gridSizePhi;
Expand All @@ -119,7 +122,8 @@ namespace dd4hep {
std::string _phiId;
/// the field name used for Z
std::string _zId;
/// encoding field used for the module
/// the isSigned attribute of the bitfield used for phi
bool _phiIsSigned;
};

} /* namespace DDSegmentation */
Expand Down
9 changes: 8 additions & 1 deletion DDCore/src/segmentations/CylindricalGridPhiZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ CylindricalGridPhiZ::~CylindricalGridPhiZ() {

}

/// Set the underlying decoder and assign isSigned attribute to phi identifier
void CylindricalGridPhiZ::setDecoder(const BitFieldCoder* newDecoder) {
this->Segmentation::setDecoder(newDecoder);
const BitFieldElement* m_phi = &((*_decoder)[_phiId]);
_phiIsSigned = m_phi->isSigned();
}

/// determine the position based on the cell ID
Vector3D CylindricalGridPhiZ::position(const CellID& cID) const {
vector<double> localPosition(3);
Expand All @@ -80,7 +87,7 @@ Vector3D CylindricalGridPhiZ::position(const CellID& cID) const {
CellID CylindricalGridPhiZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const {
double phi = atan2(localPosition.Y,localPosition.X);
double Z = localPosition.Z;
if ( phi < _offsetPhi) {
if (!_phiIsSigned && phi < _offsetPhi) {
phi += 2*M_PI;
}
CellID cID = vID ;
Expand Down
Loading