Skip to content

Commit d172821

Browse files
johnlajoiepre-commit-ci[bot]veprblruse-traveler
authored
Add FastJet plugin algorithms to jet reconstruction (#1378)
### Briefly, what does this PR introduce? This PR adds Centauro FastJet contributed algorithm ### What kind of change does this PR introduce? - [ ] Bug fix (issue #__) - [ X ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No ### Does this PR change default behavior? It does change the default behavior of the reconstruction in the generated and reconstructed Centauro jets will be created. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dmitry Kalinkin <[email protected]> Co-authored-by: Derek M Anderson <[email protected]>
1 parent eb2a13c commit d172821

File tree

9 files changed

+139
-3
lines changed

9 files changed

+139
-3
lines changed

cmake/FindFastJetContrib.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# * Locate FastJetContrib library Defines:
2+
#
3+
# FJCONTRIB_FOUND FJCONTRIB_INCLUDE_DIR FJCONTRIB_INCLUDE_DIRS (not cached)
4+
# FJCONTRIB_LIBRARY FJCONTRIB_LIBRARIES (not cached) FJCONTRIB_LIBRARY_DIRS (not
5+
# cached)
6+
7+
find_path(FJCONTRIB_INCLUDE_DIR fastjet/contrib/Centauro.hh
8+
HINTS $ENV{FASTJET_ROOT}/include ${FASTJET_ROOT_DIR}/include)
9+
10+
find_library(
11+
FJCONTRIB_LIBRARY
12+
NAMES fastjetcontribfragile
13+
HINTS $ENV{FASTJET_ROOT}/lib ${FASTJET_ROOT_DIR}/lib)
14+
15+
# handle the QUIETLY and REQUIRED arguments and set FJCONTRIB_FOUND to TRUE if
16+
# all listed variables are TRUE
17+
include(FindPackageHandleStandardArgs)
18+
find_package_handle_standard_args(FastJetContrib DEFAULT_MSG
19+
FJCONTRIB_INCLUDE_DIR FJCONTRIB_LIBRARY)
20+
21+
mark_as_advanced(FJCONTRIB_FOUND FJCONTRIB_INCLUDE_DIR FJCONTRIB_LIBRARY)
22+
23+
set(FJCONTRIB_INCLUDE_DIRS ${FJCONTRIB_INCLUDE_DIR})
24+
set(FJCONTRIB_LIBRARIES ${FJCONTRIB_LIBRARY})
25+
get_filename_component(FJCONTRIB_LIBRARY_DIRS ${FJCONTRIB_LIBRARY} PATH)

cmake/FindFastJetTools.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# * Locate FastJet Tools library Defines:
2+
#
3+
# FJTOOLS_FOUND FJTOOLS_INCLUDE_DIR FJTOOLS_INCLUDE_DIRS (not cached)
4+
# FJTOOLS_LIBRARY FJTOOLS_LIBRARIES (not cached) FJTOOLS_LIBRARY_DIRS (not
5+
# cached)
6+
7+
find_path(FJTOOLS_INCLUDE_DIR fastjet/tools/BackgroundEstimatorBase.hh
8+
HINTS $ENV{FASTJET_ROOT}/include ${FASTJET_ROOT_DIR}/include)
9+
10+
find_library(
11+
FJTOOLS_LIBRARY
12+
NAMES fastjettools
13+
HINTS $ENV{FASTJET_ROOT}/lib ${FASTJET_ROOT_DIR}/lib)
14+
15+
# handle the QUIETLY and REQUIRED arguments and set FJTOOLS_FOUND to TRUE if all
16+
# listed variables are TRUE
17+
include(FindPackageHandleStandardArgs)
18+
find_package_handle_standard_args(FastJetTools DEFAULT_MSG FJTOOLS_INCLUDE_DIR
19+
FJTOOLS_LIBRARY)
20+
21+
mark_as_advanced(FJTOOLS_FOUND FJTOOLS_INCLUDE_DIR FJTOOLS_LIBRARY)
22+
23+
set(FJTOOLS_INCLUDE_DIRS ${FJTOOLS_INCLUDE_DIR})
24+
set(FJTOOLS_LIBRARIES ${FJTOOLS_LIBRARY})
25+
get_filename_component(FJTOOLS_LIBRARY_DIRS ${FJTOOLS_LIBRARY} PATH)

cmake/jana_plugin.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,38 @@ macro(plugin_add_fastjet _name)
384384

385385
endmacro()
386386

387+
# Adds FastJetTools for a plugin
388+
macro(plugin_add_fastjettools _name)
389+
390+
if(NOT FJTOOLS_FOUND)
391+
find_package(FastJetTools REQUIRED)
392+
endif()
393+
394+
# Add include directories
395+
plugin_include_directories(${PLUGIN_NAME} SYSTEM PUBLIC
396+
${FJTOOLS_INCLUDE_DIRS})
397+
398+
# Add libraries
399+
plugin_link_libraries(${PLUGIN_NAME} ${FJTOOLS_LIBRARIES})
400+
401+
endmacro()
402+
403+
# Adds FastJetContrib for a plugin
404+
macro(plugin_add_fastjetcontrib _name)
405+
406+
if(NOT FJCONTRIB_FOUND)
407+
find_package(FastJetContrib REQUIRED)
408+
endif()
409+
410+
# Add include directories
411+
plugin_include_directories(${PLUGIN_NAME} SYSTEM PUBLIC
412+
${FJCONTRIB_INCLUDE_DIRS})
413+
414+
# Add libraries
415+
plugin_link_libraries(${PLUGIN_NAME} ${FJCONTRIB_LIBRARIES})
416+
417+
endmacro()
418+
387419
# Adds ONNX Runtime for a plugin
388420
macro(plugin_add_onnxruntime _name)
389421

src/algorithms/reco/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ plugin_add_dd4hep(${PLUGIN_NAME})
1616
plugin_add_cern_root(${PLUGIN_NAME})
1717
plugin_add_event_model(${PLUGIN_NAME})
1818
plugin_add_fastjet(${PLUGIN_NAME})
19+
plugin_add_fastjetcontrib(${PLUGIN_NAME})
20+
plugin_add_fastjettools(${PLUGIN_NAME})
1921

2022
# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then
2123
# correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds

src/algorithms/reco/JetReconstruction.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
2-
// Copyright (C) 2024 Derek Anderson, Zhongling Ji, Dmitry Kalinkin
2+
// Copyright (C) 2024 Derek Anderson, Zhongling Ji, Dmitry Kalinkin, John Lajoie
33

44
// class definition
55
#include "JetReconstruction.h"
@@ -12,6 +12,7 @@
1212
#include <fastjet/GhostedAreaSpec.hh>
1313
// for fastjet objects
1414
#include <fastjet/PseudoJet.hh>
15+
#include <fastjet/contrib/Centauro.hh>
1516
#include <fmt/core.h>
1617
#include <gsl/pointers>
1718
#include <stdexcept>
@@ -55,6 +56,20 @@ namespace eicrecon {
5556
// Choose jet definition based on no. of parameters
5657
switch (m_mapJetAlgo[m_cfg.jetAlgo]) {
5758

59+
// contributed algorithms
60+
case JetAlgorithm::plugin_algorithm:
61+
62+
// expand to other algorithms as required
63+
if(m_cfg.jetContribAlgo == "Centauro"){
64+
m_jet_plugin = std::make_unique<contrib::CentauroPlugin>(m_cfg.rJet);
65+
m_jet_def = std::make_unique<JetDefinition>(m_jet_plugin.get());
66+
}
67+
else {
68+
m_log->error(" Unknown contributed FastJet algorithm \"{}\" specified!", m_cfg.jetContribAlgo);
69+
throw JException("Invalid contributed FastJet algorithm");
70+
}
71+
break;
72+
5873
// 0 parameter algorithms
5974
case JetAlgorithm::ee_kt_algorithm:
6075
m_jet_def = std::make_unique<JetDefinition>(m_mapJetAlgo[m_cfg.jetAlgo], m_mapRecombScheme[m_cfg.recombScheme]);

src/algorithms/reco/JetReconstruction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
2-
// Copyright (C) 2024 Derek Anderson, Zhongling Ji, Dmitry Kalinkin
2+
// Copyright (C) 2024 Derek Anderson, Zhongling Ji, Dmitry Kalinkin, John Lajoie
33

44
#pragma once
55

@@ -60,6 +60,7 @@ namespace eicrecon {
6060
// fastjet components
6161
std::unique_ptr<fastjet::JetDefinition> m_jet_def;
6262
std::unique_ptr<fastjet::AreaDefinition> m_area_def;
63+
std::unique_ptr<fastjet::JetDefinition::Plugin> m_jet_plugin;
6364

6465
// maps of user input onto fastjet options
6566
std::map<std::string, fastjet::JetAlgorithm> m_mapJetAlgo = {

src/algorithms/reco/JetReconstructionConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
2-
// Copyright (C) 2023 Derek Anderson, Zhongling Ji
2+
// Copyright (C) 2023 Derek Anderson, Zhongling Ji, John Lajoie
33

44
#pragma once
55

@@ -21,6 +21,7 @@ namespace eicrecon {
2121
std::string jetAlgo = "antikt_algorithm"; // jet finding algorithm
2222
std::string recombScheme = "E_scheme"; // particle recombination scheme
2323
std::string areaType = "active_area"; // type of area calculated
24+
std::string jetContribAlgo = "Centauro"; // contributed algorithm name
2425

2526
};
2627

src/global/reco/reco.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,37 @@ void InitPlugin(JApplication *app) {
305305
));
306306
#endif
307307

308+
app->Add(new JOmniFactoryGeneratorT<TransformBreitFrame_factory>(
309+
"GeneratedBreitFrameParticles",
310+
{"MCParticles","InclusiveKinematicsElectron","GeneratedParticles"},
311+
{"GeneratedBreitFrameParticles"},
312+
{},
313+
app
314+
));
315+
316+
app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
317+
"GeneratedCentauroJets",
318+
{"GeneratedBreitFrameParticles"},
319+
{"GeneratedCentauroJets"},
320+
{
321+
.rJet = 0.8,
322+
.jetAlgo = "plugin_algorithm",
323+
.jetContribAlgo = "Centauro"
324+
},
325+
app
326+
));
327+
328+
app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
329+
"ReconstructedCentauroJets",
330+
{"ReconstructedBreitFrameParticles"},
331+
{"ReconstructedCentauroJets"},
332+
{
333+
.rJet = 0.8,
334+
.jetAlgo = "plugin_algorithm",
335+
.jetContribAlgo = "Centauro"
336+
},
337+
app
338+
));
339+
308340
}
309341
} // extern "C"

src/services/io/podio/JEventProcessorPODIO.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() {
161161

162162
// Reconstructed data
163163
"GeneratedParticles",
164+
"GeneratedBreitFrameParticles",
164165
"ReconstructedParticles",
165166
"ReconstructedParticleAssociations",
166167
"ReconstructedChargedParticles",
@@ -188,8 +189,10 @@ JEventProcessorPODIO::JEventProcessorPODIO() {
188189
"InclusiveKinematicsTruth",
189190
"GeneratedJets",
190191
"GeneratedChargedJets",
192+
"GeneratedCentauroJets",
191193
"ReconstructedJets",
192194
"ReconstructedChargedJets",
195+
"ReconstructedCentauroJets",
193196
"ReconstructedElectrons",
194197
"ScatteredElectronsTruth",
195198
"ScatteredElectronsEMinusPz",

0 commit comments

Comments
 (0)