Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d4a0a18
compile DDExternalClusteringAlgorithm
SanghyunKo Jan 20, 2026
2bb01fb
fix runtime issues
SanghyunKo Jan 20, 2026
586bcb7
to be checked by Aurora
SanghyunKo Jan 20, 2026
fceb8d4
run pre-commit hook
SanghyunKo Jan 20, 2026
7ac8448
Update k4GaudiPandora/src/DDExternalClusteringAlgorithm.cc
SanghyunKo Jan 24, 2026
1f7b4e3
change caloHitMap key to cellID to podio::ObjectID
SanghyunKo Jan 24, 2026
2b58de1
fix bug that m_dataSvc was not allocated
SanghyunKo Feb 5, 2026
8e33147
add CTest for the external clustering algorithm
SanghyunKo Mar 11, 2026
db0ec47
address Juan's comment
SanghyunKo Mar 11, 2026
627037e
avoid accessing Gaudi event store
SanghyunKo Apr 7, 2026
04f6842
avoid copying the internal vector
SanghyunKo Apr 7, 2026
60e73d0
Update k4GaudiPandora/src/DDPandoraPFANewAlgorithm.cpp
SanghyunKo Jul 8, 2026
c77070f
Update k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
SanghyunKo Jul 8, 2026
7d8bd7c
Update k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
SanghyunKo Jul 8, 2026
6733bca
Update k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
SanghyunKo Jul 8, 2026
00a772b
Update k4GaudiPandora/src/DDExternalClusteringAlgorithm.cc
SanghyunKo Jul 8, 2026
b4fe764
make pre-commit happy
SanghyunKo Jul 12, 2026
4997779
set m_flagClustersAsPhotons to false by default
SanghyunKo Jul 12, 2026
8ea2c92
fix double-delete of ExternalEventParameter
SanghyunKo Jul 12, 2026
c0cf105
avoid importing Gaudi singletons in the python config
SanghyunKo Aug 17, 2026
9ef01e3
fix broken CI
SanghyunKo Aug 17, 2026
a3f3b62
fix rebase conflict
SanghyunKo Aug 18, 2026
78a5573
fix runtime issues
SanghyunKo Jan 20, 2026
6b95e9a
to be checked by Aurora
SanghyunKo Jan 20, 2026
99d742f
run pre-commit hook
SanghyunKo Jan 20, 2026
d8e17b7
Update k4GaudiPandora/src/DDExternalClusteringAlgorithm.cc
SanghyunKo Jan 24, 2026
62d4cde
change caloHitMap key to cellID to podio::ObjectID
SanghyunKo Jan 24, 2026
afa46b4
fix bug that m_dataSvc was not allocated
SanghyunKo Feb 5, 2026
17d27c9
resolve conflicts
SanghyunKo Aug 21, 2026
2e41cf1
address Juan's comment
SanghyunKo Mar 11, 2026
fa28aa4
avoid accessing Gaudi event store
SanghyunKo Apr 7, 2026
03b8c81
avoid copying the internal vector
SanghyunKo Apr 7, 2026
48ff934
Update k4GaudiPandora/src/DDPandoraPFANewAlgorithm.cpp
SanghyunKo Jul 8, 2026
474ac01
Update k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
SanghyunKo Jul 8, 2026
c373138
Update k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
SanghyunKo Jul 8, 2026
cac38a5
Update k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
SanghyunKo Jul 8, 2026
29816b2
Update k4GaudiPandora/src/DDExternalClusteringAlgorithm.cc
SanghyunKo Jul 8, 2026
db3e281
make pre-commit happy
SanghyunKo Jul 12, 2026
8654c75
set m_flagClustersAsPhotons to false by default
SanghyunKo Jul 12, 2026
d6e1309
fix double-delete of ExternalEventParameter
SanghyunKo Jul 12, 2026
8307e09
fix merge conflict with port-pandora
SanghyunKo Oct 1, 2025
6ba093f
update the track-cluster matching parameters
SanghyunKo Oct 1, 2025
33a895f
add geometry creator for IDEA
SanghyunKo Oct 2, 2025
55ae8cc
initial simple brem recovery algo
SanghyunKo Oct 6, 2025
0c07cac
working brem recovery alg
SanghyunKo Oct 9, 2025
2018286
make Pandora Monitoring work for the IDEA o1
SanghyunKo Jan 19, 2026
d08fe8c
clean-up unused algorithms
SanghyunKo Jul 13, 2026
f6e6117
drop unused algorithm
SanghyunKo Jul 13, 2026
bbd10c8
Added HCal geometry
Jul 27, 2026
93edb22
Removed comments
Jul 28, 2026
c5b068c
Phase 0 pass - 1) build flag for onnx, 2) destage brem recovery, 3) r…
SanghyunKo Aug 9, 2026
ce9ef68
refactor PFO creators
SanghyunKo Aug 13, 2026
37650ac
class rename & update config
SanghyunKo Aug 13, 2026
2edc39e
fix rebase conflict (2)
SanghyunKo Aug 18, 2026
0b15123
clean up the steering file read function for DRC
SanghyunKo Aug 17, 2026
eaed64f
clean up PandoraPFAIdeaAlgorithm
SanghyunKo Aug 17, 2026
3e833cb
fix rebase conflict (3)
SanghyunKo Aug 18, 2026
037430e
fix rebase conflict (4)
SanghyunKo Aug 18, 2026
16332d1
make pre-commit happy
SanghyunKo Aug 18, 2026
a2785d3
fix compile error
SanghyunKo Aug 19, 2026
fb13f26
add IDEA o2 config and the option for the reduced CI geometry
SanghyunKo Aug 21, 2026
75ebd5c
add CTest for IDEA o2 PFlow
SanghyunKo Aug 24, 2026
3ded93f
Merge branch 'dev_externalClustering' into rebased-pandora-IDEA
SanghyunKo Aug 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion k4GaudiPandora/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ set(_plugin_sources ${CMAKE_CURRENT_LIST_DIR}/
src/DDScintillatorPpdDigi.cc
src/DDBFieldPlugin.cc
src/DDCaloHitCreator.cc
# src/DDExternalClusteringAlgorithm.cc
src/DDExternalClusteringAlgorithm.cc
src/DDGeometryCreator.cc
src/DDMCParticleCreator.cc
src/PfoCreatorBase.cc
src/DDPfoCreator.cc
src/DDSimpleMuonDigi.cc
src/DDTrackCreatorBase.cc
Expand All @@ -36,8 +37,19 @@ set(_plugin_sources ${CMAKE_CURRENT_LIST_DIR}/
src/DDGeometryCreatorALLEGRO.cc
src/DDTrackCreatorALLEGRO.cc
src/DDCaloHitCreatorALLEGRO.cc
src/TrackCreatorIdea.cc
src/DualReadoutCaloHitCreator.cc
src/PfoCreatorIdea.cc
src/GeometryCreatorIdea.cc
)

# PandoraPFAIdeaAlgorithm registers the ONNX algorithms (ClusterNeutralPid,
# SatelliteAssignmentOnnx) provided by LCContentML, so it is built only when ML is enabled.
option(K4GP_BUILD_ML "Build the ONNX/ML-dependent IDEA reconstruction (needs LCContentML)" OFF)
if(K4GP_BUILD_ML)
list(APPEND _plugin_sources src/PandoraPFAIdeaAlgorithm.cc)
endif()

gaudi_add_module(k4GaudiPandoraPlugins
SOURCES ${_plugin_sources}
LINK Gaudi::GaudiKernel
Expand All @@ -51,6 +63,7 @@ gaudi_add_module(k4GaudiPandoraPlugins
GSL::gslcblas # This seems to be necessary on Ubuntu 24.04 when linking with mold
${PandoraSDK_LIBRARIES}
${LCContent_LIBRARIES}
$<$<BOOL:${K4GP_BUILD_ML}>:LCContent::LCContentML>
)
if(K4GAUDIPANDORA_USE_DDKALTEST)
target_compile_definitions(k4GaudiPandoraPlugins PRIVATE K4GAUDIPANDORA_USE_DDKALTEST)
Expand Down
6 changes: 4 additions & 2 deletions k4GaudiPandora/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ faces it can choose between is whatever the upstream extrapolation stored.
Note that `OFF` does not make k4GaudiPandora depend on k4ActsTracking; nothing is linked or included
from it.

Independently of this option, a track with no `AtCalorimeter` state is still passed to pandora with
`reachesCalorimeter` false: the state remains (0,0,0) and `timeAtCalorimeter` is -1 when the track doesn't
reach calo (Pandora requires them as mendatory input parameters). Use ReachesCalorimeter() method to check it.

Caveats when `OFF`:

- The input tracks **must** carry an `AtCalorimeter` track state. Tracks without one are dropped by
the track creators, which report `Failed to extract a track`.
- `TrackStateTolerance` has no effect, since it only bounds the acceptance radius of the endcap
state.

Expand Down
47 changes: 42 additions & 5 deletions k4GaudiPandora/include/DDExternalClusteringAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,56 @@
#ifndef DDEXTERNALCLUSTERINGALGORITHM_H
#define DDEXTERNALCLUSTERINGALGORITHM_H 1

#include "Pandora/Algorithm.h"
// Pandora
#include "Helpers/XmlHelper.h"
#include "Objects/CaloHit.h"
#include "Pandora/ExternallyConfiguredAlgorithm.h"

// Podio
#include "podio/ObjectID.h"

#include "edm4hep/Cluster.h"

// c++
#include <map>
#include <unordered_map>
#include <vector>

namespace pandora {
class CaloHit;
}

/**
* @brief ExternalClusterHolder class - holds pointers to the external clusters and the calo hits
*/

class ExternalClusterHolder {
public:
ExternalClusterHolder() = default;
~ExternalClusterHolder() = default;

void setExternalClusters(std::vector<std::vector<edm4hep::Cluster>>* externalClusters);
const std::vector<std::vector<edm4hep::Cluster>>& getExternalClusters() const;

std::vector<std::vector<edm4hep::Cluster>>* m_externalClusters; ///< The external clusters
};

//------------------------------------------------------------------------------------------------------------------------------------------

/**
* @brief ExternalEventParameter class - holds Gaudi event service for external clustering
*/
class ExternalEventParameter : public pandora::ExternalParameters {
public:
ExternalClusterHolder* m_externalClusterHolder; ///< Pointer to external cluster holder
};

//------------------------------------------------------------------------------------------------------------------------------------------

/**
* @brief DDExternalClusteringAlgorithm class
*/
class DDExternalClusteringAlgorithm : public pandora::Algorithm {
class DDExternalClusteringAlgorithm : public pandora::ExternallyConfiguredAlgorithm {
public:
/**
* @brief Factory class for instantiating algorithm
Expand All @@ -59,10 +95,11 @@ class DDExternalClusteringAlgorithm : public pandora::Algorithm {
pandora::StatusCode Run();
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);

typedef std::map<const void*, const pandora::CaloHit*> ParentAddressToCaloHitMap;
typedef std::unordered_map<podio::ObjectID, const pandora::CaloHit*> ExternalToPandoraCaloHitMap;

bool m_flagClustersAsPhotons = false; ///< Whether to automatically flag new clusters as fixed photons

std::string m_externalClusterCollectionName = ""; ///< The collection name for the external clusters
bool m_flagClustersAsPhotons = true; ///< Whether to automatically flag new clusters as fixed photons
ExternalClusterHolder* m_externalClusterHolder = nullptr; ///< Pointer to external cluster holder
};

//------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions k4GaudiPandora/include/DDGeometryCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ class DDGeometryCreator {
*/
DDGeometryCreator(const Settings& settings, pandora::Pandora& pandora, Gaudi::Algorithm* algorithm);

pandora::StatusCode CreateGeometry() const;
/**
* @brief Destructor. Virtual because derived creators are held and deleted through a
* DDGeometryCreator pointer (see DDPandoraPFANewAlgorithm::m_geometryCreator).
*/
virtual ~DDGeometryCreator() = default;

virtual pandora::StatusCode CreateGeometry() const;

protected:
typedef std::map<pandora::SubDetectorType, PandoraApi::Geometry::SubDetector::Parameters> SubDetectorTypeMap;
Expand All @@ -56,7 +62,7 @@ class DDGeometryCreator {
*
* @param subDetectorTypeMap the sub detector type map
*/
void SetMandatorySubDetectorParameters(SubDetectorTypeMap& subDetectorTypeMap) const;
virtual void SetMandatorySubDetectorParameters(SubDetectorTypeMap& subDetectorTypeMap) const;

/**
* @brief Set additional sub detector parameters
Expand Down
4 changes: 2 additions & 2 deletions k4GaudiPandora/include/DDGeometryCreatorALLEGRO.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class DDGeometryCreatorALLEGRO : public DDGeometryCreator {
/**
* @brief Create geometry
*/
pandora::StatusCode CreateGeometry() const;
pandora::StatusCode CreateGeometry() const override;

private:
/**
* @brief Set mandatory sub detector parameters
*
* @param subDetectorTypeMap the sub detector type map
*/
void SetMandatorySubDetectorParameters(SubDetectorTypeMap& subDetectorTypeMap) const;
void SetMandatorySubDetectorParameters(SubDetectorTypeMap& subDetectorTypeMap) const override;
};

#endif // #ifndef GEOMETRY_CREATOR_H
13 changes: 11 additions & 2 deletions k4GaudiPandora/include/DDPandoraPFANewAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ namespace pandora {
class Pandora;
}

// forward declarations for the external clustering algorithm
class ExternalEventParameter;
class ExternalClusterHolder;

dd4hep::rec::LayeredCalorimeterData* getExtension(unsigned int includeFlag, unsigned int excludeFlag = 0);

struct DDPandoraPFANewAlgorithm final
Expand All @@ -61,7 +65,8 @@ struct DDPandoraPFANewAlgorithm final
const std::vector<const edm4hep::CalorimeterHitCollection*>&,
const std::vector<const edm4hep::CalorimeterHitCollection*>&,
const std::vector<const edm4hep::CalorimeterHitCollection*>&,
const std::vector<const edm4hep::CaloHitSimCaloHitLinkCollection*>&)> {
const std::vector<const edm4hep::CaloHitSimCaloHitLinkCollection*>&,
const std::vector<const edm4hep::ClusterCollection*>&)> {
public:
class Settings {
public:
Expand Down Expand Up @@ -137,7 +142,8 @@ struct DDPandoraPFANewAlgorithm final
const std::vector<const edm4hep::CalorimeterHitCollection*>& mCalCollections,
const std::vector<const edm4hep::CalorimeterHitCollection*>& lCalCollections,
const std::vector<const edm4hep::CalorimeterHitCollection*>& lhCalCollections,
const std::vector<const edm4hep::CaloHitSimCaloHitLinkCollection*>& caloLinkCollections) const override;
const std::vector<const edm4hep::CaloHitSimCaloHitLinkCollection*>& caloLinkCollections,
const std::vector<const edm4hep::ClusterCollection*>& clusterCollections) const override;

const pandora::Pandora* GetPandora() const;

Expand Down Expand Up @@ -165,6 +171,9 @@ struct DDPandoraPFANewAlgorithm final
std::unique_ptr<DDMCParticleCreator> m_pDDMCParticleCreator; ///< The mc particle creator
std::unique_ptr<DDPfoCreator> m_pfoCreator; ///< The pfo creator
SmartIF<IGeoSvc> m_geoSvc; ///< The GeoSvc
ExternalEventParameter* m_extEvtParam; ///< external event parameter (pandora::ExternalParameters)
///< created by this algo but deleted by Pandora
std::unique_ptr<ExternalClusterHolder> m_extClusterHolder; ///< Pointer to external cluster holder

Settings m_settings{}; ///< The settings for the pandora pfa new processor
DDCaloHitCreator::Settings m_caloHitCreatorSettings{}; ///< The calo hit creator settings
Expand Down
26 changes: 4 additions & 22 deletions k4GaudiPandora/include/DDPfoCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef K4GAUDIPANDORA_DDPFOCREATOR_H
#define K4GAUDIPANDORA_DDPFOCREATOR_H 1

#include "PfoCreatorBase.h"

#include "Api/PandoraApi.h"

#include <Gaudi/Algorithm.h>
Expand All @@ -32,7 +34,7 @@ class MutableVertex;
class VertexCollection;
} // namespace edm4hep

class DDPfoCreator {
class DDPfoCreator : public PfoCreatorBase {
public:
class Settings {
public:
Expand Down Expand Up @@ -137,24 +139,6 @@ class DDPfoCreator {
pandora::StatusCode calculateTrackBasedReferencePoint(const pandora::ParticleFlowObject* const pPandoraPfo,
pandora::CartesianVector& referencePoint) const;

/**
* @brief Add tracks to reconstructed particle
*
* @param pPandoraPfo the address of the pandora pfo
* @param pReconstructedParticle the address of the reconstructed particle to be added tracks
*/
void AddTracksToRecoParticle(const pandora::ParticleFlowObject* const pPandoraPfo,
edm4hep::MutableReconstructedParticle& pReconstructedParticle) const;

/**
* @brief Set properties of reconstructed particle from pandora pfo
*
* @param pPandoraPfo the address of the pandora pfo
* @param pReconstructedParticle the address of the reconstructed particle to be set properties
*/
void SetRecoParticlePropertiesFromPFO(const pandora::ParticleFlowObject* const pPandoraPfo,
edm4hep::MutableReconstructedParticle& pReconstructedParticle) const;

/**
* @brief Whether parent and daughter tracks are associated with the same pfo
*
Expand Down Expand Up @@ -196,9 +180,7 @@ class DDPfoCreator {
bool AreAnyOtherSiblingsInList(const pandora::Track* const pPandoraTrack,
const pandora::TrackList& allTrackList) const;

const Settings m_settings; ///< The pfo creator settings
pandora::Pandora& m_pandora; ///< Reference to the pandora object from which to extract the pfos
const Gaudi::Algorithm& m_algorithm; ///< Reference to the Gaudi algorithm for message streaming
const Settings m_settings; ///< The pfo creator settings
};

#endif // #ifndef K4GAUDIPANDORA_DDPFOCREATOR_H
30 changes: 24 additions & 6 deletions k4GaudiPandora/include/DDTrackCreatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ class DDTrackCreatorBase {
void Reset();

protected:
/**
* @brief Build the DDKalTest tracking system used by GetTrackStatesAtCalo to extrapolate track
* states to the calorimeter face. Deliberately not called from the constructor: a
* creator whose track states are already extrapolated upstream does not need it and
* should not pay to build it. A derived class that calls GetTrackStatesAtCalo must
* call this from its constructor.
*/
#ifdef K4GAUDIPANDORA_USE_DDKALTEST
void InitialiseTrackingSystem();
#endif

const Settings m_settings; ///< The track creator settings
pandora::Pandora& m_pandora; ///< Reference to the pandora object to create tracks and track relationships
const Gaudi::Algorithm& m_algorithm; ///< Reference to the parent algorithm
Expand Down Expand Up @@ -206,16 +217,19 @@ class DDTrackCreatorBase {
*
* @return boolean
*/
virtual bool PassesQualityCuts(const edm4hep::Track& pTrack,
const PandoraApi::Track::Parameters& trackParameters) const = 0;
virtual bool PassesQualityCuts(const edm4hep::Track& /*pTrack*/,
const PandoraApi::Track::Parameters& /*trackParameters*/) const {
return true; // no cuts by default: the selection may be done upstream of the creator
}

/**
* @brief Decide whether track reaches the ecal surface
*
* @param pTrack the lcio track
* @param trackParameters the track parameters
*/
virtual void TrackReachesECAL(const edm4hep::Track& pTrack, PandoraApi::Track::Parameters& trackParameters) const = 0;
virtual void TrackReachesECAL(const edm4hep::Track& /*pTrack*/,
PandoraApi::Track::Parameters& /*trackParameters*/) const {}

/**
* @brief Determine whether a track can be used to form a pfo under the following conditions:
Expand All @@ -225,8 +239,8 @@ class DDTrackCreatorBase {
* @param pTrack the lcio track
* @param trackParameters the track parameters
*/
virtual void DefineTrackPfoUsage(const edm4hep::Track& pTrack,
PandoraApi::Track::Parameters& trackParameters) const = 0;
virtual void DefineTrackPfoUsage(const edm4hep::Track& /*pTrack*/,
PandoraApi::Track::Parameters& /*trackParameters*/) const {}

/**
* @brief Extract kink information from specified collection
Expand Down Expand Up @@ -338,8 +352,12 @@ class DDTrackCreatorBase {
* @brief Obtain track time when it reaches ECAL
*
* @param pTrack the lcio track
* @param trackTime to receive the generic time: path length from the reference point to the
* intersection, divided by momentum
*
* @return STATUS_CODE_NOT_FOUND if the helix meets neither calorimeter surface
*/
float CalculateTrackTimeAtCalorimeter(const edm4hep::Track& pTrack) const;
pandora::StatusCode CalculateTrackTimeAtCalorimeter(const edm4hep::Track& pTrack, float& trackTime) const;
};

//------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
Loading
Loading