Skip to content

Commit

Permalink
Prefer std::abs over abs (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: jmcarcell <[email protected]>
  • Loading branch information
jmcarcell and jmcarcell authored Apr 24, 2024
1 parent 1fc8c71 commit fdaeb23
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions SimG4Components/src/SimG4MagneticFieldFromMapTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,26 @@ StatusCode SimG4MagneticFieldFromMapTool::loadRootMap() {
by *= tesla;
bz *= tesla;

if (m_fieldMaxR.value() > 0 && abs(x) > m_fieldMaxR.value()) {
if (m_fieldMaxR.value() > 0 && std::abs(x) > m_fieldMaxR.value()) {
continue;
}

if (m_fieldMaxR.value() > 0 && abs(y) > m_fieldMaxR.value()) {
if (m_fieldMaxR.value() > 0 && std::abs(y) > m_fieldMaxR.value()) {
continue;
}

if (m_fieldMaxZ.value() > 0 && abs(z) > m_fieldMaxZ.value()) {
if (m_fieldMaxZ.value() > 0 && std::abs(z) > m_fieldMaxZ.value()) {
continue;
}

double r = std::sqrt(std::pow(x, 2) + std::pow(y, 2));

if (m_addFieldMaxR.value() > 0 && m_addFieldMaxZ.value() > 0) {
if(r < m_addFieldMaxR.value() && abs(z) < m_addFieldMaxZ.value()) {
if(r < m_addFieldMaxR.value() && std::abs(z) < m_addFieldMaxZ.value()) {
bz += m_addFieldBz.value();
}
} else if (m_addFieldMaxR.value() <= 0 && m_addFieldMaxZ.value() > 0) {
if (abs(z) < m_addFieldMaxZ.value()) {
if (std::abs(z) < m_addFieldMaxZ.value()) {
bz += m_addFieldBz.value();
}
} else if (m_addFieldMaxR.value() > 0 && m_addFieldMaxZ.value() <= 0) {
Expand Down Expand Up @@ -312,16 +312,16 @@ StatusCode SimG4MagneticFieldFromMapTool::loadComsolMap() {
continue;
}

if (m_fieldMaxZ.value() > 0 && abs(z) > m_fieldMaxZ.value()) {
if (m_fieldMaxZ.value() > 0 && std::abs(z) > m_fieldMaxZ.value()) {
continue;
}

if (m_addFieldMaxR.value() > 0 && m_addFieldMaxZ.value() > 0) {
if(r < m_addFieldMaxR.value() && abs(z) < m_addFieldMaxZ.value()) {
if(r < m_addFieldMaxR.value() && std::abs(z) < m_addFieldMaxZ.value()) {
Bz += m_addFieldBz.value();
}
} else if (m_addFieldMaxR.value() <= 0 && m_addFieldMaxZ.value() > 0) {
if (abs(z) < m_addFieldMaxZ.value()) {
if (std::abs(z) < m_addFieldMaxZ.value()) {
Bz += m_addFieldBz.value();
}
} else if (m_addFieldMaxR.value() > 0 && m_addFieldMaxZ.value() <= 0) {
Expand Down

0 comments on commit fdaeb23

Please sign in to comment.