-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Campaing to fix tests / compilation warnings (#93)
* Adjusting CreateCaloJet * Moving ClusterJet to common directory * Formatting * Adjusting CreateTruthJet and FilterTruthParticlesForGenJets * Debugging prints * Moving debug printout elsewhere * Executing external process * Using edm4hep::labels everywhere * Removing from target creation * Using fastjet link directories * Removed unnecessary messages * Fixed missing comma
- Loading branch information
Showing
21 changed files
with
465 additions
and
482 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
################################################################################ | ||
# Package: RecCaloCommon | ||
################################################################################ | ||
|
||
file(GLOB _sources src/*.cpp ) | ||
|
||
gaudi_add_library(RecCaloCommon | ||
SOURCES ${_sources} | ||
LINK Gaudi::GaudiKernel | ||
EDM4HEP::edm4hep | ||
${FASTJET_LIBRARIES} | ||
) | ||
|
||
target_include_directories(RecCaloCommon PUBLIC ${FASTJET_INCLUDE_DIRS}) | ||
target_link_directories(RecCaloCommon PUBLIC ${FASTJET_LIBRARY_DIRS}) | ||
|
||
install(TARGETS RecCaloCommon | ||
EXPORT k4RecCalorimeterTargets | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib | ||
COMPONENT dev | ||
) |
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,81 @@ | ||
#ifndef RECCALOCOMMON_CLUSTERJET_H | ||
#define RECCALOCOMMON_CLUSTERJET_H | ||
|
||
// std | ||
#include <map> | ||
#include <vector> | ||
|
||
// Gaudi | ||
#include "GaudiAlg/GaudiAlgorithm.h" | ||
|
||
#include "fastjet/JetDefinition.hh" | ||
|
||
// EDM4hep | ||
#include "edm4hep/ClusterCollection.h" | ||
|
||
namespace k4::recCalo { | ||
|
||
class ClusterInfo : public fastjet::PseudoJet::UserInfoBase { | ||
public: | ||
ClusterInfo(const int &index) : _index(index) {} | ||
int index() const { return _index; } | ||
|
||
protected: | ||
int _index; | ||
}; | ||
|
||
/** @class ClusterJet | ||
* k4RecCalorimeter/RecCalorimeter/src/components/ClusterJet.h | ||
* | ||
* Helper class for reconstructing jets, used to avoid code duplication in the | ||
* classes that require specific input types. It takes a vector of | ||
* fastjet::PseudoJets as inputs, and returns the a vector of pseudojets after | ||
* clustering. | ||
* | ||
* JetAlg: A string corresponding to the jet algorithm for clustering | ||
* JetRadius: The radius of the jets being clustered | ||
* MinPt: The pT threshold below which jets are ignored | ||
* isExclusiveClustering: 1 if jets should use an exclusive clustering, 0 | ||
* otherwise clusterArgs: Any other clustering arguments, such as the number of | ||
* jets for exclusive clustering. This is not used everywhere, so check the code | ||
* to make sure it is implemented for your use-case. | ||
* | ||
* @author Jennifer Roloff | ||
* @date 2024-7 | ||
*/ | ||
|
||
class ClusterJet { | ||
public: | ||
ClusterJet(std::string jetAlg, double jetRadius, | ||
int isExclusiveClustering = 0, double minPt = 0, | ||
int clusterArgs = 0); | ||
StatusCode initialize(); | ||
~ClusterJet() { | ||
if (m_clustSeq) | ||
delete m_clustSeq; | ||
} | ||
|
||
std::vector<fastjet::PseudoJet> | ||
cluster(const std::vector<fastjet::PseudoJet> clustersPJ); | ||
|
||
private: | ||
std::map<std::string, fastjet::JetAlgorithm> m_jetAlgMap = { | ||
{"kt", fastjet::JetAlgorithm::kt_algorithm}, | ||
{"cambridge", fastjet::JetAlgorithm::cambridge_algorithm}, | ||
{"antikt", fastjet::JetAlgorithm::antikt_algorithm}, | ||
{"genkt", fastjet::JetAlgorithm::genkt_algorithm}, | ||
{"ee_kt", fastjet::JetAlgorithm::ee_kt_algorithm}, | ||
{"ee_genkt", fastjet::JetAlgorithm::ee_genkt_algorithm}, | ||
}; | ||
|
||
std::string m_jetAlg = "antikt"; | ||
double m_jetRadius = 0.4; | ||
int m_isExclusiveClustering = 0; // Inclusive clustering by default | ||
double m_minPt = 10; // Only relevant for inclusive clustering | ||
int m_njets = 0; // Only relevant for exclusive clustering | ||
|
||
fastjet::ClusterSequence *m_clustSeq; | ||
}; | ||
|
||
} /* namespace k4::recCalo */ | ||
#endif /* RECCALOCOMMON_CLUSTERJET_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,51 @@ | ||
#include "RecCaloCommon/ClusterJet.h" | ||
|
||
namespace k4::recCalo { | ||
|
||
ClusterJet::ClusterJet(std::string jetAlg, double jetRadius, | ||
int isExclusiveClustering, double minPt, int njets) | ||
: m_jetAlg(jetAlg), m_jetRadius(jetRadius), | ||
m_isExclusiveClustering(isExclusiveClustering), m_minPt(minPt), | ||
m_njets(njets) { | ||
m_clustSeq = nullptr; | ||
} | ||
|
||
StatusCode ClusterJet::initialize() { | ||
if (m_jetAlgMap.find(m_jetAlg) == m_jetAlgMap.end()) { | ||
std::cout << "ERROR: " | ||
<< " is not in the list of supported jet algorithms" << std::endl; | ||
; | ||
return StatusCode::FAILURE; | ||
} | ||
if (m_isExclusiveClustering > 1) { | ||
std::cout << "ERROR: " | ||
<< "Clustering of " << m_isExclusiveClustering | ||
<< " is currently not supported" << std::endl; | ||
; | ||
return StatusCode::FAILURE; | ||
} | ||
return StatusCode::SUCCESS; | ||
} | ||
|
||
std::vector<fastjet::PseudoJet> | ||
ClusterJet::cluster(const std::vector<fastjet::PseudoJet> clustersPJ) { | ||
std::vector<fastjet::PseudoJet> jets; | ||
|
||
fastjet::JetDefinition *jetDef = | ||
new fastjet::JetDefinition(m_jetAlgMap.at(m_jetAlg), m_jetRadius); | ||
if (m_clustSeq) | ||
delete m_clustSeq; | ||
m_clustSeq = new fastjet::ClusterSequence(clustersPJ, *jetDef); | ||
|
||
// Note: initialize has already checked if m_isExclusiveClustering has the | ||
// right range | ||
if (m_isExclusiveClustering == 0) { | ||
jets = fastjet::sorted_by_pt(m_clustSeq->inclusive_jets(m_minPt)); | ||
} else if (m_isExclusiveClustering == 1) { | ||
jets = fastjet::sorted_by_pt(m_clustSeq->exclusive_jets(m_njets)); | ||
} | ||
|
||
return jets; | ||
} | ||
|
||
} /* namespace k4::recCalo */ |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.