Skip to content

Commit

Permalink
fix: move from edm4eic to edm4hep::utils vector_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Nov 10, 2023
1 parent 360eb8b commit bc21315
Show file tree
Hide file tree
Showing 66 changed files with 310 additions and 310 deletions.
2 changes: 1 addition & 1 deletion JugFast/src/components/ClusterMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Event Model related classes
#include "edm4eic/ClusterCollection.h"
#include "edm4eic/MCRecoClusterParticleAssociationCollection.h"
#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"

using namespace Gaudi::Units;

Expand Down
8 changes: 4 additions & 4 deletions JugFast/src/components/InclusiveKinematicsTruth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using ROOT::Math::PxPyPzEVector;
#include "edm4hep/MCParticleCollection.h"
#include "edm4eic/InclusiveKinematicsCollection.h"

#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"

namespace Jug::Fast {

Expand Down Expand Up @@ -89,7 +89,7 @@ class InclusiveKinematicsTruth : public GaudiAlgorithm {
return StatusCode::SUCCESS;
}
const auto ei_p = ei_coll[0].getMomentum();
const auto ei_p_mag = edm4eic::magnitude(ei_p);
const auto ei_p_mag = edm4hep::utils::magnitude(ei_p);
const auto ei_mass = m_electron;
const PxPyPzEVector ei(ei_p.x, ei_p.y, ei_p.z, std::hypot(ei_p_mag, ei_mass));

Expand All @@ -102,7 +102,7 @@ class InclusiveKinematicsTruth : public GaudiAlgorithm {
return StatusCode::SUCCESS;
}
const auto pi_p = pi_coll[0].getMomentum();
const auto pi_p_mag = edm4eic::magnitude(pi_p);
const auto pi_p_mag = edm4hep::utils::magnitude(pi_p);
const auto pi_mass = pi_coll[0].getPDG() == 2212 ? m_proton : m_neutron;
const PxPyPzEVector pi(pi_p.x, pi_p.y, pi_p.z, std::hypot(pi_p_mag, pi_mass));

Expand All @@ -119,7 +119,7 @@ class InclusiveKinematicsTruth : public GaudiAlgorithm {
return StatusCode::SUCCESS;
}
const auto ef_p = ef_coll[0].getMomentum();
const auto ef_p_mag = edm4eic::magnitude(ef_p);
const auto ef_p_mag = edm4hep::utils::magnitude(ef_p);
const auto ef_mass = m_electron;
const PxPyPzEVector ef(ef_p.x, ef_p.y, ef_p.z, std::hypot(ef_p_mag, ef_mass));

Expand Down
4 changes: 2 additions & 2 deletions JugFast/src/components/MatchClusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "edm4eic/MCRecoParticleAssociationCollection.h"
#include "edm4eic/ReconstructedParticleCollection.h"
#include "edm4eic/TrackParametersCollection.h"
#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"

namespace Jug::Fast {

Expand Down Expand Up @@ -271,7 +271,7 @@ class MatchClusters : public GaudiAlgorithm {
const float energy = clus.getEnergy();
const float p = energy < mass ? 0 : std::sqrt(energy * energy - mass * mass);
const auto position = clus.getPosition();
const auto momentum = p * (position / edm4eic::magnitude(position));
const auto momentum = p * (position / edm4hep::utils::magnitude(position));
// setup our particle
edm4eic::MutableReconstructedParticle part;
part.setMomentum(momentum);
Expand Down
52 changes: 26 additions & 26 deletions JugFast/src/components/SmearedFarForwardParticles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4eic/MCRecoParticleAssociationCollection.h"
#include "edm4eic/ReconstructedParticleCollection.h"
#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"

namespace {
enum DetectorTags { kTagB0 = 1, kTagRP = 2, kTagOMD = 3, kTagZDC = 4 };
Expand Down Expand Up @@ -160,8 +160,8 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
continue;
}
// only 0-->4.5 mrad
const double mom_ion_theta = edm4eic::anglePolar(mom_ion);
const double mom_ion_phi = edm4eic::angleAzimuthal(mom_ion);
const double mom_ion_theta = edm4hep::utils::anglePolar(mom_ion);
const double mom_ion_phi = edm4hep::utils::angleAzimuthal(mom_ion);
if (mom_ion_theta > 4.5 / 1000.) {
continue;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
const double phis = phi + dphi;
const double moms = sqrt(Es * Es - part.getMass() * part.getMass());
// now cast back into float
const auto mom3s_ion = edm4eic::sphericalToVector(moms, ths, phis);
const auto mom3s_ion = edm4hep::utils::sphericalToVector(moms, ths, phis);
const auto mom3s = rotateIonToLabDirection(mom3s_ion);
RecPart rec_part;
rec_part.setType(kTagZDC);
Expand Down Expand Up @@ -220,8 +220,8 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
debug()
<< fmt::format(
"Found ZDC particle: {}, Etrue: {}, Emeas: {}, ptrue: {}, pmeas: {}, theta_true: {}, theta_meas: {}",
part.getPDG(), E, rec_part.getEnergy(), part_p_mag, edm4eic::magnitude(rec_part.getMomentum()), th,
edm4eic::anglePolar(rec_part.getMomentum()))
part.getPDG(), E, rec_part.getEnergy(), part_p_mag, edm4hep::utils::magnitude(rec_part.getMomentum()), th,
edm4hep::utils::anglePolar(rec_part.getMomentum()))
<< endmsg;
}
}
Expand All @@ -245,7 +245,7 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
}
// only 6-->20 mrad
const auto mom_ion = removeCrossingAngle(part.getMomentum()); // rotateLabToIonDirection(part.getMomentum());
const auto mom_ion_theta = edm4eic::anglePolar(mom_ion);
const auto mom_ion_theta = edm4hep::utils::anglePolar(mom_ion);
if (mom_ion_theta < m_thetaMinB0 || mom_ion_theta > m_thetaMaxB0) {
continue;
}
Expand All @@ -259,14 +259,14 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
rc.emplace_back(rc_part, assoc);
if (msgLevel(MSG::DEBUG)) {
const auto& part_p = part.getMomentum();
const auto part_p_pt = edm4eic::magnitudeTransverse(part_p);
const auto part_p_mag = edm4eic::magnitude(part_p);
const auto part_p_theta = edm4eic::anglePolar(part_p);
const auto part_p_pt = edm4hep::utils::magnitudeTransverse(part_p);
const auto part_p_mag = edm4hep::utils::magnitude(part_p);
const auto part_p_theta = edm4hep::utils::anglePolar(part_p);
debug() << fmt::format("Found B0 particle: {}, ptrue: {}, pmeas: {}, pttrue: {}, ptmeas: {}, theta_true: {}, "
"theta_meas: {}",
part.getPDG(), part_p_mag, edm4eic::magnitude(rc_part.momentum()), part_p_pt,
edm4eic::magnitudeTransverse(rc_part.momentum()), part_p_theta,
edm4eic::anglePolar(rc_part.momentum()))
part.getPDG(), part_p_mag, edm4hep::utils::magnitude(rc_part.momentum()), part_p_pt,
edm4hep::utils::magnitudeTransverse(rc_part.momentum()), part_p_theta,
edm4hep::utils::anglePolar(rc_part.momentum()))
<< endmsg;
}
}
Expand All @@ -288,7 +288,7 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
continue;
}
const auto mom_ion = removeCrossingAngle(part.getMomentum()); // rotateLabToIonDirection(part.getMomentum());
const auto mom_ion_theta = edm4eic::anglePolar(mom_ion);
const auto mom_ion_theta = edm4hep::utils::anglePolar(mom_ion);
if (mom_ion_theta < m_thetaMinRP || mom_ion_theta > m_thetaMaxRP ||
mom_ion.z < m_pMinRigidityRP * ionBeamEnergy) {
continue;
Expand All @@ -298,14 +298,14 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
rc.emplace_back(rc_part, assoc);
if (msgLevel(MSG::DEBUG)) {
const auto& part_p = part.getMomentum();
const auto part_p_pt = edm4eic::magnitudeTransverse(part_p);
const auto part_p_mag = edm4eic::magnitude(part_p);
const auto part_p_theta = edm4eic::anglePolar(part_p);
const auto part_p_pt = edm4hep::utils::magnitudeTransverse(part_p);
const auto part_p_mag = edm4hep::utils::magnitude(part_p);
const auto part_p_theta = edm4hep::utils::anglePolar(part_p);
debug() << fmt::format("Found RP particle: {}, ptrue: {}, pmeas: {}, pttrue: {}, ptmeas: {}, theta_true: {}, "
"theta_meas: {}",
part.getPDG(), part_p_mag, edm4eic::magnitude(rc_part.momentum()), part_p_pt,
edm4eic::magnitudeTransverse(rc_part.momentum()), part_p_theta,
edm4eic::anglePolar(rc_part.momentum()))
part.getPDG(), part_p_mag, edm4hep::utils::magnitude(rc_part.momentum()), part_p_pt,
edm4hep::utils::magnitudeTransverse(rc_part.momentum()), part_p_theta,
edm4hep::utils::anglePolar(rc_part.momentum()))
<< endmsg;
}
}
Expand Down Expand Up @@ -334,14 +334,14 @@ class SmearedFarForwardParticles : public GaudiAlgorithm {
rc.emplace_back(rc_part, assoc);
if (msgLevel(MSG::DEBUG)) {
const auto& part_p = part.getMomentum();
const auto part_p_pt = edm4eic::magnitudeTransverse(part_p);
const auto part_p_mag = edm4eic::magnitude(part_p);
const auto part_p_theta = edm4eic::anglePolar(part_p);
const auto part_p_pt = edm4hep::utils::magnitudeTransverse(part_p);
const auto part_p_mag = edm4hep::utils::magnitude(part_p);
const auto part_p_theta = edm4hep::utils::anglePolar(part_p);
debug() << fmt::format("Found OMD particle: {}, ptrue: {}, pmeas: {}, pttrue: {}, ptmeas: {}, theta_true: {}, "
"theta_meas: {}",
part.getPDG(), part_p_mag, edm4eic::magnitude(rc_part.momentum()), part_p_pt,
edm4eic::magnitudeTransverse(rc_part.momentum()), part_p_theta,
edm4eic::anglePolar(rc_part.momentum()))
part.getPDG(), part_p_mag, edm4hep::utils::magnitude(rc_part.momentum()), part_p_pt,
edm4hep::utils::magnitudeTransverse(rc_part.momentum()), part_p_theta,
edm4hep::utils::anglePolar(rc_part.momentum()))
<< endmsg;
}
}
Expand Down
4 changes: 2 additions & 2 deletions JugFast/src/components/TruthEnergyPositionClusterMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4eic/ClusterCollection.h"
#include "edm4eic/MCRecoClusterParticleAssociationCollection.h"
#include <edm4eic/vector_utils.h>
#include <edm4hep/utils/vector_utils.h>

