Skip to content

Commit

Permalink
Fixed zipping and selected only events with VP tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Ponce committed Oct 2, 2023
1 parent a22860a commit f6f3af8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tools/liveEventDisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@
sys.exit(1)
os.remove(localMDFFileName)

# postprocess the json file to drop events with no VP tracks
import json
content = json.load(open(phoenixFileName, 'rb'))
newcontent = {}
for event in content:
if len(content[event]['Tracks']['VeloTracks']) > 0:
newcontent[event] = content[event]
else:
print ("No VP track in %s, dropping event" % event)
# overwrite file with remaining event
json.dump(newcontent, open(phoenixFileName, 'w'))

# some sanity checks
try:
size = os.path.getsize(phoenixFileName)
Expand All @@ -109,7 +121,7 @@
# zip resulting file
import zipfile
_, zippedPhoenixFileName = tempfile.mkstemp(suffix=".json.zip")
zipfile.ZipFile(zippedPhoenixFileName, mode='w').write(phoenixFileName)
zipfile.ZipFile(zippedPhoenixFileName, mode='w', compression=zipfile.ZIP_DEFLATED, compresslevel=9).write(phoenixFileName)
os.unlink(phoenixFileName)

# move resulting file to EOS
Expand Down

0 comments on commit f6f3af8

Please sign in to comment.