Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward Tagger Energy Correction Function #85

Merged
merged 23 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#################################################################################
# GitHub Handle Name
# ============= ====
# @asligonulacar Asli Acar
# @c-dilks Christopher Dilks
# @RichCap Richard Capobianco
# @rtysonCLAS12 Richard Tyson
Expand All @@ -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
43 changes: 43 additions & 0 deletions src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc
Original file line number Diff line number Diff line change
@@ -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() {
}

}
45 changes: 45 additions & 0 deletions src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h
Original file line number Diff line number Diff line change
@@ -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;

};

}
7 changes: 7 additions & 0 deletions src/iguana/algorithms/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading