Skip to content

Commit

Permalink
fix clang-tidy problems in surface sampling (#232)
Browse files Browse the repository at this point in the history
fix clang-tidy problems in surface sampling
  • Loading branch information
ManuelHu authored Jan 19, 2025
1 parent 8a50305 commit df088ef
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 104 deletions.
12 changes: 6 additions & 6 deletions include/RMGVertexConfinement.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RMGVertexConfinement : public RMGVVertexGenerator {

/** @brief Information about the geometrical (user) defined solids. */
struct GenericGeometricalSolidData {
GeometricalSolidType solid_type;
GeometricalSolidType solid_type = GeometricalSolidType::kBox;
G4ThreeVector volume_center = G4ThreeVector(0, 0, 0);
double sphere_inner_radius = 0;
double sphere_outer_radius = -1;
Expand Down Expand Up @@ -180,12 +180,12 @@ class RMGVertexConfinement : public RMGVVertexGenerator {
* - Pick one intersection, or repeat.
*
* @param vertex The sampled vertex,
* @param max_samples The maximum number of attempts to find a valid vertex.
* @param max_attempts The maximum number of attempts to find a valid vertex.
* @param n_max The maximum number of intersections possible for the solid,
* can be an overestimate.
*
*/
[[nodiscard]] bool GenerateSurfacePoint(G4ThreeVector& vertex, int max_samples,
[[nodiscard]] bool GenerateSurfacePoint(G4ThreeVector& vertex, int max_attempts,
int n_max) const;

// methods for the generic surface sampling
Expand All @@ -203,8 +203,8 @@ class RMGVertexConfinement : public RMGVVertexGenerator {
*
* @returns A vector of the points of intersection.
*/
std::vector<G4ThreeVector> GetIntersections(const G4ThreeVector start,
const G4ThreeVector dir) const;
[[nodiscard]] std::vector<G4ThreeVector> GetIntersections(G4ThreeVector start,
G4ThreeVector dir) const;

/**
* @brief Get a position and direction for the generic surface sampling algorithm.
Expand Down Expand Up @@ -284,7 +284,7 @@ class RMGVertexConfinement : public RMGVVertexGenerator {
};

void InitializePhysicalVolumes();
void InitializeGeometricalVolumes(bool useExcludedVolumes);
void InitializeGeometricalVolumes(bool use_excluded_volumes);
bool ActualGenerateVertex(G4ThreeVector& v);

std::vector<std::string> fPhysicalVolumeNameRegexes;
Expand Down
9 changes: 3 additions & 6 deletions src/RMGVertexConfinement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool RMGVertexConfinement::SampleableObject::GenerateSurfacePoint(G4ThreeVector&
// find the intersections
std::vector<G4ThreeVector> intersections = this->GetIntersections(pos, dir);

if (intersections.size() == 0) continue;
if (intersections.empty()) continue;

// The surface sampling algorithm returns N intersections.
// We have to select one, to keep independence of the sampled points
Expand Down Expand Up @@ -310,11 +310,8 @@ bool RMGVertexConfinement::SampleableObject::Sample(G4ThreeVector& vertex, int m
}

bool RMGVertexConfinement::SampleableObjectCollection::IsInside(const G4ThreeVector& vertex) const {
auto navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
for (const auto& o : data) {
if (o.IsInside(vertex)) return true;
}
return false;
return std::any_of(data.begin(), data.end(),
[&vertex](const auto& o) { return o.IsInside(vertex); });
}


Expand Down
Loading

0 comments on commit df088ef

Please sign in to comment.