Skip to content

Commit

Permalink
Hash the algoName to get the algoID by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed May 16, 2024
1 parent 0f286fc commit f37b595
Show file tree
Hide file tree
Showing 6 changed files with 533 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/utils/test_PIDHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ TEST_CASE("PIDHandler from Frame w/ metadata", "[pid_utils]") {

const auto pidInfo = utils::PIDHandler::getAlgoInfo(metadata, "particleIds_1").value();
REQUIRE(pidInfo.algoName == "pidAlgo_1");
REQUIRE(pidInfo.algoType == 42);
REQUIRE(pidInfo.algoType() == 42);
REQUIRE(pidInfo.paramNames.size() == 2);
REQUIRE(pidInfo.paramNames[0] == "first_param");
REQUIRE(pidInfo.paramNames[1] == "second_param");
Expand Down
1 change: 1 addition & 0 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_compile_features(kinematics INTERFACE cxx_std_17)

set(utils_sources
src/ParticleIDUtils.cc
src/MurmurHash3.cpp
)

add_library(utils SHARED ${utils_sources})
Expand Down
18 changes: 17 additions & 1 deletion utils/include/edm4hep/utils/ParticleIDUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@ namespace edm4hep::utils {

/// A simple struct bundling relevant metadata for a ParticleID collection
struct ParticleIDMeta {
ParticleIDMeta(const std::string& algName, int32_t algType, const std::vector<std::string>& parNames);
ParticleIDMeta(const std::string& algName, const std::vector<std::string>& parNames);

~ParticleIDMeta() = default;
ParticleIDMeta() = default;
ParticleIDMeta(const ParticleIDMeta&) = default;
ParticleIDMeta& operator=(const ParticleIDMeta&) = default;
ParticleIDMeta(ParticleIDMeta&&) = default;
ParticleIDMeta& operator=(ParticleIDMeta&&) = default;

std::string algoName{}; ///< The name of the algorithm
int32_t algoType{0}; ///< The (user defined) algorithm type
std::vector<std::string> paramNames{}; ///< The names of the parameters

int32_t algoType() const {
return m_algoType;
}

private:
int32_t m_algoType{0}; ///< The (user defined) algorithm type
};

/// Get the index of the parameter in the passed ParticleID meta info
Expand Down
Loading

0 comments on commit f37b595

Please sign in to comment.