Skip to content

Commit

Permalink
feat: momentum corrections (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks authored Feb 21, 2024
1 parent 8892807 commit 3516e5e
Show file tree
Hide file tree
Showing 7 changed files with 503 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/UBSAN.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alignment:hipo::structure::getFloatAt
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ defaults:
env:
hipo_version: f40da676bbd1745398e9fdf233ff213ff98798f1
num_events: 10
# sanitizer options; NOTE: suppression path assumes the build directory is a subdirectory of the top-level repo directory
UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1:suppressions=../.github/UBSAN.supp
ASAN_OPTIONS: halt_on_error=1:abort_on_error=1:print_summary=1


jobs:

Expand Down
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
# GitHub Handle Name
# ============= ====
# @c-dilks Christopher Dilks
# @RichCap Richard Capobianco
# @rtysonCLAS12 Richard Tyson
#################################################################################

* @c-dilks
examples/config/ex2.yaml @rtysonCLAS12
examples/iguana-example-02-YAMLReader.cc @rtysonCLAS12
examples/iguana-example-03-zvertex-filter.cc @rtysonCLAS12
src/iguana/algorithms/clas12/MomentumCorrection.cc @RichCap @c-dilks
src/iguana/algorithms/clas12/MomentumCorrection.h @RichCap @c-dilks
src/iguana/algorithms/clas12/ZVertexFilter.cc @rtysonCLAS12
src/iguana/algorithms/clas12/ZVertexFilter.h @rtysonCLAS12
src/iguana/algorithms/clas12/ZVertexFilter.yaml @rtysonCLAS12
Expand Down
13 changes: 13 additions & 0 deletions src/iguana/algorithms/TypeDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,17 @@ namespace iguana {
/// Generic Lorentz vector container type
using lorentz_vector_t = std::tuple<lorentz_element_t, lorentz_element_t, lorentz_element_t, lorentz_element_t>;

/// Light-weight namespace for particle constants
namespace particle {

/// PDG codes
enum PDG {
electron = 11,
pi_plus = 211,
pi_minus = -211,
proton = 2212
};

}

}
406 changes: 406 additions & 0 deletions src/iguana/algorithms/clas12/MomentumCorrection.cc

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions src/iguana/algorithms/clas12/MomentumCorrection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#pragma once

#include "iguana/algorithms/Algorithm.h"

namespace iguana::clas12 {

/// @brief Momentum Corrections
///
/// Adapted from <https://clasweb.jlab.org/wiki/index.php/CLAS12_Momentum_Corrections#tab=Correction_Code>
class MomentumCorrection : public Algorithm {

DEFINE_IGUANA_ALGORITHM(MomentumCorrection, clas12::MomentumCorrection)

public:

void Start(hipo::banklist& banks) override;
void Run(hipo::banklist& banks) const override;
void Stop() override;

/// **Action function**: apply the momentum correction
/// @param px @f$p_x@f$
/// @param py @f$p_y@f$
/// @param pz @f$p_z@f$
/// @param sec the sector
/// @param pid the particle PDG
/// @param torus torus setting
/// @returns the transformed momenta
std::tuple<float,float,float> Transform(float px, float py, float pz, int sec, int pid, float torus) const;

/// Calculate the correction factor for inbending data
/// @param Px @f$p_x@f$
/// @param Py @f$p_y@f$
/// @param Pz @f$p_z@f$
/// @param sec the sector
/// @param pid the particle PDG
/// @returns the correction factor
double CorrectionInbending(const float Px, const float Py, const float Pz, const int sec, const int pid) const;

/// Calculate the correction factor for outbending data
/// @param Px @f$p_x@f$
/// @param Py @f$p_y@f$
/// @param Pz @f$p_z@f$
/// @param sec the sector
/// @param pid the particle PDG
/// @returns the correction factor
double CorrectionOutbending(const float Px, const float Py, const float Pz, const int sec, const int pid) const;

/// Energy loss correction for inbending data
/// @param Px @f$p_x@f$
/// @param Py @f$p_y@f$
/// @param Pz @f$p_z@f$
/// @param pid the particle PDG
/// @returns the correction factor
double EnergyLossInbending(const float Px, const float Py, const float Pz, const int pid) const;

/// Energy loss correction for outbending data
/// @param Px @f$p_x@f$
/// @param Py @f$p_y@f$
/// @param Pz @f$p_z@f$
/// @param pid the particle PDG
/// @returns the correction factor
double EnergyLossOutbending(const float Px, const float Py, const float Pz, const int pid) const;

private:

/// `hipo::banklist` index for the particle bank
hipo::banklist::size_type b_particle;
/// `hipo::banklist` index for the config bank
hipo::banklist::size_type b_config;

};

}
3 changes: 3 additions & 0 deletions src/iguana/algorithms/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ algo_sources = [
'clas12/EventBuilderFilter.cc',
'clas12/ZVertexFilter.cc',
'clas12/LorentzTransformer.cc',
'clas12/MomentumCorrection.cc',
]

# algorithm headers
Expand All @@ -19,6 +20,7 @@ algo_public_headers = [
'clas12/EventBuilderFilter.h',
'clas12/ZVertexFilter.h',
'clas12/LorentzTransformer.h',
'clas12/MomentumCorrection.h',
]

algo_config_files = [
Expand All @@ -31,6 +33,7 @@ algos_and_banks_for_unit_testing = {
'clas12::EventBuilderFilter': ['REC::Particle'],
'clas12::ZVertexFilter': ['REC::Particle'],
'clas12::LorentzTransformer': ['REC::Particle'],
'clas12::MomentumCorrection': ['REC::Particle', 'RUN::config'],
}

algo_lib = shared_library(
Expand Down

0 comments on commit 3516e5e

Please sign in to comment.