diff --git a/CODEOWNERS b/CODEOWNERS index 524ed3bd..da8d6248 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,6 +1,7 @@ ################################################################################# # GitHub Handle Name # ============= ==== +# @asligonulacar Asli Acar # @c-dilks Christopher Dilks # @RichCap Richard Capobianco # @rtysonCLAS12 Richard Tyson @@ -10,4 +11,5 @@ src/iguana/algorithms/clas12/MomentumCorrection/* @RichCap @c-dilks src/iguana/algorithms/clas12/ZVertexFilter/* @rtysonCLAS12 src/iguana/algorithms/clas12/SectorFinder/* @rtysonCLAS12 +src/iguana/algorithms/clas12/FTEnergyCorrection/* @asligonulacar src/iguana/services/YAMLReader.* @rtysonCLAS12 @c-dilks diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc new file mode 100644 index 00000000..48c26021 --- /dev/null +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc @@ -0,0 +1,43 @@ +#include "Algorithm.h" + +namespace iguana::clas12 { + REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection); + + void FTEnergyCorrection::Start(hipo::banklist& banks) { + b_ft_particle = GetBankIndex(banks, "RECFT::Particle"); + electron_mass = particle::mass.at(particle::electron); + } + + void FTEnergyCorrection::Run(hipo::banklist& banks) const { + auto& ftParticleBank = GetBank(banks, b_ft_particle, "RECFT::Particle"); + ShowBank(ftParticleBank, Logger::Header("INPUT FT PARTICLES")); + for(auto const& row : ftParticleBank.getRowList()) { + if(ftParticleBank.getInt("pid", row) == particle::PDG::electron) { + auto px = ftParticleBank.getFloat("px", row); + auto py = ftParticleBank.getFloat("py", row); + auto pz = ftParticleBank.getFloat("pz", row); + auto E = std::hypot(std::hypot(px, py, pz), electron_mass); + auto [px_new, py_new, pz_new, E_new] = Transform(px, py, pz, E); + ftParticleBank.putFloat("px", row, px_new); + ftParticleBank.putFloat("py", row, py_new); + ftParticleBank.putFloat("pz", row, pz_new); + } + } + ShowBank(ftParticleBank, Logger::Header("OUTPUT FT PARTICLES")); + } + + vector4_t FTEnergyCorrection::Transform( + vector_element_t px, + vector_element_t py, + vector_element_t pz, + vector_element_t E) const + { + vector_element_t rho = std::hypot(px, py, pz); + vector_element_t E_new = E + 0.0208922 + 0.050158*E - 0.0181107*pow(E,2) + 0.00305671*pow(E,3) - 0.000178235*pow(E,4); + return { E_new*(px/rho), E_new*(py/rho), E_new*(pz/rho), E_new }; + } + + void FTEnergyCorrection::Stop() { + } + +} diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h new file mode 100644 index 00000000..db89b741 --- /dev/null +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h @@ -0,0 +1,45 @@ +#pragma once + +#include "iguana/algorithms/Algorithm.h" +#include "iguana/algorithms/TypeDefs.h" + +namespace iguana::clas12 { + + /// @brief_algo Forward Tagger energy correction + /// + /// @begin_doc_algo{Transformer} + /// @input_banks{RECFT::Particle} + /// @output_banks{RECFT::Particle} + /// @end_doc + class FTEnergyCorrection : public Algorithm { + + DEFINE_IGUANA_ALGORITHM(FTEnergyCorrection, clas12::FTEnergyCorrection) + + public: + + void Start(hipo::banklist& banks) override; + void Run(hipo::banklist& banks) const override; + void Stop() override; + + /// @action_function{scalar transformer} + /// Transformation function that returns 4-vector of electron with corrected energy for the Forward Tagger. + /// Currently only validated for Fall 2018 outbending data. + /// @param px @f$p_x@f$ + /// @param py @f$p_y@f$ + /// @param pz @f$p_z@f$ + /// @param E @f$E@f$ + /// @returns an electron 4-vector with the corrected energy for the Forward Tagger. + vector4_t Transform( + vector_element_t px, + vector_element_t py, + vector_element_t pz, + vector_element_t E) const; + + private: + + hipo::banklist::size_type b_ft_particle; + double electron_mass; + + }; + +} diff --git a/src/iguana/algorithms/meson.build b/src/iguana/algorithms/meson.build index 626a13b4..0c06228a 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -65,6 +65,13 @@ algo_dict += [ 'has_validator': false, 'test_args': { 'banks': ['REC::Particle'] }, }, + { + 'name': 'clas12::FTEnergyCorrection', + 'has_config': false, + 'has_c_bindings': false, + 'has_validator': false, + 'test_args': { 'banks': ['RECFT::Particle'] }, + }, { 'name': 'clas12::MomentumCorrection', 'has_config': false,