From 3b3d6c8ebd0398f475e62bb3be114a356eef9f41 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 2 Oct 2024 18:21:58 -0400 Subject: [PATCH] feat: add beam energy as a reload function parameter, for users who do not have RCDB --- .../physics/InclusiveKinematics/Action.yaml | 2 ++ .../physics/InclusiveKinematics/Algorithm.cc | 16 ++++++---------- .../physics/InclusiveKinematics/Algorithm.h | 5 +++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Action.yaml b/src/iguana/algorithms/physics/InclusiveKinematics/Action.yaml index fe2e2e4d..81aeabb5 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics/Action.yaml +++ b/src/iguana/algorithms/physics/InclusiveKinematics/Action.yaml @@ -7,6 +7,8 @@ actions: inputs: - name: runnum type: int + - name: beam_energy + type: double outputs: - type: concurrent_key_t cast: int diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc index 67bfb675..3b52b119 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc +++ b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.cc @@ -155,36 +155,32 @@ namespace iguana::physics { /////////////////////////////////////////////////////////////////////////////// - concurrent_key_t InclusiveKinematics::PrepareEvent(int const runnum) const + concurrent_key_t InclusiveKinematics::PrepareEvent(int const runnum, double const beam_energy) const { m_log->Trace("calling PrepareEvent({})", runnum); if(o_runnum->NeedsHashing()) { std::hash hash_ftn; auto hash_key = hash_ftn(runnum); if(!o_runnum->HasKey(hash_key)) - Reload(runnum, hash_key); + Reload(runnum, beam_energy, hash_key); return hash_key; } else { if(o_runnum->IsEmpty() || o_runnum->Load(0) != runnum) - Reload(runnum, 0); + Reload(runnum, beam_energy, 0); return 0; } } /////////////////////////////////////////////////////////////////////////////// - void InclusiveKinematics::Reload(int const runnum, concurrent_key_t key) const + void InclusiveKinematics::Reload(int const runnum, double const user_beam_energy, concurrent_key_t key) const { std::lock_guard const lock(m_mutex); - m_log->Trace("-> calling Reload({}, {})", runnum, key); + m_log->Trace("-> calling Reload({}, {}, {})", runnum, user_beam_energy, key); o_runnum->Save(runnum, key); - // get the beam energy ////////////////////////////////////////////////////////// - auto beam_energy = m_rcdb->GetBeamEnergy(runnum); - m_log->Warn("Run = {}, Beam energy = {}", runnum, beam_energy); - ///////////////////////////////////////////////////////////////////////////////// - // parse config params + auto beam_energy = user_beam_energy < 0 ? m_rcdb->GetBeamEnergy(runnum) : user_beam_energy; auto beam_direction = GetOptionVector("beam_direction", {"initial_state", GetConfig()->InRange("runs", runnum), "beam_direction"}); auto target_particle = GetOptionScalar("target_particle", {"initial_state", GetConfig()->InRange("runs", runnum), "target_particle"}); diff --git a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h index b2c53e27..dda8da34 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h +++ b/src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h @@ -58,8 +58,9 @@ namespace iguana::physics { /// @action_function{reload} prepare the event /// @when_to_call{for each event} /// @param runnum the run number + /// @param beam_energy the beam energy; if negative (the default), RCDB will be used to get the beam energy from `runnum` /// @returns the key to be used in `::ComputeFromLepton` - concurrent_key_t PrepareEvent(int const runnum) const; + concurrent_key_t PrepareEvent(int const runnum, double const beam_energy = -1) const; /// @action_function{scalar creator} compute kinematics from the scattered lepton. /// @param lepton_px scattered lepton momentum component @f$p_x@f$ (GeV) @@ -85,7 +86,7 @@ namespace iguana::physics { /// @returns the bank row of the scattered lepton, or `-1` if not found int FindScatteredLepton(hipo::bank const& particle_bank, concurrent_key_t const key) const; - void Reload(int const runnum, concurrent_key_t key) const; + void Reload(int const runnum, double const user_beam_energy, concurrent_key_t key) const; // banklist indices hipo::banklist::size_type b_particle;