-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PodioSource: Adding remove, merge and createPseudoJets analyzers (#427)
* PodioSource: Adding remove, merge and createPseudoJets analyzers * Fixing formatting * Using for loop instead of std::find * Explicitelly turning on WITH_PODIO_DATASOURCE * Adding EDM4HEP::edm4hep * Building FCCAnalyses as shared library * Formatting
- Loading branch information
Showing
10 changed files
with
345 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
analyzers/dataframe/FCCAnalyses/JetClusteringUtilsSource.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef ANALYZERS_SOURCE_JET_CLUSTERING_UTILS_H | ||
#define ANALYZERS_SOURCE_JET_CLUSTERING_UTILS_H | ||
|
||
// EDM4hep | ||
#include "edm4hep/ReconstructedParticleCollection.h" | ||
|
||
// FastJet | ||
#include "FastJet/JetClustering.h" | ||
#include "fastjet/JetDefinition.hh" | ||
|
||
/** | ||
* @brief Jet clustering tools and utilities. | ||
* | ||
* This namespace contains a set of functions and utilities to perform jet | ||
* clustering using FastJet clustering algorithms with pseudoJets created from | ||
* EDM4hep collections of particles. | ||
* | ||
* Most of the analyzers work with FastJet pseudoJets. | ||
*/ | ||
namespace FCCAnalyses ::PodioSource ::JetClustering { | ||
/** | ||
* @brief Create FastJet pseudoJets for later usage by the jet clustering | ||
* algorithm(s). | ||
* | ||
* @param[in] inColl Input collection of the reconstructed particles. | ||
* @return Vector of pseudoJets. | ||
*/ | ||
std::vector<fastjet::PseudoJet> | ||
createPseudoJets(const edm4hep::ReconstructedParticleCollection &inColl); | ||
} // namespace FCCAnalyses::PodioSource::JetClustering | ||
|
||
#endif /* ANALYZERS_SOURCE_JET_CLUSTERING_UTILS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "FCCAnalyses/JetClusteringUtilsSource.h" | ||
|
||
namespace FCCAnalyses ::PodioSource ::JetClustering { | ||
// ---------------------------------------------------------------------------- | ||
std::vector<fastjet::PseudoJet> | ||
createPseudoJets(const edm4hep::ReconstructedParticleCollection &inColl) { | ||
std::vector<fastjet::PseudoJet> result; | ||
unsigned index = 0; | ||
for (const auto &particle : inColl) { | ||
result.emplace_back(particle.getMomentum().x, particle.getMomentum().y, | ||
particle.getMomentum().z, particle.getEnergy()); | ||
result.back().set_user_index(index); | ||
++index; | ||
} | ||
return result; | ||
} | ||
|
||
} // namespace FCCAnalyses::PodioSource::JetClustering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "FCCAnalyses/JetClusteringUtilsSource.h" | ||
|
||
// Catch2 | ||
#include "catch2/catch_test_macros.hpp" | ||
#include <catch2/catch_approx.hpp> | ||
|
||
TEST_CASE("create-pseudojets", "[JetClusteringUtilsSource]") { | ||
edm4hep::ReconstructedParticleCollection pColl; | ||
edm4hep::MutableReconstructedParticle p1; | ||
p1.setPDG(11); | ||
p1.setMomentum({20., 30., 40.}); | ||
p1.setMass(5.486e-4); | ||
p1.setEnergy(53.85164807); | ||
pColl.push_back(p1); | ||
edm4hep::MutableReconstructedParticle p2; | ||
p2.setPDG(13); | ||
p2.setMomentum({10., 20., 30.}); | ||
p2.setMass(1.05658e-1); | ||
p2.setEnergy(37.416723); | ||
pColl.push_back(p2); | ||
auto res = FCCAnalyses::PodioSource::JetClustering::createPseudoJets(pColl); | ||
REQUIRE(res.size() == 2); | ||
REQUIRE(res[0].px() == Catch::Approx(p1.getMomentum().x)); | ||
REQUIRE(res[0].py() == Catch::Approx(p1.getMomentum().y)); | ||
REQUIRE(res[0].pz() == Catch::Approx(p1.getMomentum().z)); | ||
REQUIRE(res[0].e() == Catch::Approx(p1.getEnergy())); | ||
REQUIRE(res[0].m2() == | ||
Catch::Approx(p1.getMass() * p1.getMass()).margin(1.e-3)); | ||
REQUIRE(res[1].px() == Catch::Approx(p2.getMomentum().x)); | ||
REQUIRE(res[1].py() == Catch::Approx(p2.getMomentum().y)); | ||
REQUIRE(res[1].pz() == Catch::Approx(p2.getMomentum().z)); | ||
REQUIRE(res[1].e() == Catch::Approx(p2.getEnergy())); | ||
REQUIRE(res[1].m2() == | ||
Catch::Approx(p2.getMass() * p2.getMass()).margin(1.e-3)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.