-
Notifications
You must be signed in to change notification settings - Fork 34
feat: add Truthiness algorithm for event quality assessment #2163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…u) (#2164) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18894504119. Please merge this PR into the branch `truthiness` to resolve failures in PR #2163. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…u) (#2165) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18918945511. Please merge this PR into the branch `truthiness` to resolve failures in PR #2163. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…u) (#2164) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18894504119. Please merge this PR into the branch `truthiness` to resolve failures in PR #2163. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…u) (#2165) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18918945511. Please merge this PR into the branch `truthiness` to resolve failures in PR #2163. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…u) (#2164) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18894504119. Please merge this PR into the branch `truthiness` to resolve failures in PR #2163. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…u) (#2165) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18918945511. Please merge this PR into the branch `truthiness` to resolve failures in PR #2163. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a Truthiness metric calculation feature that quantifies reconstruction quality by comparing reconstructed particles with Monte Carlo truth. The implementation uses conditional compilation to support both environments with and without the edm4eic::Truthiness output type.
- Adds a new algorithm (
Truthiness) that calculates a metric based on energy, momentum, and PDG code differences - Implements both factory and processor patterns depending on whether output persistence is available
- Integrates the feature into the reconstruction chain and PODIO output
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/io/podio/JEventProcessorPODIO.cc | Adds "Truthiness" to the output collection list when the header is available |
| src/global/reco/reco.cc | Registers either factory (with output) or processor (without output) based on conditional compilation |
| src/global/reco/Truthiness_processor.h | Defines processor class for running algorithm without persistent output |
| src/global/reco/Truthiness_processor.cc | Implements processor with input collection retrieval and statistics reporting |
| src/factories/reco/Truthiness_factory.h | Defines factory for running algorithm with persistent output collection |
| src/algorithms/reco/TruthinessConfig.h | Defines empty configuration structure for future extensibility |
| src/algorithms/reco/Truthiness.h | Defines algorithm interface with conditional output and statistics accessors |
| src/algorithms/reco/Truthiness.cc | Implements truthiness calculation with penalties for mismatches and missing associations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
The Truthiness algorithm accumulates statistics in mutable member
variables from a const `process()` method, creating race conditions when
called concurrently from multiple threads.
## Changes
- **`m_event_count`**: Changed from `uint64_t` to
`std::atomic<uint64_t>` for lock-free atomic operations
- **`m_stats_mutex`**: Added mutex to protect `m_average_truthiness`
updates during the online average calculation
- **Accessors**: `getAverageTruthiness()` now locks, `getEventCount()`
uses atomic `.load()`
```cpp
// In process()
{
std::lock_guard<std::mutex> lock(m_stats_mutex);
m_event_count++;
m_average_truthiness += (truthiness - m_average_truthiness) / m_event_count;
}
```
Pattern follows existing thread-safe implementations in the codebase
(e.g., `UniqueIDGenSvc`).
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: wdconinc <[email protected]>



Briefly, what does this PR introduce?
Includes:
This PR adds a truthiness value to each event. More truthiness is more confidently wrong.
See eic/EDM4eic#128 for a related effort (though this can go in without the data type; it will only log stuff though, until we can add the data type and modify the algorithm to provide the output).
What kind of change does this PR introduce?
Please check if this PR fulfills the following:
Does this PR introduce breaking changes? What changes might users need to make to their code?
No.
Does this PR change default behavior?
No.