Skip to content

Commit

Permalink
Remove repeated calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pruthvi-ch committed Jul 6, 2023
1 parent 6305413 commit 586ba63
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions SimG4CMS/Calo/src/HGCGuardRingPartial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 586ba63

Please sign in to comment.