Skip to content

Commit

Permalink
fix: do not include GBT models in algorithm header
Browse files Browse the repository at this point in the history
Instead, include them in the source file, so that the models don't need
to be installed (they are just in the library).

Closes #310
  • Loading branch information
c-dilks committed Dec 2, 2024
1 parent f1c7259 commit 7e5f0ec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
27 changes: 27 additions & 0 deletions src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
#include "Algorithm.h"
#include "iguana/algorithms/TypeDefs.h"
#include "models/RGA_inbending_pass1.cpp"
#include "models/RGA_outbending_pass1.cpp"
#include "models/RGA_inbending_pass2.cpp"
#include "models/RGA_outbending_pass2.cpp"
#include "models/RGC_Summer2022_pass1.cpp"

namespace iguana::clas12 {

REGISTER_IGUANA_ALGORITHM(PhotonGBTFilter);

// Map for the GBT Models to use depending on pass and run number
std::map<std::tuple<int, int, int>, std::function<double(std::vector<float> const &)>> const PhotonGBTFilter::modelMap = {
{{5032, 5332, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Fall2018 RGA Inbending
{{5032, 5332, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Fall2018 RGA Inbending
{{5333, 5666, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass1(data); }}, // Fall2018 RGA Outbending
{{5333, 5666, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass2(data); }}, // Fall2018 RGA Outbending
{{6616, 6783, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Spring2019 RGA Inbending
{{6616, 6783, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Spring2019 RGA Inbending
{{6156, 6603, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Spring2019 RGB Inbending
{{6156, 6603, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Spring2019 RGB Inbending
{{11093, 11283, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass1(data); }}, // Fall2019 RGB Outbending
{{11093, 11283, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass2(data); }}, // Fall2019 RGB Outbending
{{11284, 11300, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Fall2019 RGB BAND Inbending
{{11284, 11300, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Fall2019 RGB BAND Inbending
{{11323, 11571, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Spring2020 RGB Inbending
{{11323, 11571, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Spring2020 RGB Inbending
{{16042, 16772, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGC_Summer2022_pass1(data); }}, // Summer2022 RGC Inbending
{{16042, 16772, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGC_Summer2022_pass1(data); }} // Summer2022 RGC Inbending (no pass2 currently)
};

void PhotonGBTFilter::Start(hipo::banklist& banks)
{

ParseYAMLConfig();

b_particle = GetBankIndex(banks, "REC::Particle");
Expand Down
25 changes: 1 addition & 24 deletions src/iguana/algorithms/clas12/PhotonGBTFilter/Algorithm.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#pragma once

#include "iguana/algorithms/Algorithm.h"
#include "iguana/algorithms/TypeDefs.h"
#include "models/RGA_inbending_pass1.cpp"
#include "models/RGA_outbending_pass1.cpp"
#include "models/RGA_inbending_pass2.cpp"
#include "models/RGA_outbending_pass2.cpp"
#include "models/RGC_Summer2022_pass1.cpp"

#include <Math/Vector3D.h>
#include <Math/VectorUtil.h>
Expand Down Expand Up @@ -125,24 +119,7 @@ namespace iguana::clas12 {
int o_pass = 1;

/// Map for the GBT Models to use depending on pass and run number
const std::map<std::tuple<int, int, int>, std::function<double(std::vector<float> const &)>> modelMap = {
{{5032, 5332, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Fall2018 RGA Inbending
{{5032, 5332, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Fall2018 RGA Inbending
{{5333, 5666, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass1(data); }}, // Fall2018 RGA Outbending
{{5333, 5666, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass2(data); }}, // Fall2018 RGA Outbending
{{6616, 6783, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Spring2019 RGA Inbending
{{6616, 6783, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Spring2019 RGA Inbending
{{6156, 6603, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Spring2019 RGB Inbending
{{6156, 6603, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Spring2019 RGB Inbending
{{11093, 11283, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass1(data); }}, // Fall2019 RGB Outbending
{{11093, 11283, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_outbending_pass2(data); }}, // Fall2019 RGB Outbending
{{11284, 11300, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Fall2019 RGB BAND Inbending
{{11284, 11300, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Fall2019 RGB BAND Inbending
{{11323, 11571, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass1(data); }}, // Spring2020 RGB Inbending
{{11323, 11571, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGA_inbending_pass2(data); }}, // Spring2020 RGB Inbending
{{16042, 16772, 1}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGC_Summer2022_pass1(data); }}, // Summer2022 RGC Inbending
{{16042, 16772, 2}, [](std::vector<float> const &data) { return ApplyCatboostModel_RGC_Summer2022_pass1(data); }} // Summer2022 RGC Inbending (no pass2 currently)
};
static std::map<std::tuple<int, int, int>, std::function<double(std::vector<float> const &)>> const modelMap;
};

}

0 comments on commit 7e5f0ec

Please sign in to comment.