using namespace Gaudi::Units;

Expand Down Expand Up @@ -167,7 +167,7 @@ class TruthEnergyPositionClusterMerger : public GaudiAlgorithm {
new_clus.setTime(eclus.getTime());
new_clus.setNhits(eclus.getNhits());
// use nominal radius of 110cm, and use start vertex theta and phi
new_clus.setPosition(edm4eic::sphericalToVector(110.*cm, theta, phi));
new_clus.setPosition(edm4hep::utils::sphericalToVector(110.*cm, theta, phi));
new_clus.addToClusters(eclus);
if (msgLevel(MSG::DEBUG)) {
debug() << " --> Processing energy cluster " << eclus.id() << ", mcID: " << mcID << ", energy: " << eclus.getEnergy()
Expand Down
10 changes: 5 additions & 5 deletions JugReco/src/components/CalorimeterHitsEtaPhiProjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Event Model related classes
#include "edm4eic/CalorimeterHitCollection.h"
#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"

using namespace Gaudi::Units;
using Point3D = ROOT::Math::XYZPoint;
Expand Down Expand Up @@ -97,8 +97,8 @@ class CalorimeterHitsEtaPhiProjector : public GaudiAlgorithm {

for (const auto h : *m_inputHitCollection.get()) {
auto bins =
std::make_pair(static_cast<int64_t>(pos2bin(edm4eic::eta(h.getPosition()), gridSizes[0], 0.)),
static_cast<int64_t>(pos2bin(edm4eic::angleAzimuthal(h.getPosition()), gridSizes[1], 0.)));
std::make_pair(static_cast<int64_t>(pos2bin(edm4hep::utils::eta(h.getPosition()), gridSizes[0], 0.)),
static_cast<int64_t>(pos2bin(edm4hep::utils::angleAzimuthal(h.getPosition()), gridSizes[1], 0.)));
merged_hits[bins].push_back(h);
}

Expand All @@ -108,10 +108,10 @@ class CalorimeterHitsEtaPhiProjector : public GaudiAlgorithm {
hit.setCellID(ref.getCellID());
// TODO, we can do timing cut to reject noises
hit.setTime(ref.getTime());
double r = edm4eic::magnitude(ref.getPosition());
double r = edm4hep::utils::magnitude(ref.getPosition());
double eta = bin2pos(bins.first, gridSizes[0], 0.);
double phi = bin2pos(bins.second, gridSizes[1], 1.);
hit.setPosition(edm4eic::sphericalToVector(r, edm4eic::etaToAngle(eta), phi));
hit.setPosition(edm4hep::utils::sphericalToVector(r, edm4hep::utils::etaToAngle(eta), phi));
hit.setDimension({static_cast<float>(gridSizes[0]), static_cast<float>(gridSizes[1]), 0.});
// merge energy
hit.setEnergy(0.);
Expand Down
14 changes: 7 additions & 7 deletions JugReco/src/components/CalorimeterIslandCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "edm4eic/CalorimeterHitCollection.h"
#include "edm4eic/ClusterCollection.h"
#include "edm4eic/ProtoClusterCollection.h"
#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"
#include "edm4hep/Vector3f.h"
#include "edm4hep/Vector2f.h"

Expand Down Expand Up @@ -94,10 +94,10 @@ static Vector2f globalDistRPhi(const CaloHit& h1, const CaloHit& h2) {
using vector_type = decltype(Vector2f::a);
return {
static_cast<vector_type>(
edm4eic::magnitude(h1.getPosition()) - edm4eic::magnitude(h2.getPosition())
edm4hep::utils::magnitude(h1.getPosition()) - edm4hep::utils::magnitude(h2.getPosition())
),
static_cast<vector_type>(
edm4eic::angleAzimuthal(h1.getPosition()) - edm4eic::angleAzimuthal(h2.getPosition())
edm4hep::utils::angleAzimuthal(h1.getPosition()) - edm4hep::utils::angleAzimuthal(h2.getPosition())
)
};
}
Expand All @@ -106,10 +106,10 @@ static Vector2f globalDistEtaPhi(const CaloHit& h1,
using vector_type = decltype(Vector2f::a);
return {
static_cast<vector_type>(
edm4eic::eta(h1.getPosition()) - edm4eic::eta(h2.getPosition())
edm4hep::utils::eta(h1.getPosition()) - edm4hep::utils::eta(h2.getPosition())
),
static_cast<vector_type>(
edm4eic::angleAzimuthal(h1.getPosition()) - edm4eic::angleAzimuthal(h2.getPosition())
edm4hep::utils::angleAzimuthal(h1.getPosition()) - edm4hep::utils::angleAzimuthal(h2.getPosition())
)
};
}
Expand Down Expand Up @@ -272,7 +272,7 @@ class CalorimeterIslandCluster : public GaudiAlgorithm {
// different sector, local coordinates do not work, using global coordinates
} else {
// sector may have rotation (barrel), so z is included
return (edm4eic::magnitude(h1.getPosition() - h2.getPosition()) <= sectorDist);
return (edm4hep::utils::magnitude(h1.getPosition() - h2.getPosition()) <= sectorDist);
}
};

Expand Down Expand Up @@ -447,7 +447,7 @@ class CalorimeterIslandCluster : public GaudiAlgorithm {
for (const auto& chit : maxima) {
double dist_ref = chit.getDimension().x;
double energy = chit.getEnergy();
double dist = edm4eic::magnitude(hitsDist(chit, hit));
double dist = edm4hep::utils::magnitude(hitsDist(chit, hit));
weights[j] = std::exp(-dist / dist_ref) * energy;
j += 1;
}
Expand Down
10 changes: 5 additions & 5 deletions JugReco/src/components/EnergyPositionClusterMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// Event Model related classes
#include "edm4eic/ClusterCollection.h"
#include "edm4eic/vector_utils.h"
#include "edm4hep/utils/vector_utils.h"

using namespace Gaudi::Units;

Expand Down Expand Up @@ -83,7 +83,7 @@ class EnergyPositionClusterMerger : public GaudiAlgorithm {
const auto& ec = e_clus[ie];
// 1. stop if not within tolerance
// (make sure to handle rollover of phi properly)
double dphi = edm4eic::angleAzimuthal(pc.getPosition()) - edm4eic::angleAzimuthal(ec.getPosition());
double dphi = edm4hep::utils::angleAzimuthal(pc.getPosition()) - edm4hep::utils::angleAzimuthal(ec.getPosition());
if (std::abs(dphi) > M_PI) {
dphi = std::abs(dphi) - M_PI;
}
Expand Down Expand Up @@ -120,13 +120,13 @@ class EnergyPositionClusterMerger : public GaudiAlgorithm {
if (msgLevel(MSG::DEBUG)) {
debug() << fmt::format("Matched position cluster {} with energy cluster {}\n", pc.id(), ec.id()) << endmsg;
debug() << fmt::format(" - Position cluster: (E: {}, phi: {}, z: {})", pc.getEnergy(),
edm4eic::angleAzimuthal(pc.getPosition()), pc.getPosition().z)
edm4hep::utils::angleAzimuthal(pc.getPosition()), pc.getPosition().z)
<< endmsg;
debug() << fmt::format(" - Energy cluster: (E: {}, phi: {}, z: {})", ec.getEnergy(),
edm4eic::angleAzimuthal(ec.getPosition()), ec.getPosition().z)
edm4hep::utils::angleAzimuthal(ec.getPosition()), ec.getPosition().z)
<< endmsg;
debug() << fmt::format(" ---> Merged cluster: (E: {}, phi: {}, z: {})", new_clus.getEnergy(),
edm4eic::angleAzimuthal(new_clus.getPosition()), new_clus.getPosition().z)
edm4hep::utils::angleAzimuthal(new_clus.getPosition()), new_clus.getPosition().z)
<< endmsg;
}
}
Expand Down
4 changes: 2 additions & 2 deletions JugReco/src/components/FarForwardParticles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Event Model related classes
#include "edm4eic/ReconstructedParticleCollection.h"
#include "edm4eic/TrackerHitCollection.h"
#include <edm4eic/vector_utils.h>
#include <edm4hep/utils/vector_utils.h>

namespace Jug::Reco {

Expand Down Expand Up @@ -258,7 +258,7 @@ class FarForwardParticles : public GaudiAlgorithm {
edm4eic::MutableReconstructedParticle rpTrack;
rpTrack.setType(0);
rpTrack.setMomentum({prec});
rpTrack.setEnergy(std::hypot(edm4eic::magnitude(rpTrack.getMomentum()), .938272));
rpTrack.setEnergy(std::hypot(edm4hep::utils::magnitude(rpTrack.getMomentum()), .938272));
rpTrack.setReferencePoint({0, 0, 0});
rpTrack.setCharge(1);
rpTrack.setMass(.938272);
Expand Down
4 changes: 2 additions & 2 deletions JugReco/src/components/FarForwardParticlesOMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Event Model related classes
#include "edm4eic/ReconstructedParticleCollection.h"
#include "edm4eic/TrackerHitCollection.h"
#include <edm4eic/vector_utils.h>
#include <edm4hep/utils/vector_utils.h>

namespace Jug::Reco {

Expand Down Expand Up @@ -167,7 +167,7 @@ class FarForwardParticlesOMD : public GaudiAlgorithm {
edm4eic::MutableReconstructedParticle rpTrack;
rpTrack.setType(0);
rpTrack.setMomentum({prec});
rpTrack.setEnergy(std::hypot(edm4eic::magnitude(rpTrack.getMomentum()), .938272));
rpTrack.setEnergy(std::hypot(edm4hep::utils::magnitude(rpTrack.getMomentum()), .938272));
rpTrack.setReferencePoint({0, 0, 0});
rpTrack.setCharge(1);
rpTrack.setMass(.938272);
Expand Down
Loading

0 comments on commit bc21315

Please sign in to comment.