Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N NPDet
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 10
    • Issues 10
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 5
    • Merge requests 5
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • EIC
  • NPDet
  • Issues
  • #85

Closed
Open
Created Nov 08, 2021 by Wouter Deconinck@wdconincOwner

sanitize_hepmc3 fails to add END_EVENT_LISTING after discarding partial event

If the input hepmc3 file ends with a partial event, the final partial event is dropped but contrary to log messages, no END_EVENT_LISTING is appended.

WARNING: File does not end with END_EVENT_LISTING, appending
WARNING: Invalid particle count for event: E 305 8 20 @ -7.4609364157173369e-02 -7.7988299819229476e-03 9.6855910264790026e+00 -7.2251504307264325e+00
 --> skipping event
WARNING: Skipped invalid event E 305 8 20 @ -7.4609364157173369e-02 -7.7988299819229476e-03 9.6855910264790026e+00 -7.2251504307264325e+00

At the end of the file, when going into flush_buffer, the buffer has the partial event with the END_EVENT_LISTING appended:

    if not end_reached:
        warn("File does not end with END_EVENT_LISTING, appending")
        buffer.append('HepMC::Asciiv3-END_EVENT_LISTING\n')
    # final buffer flush at the end
    flush_buffer(header, buffer)

However, flush_buffer drops the entire buffer, including the END_EVENT_LISTING and returns:

def flush_buffer(header, buffer):
    if header:
        event_record = header.get_record()
        if not event_record:
            warn('Skipped invalid event', header.raw)
            return
        sys.stdout.write(header.get_record())
    for line in buffer:
        sys.stdout.write(line)

A likely fix may be to flush the buffer before if not end_reached:, then append the END_EVENT_LISTING again, and flush the buffer again.

That leaves as a case that will result in a missing END_EVENT_LISTING an input file that ends with END_EVENT_LISTING after an actual incomplete event, in which case the final buffer includes the END_EVENT_LISTING, is dropped, and doesn't trigger the if not end_reached:.

Maybe we can also just always drop END_EVENT_LISTING from the input, and always end by writing END_EVENT_LISTING to the output.

Assignee
Assign to
Time tracking