Skip to content

Commit

Permalink
refactor: Consistently use mm for time in examples IO (#2916)
Browse files Browse the repository at this point in the history
We are mixing time units in examples currently. I propose to solve this by consistently using `mm` which is the native internal core unit
  • Loading branch information
andiwand authored Feb 14, 2024
1 parent d5f264e commit 19464fa
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 32 deletions.
Binary file modified CI/physmon/reference/particles_fatras_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/particles_geant4_hist.root
Binary file not shown.
10 changes: 5 additions & 5 deletions Examples/Io/Csv/src/CsvMeasurementWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ ActsExamples::ProcessCode ActsExamples::CsvMeasurementWriter::writeT(
meas.local_key = 0;
// Create a full set of parameters
auto parameters = (m.expander() * m.parameters()).eval();
meas.local0 = parameters[Acts::eBoundLoc0];
meas.local1 = parameters[Acts::eBoundLoc1];
meas.phi = parameters[Acts::eBoundPhi];
meas.theta = parameters[Acts::eBoundTheta];
meas.time = parameters[Acts::eBoundTime] / Acts::UnitConstants::ns;
meas.local0 = parameters[Acts::eBoundLoc0] / Acts::UnitConstants::mm;
meas.local1 = parameters[Acts::eBoundLoc1] / Acts::UnitConstants::mm;
meas.phi = parameters[Acts::eBoundPhi] / Acts::UnitConstants::rad;
meas.theta = parameters[Acts::eBoundTheta] / Acts::UnitConstants::rad;
meas.time = parameters[Acts::eBoundTime] / Acts::UnitConstants::mm;

auto covariance =
(m.expander() * m.covariance() * m.expander().transpose()).eval();
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Csv/src/CsvParticleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ActsExamples::ProcessCode ActsExamples::CsvParticleReader::read(
particle.setProcess(static_cast<ActsFatras::ProcessType>(data.process));
particle.setPosition4(
data.vx * Acts::UnitConstants::mm, data.vy * Acts::UnitConstants::mm,
data.vz * Acts::UnitConstants::mm, data.vt * Acts::UnitConstants::ns);
data.vz * Acts::UnitConstants::mm, data.vt * Acts::UnitConstants::mm);
// Only used for direction; normalization/units do not matter
particle.setDirection(data.px, data.py, data.pz);
particle.setAbsoluteMomentum(std::hypot(data.px, data.py, data.pz) *
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Csv/src/CsvParticleWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ActsExamples::ProcessCode ActsExamples::CsvParticleWriter::writeT(
data.vx = particle.position().x() / Acts::UnitConstants::mm;
data.vy = particle.position().y() / Acts::UnitConstants::mm;
data.vz = particle.position().z() / Acts::UnitConstants::mm;
data.vt = particle.time() / Acts::UnitConstants::ns;
data.vt = particle.time() / Acts::UnitConstants::mm;
const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV;
data.px = p * particle.direction().x();
data.py = p * particle.direction().y();
Expand Down
4 changes: 2 additions & 2 deletions Examples/Io/Csv/src/CsvPlanarClusterReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ ActsExamples::ProcessCode ActsExamples::CsvPlanarClusterReader::read(
truth.tx * Acts::UnitConstants::mm,
truth.ty * Acts::UnitConstants::mm,
truth.tz * Acts::UnitConstants::mm,
truth.tt * Acts::UnitConstants::ns,
truth.tt * Acts::UnitConstants::mm,
};
ActsFatras::Hit::Vector4 simMom4{
truth.tpx * Acts::UnitConstants::GeV,
Expand Down Expand Up @@ -254,7 +254,7 @@ ActsExamples::ProcessCode ActsExamples::CsvPlanarClusterReader::read(
Acts::Vector3 pos(hit.x * Acts::UnitConstants::mm,
hit.y * Acts::UnitConstants::mm,
hit.z * Acts::UnitConstants::mm);
double time = hit.t * Acts::UnitConstants::ns;
double time = hit.t * Acts::UnitConstants::mm;
Acts::Vector3 mom(1, 1, 1); // fake momentum
Acts::Vector2 local(0, 0);
auto lpResult = surface->globalToLocal(ctx.geoContext, pos, mom);
Expand Down
4 changes: 2 additions & 2 deletions Examples/Io/Csv/src/CsvPlanarClusterWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ActsExamples::ProcessCode ActsExamples::CsvPlanarClusterWriter::writeT(
hit.x = globalPos.x() / Acts::UnitConstants::mm;
hit.y = globalPos.y() / Acts::UnitConstants::mm;
hit.z = globalPos.z() / Acts::UnitConstants::mm;
hit.t = parameters[2] / Acts::UnitConstants::ns;
hit.t = parameters[2] / Acts::UnitConstants::mm;
writerHits.append(hit);

// write local cell information
Expand Down Expand Up @@ -132,7 +132,7 @@ ActsExamples::ProcessCode ActsExamples::CsvPlanarClusterWriter::writeT(
truth.tx = simHit.position().x() / Acts::UnitConstants::mm;
truth.ty = simHit.position().y() / Acts::UnitConstants::mm;
truth.tz = simHit.position().z() / Acts::UnitConstants::mm;
truth.tt = simHit.time() / Acts::UnitConstants::ns;
truth.tt = simHit.time() / Acts::UnitConstants::mm;
// particle four-momentum before interaction
truth.tpx = simHit.momentum4Before().x() / Acts::UnitConstants::GeV;
truth.tpy = simHit.momentum4Before().y() / Acts::UnitConstants::GeV;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Csv/src/CsvSimHitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ActsExamples::ProcessCode ActsExamples::CsvSimHitReader::read(
data.tx * Acts::UnitConstants::mm,
data.ty * Acts::UnitConstants::mm,
data.tz * Acts::UnitConstants::mm,
data.tt * Acts::UnitConstants::ns,
data.tt * Acts::UnitConstants::mm,
};
ActsFatras::Hit::Vector4 mom4{
data.tpx * Acts::UnitConstants::GeV,
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Csv/src/CsvSimHitWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ActsExamples::ProcessCode ActsExamples::CsvSimHitWriter::writeT(
simhit.tx = globalPos4[Acts::ePos0] / Acts::UnitConstants::mm;
simhit.ty = globalPos4[Acts::ePos1] / Acts::UnitConstants::mm;
simhit.tz = globalPos4[Acts::ePos2] / Acts::UnitConstants::mm;
simhit.tt = globalPos4[Acts::eTime] / Acts::UnitConstants::ns;
simhit.tt = globalPos4[Acts::eTime] / Acts::UnitConstants::mm;
// particle four-momentum before interaction
simhit.tpx = momentum4Before[Acts::eMom0] / Acts::UnitConstants::GeV;
simhit.tpy = momentum4Before[Acts::eMom1] / Acts::UnitConstants::GeV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct ActsExamples::TrackFinderPerformanceWriter::Impl {
prtVx = particle.position().x() / Acts::UnitConstants::mm;
prtVy = particle.position().y() / Acts::UnitConstants::mm;
prtVz = particle.position().z() / Acts::UnitConstants::mm;
prtVt = particle.time() / Acts::UnitConstants::ns;
prtVt = particle.time() / Acts::UnitConstants::mm;
const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV;
prtPx = p * particle.direction().x();
prtPy = p * particle.direction().y();
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Root/src/RootParticleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ ActsExamples::ProcessCode ActsExamples::RootParticleReader::read(
p.setPosition4((*m_vx)[i] * Acts::UnitConstants::mm,
(*m_vy)[i] * Acts::UnitConstants::mm,
(*m_vz)[i] * Acts::UnitConstants::mm,
(*m_vt)[i] * Acts::UnitConstants::ns);
(*m_vt)[i] * Acts::UnitConstants::mm);
// NOTE: depends on the normalization done in setDirection
p.setDirection((*m_px)[i], (*m_py)[i], (*m_pz)[i]);
p.setAbsoluteMomentum((*m_p)[i] * Acts::UnitConstants::GeV);
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Root/src/RootParticleWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT(
m_vz.push_back(Acts::clampValue<float>(particle.fourPosition().z() /
Acts::UnitConstants::mm));
m_vt.push_back(Acts::clampValue<float>(particle.fourPosition().w() /
Acts::UnitConstants::ns));
Acts::UnitConstants::mm));
// momentum
const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV;
m_p.push_back(Acts::clampValue<float>(p));
Expand Down
8 changes: 4 additions & 4 deletions Examples/Io/Root/src/RootPlanarClusterWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ ActsExamples::ProcessCode ActsExamples::RootPlanarClusterWriter::writeT(
Acts::Vector3 mom(1, 1, 1);
// transform local into global position information
Acts::Vector3 pos = surface.localToGlobal(ctx.geoContext, local, mom);
m_x = pos.x();
m_y = pos.y();
m_z = pos.z();
m_t = parameters[2] / Acts::UnitConstants::ns;
m_x = pos.x() / Acts::UnitConstants::mm;
m_y = pos.y() / Acts::UnitConstants::mm;
m_z = pos.z() / Acts::UnitConstants::mm;
m_t = parameters[2] / Acts::UnitConstants::mm;
m_lx = local.x();
m_ly = local.y();
m_cov_lx = 0.; // @todo fill in
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Root/src/RootSimHitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ActsExamples::ProcessCode ActsExamples::RootSimHitReader::read(
m_floatColumns.at("tx") * Acts::UnitConstants::mm,
m_floatColumns.at("ty") * Acts::UnitConstants::mm,
m_floatColumns.at("tz") * Acts::UnitConstants::mm,
m_floatColumns.at("tt") * Acts::UnitConstants::ns,
m_floatColumns.at("tt") * Acts::UnitConstants::mm,
};

const Acts::Vector4 before4 = {
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/Root/src/RootSimHitWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ActsExamples::ProcessCode ActsExamples::RootSimHitWriter::writeT(
m_tx = hit.fourPosition().x() / Acts::UnitConstants::mm;
m_ty = hit.fourPosition().y() / Acts::UnitConstants::mm;
m_tz = hit.fourPosition().z() / Acts::UnitConstants::mm;
m_tt = hit.fourPosition().w() / Acts::UnitConstants::ns;
m_tt = hit.fourPosition().w() / Acts::UnitConstants::mm;
// write four-momentum before interaction
m_tpx = hit.momentum4Before().x() / Acts::UnitConstants::GeV;
m_tpy = hit.momentum4Before().y() / Acts::UnitConstants::GeV;
Expand Down
20 changes: 10 additions & 10 deletions Examples/Python/tests/root_file_hashes.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test_pythia8__pythia8_particles.root: 730f6b243dc52c06b72e9c2d9c954f5cc1e341bb84b0b3f72713eba82e681938
test_pythia8__pythia8_particles.root: 082eb3dbf142929df28acfec48d61f260e132cb103966d143f430eeeda89daa1
test_fatras__particles_simulation.root: 4ce0feb0ecb234143f418789a7a0d377f4a653d529c49bf999dda1878c50cee1
test_fatras__hits.root: 65f4ee27c9064ddf277a970953f900b8fdacf41a1a959211278f48f76874f2ca
test_geant4__particles_simulation.root: 5c125a1fd5d54e657f5a0eb1ec2d0b83ce0f495500b72bbd77f9fa76fae59313
test_geant4__hits.root: 300ed4154517454234b467921cee46434943294f99ee1057a120c565fbc7a940
test_fatras__hits.root: 2e47d9ba55fa1b377f70c361107fe811e9880d14c42cb3d7a9cd4616a6f33a54
test_geant4__particles_simulation.root: 366281a37f60392aa8f27a33554d6c7b7f7fdc967a1f8c4c4d2e7426b0dbf78d
test_geant4__hits.root: 1ed8ad8d3081980d8eb5b3cdd940f862f03c7683b7dda1cf6fe6ac900ac510be
test_seeding__estimatedparams.root: 7aaf6f92aeced00aba73ffa7b44db76e1f6be9820f864d8a27646feee9e64544
test_seeding__performance_seeding.root: 992f9c611d30dde0d3f3ab676bab19ada61ab6a4442828e27b65ec5e5b7a2880
test_seeding__particles.root: 4e70285c8dfbe4b2672fd3474d5a3649c7164181abefe7cba070b9e06792ae96
Expand Down Expand Up @@ -74,13 +74,13 @@ test_root_particle_writer[configPosConstructor]__particles.root: c694d91d18841f1
test_root_particle_writer[configKwConstructor]__particles.root: c694d91d18841f14dd03d858ec6f87963152467bca1425e83f1d0d0c559c3a6e
test_root_particle_writer[kwargsConstructor]__particles.root: c694d91d18841f14dd03d858ec6f87963152467bca1425e83f1d0d0c559c3a6e
test_root_meas_writer__meas.root: 347e5815f00859edbdae5a4d3053e3c797b793975636e1b6db20e192600d29d5
test_root_simhits_writer[configPosConstructor]__meas.root: 3af136c6562136c5db4b2d9a03ceeec27c482685c46e4750efb4907761135970
test_root_simhits_writer[configKwConstructor]__meas.root: 3af136c6562136c5db4b2d9a03ceeec27c482685c46e4750efb4907761135970
test_root_simhits_writer[kwargsConstructor]__meas.root: 3af136c6562136c5db4b2d9a03ceeec27c482685c46e4750efb4907761135970
test_root_simhits_writer[configPosConstructor]__meas.root: 9610837e081f3970446ca78d4c90ce116a611285dd1f4c646548dbece45abfa2
test_root_simhits_writer[configKwConstructor]__meas.root: 9610837e081f3970446ca78d4c90ce116a611285dd1f4c646548dbece45abfa2
test_root_simhits_writer[kwargsConstructor]__meas.root: 9610837e081f3970446ca78d4c90ce116a611285dd1f4c646548dbece45abfa2
test_root_material_writer__material.root: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
test_root_clusters_writer[configPosConstructor]__clusters.root: c7491b4a8d42851b4f694312eb44408bee840513d79c67d48012d57e5ba0457e
test_root_clusters_writer[configKwConstructor]__clusters.root: c7491b4a8d42851b4f694312eb44408bee840513d79c67d48012d57e5ba0457e
test_root_clusters_writer[kwargsConstructor]__clusters.root: c7491b4a8d42851b4f694312eb44408bee840513d79c67d48012d57e5ba0457e
test_root_clusters_writer[configPosConstructor]__clusters.root: e842df4fe04eefff3df5f32cd1026e93286be62b8040dc700a2aff557c56dec8
test_root_clusters_writer[configKwConstructor]__clusters.root: e842df4fe04eefff3df5f32cd1026e93286be62b8040dc700a2aff557c56dec8
test_root_clusters_writer[kwargsConstructor]__clusters.root: e842df4fe04eefff3df5f32cd1026e93286be62b8040dc700a2aff557c56dec8
test_exatrkx[cpu-torch]__performance_track_finding.root: e0875db5eb3aa6b46ad4baf846d39b37b68f1efd3436448cc75919b637f8d8d9
test_exatrkx[gpu-onnx]__performance_track_finding.root: 4845dc9f62e287e20c80d479e246eb69d01b279964cfdff83543bea0ea9afbed
test_exatrkx[gpu-torch]__performance_track_finding.root: e0875db5eb3aa6b46ad4baf846d39b37b68f1efd3436448cc75919b637f8d8d9
Expand Down

0 comments on commit 19464fa

Please sign in to comment.