Skip to content
Snippets Groups Projects
Commit ce3436d9 authored by Sylvester Joosten's avatar Sylvester Joosten
Browse files

Don't fail on valid HepMC3 files with less explicit vertex lines than declared

parent dd4c5e85
Branches
No related tags found
2 merge requests!273Draft: Resolve "Support FastSim and GFlash",!244Don't fail on valid HepMC3 files with less explicit vertex lines than declared
...@@ -22,8 +22,8 @@ class EventHeader: ...@@ -22,8 +22,8 @@ class EventHeader:
this.vert_cnt = 0 this.vert_cnt = 0
this.part_cnt = 0 this.part_cnt = 0
def get_record(this): def get_record(this):
if not this.vert_cnt == this.n_vertices: if this.vert_cnt > this.n_vertices:
warn('Invalid vertex count for event:', this.raw, "--> skipping event") warn('Too many vertices for event:', this.raw, "--> skipping event")
return None return None
if not this.part_cnt == this.n_particles: if not this.part_cnt == this.n_particles:
warn('Invalid particle count for event:', this.raw, "--> skipping event") warn('Invalid particle count for event:', this.raw, "--> skipping event")
...@@ -93,13 +93,15 @@ if __name__ == '__main__': ...@@ -93,13 +93,15 @@ if __name__ == '__main__':
elif 'HepMC::Asciiv3-END_EVENT_LISTING\n' == line: elif 'HepMC::Asciiv3-END_EVENT_LISTING\n' == line:
end_reached = True end_reached = True
buffer.append(line) buffer.append(line)
elif line[0] in ['A']:
buffer.append(line)
elif line[0] == 'E': elif line[0] == 'E':
flush_buffer(header, buffer) flush_buffer(header, buffer)
header = EventHeader(line) header = EventHeader(line)
buffer = [] buffer = []
else: else:
if header is None: if header is None:
raise InvalidHepmc3Error('Encountered field before the first Event header:', line) raise InvalidHepmc3Error('Encountered invalid field before the first Event header:', line)
if line[0] == 'V': if line[0] == 'V':
header.process_vertex(line) header.process_vertex(line)
elif line[0] == 'P': elif line[0] == 'P':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment