-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Truth graph metrics for Exa.TrkX with separate algorithm (#…
…3354) Refactors code for truth graph building into separate algorithm, also improve reader/writer infrastructure for graphs.
- Loading branch information
1 parent
b5069e1
commit 2413095
Showing
14 changed files
with
526 additions
and
150 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
83 changes: 83 additions & 0 deletions
83
...rithms/TrackFindingExaTrkX/include/ActsExamples/TrackFindingExaTrkX/TruthGraphBuilder.hpp
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,83 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2022 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include "Acts/Definitions/Units.hpp" | ||
#include "ActsExamples/EventData/Cluster.hpp" | ||
#include "ActsExamples/EventData/Graph.hpp" | ||
#include "ActsExamples/EventData/ProtoTrack.hpp" | ||
#include "ActsExamples/EventData/SimHit.hpp" | ||
#include "ActsExamples/EventData/SimParticle.hpp" | ||
#include "ActsExamples/EventData/SimSpacePoint.hpp" | ||
#include "ActsExamples/Framework/DataHandle.hpp" | ||
#include "ActsExamples/Framework/IAlgorithm.hpp" | ||
|
||
namespace ActsExamples { | ||
|
||
/// Algorithm to create a truth graph for computing truth metrics | ||
/// Requires spacepoints and particles collection | ||
/// Either provide a measurements particles map, or a measurement simhit map + | ||
/// simhits | ||
class TruthGraphBuilder final : public IAlgorithm { | ||
public: | ||
struct Config { | ||
/// Input spacepoint collection | ||
std::string inputSpacePoints; | ||
/// Input particles collection | ||
std::string inputParticles; | ||
/// Input measurement particles map (Optional). | ||
std::string inputMeasurementParticlesMap; | ||
/// Input simhits (Optional). | ||
std::string inputSimHits; | ||
/// Input measurement simhit map (Optional). | ||
std::string inputMeasurementSimHitsMap; | ||
/// Output truth graph | ||
std::string outputGraph; | ||
|
||
double targetMinPT = 0.5; | ||
std::size_t targetMinSize = 3; | ||
|
||
/// Only allow one hit per track & module | ||
bool uniqueModules = false; | ||
}; | ||
|
||
TruthGraphBuilder(Config cfg, Acts::Logging::Level lvl); | ||
|
||
~TruthGraphBuilder() override = default; | ||
|
||
ActsExamples::ProcessCode execute( | ||
const ActsExamples::AlgorithmContext& ctx) const final; | ||
|
||
const Config& config() const { return m_cfg; } | ||
|
||
private: | ||
Config m_cfg; | ||
|
||
std::vector<std::int64_t> buildFromMeasurements( | ||
const SimSpacePointContainer& spacepoints, | ||
const SimParticleContainer& particles, | ||
const IndexMultimap<ActsFatras::Barcode>& measPartMap) const; | ||
|
||
std::vector<std::int64_t> buildFromSimhits( | ||
const SimSpacePointContainer& spacepoints, | ||
const IndexMultimap<Index>& measHitMap, const SimHitContainer& simhits, | ||
const SimParticleContainer& particles) const; | ||
|
||
ReadDataHandle<SimSpacePointContainer> m_inputSpacePoints{this, | ||
"InputSpacePoints"}; | ||
ReadDataHandle<SimParticleContainer> m_inputParticles{this, "InputParticles"}; | ||
ReadDataHandle<IndexMultimap<ActsFatras::Barcode>> m_inputMeasParticlesMap{ | ||
this, "InputMeasParticlesMap"}; | ||
ReadDataHandle<SimHitContainer> m_inputSimhits{this, "InputSimhits"}; | ||
ReadDataHandle<IndexMultimap<Index>> m_inputMeasSimhitMap{ | ||
this, "InputMeasSimhitMap"}; | ||
|
||
WriteDataHandle<Graph> m_outputGraph{this, "OutputGraph"}; | ||
}; | ||
} // namespace ActsExamples |
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.