Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-26 09:07:04

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024 Derek Anderson, Zhongling Ji, Dmitry Kalinkin, John Lajoie
0003 
0004 #pragma once
0005 
0006 #include <algorithms/algorithm.h>
0007 #include <edm4eic/EDM4eicVersion.h>
0008 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 9, 0)
0009 #include <edm4eic/JetCollection.h>
0010 #else
0011 #include <edm4eic/ReconstructedParticleCollection.h>
0012 #endif
0013 #include <edm4hep/EventHeaderCollection.h>
0014 #include <fastjet/AreaDefinition.hh>
0015 #include <fastjet/JetDefinition.hh>
0016 #include <map>
0017 #include <memory>
0018 #include <string>
0019 #include <string_view>
0020 #include <utility>
0021 
0022 #include "JetReconstructionConfig.h"
0023 // for algorithm configuration
0024 #include "algorithms/interfaces/WithPodConfig.h"
0025 #include "algorithms/interfaces/UniqueIDGenSvc.h"
0026 
0027 namespace eicrecon {
0028 
0029 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 9, 0)
0030 using JetOutputCollection = edm4eic::JetCollection;
0031 #else
0032 using JetOutputCollection = edm4eic::ReconstructedParticleCollection;
0033 #endif
0034 
0035 template <typename InputT>
0036 using JetReconstructionAlgorithm = algorithms::Algorithm<
0037     algorithms::Input<edm4hep::EventHeaderCollection, typename InputT::collection_type>,
0038     algorithms::Output<JetOutputCollection>>;
0039 
0040 template <typename InputT>
0041 class JetReconstruction : public JetReconstructionAlgorithm<InputT>,
0042                           public WithPodConfig<JetReconstructionConfig> {
0043 
0044 public:
0045   JetReconstruction(std::string_view name)
0046       : JetReconstructionAlgorithm<InputT>{
0047             name,
0048             {"eventHeaderCollection", "inputReconstructedParticles"},
0049             {"outputReconstructedParticles"},
0050             "Performs jet reconstruction using a FastJet algorithm."} {}
0051 
0052 public:
0053   // algorithm initialization
0054   void init() final;
0055 
0056   // run algorithm
0057   void process(const typename eicrecon::JetReconstructionAlgorithm<InputT>::Input&,
0058                const typename eicrecon::JetReconstructionAlgorithm<InputT>::Output&) const final;
0059 
0060 private:
0061   // fastjet components
0062   std::unique_ptr<fastjet::JetDefinition> m_jet_def;
0063   std::unique_ptr<fastjet::AreaDefinition> m_area_def;
0064   std::unique_ptr<fastjet::JetDefinition::Plugin> m_jet_plugin;
0065 
0066   // maps of user input onto fastjet options
0067   std::map<std::string, fastjet::JetAlgorithm> m_mapJetAlgo = {
0068       {"kt_algorithm", fastjet::JetAlgorithm::kt_algorithm},
0069       {"cambridge_algorithm", fastjet::JetAlgorithm::cambridge_algorithm},
0070       {"antikt_algorithm", fastjet::JetAlgorithm::antikt_algorithm},
0071       {"genkt_algorithm", fastjet::JetAlgorithm::genkt_algorithm},
0072       {"cambridge_for_passive_algorithm", fastjet::JetAlgorithm::cambridge_for_passive_algorithm},
0073       {"genkt_for_passive_algorithm", fastjet::JetAlgorithm::genkt_for_passive_algorithm},
0074       {"ee_kt_algorithm", fastjet::JetAlgorithm::ee_kt_algorithm},
0075       {"ee_genkt_algorithm", fastjet::JetAlgorithm::ee_genkt_algorithm},
0076       {"plugin_algorithm", fastjet::JetAlgorithm::plugin_algorithm}};
0077   std::map<std::string, fastjet::RecombinationScheme> m_mapRecombScheme = {
0078       {"E_scheme", fastjet::RecombinationScheme::E_scheme},
0079       {"pt_scheme", fastjet::RecombinationScheme::pt_scheme},
0080       {"pt2_scheme", fastjet::RecombinationScheme::pt2_scheme},
0081       {"Et_scheme", fastjet::RecombinationScheme::Et_scheme},
0082       {"Et2_scheme", fastjet::RecombinationScheme::Et2_scheme},
0083       {"BIpt_scheme", fastjet::RecombinationScheme::BIpt_scheme},
0084       {"BIpt2_scheme", fastjet::RecombinationScheme::BIpt2_scheme},
0085       {"WTA_pt_scheme", fastjet::RecombinationScheme::WTA_pt_scheme},
0086       {"WTA_modp_scheme", fastjet::RecombinationScheme::WTA_modp_scheme},
0087       {"external_scheme", fastjet::RecombinationScheme::external_scheme}};
0088   std::map<std::string, fastjet::AreaType> m_mapAreaType = {
0089       {"active_area", fastjet::AreaType::active_area},
0090       {"active_area_explicit_ghosts", fastjet::AreaType::active_area_explicit_ghosts},
0091       {"one_ghost_passive_area", fastjet::AreaType::one_ghost_passive_area},
0092       {"passive_area", fastjet::AreaType::passive_area},
0093       {"voronoi_area", fastjet::AreaType::voronoi_area}};
0094 
0095   // default fastjet options
0096   const struct defaults {
0097     std::string jetAlgo;
0098     std::string recombScheme;
0099     std::string areaType;
0100   } m_defaultFastjetOpts = {"antikt_algorithm", "E_scheme", "active_area"};
0101 
0102   // unique ID service for generating reproducible seeds
0103   const algorithms::UniqueIDGenSvc& m_uid = algorithms::UniqueIDGenSvc::instance();
0104 
0105 }; // end JetReconstruction definition
0106 
0107 } // namespace eicrecon