From 586ba634e586f2d413e5c2225b6918122bd5fc49 Mon Sep 17 00:00:00 2001 From: Pruthvi Suryadevara Date: Thu, 6 Jul 2023 15:39:32 +0200 Subject: [PATCH] Remove repeated calculations --- SimG4CMS/Calo/src/HGCGuardRingPartial.cc | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/SimG4CMS/Calo/src/HGCGuardRingPartial.cc b/SimG4CMS/Calo/src/HGCGuardRingPartial.cc index c22fdde3fb043..9f24974dd3e7f 100644 --- a/SimG4CMS/Calo/src/HGCGuardRingPartial.cc +++ b/SimG4CMS/Calo/src/HGCGuardRingPartial.cc @@ -34,22 +34,15 @@ bool HGCGuardRingPartial::exclude(G4ThreeVector& point, int zside, int frontBack double delY = 2 * delX / sqrt3_; double dx = (zside > 0) ? -point.x() : point.x(); double dy = point.y(); + double tresh = std::abs(offset_ / cos_1[placement]); if (type > 0) { - check = (std::abs(dy - (dx * tan_1[placement])) < std::abs(offset_ / cos_1[placement]) || check); - check = (std::abs(dy - (dx * tan_1[placement]) + ((HGCalTypes::c10 * delY * 0.5) / cos_1[placement])) < - std::abs(offset_ / cos_1[placement]) || - check); - check = (std::abs(dy * cot_1[placement] - (dx)) < std::abs(offset_ / cos_1[placement]) || check); + check |= std::abs(dy - (dx * tan_1[placement])) < tresh; + check |= std::abs(dy - (dx * tan_1[placement]) + ((HGCalTypes::c10 * delY * 0.5) / cos_1[placement])) < tresh; + check |= std::abs(dy * cot_1[placement] - (dx)) < tresh; } else { - check = (std::abs((dy * cot_1[placement]) - dx + ((HGCalTypes::c22 * delX) / cos_1[placement])) < - std::abs(offset_ / cos_1[placement]) || - check); - check = (std::abs(dy - (dx * tan_1[placement]) - ((HGCalTypes::c27 * delY) / cos_1[placement])) < - std::abs(offset_ / cos_1[placement]) || - check); - check = (std::abs(dy - (dx * tan_1[placement]) + ((HGCalTypes::c27 * delY) / cos_1[placement])) < - std::abs(offset_ / cos_1[placement]) || - check); + check |= std::abs((dy * cot_1[placement]) - dx + ((HGCalTypes::c22 * delX) / cos_1[placement])) < tresh; + check |= std::abs(dy - (dx * tan_1[placement]) - ((HGCalTypes::c27 * delY) / cos_1[placement])) < tresh; + check |= std::abs(dy - (dx * tan_1[placement]) + ((HGCalTypes::c27 * delY) / cos_1[placement])) < tresh; } } #ifdef EDM_ML_DEBUG