From 202163b8a0a79cfa0fc0d8687b14ff7108de35c3 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:06:27 -0500 Subject: [PATCH 01/25] Create FT_Energy_Corr.cc FT Energy Correction Function --- .../algorithms/clas12/FT_Energy_Corr.cc | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/iguana/algorithms/clas12/FT_Energy_Corr.cc diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc b/src/iguana/algorithms/clas12/FT_Energy_Corr.cc new file mode 100644 index 00000000..02dbfe7f --- /dev/null +++ b/src/iguana/algorithms/clas12/FT_Energy_Corr.cc @@ -0,0 +1,41 @@ +#include "FT_Energy_Corr.h" +namespace iguana::clas12 { +REGISTER_IGUANA_ALGORITHM(FT_Energy_Corr); + +void FT_Energy_Corr::Start(hipo::banklist& banks) { + + //# This is where I would call Fiducial Cuts and Banks in a more complex algorithm. + +} + +void FT_Energy_Corr::Run(hipo::banklist& banks) const { + + //# This is where I would do the big chunk of calculations in a more complex algorithm. + +} + + +// This function returns an electron 4-vector with the corrected energy for the Forward Tagger. +// Currently only validated for Fall 2018 outbending data. + +TLorentzVector FT_Energy_Corr::Correct(TLorentzVector x) const{ + + Double_t E_new, Px_el, Py_el, Pz_el; + TLorentzVector el_new; + E_new = x.E() + 0.0208922 + 0.050158*x.E() - 0.0181107*pow(x.E(),2) + 0.00305671*pow(x.E(),3) - 0.000178235*pow(x.E(),4); + + Px_el = E_new*(x.Px()/x.Rho()); + Py_el = E_new*(x.Py()/x.Rho()); + Pz_el = E_new*(x.Pz()/x.Rho()); + + el_new.SetXYZM(Px_el, Py_el, Pz_el, 0.000511); + + return el_new; +} + +void ExampleAlgorithm::Stop() { + + + } + +} From 40b49cd433bdc4591b9c89097ba5fb6759f5c010 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:07:01 -0500 Subject: [PATCH 02/25] Create FT_Energy_Corr.h FT Energy Correction header --- src/iguana/algorithms/clas12/FT_Energy_Corr.h | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/iguana/algorithms/clas12/FT_Energy_Corr.h diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.h b/src/iguana/algorithms/clas12/FT_Energy_Corr.h new file mode 100644 index 00000000..e38ec69f --- /dev/null +++ b/src/iguana/algorithms/clas12/FT_Energy_Corr.h @@ -0,0 +1,36 @@ +#pragma once + +#include "iguana/algorithms/Algorithm.h" + +namespace iguana::clas12 { + + class FT_Energy_Corr : public Algorithm { + + //############################################################################################### + //# Variables: + //# TLorentzVector x: the 4-vector of the electron that needs to have its energy corrected. + //# Double_t E_new: the corrected energy. + //# Double_t Px_el, Py_el, Pz_el: 3-momentum components of the corrected electron. + //# TLorentzVector el_new: new electron 4-vector with the corrected energy. + //################################################################################################ + DEFINE_IGUANA_ALGORITHM(FT_Energy_Corr, example::FT_Energy_Corr) + + public: + + void Start(hipo::banklist& banks) override; + void Run(hipo::banklist& banks) const override; + void Stop() override; + + // Transformation function that returns 4-vector of electron with corrected energy for the Forward Tagger. + TLorentzVector Correct(TLorentzVector x) const; + + private: + + /// Example integer configuration option + int o_exampleInt; + /// Example float configuration option + double o_exampleFloat; + + }; + +} From 65b73bcf516fe1300ffc9b8b89690780ace3957e Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:27:54 -0500 Subject: [PATCH 03/25] Update FT_Energy_Corr.cc --- src/iguana/algorithms/clas12/FT_Energy_Corr.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc b/src/iguana/algorithms/clas12/FT_Energy_Corr.cc index 02dbfe7f..473217e6 100644 --- a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc +++ b/src/iguana/algorithms/clas12/FT_Energy_Corr.cc @@ -1,4 +1,5 @@ #include "FT_Energy_Corr.h" +#include LorentzTransformer.h namespace iguana::clas12 { REGISTER_IGUANA_ALGORITHM(FT_Energy_Corr); From 54db3a10c046f2ab92bcb5e819bde5b920c673b0 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:28:41 -0500 Subject: [PATCH 04/25] Update FT_Energy_Corr.h --- src/iguana/algorithms/clas12/FT_Energy_Corr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.h b/src/iguana/algorithms/clas12/FT_Energy_Corr.h index e38ec69f..8087f45c 100644 --- a/src/iguana/algorithms/clas12/FT_Energy_Corr.h +++ b/src/iguana/algorithms/clas12/FT_Energy_Corr.h @@ -1,6 +1,7 @@ #pragma once #include "iguana/algorithms/Algorithm.h" +#include LorentzTransformer.h namespace iguana::clas12 { From c0f058dee74d4fabc168c77f865f9264621318d3 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:29:12 -0500 Subject: [PATCH 05/25] Update FT_Energy_Corr.h --- src/iguana/algorithms/clas12/FT_Energy_Corr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.h b/src/iguana/algorithms/clas12/FT_Energy_Corr.h index 8087f45c..3035a0c6 100644 --- a/src/iguana/algorithms/clas12/FT_Energy_Corr.h +++ b/src/iguana/algorithms/clas12/FT_Energy_Corr.h @@ -2,6 +2,7 @@ #include "iguana/algorithms/Algorithm.h" #include LorentzTransformer.h +#include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { From 734ec2711306044c899dcbd46a2c8a17efb41c12 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:29:23 -0500 Subject: [PATCH 06/25] Update FT_Energy_Corr.cc --- src/iguana/algorithms/clas12/FT_Energy_Corr.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc b/src/iguana/algorithms/clas12/FT_Energy_Corr.cc index 473217e6..f18cf61d 100644 --- a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc +++ b/src/iguana/algorithms/clas12/FT_Energy_Corr.cc @@ -1,5 +1,7 @@ #include "FT_Energy_Corr.h" #include LorentzTransformer.h +#include "iguana/algorithms/TypeDefs.h" + namespace iguana::clas12 { REGISTER_IGUANA_ALGORITHM(FT_Energy_Corr); From 3553dd4ca1f67bde44ac3392c947e1dd7219496c Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 12:02:26 -0400 Subject: [PATCH 07/25] ci: re-trigger From a4109909cc43701bda2f5d66d35122ecfd308355 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 12:22:26 -0400 Subject: [PATCH 08/25] style: algorithm name -> PascalCase --- .../{FT_Energy_Corr.cc => FTEnergyCorrection.cc} | 10 +++++----- .../clas12/{FT_Energy_Corr.h => FTEnergyCorrection.h} | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/iguana/algorithms/clas12/{FT_Energy_Corr.cc => FTEnergyCorrection.cc} (76%) rename src/iguana/algorithms/clas12/{FT_Energy_Corr.h => FTEnergyCorrection.h} (90%) diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc similarity index 76% rename from src/iguana/algorithms/clas12/FT_Energy_Corr.cc rename to src/iguana/algorithms/clas12/FTEnergyCorrection.cc index f18cf61d..28254cbc 100644 --- a/src/iguana/algorithms/clas12/FT_Energy_Corr.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc @@ -1,17 +1,17 @@ -#include "FT_Energy_Corr.h" +#include "FTEnergyCorrection.h" #include LorentzTransformer.h #include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { -REGISTER_IGUANA_ALGORITHM(FT_Energy_Corr); +REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection); -void FT_Energy_Corr::Start(hipo::banklist& banks) { +void FTEnergyCorrection::Start(hipo::banklist& banks) { //# This is where I would call Fiducial Cuts and Banks in a more complex algorithm. } -void FT_Energy_Corr::Run(hipo::banklist& banks) const { +void FTEnergyCorrection::Run(hipo::banklist& banks) const { //# This is where I would do the big chunk of calculations in a more complex algorithm. @@ -21,7 +21,7 @@ void FT_Energy_Corr::Run(hipo::banklist& banks) const { // This function returns an electron 4-vector with the corrected energy for the Forward Tagger. // Currently only validated for Fall 2018 outbending data. -TLorentzVector FT_Energy_Corr::Correct(TLorentzVector x) const{ +TLorentzVector FTEnergyCorrection::Correct(TLorentzVector x) const{ Double_t E_new, Px_el, Py_el, Pz_el; TLorentzVector el_new; diff --git a/src/iguana/algorithms/clas12/FT_Energy_Corr.h b/src/iguana/algorithms/clas12/FTEnergyCorrection.h similarity index 90% rename from src/iguana/algorithms/clas12/FT_Energy_Corr.h rename to src/iguana/algorithms/clas12/FTEnergyCorrection.h index 3035a0c6..504bbea0 100644 --- a/src/iguana/algorithms/clas12/FT_Energy_Corr.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.h @@ -6,7 +6,7 @@ namespace iguana::clas12 { - class FT_Energy_Corr : public Algorithm { + class FTEnergyCorrection : public Algorithm { //############################################################################################### //# Variables: @@ -15,7 +15,7 @@ namespace iguana::clas12 { //# Double_t Px_el, Py_el, Pz_el: 3-momentum components of the corrected electron. //# TLorentzVector el_new: new electron 4-vector with the corrected energy. //################################################################################################ - DEFINE_IGUANA_ALGORITHM(FT_Energy_Corr, example::FT_Energy_Corr) + DEFINE_IGUANA_ALGORITHM(FTEnergyCorrection, clas12::FTEnergyCorrection) public: From a20b36a5e5289081c7edac0aa9f59c3f0e780a4f Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 12:23:39 -0400 Subject: [PATCH 09/25] fix: don't include `LorentzTransformer` --- src/iguana/algorithms/clas12/FTEnergyCorrection.cc | 1 - src/iguana/algorithms/clas12/FTEnergyCorrection.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc index 28254cbc..be36f5c2 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc @@ -1,5 +1,4 @@ #include "FTEnergyCorrection.h" -#include LorentzTransformer.h #include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.h b/src/iguana/algorithms/clas12/FTEnergyCorrection.h index 504bbea0..261ed3a6 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.h @@ -1,7 +1,6 @@ #pragma once #include "iguana/algorithms/Algorithm.h" -#include LorentzTransformer.h #include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { From eb5e252f31ded90c577c6c64caf0006903b7112f Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 12:26:01 -0400 Subject: [PATCH 10/25] build: include new algo --- src/iguana/algorithms/meson.build | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/iguana/algorithms/meson.build b/src/iguana/algorithms/meson.build index 3236a569..6c2af486 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -75,6 +75,14 @@ algo_dict = { 'configs': [ 'clas12/LorentzTransformer.yaml' ], 'test_args': { 'banks': ['REC::Particle'] }, }, + 'clas12::FTEnergyCorrection': { + 'algorithm': { + 'sources': [ 'clas12/FTEnergyCorrection.cc' ], + 'headers': [ 'clas12/FTEnergyCorrection.h' ], + 'needs_ROOT': true, + }, + 'test_args': { 'banks': [] }, # FIXME: what banks will this algorithm use? + }, 'clas12::MomentumCorrection': { 'algorithm': { 'sources': [ 'clas12/MomentumCorrection.cc' ], From 6fef28fe1df0f304823cce0331acb6d81d8559f4 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 12:30:01 -0400 Subject: [PATCH 11/25] fix: some build fixes --- src/iguana/algorithms/clas12/FTEnergyCorrection.cc | 2 +- src/iguana/algorithms/clas12/FTEnergyCorrection.h | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc index be36f5c2..b18d4bb5 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc @@ -35,7 +35,7 @@ TLorentzVector FTEnergyCorrection::Correct(TLorentzVector x) const{ return el_new; } -void ExampleAlgorithm::Stop() { +void FTEnergyCorrection::Stop() { } diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.h b/src/iguana/algorithms/clas12/FTEnergyCorrection.h index 261ed3a6..9c2d5830 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.h @@ -3,6 +3,8 @@ #include "iguana/algorithms/Algorithm.h" #include "iguana/algorithms/TypeDefs.h" +#include // FIXME: use `ROOTVecOps` instead + namespace iguana::clas12 { class FTEnergyCorrection : public Algorithm { @@ -24,13 +26,8 @@ namespace iguana::clas12 { // Transformation function that returns 4-vector of electron with corrected energy for the Forward Tagger. TLorentzVector Correct(TLorentzVector x) const; - + private: - - /// Example integer configuration option - int o_exampleInt; - /// Example float configuration option - double o_exampleFloat; }; From 847b5c6f6d85bafeb44b3b9895c92b77a86685a5 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 18:06:26 -0400 Subject: [PATCH 12/25] feat: fill `Run` method and remove ROOT dependence --- .../algorithms/clas12/FTEnergyCorrection.cc | 66 +++++++++---------- .../algorithms/clas12/FTEnergyCorrection.h | 27 ++++---- src/iguana/algorithms/meson.build | 3 +- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc index b18d4bb5..fd27a96c 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc @@ -1,43 +1,43 @@ #include "FTEnergyCorrection.h" -#include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { -REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection); + REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection); -void FTEnergyCorrection::Start(hipo::banklist& banks) { - - //# This is where I would call Fiducial Cuts and Banks in a more complex algorithm. - -} - -void FTEnergyCorrection::Run(hipo::banklist& banks) const { - - //# This is where I would do the big chunk of calculations in a more complex algorithm. - -} - - -// This function returns an electron 4-vector with the corrected energy for the Forward Tagger. -// Currently only validated for Fall 2018 outbending data. - -TLorentzVector FTEnergyCorrection::Correct(TLorentzVector x) const{ - - Double_t E_new, Px_el, Py_el, Pz_el; - TLorentzVector el_new; - E_new = x.E() + 0.0208922 + 0.050158*x.E() - 0.0181107*pow(x.E(),2) + 0.00305671*pow(x.E(),3) - 0.000178235*pow(x.E(),4); - - Px_el = E_new*(x.Px()/x.Rho()); - Py_el = E_new*(x.Py()/x.Rho()); - Pz_el = E_new*(x.Pz()/x.Rho()); - - el_new.SetXYZM(Px_el, Py_el, Pz_el, 0.000511); - - return el_new; -} + void FTEnergyCorrection::Start(hipo::banklist& banks) { + b_ft_particle = GetBankIndex(banks, "RECFT::Particle"); + electron_mass = particle::mass.at(particle::electron); + } -void FTEnergyCorrection::Stop() { + void FTEnergyCorrection::Run(hipo::banklist& banks) const { + auto& ftParticleBank = GetBank(banks, b_ft_particle, "RECFT::Particle"); + ShowBank(ftParticleBank, Logger::Header("INPUT FT PARTICLES")); + for(int row = 0; row < ftParticleBank.getRows(); row++) { + 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.h b/src/iguana/algorithms/clas12/FTEnergyCorrection.h index 9c2d5830..d9f30ba0 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.h @@ -3,19 +3,10 @@ #include "iguana/algorithms/Algorithm.h" #include "iguana/algorithms/TypeDefs.h" -#include // FIXME: use `ROOTVecOps` instead - namespace iguana::clas12 { class FTEnergyCorrection : public Algorithm { - //############################################################################################### - //# Variables: - //# TLorentzVector x: the 4-vector of the electron that needs to have its energy corrected. - //# Double_t E_new: the corrected energy. - //# Double_t Px_el, Py_el, Pz_el: 3-momentum components of the corrected electron. - //# TLorentzVector el_new: new electron 4-vector with the corrected energy. - //################################################################################################ DEFINE_IGUANA_ALGORITHM(FTEnergyCorrection, clas12::FTEnergyCorrection) public: @@ -24,11 +15,25 @@ namespace iguana::clas12 { void Run(hipo::banklist& banks) const override; void Stop() override; - // Transformation function that returns 4-vector of electron with corrected energy for the Forward Tagger. - TLorentzVector Correct(TLorentzVector x) const; + /// @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 6c2af486..af05d535 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -79,9 +79,8 @@ algo_dict = { 'algorithm': { 'sources': [ 'clas12/FTEnergyCorrection.cc' ], 'headers': [ 'clas12/FTEnergyCorrection.h' ], - 'needs_ROOT': true, }, - 'test_args': { 'banks': [] }, # FIXME: what banks will this algorithm use? + 'test_args': { 'banks': ['RECFT::Particle'] }, }, 'clas12::MomentumCorrection': { 'algorithm': { From 3cecae30c0fc8fca75ddaeb50ca2852401ff7af2 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 9 May 2024 18:23:53 -0400 Subject: [PATCH 13/25] fix: documentation --- src/iguana/algorithms/clas12/FTEnergyCorrection.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.h b/src/iguana/algorithms/clas12/FTEnergyCorrection.h index d9f30ba0..db89b741 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.h @@ -5,6 +5,12 @@ 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) From 917ce7159e56604489d298b623a1fbf7ade4cf0a Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 10 May 2024 22:54:32 -0400 Subject: [PATCH 14/25] fix: bank `.getRows` -> `.getRowList` --- src/iguana/algorithms/clas12/FTEnergyCorrection.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc index fd27a96c..932f2616 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection.cc @@ -11,7 +11,7 @@ namespace iguana::clas12 { void FTEnergyCorrection::Run(hipo::banklist& banks) const { auto& ftParticleBank = GetBank(banks, b_ft_particle, "RECFT::Particle"); ShowBank(ftParticleBank, Logger::Header("INPUT FT PARTICLES")); - for(int row = 0; row < ftParticleBank.getRows(); row++) { + 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); From ea121161a48ccca4f78ca50df443497590880234 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 17 May 2024 17:00:38 -0400 Subject: [PATCH 15/25] fix: `CODEOWNERS` --- CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index cc77756c..72d198aa 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 From 757afee48cc861e1d147f6de08d2b05fc3a177c6 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 17 May 2024 17:01:28 -0400 Subject: [PATCH 16/25] doc: fixme reminder for PR #206 --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 72d198aa..54f70cad 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -11,5 +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/algorithms/clas12/FTEnergyCorrection.* @asligonulacar ####### FIXME: respect PR 206 src/iguana/services/YAMLReader.* @rtysonCLAS12 @c-dilks From daa38466602ca9de8372e1b4f5d48deafec3f071 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 20 May 2024 15:57:41 -0400 Subject: [PATCH 17/25] fix: move algorithm into its own directory (respect PR #206) --- .../{FTEnergyCorrection.cc => FTEnergyCorrection/Algorithm.cc} | 0 .../{FTEnergyCorrection.h => FTEnergyCorrection/Algorithm.h} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/iguana/algorithms/clas12/{FTEnergyCorrection.cc => FTEnergyCorrection/Algorithm.cc} (100%) rename src/iguana/algorithms/clas12/{FTEnergyCorrection.h => FTEnergyCorrection/Algorithm.h} (100%) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc similarity index 100% rename from src/iguana/algorithms/clas12/FTEnergyCorrection.cc rename to src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection.h b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h similarity index 100% rename from src/iguana/algorithms/clas12/FTEnergyCorrection.h rename to src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h From c01cd25bc7ba43b947f5109716cd9c11e32076c8 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 22 May 2024 09:46:00 -0400 Subject: [PATCH 18/25] fix: wrong include --- src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc index 932f2616..48c26021 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc @@ -1,4 +1,4 @@ -#include "FTEnergyCorrection.h" +#include "Algorithm.h" namespace iguana::clas12 { REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection); From ff497c3de03ec80314e76ce7c334f59d901e20cd Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Fri, 31 May 2024 15:16:51 -0400 Subject: [PATCH 19/25] Update Algorithm.cc --- .../clas12/FTEnergyCorrection/Algorithm.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc index 48c26021..d60b6d84 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc @@ -4,26 +4,26 @@ namespace iguana::clas12 { REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection); void FTEnergyCorrection::Start(hipo::banklist& banks) { - b_ft_particle = GetBankIndex(banks, "RECFT::Particle"); + b_particle = GetBankIndex(banks, "REC::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& ParticleBank = GetBank(banks, b_particle, "REC::Particle"); + ShowBank(ParticleBank, Logger::Header("INPUT PARTICLES")); + for(auto const& row : ParticleBank.getRowList()) { + if(ParticleBank.getInt("pid", row) == particle::PDG::electron) { + auto px = ParticleBank.getFloat("px", row); + auto py = ParticleBank.getFloat("py", row); + auto pz = ParticleBank.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); + ParticleBank.putFloat("px", row, px_new); + ParticleBank.putFloat("py", row, py_new); + ParticleBank.putFloat("pz", row, pz_new); } } - ShowBank(ftParticleBank, Logger::Header("OUTPUT FT PARTICLES")); + ShowBank(ParticleBank, Logger::Header("OUTPUT PARTICLES")); } vector4_t FTEnergyCorrection::Transform( From 12e40711757051bf27df5ecff942ee99e4d52554 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Fri, 31 May 2024 15:17:22 -0400 Subject: [PATCH 20/25] Update Algorithm.h --- src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h index db89b741..0fb742ae 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.h @@ -37,7 +37,7 @@ namespace iguana::clas12 { private: - hipo::banklist::size_type b_ft_particle; + hipo::banklist::size_type b_particle; double electron_mass; }; From 679c3e2eb6706e6626ff410e17b7a48995c28e97 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Fri, 31 May 2024 15:18:20 -0400 Subject: [PATCH 21/25] Create Validator.h --- .../clas12/FTEnergyCorrection/Validator.h | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h new file mode 100644 index 00000000..35dee937 --- /dev/null +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h @@ -0,0 +1,60 @@ +#pragma once + +#include "iguana/algorithms/Algorithm.h" +#include "iguana/algorithms/Validator.h" +#include "iguana/algorithms/TypeDefs.h" +#include +#include +#include +#include +#include +#include + +namespace iguana::clas12 { + + /// @brief_algo Forward Tagger energy correction + /// + /// @begin_doc_algo{Transformer} + /// @input_banks{RECFT::Particle} + /// @output_banks{RECFT::Particle} + /// @end_doc + class FTEnergyCorrectionValidator : public Validator { + + DEFINE_IGUANA_VALIDATOR(FTEnergyCorrectionValidator, clas12::FTEnergyCorrectionValidator) + + 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: + + // How can I change this FillHistograms function so it works for TH2D histograms? I'm probably being stupid. + void InitializeHistograms(); + hipo::banklist::size_type b_particle; + double electron_mass; + std::vector const u_pdg_list = {particle::PDG::electron, particle::PDG::pion_plus, particle::PDG::pion_minus, particle::PDG::proton}; + TString m_output_file_basename; + TFile* m_output_file; + + std::map h_beforecorr; + std::map h_aftercorr; + }; + +} From ebbfeedccee74bf91cec58720a18d061a7897cb2 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Fri, 31 May 2024 15:19:32 -0400 Subject: [PATCH 22/25] Create Validator.cc --- .../clas12/FTEnergyCorrection/Validator.cc | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc new file mode 100644 index 00000000..3c76668c --- /dev/null +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc @@ -0,0 +1,161 @@ +#include "FTEnergyCorrectionValidator.h" +#include +#include + +//Edit m_E_max, -m_deltaE_max and m_deltaE_max. +//See what the plotting does. +namespace iguana::clas12 { + + REGISTER_IGUANA_VALIDATOR(FTEnergyCorrectionValidator); + + void FTEnergyCorrectionValidator::Start(hipo::banklist& banks) + { + // define the algorithm sequence + m_algo_seq = std::make_unique(); + m_algo_seq->Add("clas12::FT_Energy_Corr"); + m_algo_seq->SetOption>("clas12::EventBuilderFilter", "pids", u_pdg_list); + m_algo_seq->Start(banks); + + // get bank indices + b_particle = GetBankIndex(banks, "REC::Particle"); + electron_mass = particle::mass.at(particle::electron); + + // set an output file + auto output_dir = GetOutputDirectory(); + if(output_dir) { + m_output_file_basename = output_dir.value() + "/energy_corrections"; + m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); + + } + InitializeHistograms(); + } + + + void FTEnergyCorrectionValidator::Run(hipo::banklist& banks) const + { + // get the momenta before + auto& ParticleBank = GetBank(banks, b_particle, "REC::Particle"); + double px_el, py_el, pz_el, E_el; + double px_pim, py_pim, pz_pim; + double px_pip, py_pip, pz_pip; + double px_pr, py_pr, pz_pr; + double DeltaE; + TLorentzVector beam(0,0,10.6,10.6); + TLorentzVector target(0,0,0,0.938272); + TLorentzVector miss_el, pion_plus, pion_minus, proton, electron; + + + for(auto const& row : particle_bank.getRowList()){ + + if(ParticleBank.getInt("pid", row) == particle::PDG::electron){ + + px_el = ParticleBank.getFloat("px", row); + py_el = ParticleBank.getFloat("py", row); + pz_el = ParticleBank.getFloat("pz", row); + electron.SetXYZM(px_el, py_el, pz_el, electron_mass); + } + + if(ParticleBank.getInt("pid", row) == particle::PDG::pion_minus){ + + px_pim = ParticleBank.getFloat("px", row); + py_pim = ParticleBank.getFloat("py", row); + pz_pim = ParticleBank.getFloat("pz", row); + pion_minus.SetXYZM(px_pim, py_pim, pz_pim, 0.139600); + } + + if(ParticleBank.getInt("pid", row) == particle::PDG::pion_plus){ + + px_pip = ParticleBank.getFloat("px", row); + py_pip = ParticleBank.getFloat("py", row); + pz_pip = ParticleBank.getFloat("pz", row); + pion_plus.SetXYZM(px_pip, py_pip, pz_pip, 0.139600); + } + + if(ParticleBank.getInt("pid", row) == particle::PDG::proton){ + + px_pr = ParticleBank.getFloat("px", row); + py_pr = ParticleBank.getFloat("py", row); + pz_pr = ParticleBank.getFloat("pz", row); + proton.SetXYZM(px_pr, py_pr, pz_pr, 0.938272); + } + miss_el = beam + target - pion_minus - pion_plus - proton; + DeltaE = miss_el.E() - el.E(); + h_beforecorr->Fill(el.E(), DeltaE); + } + // run the energy corrections + m_algo_seq->Run(banks); + + for(auto const& row : particle_bank.getRowList()){ + + if(ParticleBank.getInt("pid", row) == particle::PDG::electron){ + + px_el = ParticleBank.getFloat("px", row); + py_el = ParticleBank.getFloat("py", row); + pz_el = ParticleBank.getFloat("pz", row); + electron.SetXYZM(px_el, py_el, pz_el, electron_mass); + } + + if(ParticleBank.getInt("pid", row) == particle::PDG::pion_minus){ + + px_pim = ParticleBank.getFloat("px", row); + py_pim = ParticleBank.getFloat("py", row); + pz_pim = ParticleBank.getFloat("pz", row); + pion_minus.SetXYZM(px_pim, py_pim, pz_pim, 0.139600); + } + + if(ParticleBank.getInt("pid", row) == particle::PDG::pion_plus){ + + px_pip = ParticleBank.getFloat("px", row); + py_pip = ParticleBank.getFloat("py", row); + pz_pip = ParticleBank.getFloat("pz", row); + pion_plus.SetXYZM(px_pip, py_pip, pz_pip, 0.139600); + } + + if(ParticleBank.getInt("pid", row) == particle::PDG::proton){ + + px_pr = ParticleBank.getFloat("px", row); + py_pr = ParticleBank.getFloat("py", row); + pz_pr = ParticleBank.getFloat("pz", row); + proton.SetXYZM(px_pr, py_pr, pz_pr, 0.938272); + } + miss_el = beam + target - pion_minus - pion_plus - proton; + DeltaE = miss_el.E() - el.E(); + h_aftercorr->Fill(el.E(), DeltaE); + } + + } + void FTEnergyCorrectionValidator::Stop() + { + if(GetOutputDirectory()) { + + int n_rows = 1; + int n_cols = 2; + auto canv = new TCanvas("c","c",n_cols*800,n_rows*800); + canv->Divide(n_cols,n_rows); + gStyle->SetOptStat(0); + for(int pad_num = 0; pad_num < 2; pad_num++){ + auto pad = canv->GetPad(pad_num+1); + pad->cd(); + pad->SetGrid(1, 1); + pad->SetLogz(); + pad->SetLeftMargin(0.12); + pad->SetRightMargin(0.12); + pad->SetBottomMargin(0.12); + + switch(pad_num){ + case 0: + h_beforecorr->Draw("colz"); + break; + case 1: + h_aftercorr->Draw("colz") + break; + } + } + canv->SaveAs(m_output_file_basename + "_plot.png"); + m_output_file->Write(); + m_log->Info("Wrote output file {}", m_output_file->GetName()); + m_output_file->Close(); + } + } + +} From b0b6c023b2c2477804dbaa289a830c909e83c0f9 Mon Sep 17 00:00:00 2001 From: asligonulacar <67739979+asligonulacar@users.noreply.github.com> Date: Fri, 31 May 2024 15:19:56 -0400 Subject: [PATCH 23/25] Update Validator.cc --- src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc index 3c76668c..8b3d54a6 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc @@ -1,4 +1,4 @@ -#include "FTEnergyCorrectionValidator.h" +#include "Validator.h" #include #include From 8910ab24e1ab66e16f2c11e90925f150f3c1e2e1 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 31 May 2024 17:11:34 -0400 Subject: [PATCH 24/25] fix: test the new validator --- src/iguana/algorithms/meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/src/iguana/algorithms/meson.build b/src/iguana/algorithms/meson.build index 7d60563a..75ce4595 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -69,7 +69,6 @@ algo_dict += [ 'name': 'clas12::FTEnergyCorrection', 'has_config': false, 'has_c_bindings': false, - 'has_validator': false, 'test_args': { 'banks': ['RECFT::Particle'] }, }, { From 63b8818de9a410ceeb5981312a03081415e4a2ae Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 31 May 2024 17:24:30 -0400 Subject: [PATCH 25/25] fix: some fixes --- .../clas12/FTEnergyCorrection/Validator.cc | 77 +++++++++---------- .../clas12/FTEnergyCorrection/Validator.h | 11 +-- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc index 8b3d54a6..54d3992b 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc @@ -27,14 +27,13 @@ namespace iguana::clas12 { m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); } - InitializeHistograms(); } void FTEnergyCorrectionValidator::Run(hipo::banklist& banks) const { // get the momenta before - auto& ParticleBank = GetBank(banks, b_particle, "REC::Particle"); + auto& particle_bank = GetBank(banks, b_particle, "REC::Particle"); double px_el, py_el, pz_el, E_el; double px_pim, py_pim, pz_pim; double px_pip, py_pip, pz_pip; @@ -47,80 +46,80 @@ namespace iguana::clas12 { for(auto const& row : particle_bank.getRowList()){ - if(ParticleBank.getInt("pid", row) == particle::PDG::electron){ + if(particle_bank.getInt("pid", row) == particle::PDG::electron){ - px_el = ParticleBank.getFloat("px", row); - py_el = ParticleBank.getFloat("py", row); - pz_el = ParticleBank.getFloat("pz", row); + px_el = particle_bank.getFloat("px", row); + py_el = particle_bank.getFloat("py", row); + pz_el = particle_bank.getFloat("pz", row); electron.SetXYZM(px_el, py_el, pz_el, electron_mass); } - if(ParticleBank.getInt("pid", row) == particle::PDG::pion_minus){ + if(particle_bank.getInt("pid", row) == particle::PDG::pi_minus){ - px_pim = ParticleBank.getFloat("px", row); - py_pim = ParticleBank.getFloat("py", row); - pz_pim = ParticleBank.getFloat("pz", row); + px_pim = particle_bank.getFloat("px", row); + py_pim = particle_bank.getFloat("py", row); + pz_pim = particle_bank.getFloat("pz", row); pion_minus.SetXYZM(px_pim, py_pim, pz_pim, 0.139600); } - if(ParticleBank.getInt("pid", row) == particle::PDG::pion_plus){ + if(particle_bank.getInt("pid", row) == particle::PDG::pi_plus){ - px_pip = ParticleBank.getFloat("px", row); - py_pip = ParticleBank.getFloat("py", row); - pz_pip = ParticleBank.getFloat("pz", row); + px_pip = particle_bank.getFloat("px", row); + py_pip = particle_bank.getFloat("py", row); + pz_pip = particle_bank.getFloat("pz", row); pion_plus.SetXYZM(px_pip, py_pip, pz_pip, 0.139600); } - if(ParticleBank.getInt("pid", row) == particle::PDG::proton){ + if(particle_bank.getInt("pid", row) == particle::PDG::proton){ - px_pr = ParticleBank.getFloat("px", row); - py_pr = ParticleBank.getFloat("py", row); - pz_pr = ParticleBank.getFloat("pz", row); + px_pr = particle_bank.getFloat("px", row); + py_pr = particle_bank.getFloat("py", row); + pz_pr = particle_bank.getFloat("pz", row); proton.SetXYZM(px_pr, py_pr, pz_pr, 0.938272); } miss_el = beam + target - pion_minus - pion_plus - proton; - DeltaE = miss_el.E() - el.E(); - h_beforecorr->Fill(el.E(), DeltaE); + DeltaE = miss_el.E() - electron.E(); + h_beforecorr->Fill(electron.E(), DeltaE); } // run the energy corrections m_algo_seq->Run(banks); for(auto const& row : particle_bank.getRowList()){ - if(ParticleBank.getInt("pid", row) == particle::PDG::electron){ + if(particle_bank.getInt("pid", row) == particle::PDG::electron){ - px_el = ParticleBank.getFloat("px", row); - py_el = ParticleBank.getFloat("py", row); - pz_el = ParticleBank.getFloat("pz", row); + px_el = particle_bank.getFloat("px", row); + py_el = particle_bank.getFloat("py", row); + pz_el = particle_bank.getFloat("pz", row); electron.SetXYZM(px_el, py_el, pz_el, electron_mass); } - if(ParticleBank.getInt("pid", row) == particle::PDG::pion_minus){ + if(particle_bank.getInt("pid", row) == particle::PDG::pi_minus){ - px_pim = ParticleBank.getFloat("px", row); - py_pim = ParticleBank.getFloat("py", row); - pz_pim = ParticleBank.getFloat("pz", row); + px_pim = particle_bank.getFloat("px", row); + py_pim = particle_bank.getFloat("py", row); + pz_pim = particle_bank.getFloat("pz", row); pion_minus.SetXYZM(px_pim, py_pim, pz_pim, 0.139600); } - if(ParticleBank.getInt("pid", row) == particle::PDG::pion_plus){ + if(particle_bank.getInt("pid", row) == particle::PDG::pi_plus){ - px_pip = ParticleBank.getFloat("px", row); - py_pip = ParticleBank.getFloat("py", row); - pz_pip = ParticleBank.getFloat("pz", row); + px_pip = particle_bank.getFloat("px", row); + py_pip = particle_bank.getFloat("py", row); + pz_pip = particle_bank.getFloat("pz", row); pion_plus.SetXYZM(px_pip, py_pip, pz_pip, 0.139600); } - if(ParticleBank.getInt("pid", row) == particle::PDG::proton){ + if(particle_bank.getInt("pid", row) == particle::PDG::proton){ - px_pr = ParticleBank.getFloat("px", row); - py_pr = ParticleBank.getFloat("py", row); - pz_pr = ParticleBank.getFloat("pz", row); + px_pr = particle_bank.getFloat("px", row); + py_pr = particle_bank.getFloat("py", row); + pz_pr = particle_bank.getFloat("pz", row); proton.SetXYZM(px_pr, py_pr, pz_pr, 0.938272); } miss_el = beam + target - pion_minus - pion_plus - proton; - DeltaE = miss_el.E() - el.E(); - h_aftercorr->Fill(el.E(), DeltaE); + DeltaE = miss_el.E() - electron.E(); + h_aftercorr->Fill(electron.E(), DeltaE); } } @@ -147,7 +146,7 @@ namespace iguana::clas12 { h_beforecorr->Draw("colz"); break; case 1: - h_aftercorr->Draw("colz") + h_aftercorr->Draw("colz"); break; } } diff --git a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h index 35dee937..6ac388e1 100644 --- a/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h +++ b/src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h @@ -1,14 +1,12 @@ #pragma once -#include "iguana/algorithms/Algorithm.h" #include "iguana/algorithms/Validator.h" #include "iguana/algorithms/TypeDefs.h" -#include +#include #include #include #include #include -#include namespace iguana::clas12 { @@ -46,15 +44,14 @@ namespace iguana::clas12 { private: // How can I change this FillHistograms function so it works for TH2D histograms? I'm probably being stupid. - void InitializeHistograms(); hipo::banklist::size_type b_particle; double electron_mass; - std::vector const u_pdg_list = {particle::PDG::electron, particle::PDG::pion_plus, particle::PDG::pion_minus, particle::PDG::proton}; + std::vector const u_pdg_list = {particle::PDG::electron, particle::PDG::pi_plus, particle::PDG::pi_minus, particle::PDG::proton}; TString m_output_file_basename; TFile* m_output_file; - std::map h_beforecorr; - std::map h_aftercorr; + TH2D* h_beforecorr; + TH2D* h_aftercorr; }; }