Skip to content

Commit

Permalink
addressing SonarCloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger committed Sep 30, 2024
1 parent 22fd548 commit 021c532
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
20 changes: 11 additions & 9 deletions Examples/Algorithms/Propagation/src/SimHitToSummaryConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace {
///
/// @return the concatenated step
Acts::detail::Step concatenateSteps(
const Acts::GeometryContext gctx,
const Acts::GeometryContext& gctx,
const std::vector<Acts::detail::Step>& steps,
const Acts::Surface& surface) {
// Average the position and direction
Expand All @@ -29,8 +29,9 @@ Acts::detail::Step concatenateSteps(
concatStep.position += step.position;
concatStep.momentum += step.momentum;
}
concatStep.position /= steps.size();
concatStep.momentum /= steps.size();
Acts::ActsScalar weight = 1.0 / static_cast<Acts::ActsScalar>(steps.size());
concatStep.position *= weight;
concatStep.momentum *= weight;
} else {
concatStep = steps.front();
}
Expand Down Expand Up @@ -74,7 +75,8 @@ ActsExamples::ProcessCode ActsExamples::SimHitToSummaryConversion::execute(
propagationSummaries.reserve(particles.size());

// Prepare and sort
std::unordered_map<unsigned int, std::vector<std::vector<Acts::detail::Step>>>
std::unordered_map<unsigned long,
std::vector<std::vector<Acts::detail::Step>>>
trackSteps;
for (const auto& simHitsGroup : groupByModule(simHits)) {
// Manual pair unpacking instead of using
Expand All @@ -83,11 +85,11 @@ ActsExamples::ProcessCode ActsExamples::SimHitToSummaryConversion::execute(
// binding in the lambda used for visiting the smearer below.
Acts::GeometryIdentifier moduleGeoId = simHitsGroup.first;
const auto& moduleSimHits = simHitsGroup.second;
std::unordered_map<unsigned int, std::vector<Acts::detail::Step>>
std::unordered_map<unsigned long, std::vector<Acts::detail::Step>>
moduleSteps;
for (const auto& simHit : moduleSimHits) {
unsigned int paritcleId = simHit.particleId().value();
if (moduleSteps.find(paritcleId) == moduleSteps.end()) {
unsigned long paritcleId = simHit.particleId().value();
if (!moduleSteps.contains(paritcleId)) {
moduleSteps[paritcleId] = std::vector<Acts::detail::Step>();
}
Acts::ActsScalar hx = simHit.fourPosition().x() / Acts::UnitConstants::mm;
Expand All @@ -101,8 +103,8 @@ ActsExamples::ProcessCode ActsExamples::SimHitToSummaryConversion::execute(
moduleSteps[paritcleId].push_back(step);
}
// Loop over and fill into the trackSteps
for (auto [particleId, steps] : moduleSteps) {
if (trackSteps.find(particleId) == trackSteps.end()) {
for (const auto& [particleId, steps] : moduleSteps) {
if (!trackSteps.contains(particleId)) {
trackSteps[particleId] = std::vector<std::vector<Acts::detail::Step>>();
}
trackSteps[particleId].push_back(steps);
Expand Down
8 changes: 4 additions & 4 deletions Examples/Python/src/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,21 @@ void addExperimentalGeometry(Context& ctx) {
.def("volumes", &Detector::volumes)
.def("volumePtrs", &Detector::volumePtrs)
.def("numberVolumes",
[](Detector& self) { return self.volumes().size(); })
[](const Detector& self) { return self.volumes().size(); })
.def("extractMaterialSurfaces",
[](Detector& self) {
[](const Detector& self) {
MaterialSurfaceSelector selector;
self.visitSurfaces(selector);
return selector.surfaces;
})
.def("geoIdSurfaceMap",
[](Detector& self) {
[](const Detector& self) {
IdentifierSurfacesCollector collector;
self.visitSurfaces(collector);
return collector.surfaces;
})
.def("cylindricalVolumeRepresentation",
[](Detector& self, Acts::GeometryContext& gctx) {
[](const Detector& self, const Acts::GeometryContext& gctx) {
// Loop over the volumes and gather the extent
Extent extent;
for (const auto& volume : self.volumes()) {
Expand Down

0 comments on commit 021c532

Please sign in to comment.