From 7492cc61795fc276ce791c395a8489e13f086957 Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Thu, 6 Jun 2024 11:20:07 -0400 Subject: [PATCH 01/15] Added LeptonID .c --- src/iguana/algorithms/clas12/LeptonID.cc | 163 +++++++++++++++++++++ src/iguana/algorithms/clas12/LeptonID.h | 71 +++++++++ src/iguana/algorithms/clas12/LeptonID.yaml | 3 + 3 files changed, 237 insertions(+) create mode 100644 src/iguana/algorithms/clas12/LeptonID.cc create mode 100644 src/iguana/algorithms/clas12/LeptonID.h create mode 100644 src/iguana/algorithms/clas12/LeptonID.yaml diff --git a/src/iguana/algorithms/clas12/LeptonID.cc b/src/iguana/algorithms/clas12/LeptonID.cc new file mode 100644 index 00000000..e45988ba --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonID.cc @@ -0,0 +1,163 @@ +#include "LeptonID.h" + +#include + +namespace iguana::clas12 { + + //REGISTER_IGUANA_ALGORITHM(LeptonID); //not using it + REGISTER_IGUANA_ALGORITHM(LeptonID , "clas12::leptonID"); // this algorithm creates 1 new banks + + void LeptonID::Start(hipo::banklist& banks) + { + //Get configuration + ParseYAMLConfig(); + o_pid = GetOptionScalar("pid");//Obtain pid from config file + o_weightfile = GetOptionScalar("weightfile");//Obtain weightfile from config file + //o_exampleDouble = GetOptionScalar("exampleDouble"); + + + + //Get Banks that we are going to use + b_particle = GetBankIndex(banks, "REC::Particle"); + b_calorimeter = GetBankIndex(banks, "REC::Calorimeter"); + + //Create bank to store score (should we add the variables?) + auto leptonID_schema = CreateBank( + banks, + b_leptonID, + GetClassName(), + {"pindex/S", "score/D","p/D","theta/D","phi/D","sfpcal/D","sfecin/D","sfecout/D","m2pcal/D","m2ecin/D","m2ecout/D"}, + 0xF000, + 1); + i_pindex = leptonID_schema.getEntryOrder("pindex"); + i_score = leptonID_schema.getEntryOrder("score"); + i_p = leptonID_schema.getEntryOrder("p"); + i_theta = leptonID_schema.getEntryOrder("theta"); + i_phi = leptonID_schema.getEntryOrder("phi"); + i_sfpcal = leptonID_schema.getEntryOrder("sfpcal"); + + } + + + void LeptonID::Run(hipo::banklist& banks) const + { + auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); + auto& calorimeterBank = GetBank(banks, b_calorimeter, "REC::Calorimeter"); + + + ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); + + auto lepton_pindex = FindLepton(particleBank); + if(lepton_pindex < 0) { + ShowBank(leptonID_schema, Logger::Header("CREATED BANK IS EMPTY")); + return; + } + + auto lepton_vars=GetLeptonIDVariables(lepton_pindex,particleBank,calorimeterBank); + + result_bank.setRows(1); + result_bank.putShort(i_pindex, 0, static_cast(lepton_pindex)); + result_bank.putDouble(i_score, 0, lepton_vars.score); + + ShowBank(result_bank, Logger::Header("CREATED BANK")); + + ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); + } + + + int FindLepton(hipo::bank const& particle_bank) const{ + int lepton_pindex= -1; + for(int row = 0; row < particle_bank.getRows(); row++) { + auto status = particle_bank.getShort("status", row); + if(particle_bank.getInt("pid", row) == o_pid && abs(status)>=2000 && abs(status)<4000) { + lepton_pindex=row; + break; + } + } + if(lepton_pindex >= 0) + m_log->Debug("Found lepton: pindex={}", lepton_pindex); + else + m_log->Debug("Lepton not found"); + return lepton_pindex; + } + + LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ + + double px = particle_bank.getFloat("px", plepton); + double py = particle_bank.getFloat("py", plepton); + double pz = particle_bank.getFloat("pz", plepton); + double E = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2) + std::pow(0.000511, 2)); + ROOT::Math::PxPyPzMVector vec_lepton=(px, py, pz, E); + + LeptonIDVars lepton; + + lepton.P =vec_lepton.P(); + lepton.Theta=vec_lepton.Theta(); + lepton.Phi =vec_lepton.Phi(); + + m_log->Debug("Variables obtained from particle bank"); + + + lepton.m2pcal=-1; + lepton.m2ecin=-1; + lepton.m2ecout=-1; + + for(int row = 0; row < calorimeter_bank.getRows(); row++) { + auto pindex = calorimeter_bank.getShort("pindex",row); + auto layer = calorimeter_bank.getByte("layer",row); + auto energy = calorimeter_bank.getFloat("energy",row); + auto m2u = calorimeter_bank.getFloat("m2u",row); + auto m2v = calorimeter_bank.getFloat("m2v",row); + auto m2w = calorimeter_bank.getFloat("m2w",row); + + if(pindex==plepton && layer=1) { + lepton.SFpcal=energy/vec_lepton.P(); + lepton.m2pcal=(m2u+m2v+m2w)/3; + } + + if(pindex==plepton && layer==4) { + lepton.SFecin=energy/vec_lepton.P(); + lepton.m2ecin=(m2u+m2v+m2w)/3; + } + if(pindex==plepton && layer==7) { + lepton.SFecout=energy/vec_lepton.P(); + lepton.m2ecout=(m2u+m2v+m2w)/3; + } + + } + + + m_log->Debug("Variables obtained from calorimeter bank"); + + //Get TMVA reader + TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); + // Create a set of variables and declare them to the reader + Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; + + readerTMVA->AddVariable( "P",&P ); + readerTMVA->AddVariable( "Theta",&Theta); + readerTMVA->AddVariable( "Phi",&Phi); + readerTMVA->AddVariable( "SFPCAL",&PCAL); + readerTMVA->AddVariable( "SFECIN",&ECIN); + readerTMVA->AddVariable( "SFECOUT",&ECOUT ); + readerTMVA->AddVariable( "m2PCAL",&m2PCAL); + readerTMVA->AddVariable( "m2ECIN",&m2ECIN); + readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); + + m_log->Debug("Add variables to readerTMVA"); + + readerTMVA->BookMVA( "BDT", o_weightfile ); + + m_log->Debug("TMVA method booked"); + + lepton.score=readerTMVA->EvaluateMVA("BDT"); + + return lepton; + } + + + void LeptonID::Stop() + { + } + +} diff --git a/src/iguana/algorithms/clas12/LeptonID.h b/src/iguana/algorithms/clas12/LeptonID.h new file mode 100644 index 00000000..a9d44c6e --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonID.h @@ -0,0 +1,71 @@ +#pragma once + +#include "iguana/algorithms/Algorithm.h" + +namespace iguana::clas12 { + + /// Set of inclusive kinematics variables + struct LeptonIDVars { + double P; + double Theta; + double Phi; + double SFpcal; + double SFecin; + double SFecout; + double m2pcal; + double m2ecin; + double m2ecout; + double score; + }; + + /// + /// @brief_algo This is a template algorithm, used as an example showing how to write an algorithm. + /// + /// Provide a more detailed description of your algorithm here. + /// + /// @begin_doc_algo{Filter} + /// @input_banks{REC::Particle} + /// @output_banks{REC::Particle} + /// @end_doc + /// + /// @begin_doc_config + /// @config_param{exampleInt | int | an example `integer` configuration parameter} + /// @config_param{exampleDouble | double | an example `double` configuration parameter} + /// @end_doc + class LeptonID : public Algorithm + { + + DEFINE_IGUANA_ALGORITHM(LeptonID, clas12::LeptonID) + + public: + + void Start(hipo::banklist& banks) override; + void Run(hipo::banklist& banks) const override; + void Stop() override; + + /// **FindLepton function**: returns the pindex of the lepton + /// @param particle_bank the particle bank + /// @returns pindex of the lepton, -1 if there is no lepton + int FindLepton(hipo::bank const& particle_bank) const; + + /// **CalculateScore function**: Using the pindex retrieves the necessary variables from banks + ///to do the Lepton ID + /// @param plepton pindex of the lepton + /// @param particle_bank the particle bank + /// @param calorimeter_bank the calorimeter bank + /// @returns LeptonIDVars, the variables required for identification + LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const; + + private: + + /// `hipo::banklist` index for the particle bank (as an example) + hipo::banklist::size_type b_particle; + hipo::banklist::size_type b_calorimeter; + + /// Example integer configuration option + int o_pid; + /// Example double configuration option + //double o_exampleDouble; + }; + +} diff --git a/src/iguana/algorithms/clas12/LeptonID.yaml b/src/iguana/algorithms/clas12/LeptonID.yaml new file mode 100644 index 00000000..079e872b --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonID.yaml @@ -0,0 +1,3 @@ +clas12::LeptonID: + exampleInt: 8 + exampleDouble: 7.5 From c4a49d7dbc63df8cdc037dfbb944cc253f8e3494 Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Thu, 13 Jun 2024 10:49:43 -0400 Subject: [PATCH 02/15] Add LeptonID --- meson/minimum-version.sh | 2 +- src/iguana/algorithms/LeptonID.cc | 163 ++++++++++++++++++++++++++++ src/iguana/algorithms/LeptonID.h | 71 ++++++++++++ src/iguana/algorithms/LeptonID.yaml | 3 + 4 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 src/iguana/algorithms/LeptonID.cc create mode 100644 src/iguana/algorithms/LeptonID.h create mode 100644 src/iguana/algorithms/LeptonID.yaml diff --git a/meson/minimum-version.sh b/meson/minimum-version.sh index dc397f37..4241ec95 100755 --- a/meson/minimum-version.sh +++ b/meson/minimum-version.sh @@ -32,7 +32,7 @@ case $dep in [ "$cmd" = "src" ] && echo "ERROR: command '$cmd' is not used for '$dep'" >&2 && exit 1 ;; root|ROOT) - result_meson='>=6.28' + result_meson='>=6.26' [ "$cmd" = "ALA" ] && echo "ERROR: command '$cmd' is not used for '$dep'" >&2 && exit 1 result_src='https://root.cern/download/root_v6.28.12.source.tar.gz' ;; diff --git a/src/iguana/algorithms/LeptonID.cc b/src/iguana/algorithms/LeptonID.cc new file mode 100644 index 00000000..e45988ba --- /dev/null +++ b/src/iguana/algorithms/LeptonID.cc @@ -0,0 +1,163 @@ +#include "LeptonID.h" + +#include + +namespace iguana::clas12 { + + //REGISTER_IGUANA_ALGORITHM(LeptonID); //not using it + REGISTER_IGUANA_ALGORITHM(LeptonID , "clas12::leptonID"); // this algorithm creates 1 new banks + + void LeptonID::Start(hipo::banklist& banks) + { + //Get configuration + ParseYAMLConfig(); + o_pid = GetOptionScalar("pid");//Obtain pid from config file + o_weightfile = GetOptionScalar("weightfile");//Obtain weightfile from config file + //o_exampleDouble = GetOptionScalar("exampleDouble"); + + + + //Get Banks that we are going to use + b_particle = GetBankIndex(banks, "REC::Particle"); + b_calorimeter = GetBankIndex(banks, "REC::Calorimeter"); + + //Create bank to store score (should we add the variables?) + auto leptonID_schema = CreateBank( + banks, + b_leptonID, + GetClassName(), + {"pindex/S", "score/D","p/D","theta/D","phi/D","sfpcal/D","sfecin/D","sfecout/D","m2pcal/D","m2ecin/D","m2ecout/D"}, + 0xF000, + 1); + i_pindex = leptonID_schema.getEntryOrder("pindex"); + i_score = leptonID_schema.getEntryOrder("score"); + i_p = leptonID_schema.getEntryOrder("p"); + i_theta = leptonID_schema.getEntryOrder("theta"); + i_phi = leptonID_schema.getEntryOrder("phi"); + i_sfpcal = leptonID_schema.getEntryOrder("sfpcal"); + + } + + + void LeptonID::Run(hipo::banklist& banks) const + { + auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); + auto& calorimeterBank = GetBank(banks, b_calorimeter, "REC::Calorimeter"); + + + ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); + + auto lepton_pindex = FindLepton(particleBank); + if(lepton_pindex < 0) { + ShowBank(leptonID_schema, Logger::Header("CREATED BANK IS EMPTY")); + return; + } + + auto lepton_vars=GetLeptonIDVariables(lepton_pindex,particleBank,calorimeterBank); + + result_bank.setRows(1); + result_bank.putShort(i_pindex, 0, static_cast(lepton_pindex)); + result_bank.putDouble(i_score, 0, lepton_vars.score); + + ShowBank(result_bank, Logger::Header("CREATED BANK")); + + ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); + } + + + int FindLepton(hipo::bank const& particle_bank) const{ + int lepton_pindex= -1; + for(int row = 0; row < particle_bank.getRows(); row++) { + auto status = particle_bank.getShort("status", row); + if(particle_bank.getInt("pid", row) == o_pid && abs(status)>=2000 && abs(status)<4000) { + lepton_pindex=row; + break; + } + } + if(lepton_pindex >= 0) + m_log->Debug("Found lepton: pindex={}", lepton_pindex); + else + m_log->Debug("Lepton not found"); + return lepton_pindex; + } + + LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ + + double px = particle_bank.getFloat("px", plepton); + double py = particle_bank.getFloat("py", plepton); + double pz = particle_bank.getFloat("pz", plepton); + double E = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2) + std::pow(0.000511, 2)); + ROOT::Math::PxPyPzMVector vec_lepton=(px, py, pz, E); + + LeptonIDVars lepton; + + lepton.P =vec_lepton.P(); + lepton.Theta=vec_lepton.Theta(); + lepton.Phi =vec_lepton.Phi(); + + m_log->Debug("Variables obtained from particle bank"); + + + lepton.m2pcal=-1; + lepton.m2ecin=-1; + lepton.m2ecout=-1; + + for(int row = 0; row < calorimeter_bank.getRows(); row++) { + auto pindex = calorimeter_bank.getShort("pindex",row); + auto layer = calorimeter_bank.getByte("layer",row); + auto energy = calorimeter_bank.getFloat("energy",row); + auto m2u = calorimeter_bank.getFloat("m2u",row); + auto m2v = calorimeter_bank.getFloat("m2v",row); + auto m2w = calorimeter_bank.getFloat("m2w",row); + + if(pindex==plepton && layer=1) { + lepton.SFpcal=energy/vec_lepton.P(); + lepton.m2pcal=(m2u+m2v+m2w)/3; + } + + if(pindex==plepton && layer==4) { + lepton.SFecin=energy/vec_lepton.P(); + lepton.m2ecin=(m2u+m2v+m2w)/3; + } + if(pindex==plepton && layer==7) { + lepton.SFecout=energy/vec_lepton.P(); + lepton.m2ecout=(m2u+m2v+m2w)/3; + } + + } + + + m_log->Debug("Variables obtained from calorimeter bank"); + + //Get TMVA reader + TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); + // Create a set of variables and declare them to the reader + Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; + + readerTMVA->AddVariable( "P",&P ); + readerTMVA->AddVariable( "Theta",&Theta); + readerTMVA->AddVariable( "Phi",&Phi); + readerTMVA->AddVariable( "SFPCAL",&PCAL); + readerTMVA->AddVariable( "SFECIN",&ECIN); + readerTMVA->AddVariable( "SFECOUT",&ECOUT ); + readerTMVA->AddVariable( "m2PCAL",&m2PCAL); + readerTMVA->AddVariable( "m2ECIN",&m2ECIN); + readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); + + m_log->Debug("Add variables to readerTMVA"); + + readerTMVA->BookMVA( "BDT", o_weightfile ); + + m_log->Debug("TMVA method booked"); + + lepton.score=readerTMVA->EvaluateMVA("BDT"); + + return lepton; + } + + + void LeptonID::Stop() + { + } + +} diff --git a/src/iguana/algorithms/LeptonID.h b/src/iguana/algorithms/LeptonID.h new file mode 100644 index 00000000..a9d44c6e --- /dev/null +++ b/src/iguana/algorithms/LeptonID.h @@ -0,0 +1,71 @@ +#pragma once + +#include "iguana/algorithms/Algorithm.h" + +namespace iguana::clas12 { + + /// Set of inclusive kinematics variables + struct LeptonIDVars { + double P; + double Theta; + double Phi; + double SFpcal; + double SFecin; + double SFecout; + double m2pcal; + double m2ecin; + double m2ecout; + double score; + }; + + /// + /// @brief_algo This is a template algorithm, used as an example showing how to write an algorithm. + /// + /// Provide a more detailed description of your algorithm here. + /// + /// @begin_doc_algo{Filter} + /// @input_banks{REC::Particle} + /// @output_banks{REC::Particle} + /// @end_doc + /// + /// @begin_doc_config + /// @config_param{exampleInt | int | an example `integer` configuration parameter} + /// @config_param{exampleDouble | double | an example `double` configuration parameter} + /// @end_doc + class LeptonID : public Algorithm + { + + DEFINE_IGUANA_ALGORITHM(LeptonID, clas12::LeptonID) + + public: + + void Start(hipo::banklist& banks) override; + void Run(hipo::banklist& banks) const override; + void Stop() override; + + /// **FindLepton function**: returns the pindex of the lepton + /// @param particle_bank the particle bank + /// @returns pindex of the lepton, -1 if there is no lepton + int FindLepton(hipo::bank const& particle_bank) const; + + /// **CalculateScore function**: Using the pindex retrieves the necessary variables from banks + ///to do the Lepton ID + /// @param plepton pindex of the lepton + /// @param particle_bank the particle bank + /// @param calorimeter_bank the calorimeter bank + /// @returns LeptonIDVars, the variables required for identification + LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const; + + private: + + /// `hipo::banklist` index for the particle bank (as an example) + hipo::banklist::size_type b_particle; + hipo::banklist::size_type b_calorimeter; + + /// Example integer configuration option + int o_pid; + /// Example double configuration option + //double o_exampleDouble; + }; + +} diff --git a/src/iguana/algorithms/LeptonID.yaml b/src/iguana/algorithms/LeptonID.yaml new file mode 100644 index 00000000..079e872b --- /dev/null +++ b/src/iguana/algorithms/LeptonID.yaml @@ -0,0 +1,3 @@ +clas12::LeptonID: + exampleInt: 8 + exampleDouble: 7.5 From 3ffd7e15f2d352832fd3e9a95855c0c916943a74 Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Thu, 27 Jun 2024 16:45:22 -0400 Subject: [PATCH 03/15] Added algorithm to folder, added weight file --- .../clas12/LeptonIDFilter/Algorithm.cc | 169 + .../clas12/LeptonIDFilter/Algorithm.h | 84 + .../clas12/LeptonIDFilter/config.yaml | 4 + .../weights/9_BDT_positrons_S19.weights.xml | 13538 ++++++++++++++++ 4 files changed, 13795 insertions(+) create mode 100644 src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc create mode 100644 src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h create mode 100644 src/iguana/algorithms/clas12/LeptonIDFilter/config.yaml create mode 100644 src/iguana/algorithms/clas12/LeptonIDFilter/weights/9_BDT_positrons_S19.weights.xml diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc new file mode 100644 index 00000000..a616f86b --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -0,0 +1,169 @@ +#include "Algorithm.h" + +#include + +namespace iguana::clas12 { + + //REGISTER_IGUANA_ALGORITHM(LeptonID); //not using it + REGISTER_IGUANA_ALGORITHM(LeptonID , "clas12::leptonID"); // this algorithm creates 1 new banks + + void LeptonID::Start(hipo::banklist& banks) + { + //Get configuration + ParseYAMLConfig(); + o_pid = GetOptionScalar("pid");//Obtain pid from config file (+11/-11) + o_weightfile = GetOptionScalar("weightfile");//Obtain weightfile from config file + o_cut = GetOptionScalar("cut"); + + + + //Get Banks that we are going to use + b_particle = GetBankIndex(banks, "REC::Particle"); + b_calorimeter = GetBankIndex(banks, "REC::Calorimeter"); + + + } + + + void LeptonID::Run(hipo::banklist& banks) const + { + auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); + auto& calorimeterBank = GetBank(banks, b_calorimeter, "REC::Calorimeter"); + + ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); + + // + particleBank.getMutableRowList().filter([this](auto bank, auto row) { + auto lepton_pindex = FindLepton(particleBank); + auto lepton_vars=GetLeptonIDVariables(lepton_pindex,particleBank,calorimeterBank); + lepton_vars.score=CalculateScore(lepton_vars); + + return Filter(lepton_vars.score); + }); + + // dump the modified bank + ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); + + } + + + int FindLepton(hipo::bank const& particle_bank) const{ + int lepton_pindex= -1; + for(int row = 0; row < particle_bank.getRows(); row++) { + auto status = particle_bank.getShort("status", row); + if(particle_bank.getInt("pid", row) == o_pid && abs(status)>=2000 && abs(status)<4000) { + lepton_pindex=row; + break; + } + } + if(lepton_pindex >= 0) + m_log->Debug("Found lepton: pindex={}", lepton_pindex); + else + m_log->Debug("Lepton not found"); + return lepton_pindex; + } + + LeptonIDVars GetLeptonIDVariables(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ + + double px = particle_bank.getFloat("px", plepton); + double py = particle_bank.getFloat("py", plepton); + double pz = particle_bank.getFloat("pz", plepton); + double E = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2) + std::pow(0.000511, 2)); + ROOT::Math::PxPyPzMVector vec_lepton=(px, py, pz, E); + + LeptonIDVars lepton; + + lepton.P =vec_lepton.P(); + lepton.Theta=vec_lepton.Theta(); + lepton.Phi =vec_lepton.Phi(); + + m_log->Debug("Variables obtained from particle bank"); + + + lepton.m2pcal=-1; + lepton.m2ecin=-1; + lepton.m2ecout=-1; + + for(int row = 0; row < calorimeter_bank.getRows(); row++) { + auto pindex = calorimeter_bank.getShort("pindex",row); + auto layer = calorimeter_bank.getByte("layer",row); + auto energy = calorimeter_bank.getFloat("energy",row); + auto m2u = calorimeter_bank.getFloat("m2u",row); + auto m2v = calorimeter_bank.getFloat("m2v",row); + auto m2w = calorimeter_bank.getFloat("m2w",row); + + if(pindex==plepton && layer==1) { + lepton.SFpcal=energy/vec_lepton.P(); + lepton.m2pcal=(m2u+m2v+m2w)/3; + } + + if(pindex==plepton && layer==4) { + lepton.SFecin=energy/vec_lepton.P(); + lepton.m2ecin=(m2u+m2v+m2w)/3; + } + if(pindex==plepton && layer==7) { + lepton.SFecout=energy/vec_lepton.P(); + lepton.m2ecout=(m2u+m2v+m2w)/3; + } + + } + + + m_log->Debug("Variables obtained from calorimeter bank"); + + return lepton; + + } + + double CalculateScore(LeptonIDVars lepton_vars) const{ + + //Get TMVA reader + TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); + // Create a set of variables and declare them to the reader + Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; + + P=lepton_vars.P; + Theta=lepton_vars.Theta; + Phi=lepton_vars.Phi; + PCAL=lepton_vars.SFpcal; + ECIN=lepton_vars.SFecin; + ECOUT=lepton_vars.SFecout; + m2PCAL=lepton_vars.m2pcal; + m2ECIN=lepton_vars.m2ecin; + m2ECOUT=lepton_vars.m2ecout; + + readerTMVA->AddVariable( "P",&P ); + readerTMVA->AddVariable( "Theta",&Theta); + readerTMVA->AddVariable( "Phi",&Phi); + readerTMVA->AddVariable( "SFPCAL",&PCAL); + readerTMVA->AddVariable( "SFECIN",&ECIN); + readerTMVA->AddVariable( "SFECOUT",&ECOUT ); + readerTMVA->AddVariable( "m2PCAL",&m2PCAL); + readerTMVA->AddVariable( "m2ECIN",&m2ECIN); + readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); + + m_log->Debug("Add variables to readerTMVA"); + + readerTMVA->BookMVA( "BDT", o_weightfile ); + + m_log->Debug("TMVA method booked"); + + auto score=readerTMVA->EvaluateMVA("BDT"); + + return score; + } + + bool Filter(double score) const{ + if(score>=o_cut) + return true; + else + return false; + } + + + + void LeptonID::Stop() + { + } + +} diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h new file mode 100644 index 00000000..30ca1ca3 --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -0,0 +1,84 @@ +#pragma once + +#include "iguana/algorithms/Algorithm.h" +#include "iguana/algorithms/TypeDefs.h" + +namespace iguana::clas12 { + + /// Set of inclusive kinematics variables + struct LeptonIDVars { + double P; + double Theta; + double Phi; + double SFpcal; + double SFecin; + double SFecout; + double m2pcal; + double m2ecin; + double m2ecout; + double score; + }; + + /// + /// @brief_algo This is a template algorithm, used as an example showing how to write an algorithm. + /// + /// Provide a more detailed description of your algorithm here. + /// + /// @begin_doc_algo{Filter} + /// @input_banks{REC::Particle} + /// @output_banks{REC::Particle} + /// @end_doc + /// + /// @begin_doc_config + /// @config_param{exampleInt | int | an example `integer` configuration parameter} + /// @config_param{exampleDouble | double | an example `double` configuration parameter} + /// @end_doc + class LeptonID : public Algorithm + { + + DEFINE_IGUANA_ALGORITHM(LeptonID, clas12::LeptonID) + + public: + + void Start(hipo::banklist& banks) override; + void Run(hipo::banklist& banks) const override; + void Stop() override; + + /// **FindLepton function**: returns the pindex of the lepton + /// @param particle_bank the particle bank + /// @returns pindex of the lepton, -1 if there is no lepton + int FindLepton(hipo::bank const& particle_bank) const; + + + /// **GetLeptonIDVariables function**: Using the pindex retrieves the necessary variables from banks + /// @param plepton pindex of the lepton + /// @param particle_bank the particle bank + /// @param calorimeter_bank the calorimeter bank + /// @returns LeptonIDVars, the variables required for identification + LeptonIDVars GetLeptonIDVariables(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const; + + + /// **CalculateScore function**: Using the LeptonIDVars variables calculate the score + /// @param lepton_vars LeptonIDVars variables + /// @returns double, the score + double CalculateScore(LeptonIDVars lepton_vars) const; + + /// **Filter function**: Returns true if the particle passed the cut + /// @param score the score obtained from the CalculateScore function + /// @returns bool, true if score>=cut, false otherwise + bool Filter(double score) const + + + private: + + /// `hipo::banklist` index for the particle bank (as an example) + hipo::banklist::size_type b_particle; + hipo::banklist::size_type b_calorimeter; + + /// Example integer configuration option + int o_pid; + /// Example double configuration option + //double o_exampleDouble; + }; + +} diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/config.yaml b/src/iguana/algorithms/clas12/LeptonIDFilter/config.yaml new file mode 100644 index 00000000..aaa6d6e5 --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/config.yaml @@ -0,0 +1,4 @@ +clas12::LeptonIDFilter: + pid: -11 + weightfile: "/weights/9_BDT_positrons_S19.weights.xml" + cut: 0.0 diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/weights/9_BDT_positrons_S19.weights.xml b/src/iguana/algorithms/clas12/LeptonIDFilter/weights/9_BDT_positrons_S19.weights.xml new file mode 100644 index 00000000..f4b4ac60 --- /dev/null +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/weights/9_BDT_positrons_S19.weights.xml @@ -0,0 +1,13538 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b6b382714a1c839557ea4ce448fbf5424490f790 Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Thu, 27 Jun 2024 16:49:49 -0400 Subject: [PATCH 04/15] Removed extra LeptonID files --- src/iguana/algorithms/LeptonID.cc | 163 --------------------- src/iguana/algorithms/LeptonID.h | 71 --------- src/iguana/algorithms/LeptonID.yaml | 3 - src/iguana/algorithms/clas12/LeptonID.cc | 163 --------------------- src/iguana/algorithms/clas12/LeptonID.h | 71 --------- src/iguana/algorithms/clas12/LeptonID.yaml | 3 - 6 files changed, 474 deletions(-) delete mode 100644 src/iguana/algorithms/LeptonID.cc delete mode 100644 src/iguana/algorithms/LeptonID.h delete mode 100644 src/iguana/algorithms/LeptonID.yaml delete mode 100644 src/iguana/algorithms/clas12/LeptonID.cc delete mode 100644 src/iguana/algorithms/clas12/LeptonID.h delete mode 100644 src/iguana/algorithms/clas12/LeptonID.yaml diff --git a/src/iguana/algorithms/LeptonID.cc b/src/iguana/algorithms/LeptonID.cc deleted file mode 100644 index e45988ba..00000000 --- a/src/iguana/algorithms/LeptonID.cc +++ /dev/null @@ -1,163 +0,0 @@ -#include "LeptonID.h" - -#include - -namespace iguana::clas12 { - - //REGISTER_IGUANA_ALGORITHM(LeptonID); //not using it - REGISTER_IGUANA_ALGORITHM(LeptonID , "clas12::leptonID"); // this algorithm creates 1 new banks - - void LeptonID::Start(hipo::banklist& banks) - { - //Get configuration - ParseYAMLConfig(); - o_pid = GetOptionScalar("pid");//Obtain pid from config file - o_weightfile = GetOptionScalar("weightfile");//Obtain weightfile from config file - //o_exampleDouble = GetOptionScalar("exampleDouble"); - - - - //Get Banks that we are going to use - b_particle = GetBankIndex(banks, "REC::Particle"); - b_calorimeter = GetBankIndex(banks, "REC::Calorimeter"); - - //Create bank to store score (should we add the variables?) - auto leptonID_schema = CreateBank( - banks, - b_leptonID, - GetClassName(), - {"pindex/S", "score/D","p/D","theta/D","phi/D","sfpcal/D","sfecin/D","sfecout/D","m2pcal/D","m2ecin/D","m2ecout/D"}, - 0xF000, - 1); - i_pindex = leptonID_schema.getEntryOrder("pindex"); - i_score = leptonID_schema.getEntryOrder("score"); - i_p = leptonID_schema.getEntryOrder("p"); - i_theta = leptonID_schema.getEntryOrder("theta"); - i_phi = leptonID_schema.getEntryOrder("phi"); - i_sfpcal = leptonID_schema.getEntryOrder("sfpcal"); - - } - - - void LeptonID::Run(hipo::banklist& banks) const - { - auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); - auto& calorimeterBank = GetBank(banks, b_calorimeter, "REC::Calorimeter"); - - - ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); - - auto lepton_pindex = FindLepton(particleBank); - if(lepton_pindex < 0) { - ShowBank(leptonID_schema, Logger::Header("CREATED BANK IS EMPTY")); - return; - } - - auto lepton_vars=GetLeptonIDVariables(lepton_pindex,particleBank,calorimeterBank); - - result_bank.setRows(1); - result_bank.putShort(i_pindex, 0, static_cast(lepton_pindex)); - result_bank.putDouble(i_score, 0, lepton_vars.score); - - ShowBank(result_bank, Logger::Header("CREATED BANK")); - - ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); - } - - - int FindLepton(hipo::bank const& particle_bank) const{ - int lepton_pindex= -1; - for(int row = 0; row < particle_bank.getRows(); row++) { - auto status = particle_bank.getShort("status", row); - if(particle_bank.getInt("pid", row) == o_pid && abs(status)>=2000 && abs(status)<4000) { - lepton_pindex=row; - break; - } - } - if(lepton_pindex >= 0) - m_log->Debug("Found lepton: pindex={}", lepton_pindex); - else - m_log->Debug("Lepton not found"); - return lepton_pindex; - } - - LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ - - double px = particle_bank.getFloat("px", plepton); - double py = particle_bank.getFloat("py", plepton); - double pz = particle_bank.getFloat("pz", plepton); - double E = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2) + std::pow(0.000511, 2)); - ROOT::Math::PxPyPzMVector vec_lepton=(px, py, pz, E); - - LeptonIDVars lepton; - - lepton.P =vec_lepton.P(); - lepton.Theta=vec_lepton.Theta(); - lepton.Phi =vec_lepton.Phi(); - - m_log->Debug("Variables obtained from particle bank"); - - - lepton.m2pcal=-1; - lepton.m2ecin=-1; - lepton.m2ecout=-1; - - for(int row = 0; row < calorimeter_bank.getRows(); row++) { - auto pindex = calorimeter_bank.getShort("pindex",row); - auto layer = calorimeter_bank.getByte("layer",row); - auto energy = calorimeter_bank.getFloat("energy",row); - auto m2u = calorimeter_bank.getFloat("m2u",row); - auto m2v = calorimeter_bank.getFloat("m2v",row); - auto m2w = calorimeter_bank.getFloat("m2w",row); - - if(pindex==plepton && layer=1) { - lepton.SFpcal=energy/vec_lepton.P(); - lepton.m2pcal=(m2u+m2v+m2w)/3; - } - - if(pindex==plepton && layer==4) { - lepton.SFecin=energy/vec_lepton.P(); - lepton.m2ecin=(m2u+m2v+m2w)/3; - } - if(pindex==plepton && layer==7) { - lepton.SFecout=energy/vec_lepton.P(); - lepton.m2ecout=(m2u+m2v+m2w)/3; - } - - } - - - m_log->Debug("Variables obtained from calorimeter bank"); - - //Get TMVA reader - TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); - // Create a set of variables and declare them to the reader - Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; - - readerTMVA->AddVariable( "P",&P ); - readerTMVA->AddVariable( "Theta",&Theta); - readerTMVA->AddVariable( "Phi",&Phi); - readerTMVA->AddVariable( "SFPCAL",&PCAL); - readerTMVA->AddVariable( "SFECIN",&ECIN); - readerTMVA->AddVariable( "SFECOUT",&ECOUT ); - readerTMVA->AddVariable( "m2PCAL",&m2PCAL); - readerTMVA->AddVariable( "m2ECIN",&m2ECIN); - readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); - - m_log->Debug("Add variables to readerTMVA"); - - readerTMVA->BookMVA( "BDT", o_weightfile ); - - m_log->Debug("TMVA method booked"); - - lepton.score=readerTMVA->EvaluateMVA("BDT"); - - return lepton; - } - - - void LeptonID::Stop() - { - } - -} diff --git a/src/iguana/algorithms/LeptonID.h b/src/iguana/algorithms/LeptonID.h deleted file mode 100644 index a9d44c6e..00000000 --- a/src/iguana/algorithms/LeptonID.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include "iguana/algorithms/Algorithm.h" - -namespace iguana::clas12 { - - /// Set of inclusive kinematics variables - struct LeptonIDVars { - double P; - double Theta; - double Phi; - double SFpcal; - double SFecin; - double SFecout; - double m2pcal; - double m2ecin; - double m2ecout; - double score; - }; - - /// - /// @brief_algo This is a template algorithm, used as an example showing how to write an algorithm. - /// - /// Provide a more detailed description of your algorithm here. - /// - /// @begin_doc_algo{Filter} - /// @input_banks{REC::Particle} - /// @output_banks{REC::Particle} - /// @end_doc - /// - /// @begin_doc_config - /// @config_param{exampleInt | int | an example `integer` configuration parameter} - /// @config_param{exampleDouble | double | an example `double` configuration parameter} - /// @end_doc - class LeptonID : public Algorithm - { - - DEFINE_IGUANA_ALGORITHM(LeptonID, clas12::LeptonID) - - public: - - void Start(hipo::banklist& banks) override; - void Run(hipo::banklist& banks) const override; - void Stop() override; - - /// **FindLepton function**: returns the pindex of the lepton - /// @param particle_bank the particle bank - /// @returns pindex of the lepton, -1 if there is no lepton - int FindLepton(hipo::bank const& particle_bank) const; - - /// **CalculateScore function**: Using the pindex retrieves the necessary variables from banks - ///to do the Lepton ID - /// @param plepton pindex of the lepton - /// @param particle_bank the particle bank - /// @param calorimeter_bank the calorimeter bank - /// @returns LeptonIDVars, the variables required for identification - LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const; - - private: - - /// `hipo::banklist` index for the particle bank (as an example) - hipo::banklist::size_type b_particle; - hipo::banklist::size_type b_calorimeter; - - /// Example integer configuration option - int o_pid; - /// Example double configuration option - //double o_exampleDouble; - }; - -} diff --git a/src/iguana/algorithms/LeptonID.yaml b/src/iguana/algorithms/LeptonID.yaml deleted file mode 100644 index 079e872b..00000000 --- a/src/iguana/algorithms/LeptonID.yaml +++ /dev/null @@ -1,3 +0,0 @@ -clas12::LeptonID: - exampleInt: 8 - exampleDouble: 7.5 diff --git a/src/iguana/algorithms/clas12/LeptonID.cc b/src/iguana/algorithms/clas12/LeptonID.cc deleted file mode 100644 index e45988ba..00000000 --- a/src/iguana/algorithms/clas12/LeptonID.cc +++ /dev/null @@ -1,163 +0,0 @@ -#include "LeptonID.h" - -#include - -namespace iguana::clas12 { - - //REGISTER_IGUANA_ALGORITHM(LeptonID); //not using it - REGISTER_IGUANA_ALGORITHM(LeptonID , "clas12::leptonID"); // this algorithm creates 1 new banks - - void LeptonID::Start(hipo::banklist& banks) - { - //Get configuration - ParseYAMLConfig(); - o_pid = GetOptionScalar("pid");//Obtain pid from config file - o_weightfile = GetOptionScalar("weightfile");//Obtain weightfile from config file - //o_exampleDouble = GetOptionScalar("exampleDouble"); - - - - //Get Banks that we are going to use - b_particle = GetBankIndex(banks, "REC::Particle"); - b_calorimeter = GetBankIndex(banks, "REC::Calorimeter"); - - //Create bank to store score (should we add the variables?) - auto leptonID_schema = CreateBank( - banks, - b_leptonID, - GetClassName(), - {"pindex/S", "score/D","p/D","theta/D","phi/D","sfpcal/D","sfecin/D","sfecout/D","m2pcal/D","m2ecin/D","m2ecout/D"}, - 0xF000, - 1); - i_pindex = leptonID_schema.getEntryOrder("pindex"); - i_score = leptonID_schema.getEntryOrder("score"); - i_p = leptonID_schema.getEntryOrder("p"); - i_theta = leptonID_schema.getEntryOrder("theta"); - i_phi = leptonID_schema.getEntryOrder("phi"); - i_sfpcal = leptonID_schema.getEntryOrder("sfpcal"); - - } - - - void LeptonID::Run(hipo::banklist& banks) const - { - auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); - auto& calorimeterBank = GetBank(banks, b_calorimeter, "REC::Calorimeter"); - - - ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); - - auto lepton_pindex = FindLepton(particleBank); - if(lepton_pindex < 0) { - ShowBank(leptonID_schema, Logger::Header("CREATED BANK IS EMPTY")); - return; - } - - auto lepton_vars=GetLeptonIDVariables(lepton_pindex,particleBank,calorimeterBank); - - result_bank.setRows(1); - result_bank.putShort(i_pindex, 0, static_cast(lepton_pindex)); - result_bank.putDouble(i_score, 0, lepton_vars.score); - - ShowBank(result_bank, Logger::Header("CREATED BANK")); - - ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); - } - - - int FindLepton(hipo::bank const& particle_bank) const{ - int lepton_pindex= -1; - for(int row = 0; row < particle_bank.getRows(); row++) { - auto status = particle_bank.getShort("status", row); - if(particle_bank.getInt("pid", row) == o_pid && abs(status)>=2000 && abs(status)<4000) { - lepton_pindex=row; - break; - } - } - if(lepton_pindex >= 0) - m_log->Debug("Found lepton: pindex={}", lepton_pindex); - else - m_log->Debug("Lepton not found"); - return lepton_pindex; - } - - LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ - - double px = particle_bank.getFloat("px", plepton); - double py = particle_bank.getFloat("py", plepton); - double pz = particle_bank.getFloat("pz", plepton); - double E = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2) + std::pow(0.000511, 2)); - ROOT::Math::PxPyPzMVector vec_lepton=(px, py, pz, E); - - LeptonIDVars lepton; - - lepton.P =vec_lepton.P(); - lepton.Theta=vec_lepton.Theta(); - lepton.Phi =vec_lepton.Phi(); - - m_log->Debug("Variables obtained from particle bank"); - - - lepton.m2pcal=-1; - lepton.m2ecin=-1; - lepton.m2ecout=-1; - - for(int row = 0; row < calorimeter_bank.getRows(); row++) { - auto pindex = calorimeter_bank.getShort("pindex",row); - auto layer = calorimeter_bank.getByte("layer",row); - auto energy = calorimeter_bank.getFloat("energy",row); - auto m2u = calorimeter_bank.getFloat("m2u",row); - auto m2v = calorimeter_bank.getFloat("m2v",row); - auto m2w = calorimeter_bank.getFloat("m2w",row); - - if(pindex==plepton && layer=1) { - lepton.SFpcal=energy/vec_lepton.P(); - lepton.m2pcal=(m2u+m2v+m2w)/3; - } - - if(pindex==plepton && layer==4) { - lepton.SFecin=energy/vec_lepton.P(); - lepton.m2ecin=(m2u+m2v+m2w)/3; - } - if(pindex==plepton && layer==7) { - lepton.SFecout=energy/vec_lepton.P(); - lepton.m2ecout=(m2u+m2v+m2w)/3; - } - - } - - - m_log->Debug("Variables obtained from calorimeter bank"); - - //Get TMVA reader - TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); - // Create a set of variables and declare them to the reader - Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; - - readerTMVA->AddVariable( "P",&P ); - readerTMVA->AddVariable( "Theta",&Theta); - readerTMVA->AddVariable( "Phi",&Phi); - readerTMVA->AddVariable( "SFPCAL",&PCAL); - readerTMVA->AddVariable( "SFECIN",&ECIN); - readerTMVA->AddVariable( "SFECOUT",&ECOUT ); - readerTMVA->AddVariable( "m2PCAL",&m2PCAL); - readerTMVA->AddVariable( "m2ECIN",&m2ECIN); - readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); - - m_log->Debug("Add variables to readerTMVA"); - - readerTMVA->BookMVA( "BDT", o_weightfile ); - - m_log->Debug("TMVA method booked"); - - lepton.score=readerTMVA->EvaluateMVA("BDT"); - - return lepton; - } - - - void LeptonID::Stop() - { - } - -} diff --git a/src/iguana/algorithms/clas12/LeptonID.h b/src/iguana/algorithms/clas12/LeptonID.h deleted file mode 100644 index a9d44c6e..00000000 --- a/src/iguana/algorithms/clas12/LeptonID.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include "iguana/algorithms/Algorithm.h" - -namespace iguana::clas12 { - - /// Set of inclusive kinematics variables - struct LeptonIDVars { - double P; - double Theta; - double Phi; - double SFpcal; - double SFecin; - double SFecout; - double m2pcal; - double m2ecin; - double m2ecout; - double score; - }; - - /// - /// @brief_algo This is a template algorithm, used as an example showing how to write an algorithm. - /// - /// Provide a more detailed description of your algorithm here. - /// - /// @begin_doc_algo{Filter} - /// @input_banks{REC::Particle} - /// @output_banks{REC::Particle} - /// @end_doc - /// - /// @begin_doc_config - /// @config_param{exampleInt | int | an example `integer` configuration parameter} - /// @config_param{exampleDouble | double | an example `double` configuration parameter} - /// @end_doc - class LeptonID : public Algorithm - { - - DEFINE_IGUANA_ALGORITHM(LeptonID, clas12::LeptonID) - - public: - - void Start(hipo::banklist& banks) override; - void Run(hipo::banklist& banks) const override; - void Stop() override; - - /// **FindLepton function**: returns the pindex of the lepton - /// @param particle_bank the particle bank - /// @returns pindex of the lepton, -1 if there is no lepton - int FindLepton(hipo::bank const& particle_bank) const; - - /// **CalculateScore function**: Using the pindex retrieves the necessary variables from banks - ///to do the Lepton ID - /// @param plepton pindex of the lepton - /// @param particle_bank the particle bank - /// @param calorimeter_bank the calorimeter bank - /// @returns LeptonIDVars, the variables required for identification - LeptonIDVars CalculateScore(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const; - - private: - - /// `hipo::banklist` index for the particle bank (as an example) - hipo::banklist::size_type b_particle; - hipo::banklist::size_type b_calorimeter; - - /// Example integer configuration option - int o_pid; - /// Example double configuration option - //double o_exampleDouble; - }; - -} diff --git a/src/iguana/algorithms/clas12/LeptonID.yaml b/src/iguana/algorithms/clas12/LeptonID.yaml deleted file mode 100644 index 079e872b..00000000 --- a/src/iguana/algorithms/clas12/LeptonID.yaml +++ /dev/null @@ -1,3 +0,0 @@ -clas12::LeptonID: - exampleInt: 8 - exampleDouble: 7.5 From 1883b27caa3a9556424b994b3b8c51377654fd6d Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Thu, 27 Jun 2024 17:03:17 -0400 Subject: [PATCH 05/15] Added config variables --- src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index 30ca1ca3..1781bb0e 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -77,8 +77,8 @@ namespace iguana::clas12 { /// Example integer configuration option int o_pid; - /// Example double configuration option - //double o_exampleDouble; + std::string o_weightfile; + double o_cut; }; } From 0e927598e39d3d750a344b30fcc98f980108cf09 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 28 Jun 2024 15:54:05 -0400 Subject: [PATCH 06/15] renamed: LeptonIDFilter/config.yaml -> LeptonIDFilter/Config.yaml --- .../algorithms/clas12/LeptonIDFilter/{config.yaml => Config.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/iguana/algorithms/clas12/LeptonIDFilter/{config.yaml => Config.yaml} (100%) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/config.yaml b/src/iguana/algorithms/clas12/LeptonIDFilter/Config.yaml similarity index 100% rename from src/iguana/algorithms/clas12/LeptonIDFilter/config.yaml rename to src/iguana/algorithms/clas12/LeptonIDFilter/Config.yaml From 53c3686907b55f6f45890be142d24150ab5e0354 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 28 Jun 2024 16:24:32 -0400 Subject: [PATCH 07/15] fix: compilation fixes --- meson.build | 1 + .../clas12/LeptonIDFilter/Algorithm.cc | 23 ++++++++++--------- .../clas12/LeptonIDFilter/Algorithm.h | 7 +++--- src/iguana/algorithms/meson.build | 9 +++++++- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/meson.build b/meson.build index dae9a4d0..77eff5c8 100644 --- a/meson.build +++ b/meson.build @@ -124,6 +124,7 @@ if ROOT_dep.found() '-lGenVector', '-lROOTDataFrame', '-lROOTVecOps', + '-lTMVA', '-lTreePlayer', ] ROOT_dep_link_args_for_validators = [ diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc index a616f86b..56a3ed08 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -1,13 +1,14 @@ #include "Algorithm.h" #include +#include +#include namespace iguana::clas12 { - //REGISTER_IGUANA_ALGORITHM(LeptonID); //not using it - REGISTER_IGUANA_ALGORITHM(LeptonID , "clas12::leptonID"); // this algorithm creates 1 new banks + REGISTER_IGUANA_ALGORITHM(LeptonIDFilter , "clas12::LeptonIDFilter"); - void LeptonID::Start(hipo::banklist& banks) + void LeptonIDFilter::Start(hipo::banklist& banks) { //Get configuration ParseYAMLConfig(); @@ -25,7 +26,7 @@ namespace iguana::clas12 { } - void LeptonID::Run(hipo::banklist& banks) const + void LeptonIDFilter::Run(hipo::banklist& banks) const { auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); auto& calorimeterBank = GetBank(banks, b_calorimeter, "REC::Calorimeter"); @@ -33,7 +34,7 @@ namespace iguana::clas12 { ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); // - particleBank.getMutableRowList().filter([this](auto bank, auto row) { + particleBank.getMutableRowList().filter([this,&particleBank,&calorimeterBank](auto bank, auto row) { auto lepton_pindex = FindLepton(particleBank); auto lepton_vars=GetLeptonIDVariables(lepton_pindex,particleBank,calorimeterBank); lepton_vars.score=CalculateScore(lepton_vars); @@ -47,7 +48,7 @@ namespace iguana::clas12 { } - int FindLepton(hipo::bank const& particle_bank) const{ + int LeptonIDFilter::FindLepton(hipo::bank const& particle_bank) const{ int lepton_pindex= -1; for(int row = 0; row < particle_bank.getRows(); row++) { auto status = particle_bank.getShort("status", row); @@ -63,13 +64,13 @@ namespace iguana::clas12 { return lepton_pindex; } - LeptonIDVars GetLeptonIDVariables(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ + LeptonIDVars LeptonIDFilter::GetLeptonIDVariables(int const plepton, hipo::bank const& particle_bank, hipo::bank const& calorimeter_bank) const{ double px = particle_bank.getFloat("px", plepton); double py = particle_bank.getFloat("py", plepton); double pz = particle_bank.getFloat("pz", plepton); double E = std::sqrt(std::pow(px, 2) + std::pow(py, 2) + std::pow(pz, 2) + std::pow(0.000511, 2)); - ROOT::Math::PxPyPzMVector vec_lepton=(px, py, pz, E); + ROOT::Math::PxPyPzMVector vec_lepton(px, py, pz, E); LeptonIDVars lepton; @@ -115,7 +116,7 @@ namespace iguana::clas12 { } - double CalculateScore(LeptonIDVars lepton_vars) const{ + double LeptonIDFilter::CalculateScore(LeptonIDVars lepton_vars) const{ //Get TMVA reader TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); @@ -153,7 +154,7 @@ namespace iguana::clas12 { return score; } - bool Filter(double score) const{ + bool LeptonIDFilter::Filter(double score) const{ if(score>=o_cut) return true; else @@ -162,7 +163,7 @@ namespace iguana::clas12 { - void LeptonID::Stop() + void LeptonIDFilter::Stop() { } diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index 1781bb0e..c343ba4c 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -1,7 +1,6 @@ #pragma once #include "iguana/algorithms/Algorithm.h" -#include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { @@ -33,10 +32,10 @@ namespace iguana::clas12 { /// @config_param{exampleInt | int | an example `integer` configuration parameter} /// @config_param{exampleDouble | double | an example `double` configuration parameter} /// @end_doc - class LeptonID : public Algorithm + class LeptonIDFilter : public Algorithm { - DEFINE_IGUANA_ALGORITHM(LeptonID, clas12::LeptonID) + DEFINE_IGUANA_ALGORITHM(LeptonIDFilter, clas12::LeptonIDFilter) public: @@ -66,7 +65,7 @@ namespace iguana::clas12 { /// **Filter function**: Returns true if the particle passed the cut /// @param score the score obtained from the CalculateScore function /// @returns bool, true if score>=cut, false otherwise - bool Filter(double score) const + bool Filter(double score) const; private: diff --git a/src/iguana/algorithms/meson.build b/src/iguana/algorithms/meson.build index 6628d396..873bf83c 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -97,7 +97,14 @@ algo_dict += [ 'algorithm_needs_ROOT': true, 'has_validator': true, 'test_args': { 'banks': ['REC::Particle', 'REC::Calorimeter', 'RUN::config'] }, - } + }, + { + 'name': 'clas12::LeptonIDFilter', + 'has_c_bindings': false, + 'algorithm_needs_ROOT': true, + 'has_validator': false, + 'test_args': { 'banks': ['REC::Particle', 'REC::Calorimeter'] }, + }, ] # make lists of objects to build; inclusion depends on whether ROOT is needed or not, and if we have ROOT From 0563625a1cc869890b30ae6bc0f4972726b1ae25 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 1 Jul 2024 14:46:15 -0400 Subject: [PATCH 08/15] feat: install and use algorithm data files (viz., weight files) --- meson.build | 13 ++++- src/iguana/algorithms/Algorithm.cc | 11 ++++ src/iguana/algorithms/Algorithm.h | 9 +++ .../clas12/LeptonIDFilter/Algorithm.cc | 6 +- .../clas12/LeptonIDFilter/Algorithm.h | 1 + .../clas12/LeptonIDFilter/Config.yaml | 2 +- src/iguana/algorithms/meson.build | 17 +++++- src/iguana/services/ConfigFileReader.cc | 55 +++++++++++-------- src/iguana/services/ConfigFileReader.h | 8 ++- src/iguana/services/DataFileReader.cc | 15 +++++ src/iguana/services/DataFileReader.h | 19 +++++++ src/iguana/services/meson.build | 2 + 12 files changed, 128 insertions(+), 30 deletions(-) create mode 100644 src/iguana/services/DataFileReader.cc create mode 100644 src/iguana/services/DataFileReader.h diff --git a/meson.build b/meson.build index 77eff5c8..21129acc 100644 --- a/meson.build +++ b/meson.build @@ -22,6 +22,14 @@ project_description = 'Implementation Guardian of Analysis Algorithms' # initialize binding languanges add_languages('fortran', native: false, required: get_option('bind_fortran')) +# check built-in build options +if get_option('libdir') != 'lib' + warning('build option "libdir" = "' + get_option('libdir') + '", which is not "lib"; if you experience any issues, please report them') +endif +if get_option('datadir') != 'share' + error('build option "datadir" must be "share", but it is set to "' + get_option('datadir') + '"') +endif + # meson modules pkg = import('pkgconfig') fs = import('fs') @@ -142,6 +150,7 @@ project_inc = include_directories('src') project_libs = [] project_deps = declare_dependency(dependencies: [ fmt_dep, yamlcpp_dep, hipo_dep ] ) # do NOT include ROOT here project_etc = get_option('sysconfdir') / meson.project_name() +project_data = get_option('datadir') / meson.project_name() project_test_env = environment() project_pkg_vars = [ 'bindir=' + '${prefix}' / get_option('bindir'), @@ -172,7 +181,9 @@ project_test_env.set( # set preprocessor macros add_project_arguments( - '-DIGUANA_ETCDIR="' + get_option('prefix') / project_etc + '"', + '-DIGUANA_PREFIX="' + get_option('prefix') + '"', + '-DIGUANA_ETCDIR="' + project_etc + '"', + '-DIGUANA_DATADIR="' + project_data + '"', language: ['cpp'], ) diff --git a/src/iguana/algorithms/Algorithm.cc b/src/iguana/algorithms/Algorithm.cc index 900e03eb..d845ff89 100644 --- a/src/iguana/algorithms/Algorithm.cc +++ b/src/iguana/algorithms/Algorithm.cc @@ -112,6 +112,17 @@ namespace iguana { /////////////////////////////////////////////////////////////////////////////// + std::string Algorithm::GetDataFile(std::string const& name) + { + if(!m_datafile_reader) { + m_datafile_reader = std::make_unique(ConfigFileReader::ConvertAlgoNameToConfigDir(m_class_name), "data|" + m_name); + m_datafile_reader->SetLogLevel(m_log->GetLevel()); + } + return m_datafile_reader->FindFile(name); + } + + /////////////////////////////////////////////////////////////////////////////// + void Algorithm::ParseYAMLConfig() { if(!m_yaml_config) { diff --git a/src/iguana/algorithms/Algorithm.h b/src/iguana/algorithms/Algorithm.h index 7c198aa2..77f6e814 100644 --- a/src/iguana/algorithms/Algorithm.h +++ b/src/iguana/algorithms/Algorithm.h @@ -8,6 +8,7 @@ #include "iguana/algorithms/AlgorithmBoilerplate.h" #include "iguana/services/YAMLReader.h" +#include "iguana/services/DataFileReader.h" namespace iguana { @@ -136,6 +137,11 @@ namespace iguana { /// @param name the directory name void SetConfigDirectory(std::string const& name); + /// Get the full path to a data file, such as a machine-learning model + /// @param name the name of the file; if found in the user's current working directory (`./`), that will be the file that is used; + /// otherwise the _installed_ file (in `$IGUANA/share/`) will be used by default + std::string GetDataFile(std::string const& name); + protected: // methods /// Parse YAML configuration files. Sets `m_yaml_config`. @@ -226,6 +232,9 @@ namespace iguana { /// YAML reader std::unique_ptr m_yaml_config; + + /// Data file reader + std::unique_ptr m_datafile_reader; }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc index 56a3ed08..598d2cc2 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -16,7 +16,9 @@ namespace iguana::clas12 { o_weightfile = GetOptionScalar("weightfile");//Obtain weightfile from config file o_cut = GetOptionScalar("cut"); - + // load the weights file + o_weightfile_fullpath = GetDataFile(o_weightfile); + m_log->Debug("Loaded weight file {}", o_weightfile_fullpath); //Get Banks that we are going to use b_particle = GetBankIndex(banks, "REC::Particle"); @@ -145,7 +147,7 @@ namespace iguana::clas12 { m_log->Debug("Add variables to readerTMVA"); - readerTMVA->BookMVA( "BDT", o_weightfile ); + readerTMVA->BookMVA( "BDT", o_weightfile_fullpath ); m_log->Debug("TMVA method booked"); diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index c343ba4c..a18426ad 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -77,6 +77,7 @@ namespace iguana::clas12 { /// Example integer configuration option int o_pid; std::string o_weightfile; + std::string o_weightfile_fullpath; double o_cut; }; diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Config.yaml b/src/iguana/algorithms/clas12/LeptonIDFilter/Config.yaml index aaa6d6e5..0c116994 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Config.yaml +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Config.yaml @@ -1,4 +1,4 @@ clas12::LeptonIDFilter: pid: -11 - weightfile: "/weights/9_BDT_positrons_S19.weights.xml" + weightfile: "weights/9_BDT_positrons_S19.weights.xml" cut: 0.0 diff --git a/src/iguana/algorithms/meson.build b/src/iguana/algorithms/meson.build index 873bf83c..1dd88905 100644 --- a/src/iguana/algorithms/meson.build +++ b/src/iguana/algorithms/meson.build @@ -27,6 +27,7 @@ algo_dict = [ # 'validator_needs_ROOT': bool # whether this validator needs ROOT or not (default=true) # 'add_algorithm_sources': list[str] # list of additional algorithm source files (default=[]) # 'add_algorithm_headers': list[str] # list of additional algorithm header files (default=[]) +# 'add_algorithm_data': list[str] # list of additional files to install (default=[]) # 'add_validator_sources': list[str] # list of additional validator source files (default=[]) # 'add_validator_headers': list[str] # list of additional validator header files (default=[]) # 'test_args': { dict[str], # if excluded, tests won't run for this algorithm @@ -103,6 +104,9 @@ algo_dict += [ 'has_c_bindings': false, 'algorithm_needs_ROOT': true, 'has_validator': false, + 'add_algorithm_data': [ + 'weights/9_BDT_positrons_S19.weights.xml', + ], 'test_args': { 'banks': ['REC::Particle', 'REC::Calorimeter'] }, }, ] @@ -110,6 +114,7 @@ algo_dict += [ # make lists of objects to build; inclusion depends on whether ROOT is needed or not, and if we have ROOT algo_sources = [] algo_headers = [] +algo_data = [] algo_configs = [] vdor_sources = [] vdor_headers = [] @@ -127,7 +132,7 @@ foreach algo : algo_dict # algorithms: if (algo_needs_ROOT and ROOT_dep.found()) or not algo_needs_ROOT - # sources and headers + # sources, headers, and data algo_sources += algo_dir / 'Algorithm.cc' algo_headers += algo_dir / 'Algorithm.h' foreach src_file : algo.get('add_algorithm_sources', []) @@ -136,6 +141,9 @@ foreach algo : algo_dict foreach src_file : algo.get('add_algorithm_headers', []) algo_headers += algo_dir / src_file endforeach + foreach src_file : algo.get('add_algorithm_data', []) + algo_data += algo_dir / src_file + endforeach # C/Fortran bindings if get_option('bind_fortran') @@ -189,6 +197,13 @@ install_headers( subdir: meson.project_name() / 'algorithms', preserve_path: true, ) +foreach algo_datum : algo_data + install_data( + algo_data, + install_dir: project_data / 'algorithms', + preserve_path: true, + ) +endforeach project_libs += algo_lib # build and install validators diff --git a/src/iguana/services/ConfigFileReader.cc b/src/iguana/services/ConfigFileReader.cc index a97fd0b9..86e0500a 100644 --- a/src/iguana/services/ConfigFileReader.cc +++ b/src/iguana/services/ConfigFileReader.cc @@ -5,35 +5,37 @@ namespace iguana { - ConfigFileReader::ConfigFileReader(std::string_view name) + ConfigFileReader::ConfigFileReader(std::string_view name, bool set_default_dirs) : Object(name) { - // the algorithms need to know where the config files are; - // first, add config files from installation prefix; since this - // is added first, it's the lowest priority in the configuration - // search path - AddDirectory(GetConfigInstallationPrefix()); - // next, add `IGUANA_CONFIG_PATH` paths, which provides: - // - user override of the configuration path(s) - // - a fallback, if `GetConfigInstallationPrefix` is wrong, which happens - // if the Iguana installation is relocated - auto user_paths_env_var = std::getenv("IGUANA_CONFIG_PATH"); - if(user_paths_env_var != nullptr) { - std::istringstream user_paths_stream(user_paths_env_var); - std::string user_path_token; - decltype(m_directories) user_paths; - while(getline(user_paths_stream, user_path_token, ':')) // tokenize `IGUANA_CONFIG_PATH` - user_paths.push_front(user_path_token); - for(auto const& user_path : user_paths) // add the paths in the correct order - AddDirectory(user_path); - // after these default paths have been added, the user - // may still override by calling `AddDirectory` etc. themselves + if(set_default_dirs) { + // the algorithms need to know where the config files are; + // first, add config files from installation prefix; since this + // is added first, it's the lowest priority in the configuration + // search path + AddDirectory(GetConfigInstallationPrefix()); + // next, add `IGUANA_CONFIG_PATH` paths, which provides: + // - user override of the configuration path(s) + // - a fallback, if `GetConfigInstallationPrefix` is wrong, which happens + // if the Iguana installation is relocated + auto user_paths_env_var = std::getenv("IGUANA_CONFIG_PATH"); + if(user_paths_env_var != nullptr) { + std::istringstream user_paths_stream(user_paths_env_var); + std::string user_path_token; + decltype(m_directories) user_paths; + while(getline(user_paths_stream, user_path_token, ':')) // tokenize `IGUANA_CONFIG_PATH` + user_paths.push_front(user_path_token); + for(auto const& user_path : user_paths) // add the paths in the correct order + AddDirectory(user_path); + // after these default paths have been added, the user + // may still override by calling `AddDirectory` etc. themselves + } } } std::string ConfigFileReader::GetConfigInstallationPrefix() { - return IGUANA_ETCDIR; + return std::string(IGUANA_PREFIX) + "/" + std::string(IGUANA_ETCDIR); } void ConfigFileReader::AddDirectory(std::string const& dir) @@ -88,13 +90,18 @@ namespace iguana { throw std::runtime_error("configuration file not found"); } - std::string ConfigFileReader::ConvertAlgoNameToConfigName(std::string_view algo_name, std::string_view ext) + std::string ConfigFileReader::ConvertAlgoNameToConfigDir(std::string_view algo_name) { std::string result = std::string(algo_name); std::string::size_type it = 0; while((it = result.find("::", it)) != std::string::npos) result.replace(it, 2, "/"); - return "algorithms/" + result + "/Config." + std::string(ext); + return "algorithms/" + result; + } + + std::string ConfigFileReader::ConvertAlgoNameToConfigName(std::string_view algo_name, std::string_view ext) + { + return ConvertAlgoNameToConfigDir(algo_name) + "/Config." + std::string(ext); } } diff --git a/src/iguana/services/ConfigFileReader.h b/src/iguana/services/ConfigFileReader.h index 6df04ad5..c37979ad 100644 --- a/src/iguana/services/ConfigFileReader.h +++ b/src/iguana/services/ConfigFileReader.h @@ -12,7 +12,8 @@ namespace iguana { public: /// @param name the name of this configuration file handler - ConfigFileReader(std::string_view name = "config"); + /// @param set_default_dirs if true, add the default configuration directories + ConfigFileReader(std::string_view name = "config", bool set_default_dirs = true); /// Get the config files' _fixed_ installation prefix /// @warning if the Iguana installation is _relocated_, this directory will **not** be correct, @@ -42,6 +43,11 @@ namespace iguana { /// @return the found configuration file (with the directory) std::string FindFile(std::string const& name); + /// Convert a full algorithm name to its corresponding default config file subdirectory + /// @param algo_name the algorithm name + /// @return the config file subdirectory + static std::string ConvertAlgoNameToConfigDir(std::string_view algo_name); + /// Convert a full algorithm name to its corresponding default config file name /// @param algo_name the algorithm name /// @param ext the file extension diff --git a/src/iguana/services/DataFileReader.cc b/src/iguana/services/DataFileReader.cc new file mode 100644 index 00000000..4e1f18e4 --- /dev/null +++ b/src/iguana/services/DataFileReader.cc @@ -0,0 +1,15 @@ +#include "DataFileReader.h" + +namespace iguana { + DataFileReader::DataFileReader(std::string_view datadir_subdir, std::string_view name) : ConfigFileReader(name, false) + { + // first, add the "fallback" directory; this is the lowest priority directory, relying + // on the environment variable '$IGUANA', in case the higher-priority, build-time path fails + auto user_prefix = std::getenv("IGUANA"); + if(user_prefix != nullptr) + AddDirectory(std::string(user_prefix) + "/" + std::string(IGUANA_DATADIR) + "/" + std::string(datadir_subdir)); + // then add the hard-coded path, which is set at build time; if Iguana installation is + // relocated, this path will be wrong and the above fallback will be used instead + AddDirectory(std::string(IGUANA_PREFIX) + "/" + std::string(IGUANA_DATADIR) + "/" + std::string(datadir_subdir)); + } +} diff --git a/src/iguana/services/DataFileReader.h b/src/iguana/services/DataFileReader.h new file mode 100644 index 00000000..a2d31143 --- /dev/null +++ b/src/iguana/services/DataFileReader.h @@ -0,0 +1,19 @@ +#pragma once + +#include "ConfigFileReader.h" + +namespace iguana { + + /// @brief A data file reader, for example, weights files for machine learning-dependent algorithms + class DataFileReader : public ConfigFileReader + { + + public: + + /// @param datadir_subdir the subdirectory within build option `datadir` where the file may be found + /// @param name of this reader (for `Logger`) + DataFileReader(std::string_view datadir_subdir = "", std::string_view name = "data_file"); + ~DataFileReader() {} + + }; +} diff --git a/src/iguana/services/meson.build b/src/iguana/services/meson.build index 805fc072..3867dbec 100644 --- a/src/iguana/services/meson.build +++ b/src/iguana/services/meson.build @@ -3,6 +3,7 @@ services_sources = [ 'Object.cc', 'ConfigFileReader.cc', 'YAMLReader.cc', + 'DataFileReader.cc', ] services_public_headers = [ @@ -10,6 +11,7 @@ services_public_headers = [ 'Object.h', 'ConfigFileReader.h', 'YAMLReader.h', + 'DataFileReader.h', ] services_lib = shared_library( From fcb35284456afc34dc941f26fc85e07a132f5204 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 1 Jul 2024 14:52:40 -0400 Subject: [PATCH 09/15] doc: some doxygen fixes --- src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index a18426ad..ece8efd4 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -4,7 +4,7 @@ namespace iguana::clas12 { - /// Set of inclusive kinematics variables + /// Set of lepton ID variables struct LeptonIDVars { double P; double Theta; @@ -23,7 +23,7 @@ namespace iguana::clas12 { /// /// Provide a more detailed description of your algorithm here. /// - /// @begin_doc_algo{Filter} + /// @begin_doc_algo{clas12::LeptonIDFilter | Filter} /// @input_banks{REC::Particle} /// @output_banks{REC::Particle} /// @end_doc From 57e20dfa340f587b445d8f067e52a3f72823d9d4 Mon Sep 17 00:00:00 2001 From: MarianaT27 <84591454+MarianaT27@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:58:13 -0400 Subject: [PATCH 10/15] Update src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc Co-authored-by: Christopher Dilks --- src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc index 598d2cc2..646e19ef 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -121,7 +121,8 @@ namespace iguana::clas12 { double LeptonIDFilter::CalculateScore(LeptonIDVars lepton_vars) const{ //Get TMVA reader - TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color:!Silent" ); + TString silent_opt = m_log->GetLevel() <= Logger::Level::trace ? "!Silent" : "Silent"; + TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color" + silent_opt ); // Create a set of variables and declare them to the reader Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; From db2d4417c87833eb66d428b3437d315baf8ec569 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 2 Jul 2024 09:03:38 -0400 Subject: [PATCH 11/15] fix: increase `algorithm` test timeout --- src/iguana/tests/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/src/iguana/tests/meson.build b/src/iguana/tests/meson.build index d525f5c4..5621f325 100644 --- a/src/iguana/tests/meson.build +++ b/src/iguana/tests/meson.build @@ -43,6 +43,7 @@ foreach algo : algo_dict suite: ['algorithm'], args: test_args + [ '-n', get_option('test_num_events') ], env: project_test_env, + timeout: 120, ) benchmark( 'benchmark-algorithm-' + test_name_algo, From 703a59376adb1f5ead1ac0e2455a4dc6808ff41a Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Tue, 2 Jul 2024 10:22:01 -0400 Subject: [PATCH 12/15] Added: documentation descriptions --- .../algorithms/clas12/LeptonIDFilter/Algorithm.cc | 3 ++- .../algorithms/clas12/LeptonIDFilter/Algorithm.h | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc index 646e19ef..477f7605 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -125,7 +125,7 @@ namespace iguana::clas12 { TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color" + silent_opt ); // Create a set of variables and declare them to the reader Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; - + @doxygen_off P=lepton_vars.P; Theta=lepton_vars.Theta; Phi=lepton_vars.Phi; @@ -135,6 +135,7 @@ namespace iguana::clas12 { m2PCAL=lepton_vars.m2pcal; m2ECIN=lepton_vars.m2ecin; m2ECOUT=lepton_vars.m2ecout; + @doxygen_on readerTMVA->AddVariable( "P",&P ); readerTMVA->AddVariable( "Theta",&Theta); diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index ece8efd4..94c15c4a 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -19,18 +19,19 @@ namespace iguana::clas12 { }; /// - /// @brief_algo This is a template algorithm, used as an example showing how to write an algorithm. + /// @brief_algo Filter the leptons from the pion contamination using TMVA models /// - /// Provide a more detailed description of your algorithm here. + /// For each lepton, either positron or electron, it takes some variables from `REC::Particle` (P, Theta and Phi) and `REC::Particle` (Sampling fraction and second moments). + /// Using those variables, it call the TMVA method using the weight file, and it computes a score. By a pplying a cut to the score we can separate leptons from pions. /// /// @begin_doc_algo{clas12::LeptonIDFilter | Filter} - /// @input_banks{REC::Particle} - /// @output_banks{REC::Particle} + /// @input_banks{REC::Particle,REC::Calorimeter} /// @end_doc /// /// @begin_doc_config - /// @config_param{exampleInt | int | an example `integer` configuration parameter} - /// @config_param{exampleDouble | double | an example `double` configuration parameter} + /// @config_param{o_pid | int | PID of the particle; -11 for positrons and 11 for electrons} + /// @config_param{o_weightfile | std::string | Location of the weight file of the classifier} + /// @config_param{o_cut | double | Value of the score to apply the cut. The algorith will keep all particles that have a score grater than ths value} /// @end_doc class LeptonIDFilter : public Algorithm { From e576c70fd98d35e58f178d951c8ca6cfac3a383c Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Tue, 2 Jul 2024 12:14:31 -0400 Subject: [PATCH 13/15] Moved declaration of TMVAReader to header; Added documentation --- .../clas12/LeptonIDFilter/Algorithm.cc | 23 +---- .../clas12/LeptonIDFilter/Algorithm.h | 83 +++++++++++++++---- 2 files changed, 66 insertions(+), 40 deletions(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc index 477f7605..207328b8 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -120,12 +120,7 @@ namespace iguana::clas12 { double LeptonIDFilter::CalculateScore(LeptonIDVars lepton_vars) const{ - //Get TMVA reader - TString silent_opt = m_log->GetLevel() <= Logger::Level::trace ? "!Silent" : "Silent"; - TMVA::Reader *readerTMVA = new TMVA::Reader( "!Color" + silent_opt ); - // Create a set of variables and declare them to the reader - Float_t P, Theta, Phi, PCAL,ECIN,ECOUT,m2PCAL,m2ECIN,m2ECOUT; - @doxygen_off + ///Assing variables from lepton_vars for TMVA method P=lepton_vars.P; Theta=lepton_vars.Theta; Phi=lepton_vars.Phi; @@ -135,24 +130,8 @@ namespace iguana::clas12 { m2PCAL=lepton_vars.m2pcal; m2ECIN=lepton_vars.m2ecin; m2ECOUT=lepton_vars.m2ecout; - @doxygen_on - - readerTMVA->AddVariable( "P",&P ); - readerTMVA->AddVariable( "Theta",&Theta); - readerTMVA->AddVariable( "Phi",&Phi); - readerTMVA->AddVariable( "SFPCAL",&PCAL); - readerTMVA->AddVariable( "SFECIN",&ECIN); - readerTMVA->AddVariable( "SFECOUT",&ECOUT ); - readerTMVA->AddVariable( "m2PCAL",&m2PCAL); - readerTMVA->AddVariable( "m2ECIN",&m2ECIN); - readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); m_log->Debug("Add variables to readerTMVA"); - - readerTMVA->BookMVA( "BDT", o_weightfile_fullpath ); - - m_log->Debug("TMVA method booked"); - auto score=readerTMVA->EvaluateMVA("BDT"); return score; diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index 94c15c4a..340b5b59 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -3,21 +3,6 @@ #include "iguana/algorithms/Algorithm.h" namespace iguana::clas12 { - - /// Set of lepton ID variables - struct LeptonIDVars { - double P; - double Theta; - double Phi; - double SFpcal; - double SFecin; - double SFecout; - double m2pcal; - double m2ecin; - double m2ecout; - double score; - }; - /// /// @brief_algo Filter the leptons from the pion contamination using TMVA models /// @@ -70,15 +55,77 @@ namespace iguana::clas12 { private: - - /// `hipo::banklist` index for the particle bank (as an example) + ///Struct to store variables + struct LeptonIDVars { + /// @brief momentum + double P; + /// @brief Theta angle + double Theta; + /// @brief Phi angle + double Phi; + /// @brief Sampling fraction on the PCAL + double SFpcal; + /// @brief Sampling fraction on the ECIN + double SFecin; + /// @brief Sampling fraction on the ECOUT + double SFecout; + /// @brief Second-momenta of PCAL + double m2pcal; + /// @brief Second-momenta of ECIN + double m2ecin; + /// @brief Second-momenta of ECOUT + double m2ecout; + /// @brief Score + double score; + }; + + /// `hipo::banklist` hipo::banklist::size_type b_particle; hipo::banklist::size_type b_calorimeter; - /// Example integer configuration option + //Create TMVA reader + TMVA::Reader *readerTMVA = new TMVA::Reader(); + + ///Set of variables for the reader + ///Momentum + Float_t P; + ///Theta angle + Float_t Theta; + ///Phi angle + Float_t Phi; + ///Sampling fraction on the PCAL + Float_t PCAL; + ///Sampling fraction on the ECIN + Float_t ECIN; + ///Sampling fraction on the ECOUT + Float_t ECOUT; + ///Second-momenta of PCAL + Float_t m2PCAL; + ///Second-momenta of ECIN + Float_t m2ECIN; + ///Second-momenta of ECOUT + Float_t m2ECOUT; + + /// @brief Add variables to the readerTMVA + readerTMVA->AddVariable( "P",&P ); + readerTMVA->AddVariable( "Theta",&Theta); + readerTMVA->AddVariable( "Phi",&Phi); + readerTMVA->AddVariable( "SFPCAL",&PCAL); + readerTMVA->AddVariable( "SFECIN",&ECIN); + readerTMVA->AddVariable( "SFECOUT",&ECOUT ); + readerTMVA->AddVariable( "m2PCAL",&m2PCAL); + readerTMVA->AddVariable( "m2ECIN",&m2ECIN); + readerTMVA->AddVariable( "m2ECOUT",&m2ECOUT); + + readerTMVA->BookMVA( "BDT", o_weightfile_fullpath ); + + + /// pid of the lepton int o_pid; + /// Location of the weight file std::string o_weightfile; std::string o_weightfile_fullpath; + /// Value of the cut double o_cut; }; From f41b895daecdd49e38a0786ecb59ff682f806bcd Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Tue, 2 Jul 2024 14:24:39 -0400 Subject: [PATCH 14/15] Fixed some errors --- .../clas12/LeptonIDFilter/Algorithm.cc | 1 - .../clas12/LeptonIDFilter/Algorithm.h | 49 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc index 207328b8..d1e31599 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.cc @@ -2,7 +2,6 @@ #include #include -#include namespace iguana::clas12 { diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index 340b5b59..9b088cf3 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -1,6 +1,31 @@ #pragma once #include "iguana/algorithms/Algorithm.h" +#include + +///Struct to store variables + struct LeptonIDVars { + /// @brief momentum + double P; + /// @brief Theta angle + double Theta; + /// @brief Phi angle + double Phi; + /// @brief Sampling fraction on the PCAL + double SFpcal; + /// @brief Sampling fraction on the ECIN + double SFecin; + /// @brief Sampling fraction on the ECOUT + double SFecout; + /// @brief Second-momenta of PCAL + double m2pcal; + /// @brief Second-momenta of ECIN + double m2ecin; + /// @brief Second-momenta of ECOUT + double m2ecout; + /// @brief Score + double score; + }; namespace iguana::clas12 { /// @@ -55,29 +80,7 @@ namespace iguana::clas12 { private: - ///Struct to store variables - struct LeptonIDVars { - /// @brief momentum - double P; - /// @brief Theta angle - double Theta; - /// @brief Phi angle - double Phi; - /// @brief Sampling fraction on the PCAL - double SFpcal; - /// @brief Sampling fraction on the ECIN - double SFecin; - /// @brief Sampling fraction on the ECOUT - double SFecout; - /// @brief Second-momenta of PCAL - double m2pcal; - /// @brief Second-momenta of ECIN - double m2ecin; - /// @brief Second-momenta of ECOUT - double m2ecout; - /// @brief Score - double score; - }; + /// `hipo::banklist` hipo::banklist::size_type b_particle; From bcdfb1c69f139c8ce76da8ab00d4e1170b01cc45 Mon Sep 17 00:00:00 2001 From: MarianaT27 Date: Tue, 2 Jul 2024 15:44:24 -0400 Subject: [PATCH 15/15] Fixed more errors --- .../clas12/LeptonIDFilter/Algorithm.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h index 9b088cf3..5c776923 100644 --- a/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/LeptonIDFilter/Algorithm.h @@ -78,14 +78,6 @@ namespace iguana::clas12 { /// @returns bool, true if score>=cut, false otherwise bool Filter(double score) const; - - private: - - - /// `hipo::banklist` - hipo::banklist::size_type b_particle; - hipo::banklist::size_type b_calorimeter; - //Create TMVA reader TMVA::Reader *readerTMVA = new TMVA::Reader(); @@ -122,6 +114,16 @@ namespace iguana::clas12 { readerTMVA->BookMVA( "BDT", o_weightfile_fullpath ); + + private: + + + /// `hipo::banklist` + hipo::banklist::size_type b_particle; + hipo::banklist::size_type b_calorimeter; + + + /// pid of the lepton int o_pid;