Skip to content

Commit

Permalink
fix: Smearing-digitization with Geant4 (#2182)
Browse files Browse the repository at this point in the history
Geant4 hits may not be exactely on the surface. This PR adjusts the tolerance for the free-to-bound conversion to address this. Also bumps the corresponding log message to a warning.

The error still occurs around 40 times for 2000 muons... but at least we are not loosing around 50% of the hits anymore...

cc @asalzburger
  • Loading branch information
benjaminhuth committed Jun 8, 2023
1 parent fd37ded commit 078a01e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ ActsExamples::ProcessCode ActsExamples::DigitizationAlgorithm::execute(
auto res =
digitizer.smearing(rng, simHit, *surfacePtr, ctx.geoContext);
if (not res.ok()) {
ACTS_DEBUG("Problem in hit smearing, skipping this hit.")
ACTS_WARNING("Problem in hit smearing, skip hit ("
<< res.error().message() << ")");
continue;
}
const auto& [par, cov] = res.value();
Expand Down
15 changes: 12 additions & 3 deletions Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/detail/TransformationFreeToBound.hpp"
#include "Acts/Geometry/DetectorElementBase.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Result.hpp"
#include "ActsFatras/EventData/Hit.hpp"
Expand Down Expand Up @@ -62,12 +63,20 @@ struct BoundParametersSmearer {
Result operator()(generator_t& rng, const Hit& hit,
const Acts::Surface& surface,
const Acts::GeometryContext& geoCtx) const {
// We use the thickness of the detector element as tolerance, because Geant4
// treats the Surfaces as volumes and thus it is not ensured, that each hit
// lies exactely on the Acts::Surface
const auto tolerance =
surface.associatedDetectorElement() != nullptr
? surface.associatedDetectorElement()->thickness()
: Acts::s_onSurfaceTolerance;

// construct full bound parameters. they are probably not all needed, but it
// is easier to just create them all and then select the requested ones.
Acts::Result<Acts::BoundVector> boundParamsRes =
Acts::detail::transformFreeToBoundParameters(hit.position(), hit.time(),
hit.unitDirection(), 0,
surface, geoCtx);
Acts::detail::transformFreeToBoundParameters(
hit.position(), hit.time(), hit.unitDirection(), 0, surface, geoCtx,
tolerance);

if (!boundParamsRes.ok()) {
return boundParamsRes.error();
Expand Down

0 comments on commit 078a01e

Please sign in to comment.