From f68e680436c984ded75bff1d50dd591da0ba894a Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 24 Jul 2024 19:51:07 -0400 Subject: [PATCH] test: try it --- .../physics/InclusiveKinematics/Algorithm.cc | 12 +++++++----- .../physics/InclusiveKinematics/Algorithm.h | 4 +++- .../physics/InclusiveKinematics/Config.yaml | 3 +-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc index d0d1d586..e57da087 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc +++ b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc @@ -1,5 +1,4 @@ #include "Algorithm.h" -#include "iguana/services/RCDBReader.h" // ROOT #include @@ -34,10 +33,13 @@ namespace iguana::physics { // parse config file ParseYAMLConfig(); - o_runnum = GetCachedOption("runnum").value_or(0); // FIXME: should be set from RUN::conig + o_runnum = GetCachedOption("runnum").value_or(6666); // FIXME: should be set from RUN::conig + // get the beam energy + m_rcdb = std::make_unique("RCDB|" + GetName()); + m_beam_energy = m_rcdb->GetBeamEnergy(o_runnum); + m_log->Error("Beam energy = {}", m_beam_energy); // get initial state configuration - o_beam_energy = GetOptionScalar("beam_energy", {"initial_state", GetConfig()->InRange("runs", o_runnum), "beam_energy"}); o_beam_direction = GetOptionVector("beam_direction", {"initial_state", GetConfig()->InRange("runs", o_runnum), "beam_direction"}); o_beam_particle = GetOptionScalar("beam_particle", {"initial_state", GetConfig()->InRange("runs", o_runnum), "beam_particle"}); o_target_particle = GetOptionScalar("target_particle", {"initial_state", GetConfig()->InRange("runs", o_runnum), "target_particle"}); @@ -87,7 +89,7 @@ namespace iguana::physics { o_beam_direction = {0.0, 0.0, 1.0}; } auto dir_mag = std::hypot(o_beam_direction[0], o_beam_direction[1], o_beam_direction[2]); - auto beam_p = std::sqrt(std::pow(o_beam_energy, 2) - std::pow(m_beam.mass, 2)); + auto beam_p = std::sqrt(std::pow(m_beam_energy, 2) - std::pow(m_beam.mass, 2)); if(dir_mag > 0) { m_beam.px = o_beam_direction[0] * beam_p / dir_mag; m_beam.py = o_beam_direction[1] * beam_p / dir_mag; @@ -103,7 +105,7 @@ namespace iguana::physics { // print the configuration m_log->Debug(Logger::Header("CONFIGURATION")); - m_log->Debug("{:>30}: {}", "beam energy", o_beam_energy); + m_log->Debug("{:>30}: {}", "beam energy", m_beam_energy); m_log->Debug("{:>30}: {}, mass = {}, p = ({}, {}, {})", "beam particle", o_beam_particle, m_beam.mass, m_beam.px, m_beam.py, m_beam.pz); m_log->Debug("{:>30}: {}, mass = {}, p = ({}, {}, {})", "target particle", o_target_particle, m_target.mass, m_target.px, m_target.py, m_target.pz); m_log->Debug("{:>30}: {}", "reconstruction method", method_reconstruction_str); diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h index 0f86c54c..cf36093b 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h +++ b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h @@ -2,6 +2,7 @@ #include "iguana/algorithms/Algorithm.h" #include "iguana/algorithms/TypeDefs.h" +#include "iguana/services/RCDBReader.h" namespace iguana::physics { @@ -89,7 +90,6 @@ namespace iguana::physics { // config options int o_runnum; - double o_beam_energy; std::vector o_beam_direction; std::string o_beam_particle; std::string o_target_particle; @@ -108,6 +108,8 @@ namespace iguana::physics { }; particle_t m_beam; particle_t m_target; + double m_beam_energy; + std::unique_ptr m_rcdb; }; } diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Config.yaml b/src/iguana/algorithms/physics/InclusiveKinematics/Config.yaml index 4af86847..a5272b97 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics/Config.yaml +++ b/src/iguana/algorithms/physics/InclusiveKinematics/Config.yaml @@ -1,8 +1,7 @@ physics::InclusiveKinematics: - initial_state: # FIXME: add run ranges + initial_state: - default: - beam_energy: 10.6 beam_direction: [ 0.0, 0.0, 1.0 ] beam_particle: electron target_particle: proton