Skip to content

Fix: Update eventsProcessed lookup for ROOT 6.38 and add fallback warning#512

Open
ShreyasBakare wants to merge 1 commit intoHEP-FCC:masterfrom
ShreyasBakare:fix/metadata-extraction
Open

Fix: Update eventsProcessed lookup for ROOT 6.38 and add fallback warning#512
ShreyasBakare wants to merge 1 commit intoHEP-FCC:masterfrom
ShreyasBakare:fix/metadata-extraction

Conversation

@ShreyasBakare
Copy link
Copy Markdown
Contributor

This PR addresses an AttributeError encountered when reading metadata using the latest Key4hep stack, as reported in this FCCSW-Forum post.

The run_histmaker function in python/run_analysis.py previously used PyROOT's dynamic attribute lookup to check for the 'eventsProcessed' TParameter. On the newer Key4hep stack (-r 2026-02-01), which updates to ROOT 6.38, this dynamic lookup fails, leading to the following error when reading files from EOS:

AttributeError: 'TNetXNGFile' object has no attribute 'eventsProcessed'

To resolve this incompatibility, this PR replaces the dynamic lookup infile.eventsProcessed.GetVal() with infile.Get("eventsProcessed").GetVal().

Additional improvements in this PR:

  • Removed the GetListOfKeys() loop, fetching the parameter directly.

  • Added a LOGGER.warning. If a user runs Stage 2 (or later) scripts on an input file missing this metadata tag (e.g., after intermediate processing with uproot), the framework will explicitly warn them that cross-section scaling will fall back to the current tree's entry count, which may artificially inflate results. As described in this FCCSW-Forum post.

This change can be tested by running any Stage 2 histmaker script over EOS files (root://eosuser.cern.ch/...) on the new Key4hep stack (-r 2026-02-01).

- Replaced PyROOT dynamic lookup with explicit .Get() to fix AttributeError on ROOT 6.38.

- Removed GetListOfKeys() loop by fetching the parameter directly.

- Added LOGGER.warning to alert users if cross-section scaling falls back to the current tree's entry count.
@kjvbrt
Copy link
Copy Markdown
Contributor

kjvbrt commented Mar 19, 2026

Hi @ShreyasBakare,

thanks for the fix.

if events_param:
nevents_meta += events_param.GetVal()
else:
LOGGER.warning('Missing "eventsProcessed" in %s! Cross-section scaling may fall back to filtered event count.', file_name)
Copy link
Copy Markdown
Contributor

@kjvbrt kjvbrt Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning message might be a bit too much, since this will be issued for every file. Maybe a debug message would be more suitable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants