diff --git a/CI/physmon/fpe_masks.yml b/CI/physmon/fpe_masks.yml index 98b4f7222fa..62f1f1339de 100644 --- a/CI/physmon/fpe_masks.yml +++ b/CI/physmon/fpe_masks.yml @@ -1,6 +1,6 @@ "Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp:66": FLTUND: 1 -"Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp:178": +"Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp:177": FLTUND: 1 "Core/include/Acts/TrackFitting/detail/GsfUtils.hpp:197": FLTUND: 1 diff --git a/Core/include/Acts/Seeding/SeedFinder.ipp b/Core/include/Acts/Seeding/SeedFinder.ipp index d9be9e7a5e6..dc901d9b735 100644 --- a/Core/include/Acts/Seeding/SeedFinder.ipp +++ b/Core/include/Acts/Seeding/SeedFinder.ipp @@ -715,19 +715,12 @@ inline void SeedFinder::filterCandidates( // maxPtScattering instead of pt. // To avoid 0-divison the pT check is skipped in case of B2==0, and // p2scatterSigma is calculated directly from maxPtScattering - if (B2 == 0) { + if (B2 == 0 or options.pTPerHelixRadius * std::sqrt(S2 / B2) > + 2. * m_config.maxPtScattering) { float pTscatterSigma = (m_config.highland / m_config.maxPtScattering) * m_config.sigmaScattering; p2scatterSigma = pTscatterSigma * pTscatterSigma * iSinTheta2; - } else { - float pT = options.pTPerHelixRadius * std::sqrt(S2 / B2) / 2.; - if (pT > m_config.maxPtScattering) { - float pTscatterSigma = - (m_config.highland / m_config.maxPtScattering) * - m_config.sigmaScattering; - p2scatterSigma = pTscatterSigma * pTscatterSigma * iSinTheta2; - } } } diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 3695584789a..158d4d334ea 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -436,8 +436,8 @@ void SeedFinderOrthogonal::filterCandidates( if (!std::isinf(m_config.maxPtScattering)) { // if pT > maxPtScattering, calculate allowed scattering angle using // maxPtScattering instead of pt. - float pT = options.pTPerHelixRadius * std::sqrt(S2 / B2) / 2.; - if (pT > m_config.maxPtScattering) { + if (B2 == 0 or options.pTPerHelixRadius * std::sqrt(S2 / B2) > + 2. * m_config.maxPtScattering) { float pTscatterSigma = (m_config.highland / m_config.maxPtScattering) * m_config.sigmaScattering; diff --git a/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.cpp b/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.cpp index c440094e6de..9a4134a48b0 100644 --- a/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.cpp +++ b/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.cpp @@ -63,7 +63,7 @@ void PrimaryGeneratorAction::prepareParticleGun( m_particleGun->SetParticleDefinition(particle); // Particle properties const auto pos = part.position() * convertLength; - const auto dir = part.unitDirection(); + const auto dir = part.direction(); m_particleGun->SetParticlePosition({pos[0], pos[1], pos[2]}); m_particleGun->SetParticleMomentum(part.absoluteMomentum() * convertEnergy); m_particleGun->SetParticleMomentumDirection({dir[0], dir[1], dir[2]}); diff --git a/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp b/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp index 653884bc0a4..59c80d58aa6 100644 --- a/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp +++ b/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp @@ -43,7 +43,7 @@ ActsExamples::ProcessCode ActsExamples::ParticlesPrinter::execute( ACTS_INFO(" process_type: " << particle.process()) ACTS_INFO(" position: " << particle.position().transpose() / 1_mm << " mm"); - ACTS_INFO(" direction: " << particle.unitDirection().transpose()); + ACTS_INFO(" direction: " << particle.direction().transpose()); ACTS_INFO(" time: " << particle.time() / 1_ns << " ns"); ACTS_INFO(" |p|: " << particle.absoluteMomentum() / 1_GeV << " GeV"); diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp index e262a6e1c8e..de22b03914c 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp @@ -59,8 +59,8 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( return (min <= x) and (x < max); }; auto isValidParticle = [&](const ActsFatras::Particle& p) { - const auto eta = Acts::VectorHelpers::eta(p.unitDirection()); - const auto phi = Acts::VectorHelpers::phi(p.unitDirection()); + const auto eta = Acts::VectorHelpers::eta(p.direction()); + const auto phi = Acts::VectorHelpers::phi(p.direction()); const auto rho = Acts::VectorHelpers::perp(p.position()); // define charge selection const bool validNeutral = (p.charge() == 0) and not m_cfg.removeNeutral; diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp index 72139ea9675..70a022c4d8f 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp @@ -63,8 +63,8 @@ ActsExamples::ProcessCode ActsExamples::ParticleSmearing::execute( for (const auto& particle : vtxParticles) { const auto time = particle.time(); - const auto phi = Acts::VectorHelpers::phi(particle.unitDirection()); - const auto theta = Acts::VectorHelpers::theta(particle.unitDirection()); + const auto phi = Acts::VectorHelpers::phi(particle.direction()); + const auto theta = Acts::VectorHelpers::theta(particle.direction()); const auto pt = particle.transverseMomentum(); const auto p = particle.absoluteMomentum(); const auto q = particle.charge(); @@ -107,7 +107,7 @@ ActsExamples::ProcessCode ActsExamples::ParticleSmearing::execute( ctx.geoContext, Acts::Vector2{params[Acts::eBoundLoc0], params[Acts::eBoundLoc1]}, - particle.unitDirection() * p) + particle.direction() * p) .transpose() << ", " << params[Acts::eBoundTime] << ", " << params[Acts::eBoundPhi] << ", " diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp index acc1be6584e..639d0ecc2ed 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp @@ -60,8 +60,8 @@ ProcessCode TruthSeedSelector::execute(const AlgorithmContext& ctx) const { return (min <= x) and (x < max); }; auto isValidparticle = [&](const auto& p) { - const auto eta = Acts::VectorHelpers::eta(p.unitDirection()); - const auto phi = Acts::VectorHelpers::phi(p.unitDirection()); + const auto eta = Acts::VectorHelpers::eta(p.direction()); + const auto phi = Acts::VectorHelpers::phi(p.direction()); const auto rho = Acts::VectorHelpers::perp(p.position()); // find the corresponding hits for this particle const auto& hits = makeRange(particleHitsMap.equal_range(p.particleId())); diff --git a/Examples/Framework/src/Validation/DuplicationPlotTool.cpp b/Examples/Framework/src/Validation/DuplicationPlotTool.cpp index f1e075ff2e5..2bd61f7b0c1 100644 --- a/Examples/Framework/src/Validation/DuplicationPlotTool.cpp +++ b/Examples/Framework/src/Validation/DuplicationPlotTool.cpp @@ -99,8 +99,8 @@ void ActsExamples::DuplicationPlotTool::fill( void ActsExamples::DuplicationPlotTool::fill( DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache, const ActsFatras::Particle& truthParticle, size_t nDuplicatedTracks) const { - const auto t_phi = phi(truthParticle.unitDirection()); - const auto t_eta = eta(truthParticle.unitDirection()); + const auto t_phi = phi(truthParticle.direction()); + const auto t_eta = eta(truthParticle.direction()); const auto t_pT = truthParticle.transverseMomentum(); PlotHelpers::fillProf(duplicationPlotCache.nDuplicated_vs_pT, t_pT, diff --git a/Examples/Framework/src/Validation/EffPlotTool.cpp b/Examples/Framework/src/Validation/EffPlotTool.cpp index 239cf2b3259..95179d4a889 100644 --- a/Examples/Framework/src/Validation/EffPlotTool.cpp +++ b/Examples/Framework/src/Validation/EffPlotTool.cpp @@ -55,8 +55,8 @@ void ActsExamples::EffPlotTool::write( void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache, const ActsFatras::Particle& truthParticle, bool status) const { - const auto t_phi = phi(truthParticle.unitDirection()); - const auto t_eta = eta(truthParticle.unitDirection()); + const auto t_phi = phi(truthParticle.direction()); + const auto t_eta = eta(truthParticle.direction()); const auto t_pT = truthParticle.transverseMomentum(); PlotHelpers::fillEff(effPlotCache.trackEff_vs_pT, t_pT, status); diff --git a/Examples/Framework/src/Validation/FakeRatePlotTool.cpp b/Examples/Framework/src/Validation/FakeRatePlotTool.cpp index 9dc31b27eb8..e840ad67eff 100644 --- a/Examples/Framework/src/Validation/FakeRatePlotTool.cpp +++ b/Examples/Framework/src/Validation/FakeRatePlotTool.cpp @@ -111,7 +111,7 @@ void ActsExamples::FakeRatePlotTool::fill( FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache, const ActsFatras::Particle& truthParticle, size_t nTruthMatchedTracks, size_t nFakeTracks) const { - const auto t_eta = eta(truthParticle.unitDirection()); + const auto t_eta = eta(truthParticle.direction()); const auto t_pT = truthParticle.transverseMomentum(); PlotHelpers::fillHisto(fakeRatePlotCache.nReco_vs_pT, t_pT, diff --git a/Examples/Framework/src/Validation/ResPlotTool.cpp b/Examples/Framework/src/Validation/ResPlotTool.cpp index 1cd6df2fdb3..5557c767f88 100644 --- a/Examples/Framework/src/Validation/ResPlotTool.cpp +++ b/Examples/Framework/src/Validation/ResPlotTool.cpp @@ -165,7 +165,7 @@ void ActsExamples::ResPlotTool::fill( // get the truth perigee parameter auto lpResult = pSurface->globalToLocal(gctx, truthParticle.position(), - truthParticle.unitDirection()); + truthParticle.direction()); if (lpResult.ok()) { truthParameter[Acts::BoundIndices::eBoundLoc0] = lpResult.value()[Acts::BoundIndices::eBoundLoc0]; @@ -175,15 +175,15 @@ void ActsExamples::ResPlotTool::fill( ACTS_ERROR("Global to local transformation did not succeed."); } truthParameter[Acts::BoundIndices::eBoundPhi] = - phi(truthParticle.unitDirection()); + phi(truthParticle.direction()); truthParameter[Acts::BoundIndices::eBoundTheta] = - theta(truthParticle.unitDirection()); + theta(truthParticle.direction()); truthParameter[Acts::BoundIndices::eBoundQOverP] = truthParticle.charge() / truthParticle.absoluteMomentum(); truthParameter[Acts::BoundIndices::eBoundTime] = truthParticle.time(); // get the truth eta and pT - const auto truthEta = eta(truthParticle.unitDirection()); + const auto truthEta = eta(truthParticle.direction()); const auto truthPt = truthParticle.transverseMomentum(); // fill the histograms for residual and pull diff --git a/Examples/Io/Csv/src/CsvParticleWriter.cpp b/Examples/Io/Csv/src/CsvParticleWriter.cpp index 14475fe37a7..45f62c9349e 100644 --- a/Examples/Io/Csv/src/CsvParticleWriter.cpp +++ b/Examples/Io/Csv/src/CsvParticleWriter.cpp @@ -49,9 +49,9 @@ ActsExamples::ProcessCode ActsExamples::CsvParticleWriter::writeT( data.vz = particle.position().z() / Acts::UnitConstants::mm; data.vt = particle.time() / Acts::UnitConstants::ns; const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV; - data.px = p * particle.unitDirection().x(); - data.py = p * particle.unitDirection().y(); - data.pz = p * particle.unitDirection().z(); + data.px = p * particle.direction().x(); + data.py = p * particle.direction().y(); + data.pz = p * particle.direction().z(); data.m = particle.mass() / Acts::UnitConstants::GeV; data.q = particle.charge() / Acts::UnitConstants::e; writer.append(data); diff --git a/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFinderPerformanceWriter.cpp b/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFinderPerformanceWriter.cpp index 6b9117e5c25..5a9be59efb6 100644 --- a/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFinderPerformanceWriter.cpp +++ b/Examples/Io/Performance/ActsExamples/Io/Performance/TrackFinderPerformanceWriter.cpp @@ -226,9 +226,9 @@ struct ActsExamples::TrackFinderPerformanceWriter::Impl { prtVz = particle.position().z() / Acts::UnitConstants::mm; prtVt = particle.time() / Acts::UnitConstants::ns; const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV; - prtPx = p * particle.unitDirection().x(); - prtPy = p * particle.unitDirection().y(); - prtPz = p * particle.unitDirection().z(); + prtPx = p * particle.direction().x(); + prtPy = p * particle.direction().y(); + prtPz = p * particle.direction().z(); prtM = particle.mass() / Acts::UnitConstants::GeV; prtQ = particle.charge() / Acts::UnitConstants::e; // reconstruction diff --git a/Examples/Io/Root/src/RootParticleWriter.cpp b/Examples/Io/Root/src/RootParticleWriter.cpp index 5dce053fb5f..93c86b70722 100644 --- a/Examples/Io/Root/src/RootParticleWriter.cpp +++ b/Examples/Io/Root/src/RootParticleWriter.cpp @@ -110,9 +110,9 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT( // momentum const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV; m_p.push_back(Acts::clampValue(p)); - m_px.push_back(Acts::clampValue(p * particle.unitDirection().x())); - m_py.push_back(Acts::clampValue(p * particle.unitDirection().y())); - m_pz.push_back(Acts::clampValue(p * particle.unitDirection().z())); + m_px.push_back(Acts::clampValue(p * particle.direction().x())); + m_py.push_back(Acts::clampValue(p * particle.direction().y())); + m_pz.push_back(Acts::clampValue(p * particle.direction().z())); // particle constants m_m.push_back( Acts::clampValue(particle.mass() / Acts::UnitConstants::GeV)); @@ -120,11 +120,11 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT( Acts::clampValue(particle.charge() / Acts::UnitConstants::e)); // derived kinematic quantities m_eta.push_back(Acts::clampValue( - Acts::VectorHelpers::eta(particle.unitDirection()))); + Acts::VectorHelpers::eta(particle.direction()))); m_phi.push_back(Acts::clampValue( - Acts::VectorHelpers::phi(particle.unitDirection()))); + Acts::VectorHelpers::phi(particle.direction()))); m_pt.push_back(Acts::clampValue( - p * Acts::VectorHelpers::perp(particle.unitDirection()))); + p * Acts::VectorHelpers::perp(particle.direction()))); // decoded barcode components m_vertexPrimary.push_back(particle.particleId().vertexPrimary()); m_vertexSecondary.push_back(particle.particleId().vertexSecondary()); diff --git a/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp b/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp index b0754a63a80..823cc4d0184 100644 --- a/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp +++ b/Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp @@ -273,24 +273,24 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT( t_vx = particle.position().x(); t_vy = particle.position().y(); t_vz = particle.position().z(); - t_px = t_p * particle.unitDirection().x(); - t_py = t_p * particle.unitDirection().y(); - t_pz = t_p * particle.unitDirection().z(); - t_theta = theta(particle.unitDirection()); - t_phi = phi(particle.unitDirection()); - t_eta = eta(particle.unitDirection()); - t_pT = t_p * perp(particle.unitDirection()); - t_qop = particle.qop(); + t_px = t_p * particle.direction().x(); + t_py = t_p * particle.direction().y(); + t_pz = t_p * particle.direction().z(); + t_theta = theta(particle.direction()); + t_phi = phi(particle.direction()); + t_eta = eta(particle.direction()); + t_pT = t_p * perp(particle.direction()); + t_qop = particle.qOverP(); if (pSurface != nullptr) { auto intersection = pSurface->intersect(ctx.geoContext, particle.position(), - particle.unitDirection(), false); + particle.direction(), false); auto position = intersection.intersection.position; // get the truth perigee parameter auto lpResult = pSurface->globalToLocal(ctx.geoContext, position, - particle.unitDirection()); + particle.direction()); if (lpResult.ok()) { t_d0 = lpResult.value()[Acts::BoundIndices::eBoundLoc0]; t_z0 = lpResult.value()[Acts::BoundIndices::eBoundLoc1]; diff --git a/Examples/Python/tests/test_examples.py b/Examples/Python/tests/test_examples.py index 76af5013c6f..d06e8bcf6cf 100644 --- a/Examples/Python/tests/test_examples.py +++ b/Examples/Python/tests/test_examples.py @@ -614,7 +614,7 @@ def test_truth_tracking_gsf(tmp_path, assert_root_hash, detector_config): 1, ), ( - "Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp:178", + "Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp:177", acts.FpeType.FLTUND, 1, ), diff --git a/Fatras/include/ActsFatras/EventData/Particle.hpp b/Fatras/include/ActsFatras/EventData/Particle.hpp index 3ff9e05868f..24db2b1baef 100644 --- a/Fatras/include/ActsFatras/EventData/Particle.hpp +++ b/Fatras/include/ActsFatras/EventData/Particle.hpp @@ -113,16 +113,16 @@ class Particle { } /// Set the direction three-vector Particle &setDirection(const Vector3 &direction) { - m_unitDirection = direction; - m_unitDirection.normalize(); + m_direction = direction; + m_direction.normalize(); return *this; } /// Set the direction three-vector from scalar components. Particle &setDirection(Scalar dx, Scalar dy, Scalar dz) { - m_unitDirection[Acts::ePos0] = dx; - m_unitDirection[Acts::ePos1] = dy; - m_unitDirection[Acts::ePos2] = dz; - m_unitDirection.normalize(); + m_direction[Acts::ePos0] = dx; + m_direction[Acts::ePos1] = dy; + m_direction[Acts::ePos2] = dz; + m_direction.normalize(); return *this; } /// Set the absolute momentum. @@ -154,11 +154,15 @@ class Particle { constexpr Acts::PdgParticle pdg() const { return m_pdg; } /// Particle charge. constexpr Scalar charge() const { return m_charge; } + /// Particle absolute charge. + constexpr Scalar absoluteCharge() const { return std::abs(m_charge); } /// Particle mass. constexpr Scalar mass() const { return m_mass; } - /// Particl qop. - constexpr Scalar qop() const { - return (charge() == 0 ? 1 : charge()) / absoluteMomentum(); + + /// Particl qOverP. + constexpr Scalar qOverP() const { + return charge() == 0 ? 1 / absoluteMomentum() + : charge() / absoluteMomentum(); } /// Space-time position four-vector. @@ -171,20 +175,22 @@ class Particle { Vector4 fourMomentum() const { Vector4 mom4; // stored direction is always normalized - mom4[Acts::eMom0] = m_absMomentum * m_unitDirection[Acts::ePos0]; - mom4[Acts::eMom1] = m_absMomentum * m_unitDirection[Acts::ePos1]; - mom4[Acts::eMom2] = m_absMomentum * m_unitDirection[Acts::ePos2]; + mom4[Acts::eMom0] = m_absMomentum * m_direction[Acts::ePos0]; + mom4[Acts::eMom1] = m_absMomentum * m_direction[Acts::ePos1]; + mom4[Acts::eMom2] = m_absMomentum * m_direction[Acts::ePos2]; mom4[Acts::eEnergy] = energy(); return mom4; } /// Unit three-direction, i.e. the normalized momentum three-vector. - const Vector3 &unitDirection() const { return m_unitDirection; } + const Vector3 &direction() const { return m_direction; } /// Absolute momentum in the x-y plane. Scalar transverseMomentum() const { - return m_absMomentum * m_unitDirection.segment<2>(Acts::eMom0).norm(); + return m_absMomentum * m_direction.segment<2>(Acts::eMom0).norm(); } /// Absolute momentum. constexpr Scalar absoluteMomentum() const { return m_absMomentum; } + /// Absolute momentum. + Vector3 momentum() const { return absoluteMomentum() * direction(); } /// Total energy, i.e. norm of the four-momentum. Scalar energy() const { return std::hypot(m_mass, m_absMomentum); } @@ -234,7 +240,7 @@ class Particle { Scalar m_charge = Scalar(0); Scalar m_mass = Scalar(0); // kinematics, i.e. things that change over the particle lifetime. - Vector3 m_unitDirection = Vector3::UnitZ(); + Vector3 m_direction = Vector3::UnitZ(); Scalar m_absMomentum = Scalar(0); Vector4 m_position4 = Vector4::Zero(); // proper time in the particle rest frame diff --git a/Fatras/include/ActsFatras/Kernel/Simulation.hpp b/Fatras/include/ActsFatras/Kernel/Simulation.hpp index 00602b0c915..9c02eb0236c 100644 --- a/Fatras/include/ActsFatras/Kernel/Simulation.hpp +++ b/Fatras/include/ActsFatras/Kernel/Simulation.hpp @@ -93,7 +93,7 @@ struct SingleParticleSimulation { actor.initialParticle = particle; // use AnyCharge to be able to handle neutral and charged parameters Acts::SingleCurvilinearTrackParameters start( - particle.fourPosition(), particle.unitDirection(), + particle.fourPosition(), particle.direction(), particle.absoluteMomentum(), particle.charge()); auto result = propagator.propagate(start, options); if (not result.ok()) { diff --git a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp index d63199ddf21..d77bd71ccf4 100644 --- a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp +++ b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp @@ -159,7 +159,7 @@ struct SimulationActor { // it should in principle never happen, so probably it would be best // to change to a model using transform() directly auto lpResult = surface.globalToLocal(state.geoContext, before.position(), - before.unitDirection()); + before.direction()); if (lpResult.ok()) { Acts::Vector2 local = lpResult.value(); Acts::MaterialSlab slab = @@ -170,8 +170,7 @@ struct SimulationActor { auto normal = surface.normal(state.geoContext, local); // dot-product(unit normal, direction) = cos(incidence angle) // particle direction is normalized, not sure about surface normal - auto cosIncidenceInv = - normal.norm() / normal.dot(before.unitDirection()); + auto cosIncidenceInv = normal.norm() / normal.dot(before.direction()); // apply abs in case `normal` and `before` produce an angle > 90° slab.scaleThickness(std::abs(cosIncidenceInv)); // run the interaction simulation @@ -196,8 +195,8 @@ struct SimulationActor { } // continue the propagation with the modified parameters - stepper.update(state.stepping, after.position(), after.unitDirection(), - after.qop(), after.time()); + stepper.update(state.stepping, after.position(), after.direction(), + after.qOverP(), after.time()); } /// Construct the current particle state from the stepper state. diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp index 03982558f79..239332e1b0d 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp @@ -72,9 +72,8 @@ struct BetheHeitler { bremPhoton(particle, sampledEnergyLoss, uDist(generator), uDist(generator), uDist(generator), uDist(generator)); // Recoil input momentum - particle.setDirection(particle.unitDirection() * - particle.absoluteMomentum() - - photon.energy() * photon.unitDirection()); + particle.setDirection(particle.direction() * particle.absoluteMomentum() - + photon.energy() * photon.direction()); // apply the energy loss particle.correctEnergy(-sampledEnergyLoss); diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp index 1b301292205..346f4f07616 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp @@ -244,7 +244,7 @@ Particle::Vector3 PhotonConversion::generateChildDirection( const auto psi = std::uniform_real_distribution(-M_PI, M_PI)(generator); - Acts::Vector3 direction = particle.unitDirection(); + Acts::Vector3 direction = particle.direction(); // construct the combined rotation to the scattered direction Acts::RotationMatrix3 rotation( // rotation of the scattering deflector axis relative to the reference diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp index d17e2cc6956..22c6469f354 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp @@ -58,7 +58,7 @@ struct ScatteringImpl { // draw the scattering angle const auto theta = angle(generator, slab, particle); - Acts::Vector3 direction = particle.unitDirection(); + Acts::Vector3 direction = particle.direction(); // construct the combined rotation to the scattered direction Acts::RotationMatrix3 rotation( // rotation of the scattering deflector axis relative to the reference diff --git a/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp b/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp index e2fa9aaa3a5..ebee2350bca 100644 --- a/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp +++ b/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp @@ -502,7 +502,7 @@ std::vector NuclearInteraction::convertParametersToParticles( const Acts::ActsDynamicVector& invariantMasses, Particle& initialParticle, float parametrizedMomentum, bool soft) const { std::uniform_real_distribution uniformDistribution{0., 1.}; - const auto& initialDirection = initialParticle.unitDirection(); + const auto& initialDirection = initialParticle.direction(); const double phi = Acts::VectorHelpers::phi(initialDirection); const double theta = Acts::VectorHelpers::theta(initialDirection); const unsigned int size = momenta.size(); diff --git a/Fatras/include/ActsFatras/Selectors/KinematicCasts.hpp b/Fatras/include/ActsFatras/Selectors/KinematicCasts.hpp index 712f503ed65..045e7691259 100644 --- a/Fatras/include/ActsFatras/Selectors/KinematicCasts.hpp +++ b/Fatras/include/ActsFatras/Selectors/KinematicCasts.hpp @@ -8,6 +8,7 @@ #pragma once +#include "Acts/Utilities/VectorHelpers.hpp" #include "ActsFatras/EventData/Particle.hpp" #include @@ -40,7 +41,7 @@ struct AbsVz { struct Eta { double operator()(const Particle& particle) const { // particle direction is always normalized, i.e. dz = pz / p - return std::atanh(particle.unitDirection().z()); + return std::atanh(particle.direction().z()); } }; @@ -48,7 +49,7 @@ struct Eta { struct AbsEta { double operator()(const Particle& particle) const { // particle direction is always normalized, i.e. dz = pz / p - return std::atanh(std::abs(particle.unitDirection().z())); + return std::atanh(std::abs(particle.direction().z())); } }; @@ -57,8 +58,7 @@ struct Pt { double operator()(const Particle& particle) const { // particle direction is always normalized, i.e. dt²+dz²=1 w/ dt²=dx²+dy² return particle.absoluteMomentum() * - std::hypot(particle.unitDirection().x(), - particle.unitDirection().y()); + Acts::VectorHelpers::perp(particle.direction()); } }; diff --git a/Fatras/src/Physics/BetheHeitler.cpp b/Fatras/src/Physics/BetheHeitler.cpp index 952d1bacf3c..82b5d142fc5 100644 --- a/Fatras/src/Physics/BetheHeitler.cpp +++ b/Fatras/src/Physics/BetheHeitler.cpp @@ -46,7 +46,7 @@ ActsFatras::Particle ActsFatras::BetheHeitler::bremPhoton( theta *= (rndTheta1 < 0.25) ? u : u / 3.; // 9./(9.+27) = 0.25 } - Vector3 particleDirection = particle.unitDirection(); + Vector3 particleDirection = particle.direction(); Vector3 photonDirection = particleDirection; // construct the combined rotation to the scattered direction diff --git a/Tests/UnitTests/Fatras/EventData/ParticleTests.cpp b/Tests/UnitTests/Fatras/EventData/ParticleTests.cpp index b146b57d8d5..bcf1fbda62e 100644 --- a/Tests/UnitTests/Fatras/EventData/ParticleTests.cpp +++ b/Tests/UnitTests/Fatras/EventData/ParticleTests.cpp @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(Construct) { BOOST_CHECK_EQUAL(particle.fourPosition().z(), particle.position().z()); BOOST_CHECK_EQUAL(particle.fourPosition().w(), particle.time()); // particle direction is undefined, but must be normalized - CHECK_CLOSE_REL(particle.unitDirection().norm(), 1, eps); + CHECK_CLOSE_REL(particle.direction().norm(), 1, eps); BOOST_CHECK_EQUAL(particle.transverseMomentum(), Particle::Scalar(0)); BOOST_CHECK_EQUAL(particle.absoluteMomentum(), Particle::Scalar(0)); // particle is created at rest and thus not alive @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(CorrectEnergy) { BOOST_CHECK_EQUAL(particle.absoluteMomentum(), 2_GeV); BOOST_CHECK_EQUAL(particle.energy(), std::hypot(1_GeV, 2_GeV)); // particle direction must be normalized - CHECK_CLOSE_REL(particle.unitDirection().norm(), 1, eps); + CHECK_CLOSE_REL(particle.direction().norm(), 1, eps); // loose some energy particle.correctEnergy(-100_MeV); @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(CorrectEnergy) { BOOST_CHECK_LT(particle.absoluteMomentum(), 2_GeV); BOOST_CHECK_EQUAL(particle.energy(), Particle::Scalar(std::hypot(1_GeV, 2_GeV) - 100_MeV)); - CHECK_CLOSE_REL(particle.unitDirection().norm(), 1, eps); + CHECK_CLOSE_REL(particle.direction().norm(), 1, eps); // particle is still alive BOOST_CHECK(particle.isAlive()); @@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(CorrectEnergy) { BOOST_CHECK_LT(particle.absoluteMomentum(), 2_GeV); BOOST_CHECK_EQUAL(particle.energy(), Particle::Scalar(std::hypot(1_GeV, 2_GeV) - 300_MeV)); - CHECK_CLOSE_REL(particle.unitDirection().norm(), 1, eps); + CHECK_CLOSE_REL(particle.direction().norm(), 1, eps); // particle is still alive BOOST_CHECK(particle.isAlive()); @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(CorrectEnergy) { BOOST_CHECK_EQUAL(particle.transverseMomentum(), Particle::Scalar(0)); BOOST_CHECK_EQUAL(particle.absoluteMomentum(), Particle::Scalar(0)); BOOST_CHECK_EQUAL(particle.energy(), particle.mass()); - CHECK_CLOSE_REL(particle.unitDirection().norm(), 1, eps); + CHECK_CLOSE_REL(particle.direction().norm(), 1, eps); // particle is not alive anymore BOOST_CHECK(not particle.isAlive()); @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(CorrectEnergy) { BOOST_CHECK_EQUAL(particle.transverseMomentum(), Particle::Scalar(0)); BOOST_CHECK_EQUAL(particle.absoluteMomentum(), Particle::Scalar(0)); BOOST_CHECK_EQUAL(particle.energy(), particle.mass()); - CHECK_CLOSE_REL(particle.unitDirection().norm(), 1, eps); + CHECK_CLOSE_REL(particle.direction().norm(), 1, eps); // particle is still not alive BOOST_CHECK(not particle.isAlive()); } diff --git a/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp b/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp index ef4d9bb7251..e034cac5c92 100644 --- a/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp +++ b/Tests/UnitTests/Fatras/Kernel/SimulationActorTests.cpp @@ -179,7 +179,7 @@ struct Fixture { state.navigation.currentSurface = surface.get(); state.stepping.pos = particle.position(); state.stepping.time = particle.time(); - state.stepping.dir = particle.unitDirection(); + state.stepping.dir = particle.direction(); state.stepping.p = particle.absoluteMomentum(); } }; @@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(HitsOnEmptySurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); BOOST_CHECK_EQUAL(f.state.stepping.p, f.result.particle.absoluteMomentum()); // call.actor again: one more hit, still no secondary @@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(HitsOnEmptySurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); BOOST_CHECK_EQUAL(f.state.stepping.p, f.result.particle.absoluteMomentum()); // particle identity should be the same as the initial input @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(HitsOnMaterialSurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); CHECK_CLOSE_REL(f.state.stepping.p, f.result.particle.absoluteMomentum(), tol); @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(HitsOnMaterialSurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); BOOST_CHECK_EQUAL(f.state.stepping.p, f.result.particle.absoluteMomentum()); // particle identity should be the same as the initial input @@ -371,7 +371,7 @@ BOOST_AUTO_TEST_CASE(NoHitsEmptySurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); BOOST_CHECK_EQUAL(f.state.stepping.p, f.result.particle.absoluteMomentum()); // call.actor again: no hit, still no secondary @@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE(NoHitsEmptySurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); BOOST_CHECK_EQUAL(f.state.stepping.p, f.result.particle.absoluteMomentum()); // particle identity should be the same as the initial input @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(NoHitsMaterialSurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); CHECK_CLOSE_REL(f.state.stepping.p, f.result.particle.absoluteMomentum(), tol); @@ -452,7 +452,7 @@ BOOST_AUTO_TEST_CASE(NoHitsMaterialSurface) { // check consistency between particle and stepper state BOOST_CHECK_EQUAL(f.state.stepping.pos, f.result.particle.position()); BOOST_CHECK_EQUAL(f.state.stepping.time, f.result.particle.time()); - BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.unitDirection()); + BOOST_CHECK_EQUAL(f.state.stepping.dir, f.result.particle.direction()); BOOST_CHECK_EQUAL(f.state.stepping.p, f.result.particle.absoluteMomentum()); // particle identity should be the same as the initial input diff --git a/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp b/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp index 287a3c08edc..20999911f1b 100644 --- a/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp +++ b/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp @@ -35,7 +35,7 @@ void test(const Scattering& scattering, uint32_t seed, CHECK_CLOSE_REL(after.absoluteMomentum(), before.absoluteMomentum(), eps); CHECK_CLOSE_REL(after.energy(), before.energy(), eps); // scattering has changed the direction - BOOST_CHECK_LT(before.unitDirection().dot(after.unitDirection()), 1); + BOOST_CHECK_LT(before.direction().dot(after.direction()), 1); // scattering creates no new particles BOOST_CHECK(outgoing.empty()); }