From 00d83fe3f414135b8c1c8f79bf03d77f2bd83f73 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 19 Jan 2024 18:42:15 -0600 Subject: [PATCH] fix: use qOverP to get the charge of TrackParameters (#18) After https://github.com/eic/EDM4eic/pull/58, there is no more `charge` field in edm4eic::TrackParameters, so we have to get this from `qOverP`, but this is backwards compatible. --- truth/src/ParticlesWithTruthPID.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truth/src/ParticlesWithTruthPID.cpp b/truth/src/ParticlesWithTruthPID.cpp index b0f604a..cce5f67 100644 --- a/truth/src/ParticlesWithTruthPID.cpp +++ b/truth/src/ParticlesWithTruthPID.cpp @@ -29,7 +29,7 @@ void ParticlesWithTruthPID::process(const ParticlesWithTruthPID::Input& input, for (const auto& trk : tracks) { const auto mom = edm4hep::utils::sphericalToVector(1.0 / std::abs(trk.getQOverP()), trk.getTheta(), trk.getPhi()); - const auto charge_rec = trk.getCharge(); + const auto charge_rec = std::copysign(1., trk.getQOverP()); // utility variables for matching int best_match = -1; double best_delta = std::numeric_limits::max();