Skip to content

Commit

Permalink
use float instead of double
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Feb 29, 2024
1 parent e7e4245 commit 37e64a1
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ class RootParticleReader : public IReader {
std::vector<std::uint64_t>* m_particleId = new std::vector<std::uint64_t>;
std::vector<int32_t>* m_particleType = new std::vector<int32_t>;
std::vector<std::uint32_t>* m_process = new std::vector<std::uint32_t>;
std::vector<double>* m_vx = new std::vector<double>;
std::vector<double>* m_vy = new std::vector<double>;
std::vector<double>* m_vz = new std::vector<double>;
std::vector<double>* m_vt = new std::vector<double>;
std::vector<double>* m_px = new std::vector<double>;
std::vector<double>* m_py = new std::vector<double>;
std::vector<double>* m_pz = new std::vector<double>;
std::vector<double>* m_m = new std::vector<double>;
std::vector<double>* m_q = new std::vector<double>;
std::vector<double>* m_eta = new std::vector<double>;
std::vector<double>* m_phi = new std::vector<double>;
std::vector<double>* m_pt = new std::vector<double>;
std::vector<double>* m_p = new std::vector<double>;
std::vector<float>* m_vx = new std::vector<float>;
std::vector<float>* m_vy = new std::vector<float>;
std::vector<float>* m_vz = new std::vector<float>;
std::vector<float>* m_vt = new std::vector<float>;
std::vector<float>* m_px = new std::vector<float>;
std::vector<float>* m_py = new std::vector<float>;
std::vector<float>* m_pz = new std::vector<float>;
std::vector<float>* m_m = new std::vector<float>;
std::vector<float>* m_q = new std::vector<float>;
std::vector<float>* m_eta = new std::vector<float>;
std::vector<float>* m_phi = new std::vector<float>;
std::vector<float>* m_pt = new std::vector<float>;
std::vector<float>* m_p = new std::vector<float>;
std::vector<std::uint32_t>* m_vertexPrimary = new std::vector<std::uint32_t>;
std::vector<std::uint32_t>* m_vertexSecondary =
new std::vector<std::uint32_t>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ class RootParticleWriter final : public WriterT<SimParticleContainer> {
/// Production process type, i.e. what generated the particle.
std::vector<std::uint32_t> m_process;
/// Production position components in mm.
std::vector<double> m_vx;
std::vector<double> m_vy;
std::vector<double> m_vz;
std::vector<double> m_vt;
std::vector<float> m_vx;
std::vector<float> m_vy;
std::vector<float> m_vz;
std::vector<float> m_vt;
/// Total momentum in GeV
std::vector<double> m_p;
std::vector<float> m_p;
/// Momentum components in GeV.
std::vector<double> m_px;
std::vector<double> m_py;
std::vector<double> m_pz;
std::vector<float> m_px;
std::vector<float> m_py;
std::vector<float> m_pz;
/// Mass in GeV.
std::vector<double> m_m;
std::vector<float> m_m;
/// Charge in e.
std::vector<double> m_q;
std::vector<float> m_q;
// Derived kinematic quantities
/// Direction pseudo-rapidity.
std::vector<double> m_eta;
std::vector<float> m_eta;
/// Direction angle in the transverse plane.
std::vector<double> m_phi;
std::vector<float> m_phi;
/// Transverse momentum in GeV.
std::vector<double> m_pt;
std::vector<float> m_pt;
// Decoded particle identifier; see Barcode definition for details.
std::vector<std::uint32_t> m_vertexPrimary;
std::vector<std::uint32_t> m_vertexSecondary;
Expand All @@ -125,11 +125,11 @@ class RootParticleWriter final : public WriterT<SimParticleContainer> {

// Optional information depending on input collections.
/// Total energy loss in GeV.
std::vector<double> m_eLoss;
std::vector<float> m_eLoss;
/// Accumulated material
std::vector<double> m_pathInX0;
std::vector<float> m_pathInX0;
/// Accumulated material
std::vector<double> m_pathInL0;
std::vector<float> m_pathInL0;
/// Number of hits.
std::vector<std::int32_t> m_numberOfHits;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ class RootVertexReader : public IReader {

std::vector<std::uint64_t>* m_vertexId = new std::vector<std::uint64_t>;
std::vector<std::uint32_t>* m_process = new std::vector<std::uint32_t>;
std::vector<double>* m_vx = new std::vector<double>;
std::vector<double>* m_vy = new std::vector<double>;
std::vector<double>* m_vz = new std::vector<double>;
std::vector<double>* m_vt = new std::vector<double>;
std::vector<float>* m_vx = new std::vector<float>;
std::vector<float>* m_vy = new std::vector<float>;
std::vector<float>* m_vz = new std::vector<float>;
std::vector<float>* m_vt = new std::vector<float>;
std::vector<std::uint32_t>* m_vertexPrimary = new std::vector<std::uint32_t>;
std::vector<std::uint32_t>* m_vertexSecondary =
new std::vector<std::uint32_t>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class RootVertexWriter final : public WriterT<SimVertexContainer> {
/// Production process type, i.e. what generated the vertex.
std::vector<std::uint32_t> m_process;
/// Production position components in mm.
std::vector<double> m_vx;
std::vector<double> m_vy;
std::vector<double> m_vz;
std::vector<double> m_vt;
std::vector<float> m_vx;
std::vector<float> m_vy;
std::vector<float> m_vz;
std::vector<float> m_vt;
/// Outgoing particles from the vertex.
std::vector<std::vector<double>> m_outgoingParticles;
// Decoded vertex identifier; see Barcode definition for details.
Expand Down
48 changes: 29 additions & 19 deletions Examples/Io/Root/src/RootParticleWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,32 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT(
m_particleType.push_back(particle.pdg());
m_process.push_back(static_cast<uint32_t>(particle.process()));
// position
m_vx.push_back(particle.fourPosition().x() / Acts::UnitConstants::mm);
m_vy.push_back(particle.fourPosition().y() / Acts::UnitConstants::mm);
m_vz.push_back(particle.fourPosition().z() / Acts::UnitConstants::mm);
m_vt.push_back(particle.fourPosition().w() / Acts::UnitConstants::mm);
m_vx.push_back(Acts::clampValue<float>(particle.fourPosition().x() /
Acts::UnitConstants::mm));
m_vy.push_back(Acts::clampValue<float>(particle.fourPosition().y() /
Acts::UnitConstants::mm));
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::mm));
// momentum
const auto p = particle.absoluteMomentum() / Acts::UnitConstants::GeV;
m_p.push_back(p);
m_px.push_back(p * particle.direction().x());
m_py.push_back(p * particle.direction().y());
m_pz.push_back(p * particle.direction().z());
m_p.push_back(Acts::clampValue<float>(p));
m_px.push_back(Acts::clampValue<float>(p * particle.direction().x()));
m_py.push_back(Acts::clampValue<float>(p * particle.direction().y()));
m_pz.push_back(Acts::clampValue<float>(p * particle.direction().z()));
// particle constants
m_m.push_back(particle.mass() / Acts::UnitConstants::GeV);
m_q.push_back(particle.charge() / Acts::UnitConstants::e);
m_m.push_back(
Acts::clampValue<float>(particle.mass() / Acts::UnitConstants::GeV));
m_q.push_back(
Acts::clampValue<float>(particle.charge() / Acts::UnitConstants::e));
// derived kinematic quantities
m_eta.push_back(Acts::VectorHelpers::eta(particle.direction()));
m_phi.push_back(Acts::VectorHelpers::phi(particle.direction()));
m_pt.push_back(p * Acts::VectorHelpers::perp(particle.direction()));
m_eta.push_back(Acts::clampValue<float>(
Acts::VectorHelpers::eta(particle.direction())));
m_phi.push_back(Acts::clampValue<float>(
Acts::VectorHelpers::phi(particle.direction())));
m_pt.push_back(Acts::clampValue<float>(
p * Acts::VectorHelpers::perp(particle.direction())));
// decoded barcode components
m_vertexPrimary.push_back(particle.particleId().vertexPrimary());
m_vertexSecondary.push_back(particle.particleId().vertexSecondary());
Expand All @@ -157,14 +166,15 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT(
} else {
const auto& finalParticle = *it;
// get the energy loss
m_eLoss.push_back((particle.energy() - finalParticle.energy()) /
Acts::UnitConstants::GeV);
m_eLoss.push_back(Acts::clampValue<float>(
(particle.energy() - finalParticle.energy()) /
Acts::UnitConstants::GeV));
// get the path in X0
m_pathInX0.push_back(finalParticle.pathInX0() /
Acts::UnitConstants::mm);
m_pathInX0.push_back(Acts::clampValue<float>(finalParticle.pathInX0() /
Acts::UnitConstants::mm));
// get the path in L0
m_pathInL0.push_back(finalParticle.pathInL0() /
Acts::UnitConstants::mm);
m_pathInL0.push_back(Acts::clampValue<float>(finalParticle.pathInL0() /
Acts::UnitConstants::mm));
}
} else {
m_eLoss.push_back(nan);
Expand Down
12 changes: 8 additions & 4 deletions Examples/Io/Root/src/RootVertexWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ ProcessCode RootVertexWriter::writeT(const AlgorithmContext& ctx,
m_vertexId.push_back(vertex.vertexId().value());
m_process.push_back(static_cast<uint32_t>(vertex.process));
// position
m_vx.push_back(vertex.position4.x() / Acts::UnitConstants::mm);
m_vy.push_back(vertex.position4.y() / Acts::UnitConstants::mm);
m_vz.push_back(vertex.position4.z() / Acts::UnitConstants::mm);
m_vt.push_back(vertex.position4.w() / Acts::UnitConstants::mm);
m_vx.push_back(Acts::clampValue<float>(vertex.position4.x() /
Acts::UnitConstants::mm));
m_vy.push_back(Acts::clampValue<float>(vertex.position4.y() /
Acts::UnitConstants::mm));
m_vz.push_back(Acts::clampValue<float>(vertex.position4.z() /
Acts::UnitConstants::mm));
m_vt.push_back(Acts::clampValue<float>(vertex.position4.w() /
Acts::UnitConstants::mm));
// TODO ingoing particles
// outgoing particles
std::vector<double> outgoing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(RoundTripTest) {
// Read //
//////////
RootSimHitReader::Config readerConfig;
readerConfig.simHitCollection = "hits";
readerConfig.outputSimHits = "hits";
readerConfig.filePath = "./testhits.root";

RootSimHitReader reader(readerConfig, Acts::Logging::WARNING);
Expand Down

0 comments on commit 37e64a1

Please sign in to comment.