Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: fatras: double for globalAngle #3922

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ struct NuclearInteraction {
///
/// @return Azimuthal and polar angle of the second particle in the global
/// coordinate system
std::pair<double, double> globalAngle(double phi1, double theta1, float phi2,
float theta2) const;
std::pair<double, double> globalAngle(double phi1, double theta1, double phi2,
double theta2) const;

/// Converter from sampled numbers to a vector of particles
///
Expand Down Expand Up @@ -483,7 +483,7 @@ NuclearInteraction::sampleKinematics(
if (trials == nMatchingTrialsTotal) {
return std::nullopt;
}
// Re-sampole invariant masses if no fitting momenta were found
// Re-sample invariant masses if no fitting momenta were found
if (trials++ % nMatchingTrials == 0) {
invariantMasses = sampleInvariantMasses(generator, parameters);
} else {
Expand Down Expand Up @@ -513,13 +513,13 @@ std::vector<Particle> NuclearInteraction::convertParametersToParticles(
const float momentum = momenta[i];
const float invariantMass = invariantMasses[i];
const float p1p2 = 2. * momentum * parametrizedMomentum;
const float costheta = 1. - invariantMass * invariantMass / p1p2;
const double costheta = 1. - invariantMass * invariantMass / p1p2;

const auto phiTheta = globalAngle(
const auto [phiGlobal, thetaGlobal] = globalAngle(
phi, theta, uniformDistribution(generator) * 2. * std::numbers::pi,
std::acos(costheta));
const auto direction =
Acts::makeDirectionFromPhiTheta(phiTheta.first, phiTheta.second);
Acts::makeDirectionFromPhiTheta(phiGlobal, thetaGlobal);

Particle p = Particle(initialParticle.particleId().makeDescendant(i),
static_cast<Acts::PdgParticle>(pdgId[i]));
Expand Down
10 changes: 5 additions & 5 deletions Fatras/src/Physics/NuclearInteraction/NuclearInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ unsigned int NuclearInteraction::finalStateMultiplicity(

std::pair<double, double> NuclearInteraction::globalAngle(double phi1,
double theta1,
float phi2,
float theta2) const {
double phi2,
double theta2) const {
// Rotation around the global y-axis
Acts::SquareMatrix3 rotY = Acts::SquareMatrix3::Zero();
rotY(0, 0) = std::cos(theta1);
Expand All @@ -138,10 +138,10 @@ std::pair<double, double> NuclearInteraction::globalAngle(double phi1,
const Acts::Vector3 vectorSum = rotZ * rotY * vector2;

// Calculate the global angles
const float theta = std::acos(vectorSum.z() / vectorSum.norm());
const float phi = std::atan2(vectorSum.y(), vectorSum.x());
const double theta = std::acos(vectorSum.z() / vectorSum.norm());
const double phi = std::atan2(vectorSum.y(), vectorSum.x());

return std::make_pair(phi, theta);
return {phi, theta};
}

bool NuclearInteraction::match(const Acts::ActsDynamicVector& momenta,
Expand Down
Loading