-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic implementation of event pooling in O2DPG workflow (#1760)
* Allow to generate events for event-pool usage (no vertex applied + kinematic merging) * Example script demonstrating simple event pool creation and reading events from pool https://its.cern.ch/jira/browse/O2-5216
- Loading branch information
1 parent
f26dfd2
commit 15049b0
Showing
3 changed files
with
140 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Example on how to produce an event pool and how to feed it | ||
# to the O2DPG simulation workflow | ||
|
||
# make sure O2DPG + O2 is loaded | ||
[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1 | ||
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1 | ||
|
||
# Parse arguments | ||
MAKE=false | ||
INPUT="" | ||
|
||
help() { | ||
echo "Usage: $0 [--make] [-i|--input <input_file>]" | ||
echo " --make: Create the event pool" | ||
echo " -i|--input: Input event pool file to be used in the simulation workflow. Alien paths are supported." | ||
echo " A full path must be provided (use of environment variables allowed), otherwise generation will fail." | ||
echo " -h|--help: Display this help message" | ||
exit 0 | ||
} | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--make) MAKE=true ;; | ||
-i|--input) INPUT="$2"; shift ;; | ||
-h|--help) help ;; | ||
*) echo "Unknown operation requested: $1"; help ;; | ||
esac | ||
shift | ||
done | ||
|
||
if $MAKE; then | ||
echo "Started generation of event pool" | ||
# Workflow creation. All the parameters are used as examples | ||
# No transport will be executed. The workflow will stop at the event generation and will conclude with the merging of all the | ||
# kinematic root files of the timeframes in a file called evtpool.root in the current working directory | ||
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 14000 -col pp -gen pythia8 -proc cdiff -tf 2 -ns 5000 --make-evtpool -seed 546 -interactionRate 500000 -productionTag "evtpoolcreation" -o evtpool | ||
# Workflow runner | ||
${O2DPG_ROOT}/MC/bin/o2dpg_workflow_runner.py -f evtpool.json -tt pool | ||
elif [[ -n "$INPUT" ]]; then | ||
echo "Input file provided: $INPUT" | ||
if [[ -f "$INPUT" && -s "$INPUT" ]] || [[ "$INPUT" == alien://* ]]; then | ||
# Workflow creation. Phi Rotation is set manually, while the event randomisation of the pool is set by default | ||
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 14000 -confKey "GeneratorFromO2Kine.randomphi=true;GeneratorFromO2Kine.fileName=$INPUT" -gen extkinO2 -tf 2 -ns 10 -e TGeant4 -j 4 -interactionRate 500000 -seed 546 -productionTag "evtpooltest" | ||
# Workflow runner. The rerun option is set in case you will run directly the script in the same folder (no need to manually delete files) | ||
${O2DPG_ROOT}/MC/bin/o2dpg_workflow_runner.py -f workflow.json -tt aod --rerun-from grpcreate | ||
else | ||
echo "Error: File does not exist or is empty: $INPUT" | ||
exit 1 | ||
fi | ||
else | ||
echo "Usage: $0 [--make] [-i|--input <input_file>]" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Simple ROOT files merger | ||
|
||
from ROOT import TFile, TFileMerger | ||
import sys | ||
import os | ||
import argparse | ||
|
||
output_file = '' | ||
input_files = [] | ||
# defining command line options | ||
|
||
parser = argparse.ArgumentParser(description='Simple ROOT files merger', | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
|
||
parser.add_argument('-o','--output', help='Output ROOT filename', required=True) | ||
parser.add_argument('-i','--input', help='Input ROOT files to be merged, separated by a comma', required=True) | ||
|
||
args = parser.parse_args() | ||
|
||
output_file = args.output | ||
input_files = args.input.split(',') | ||
|
||
merger = TFileMerger(False) | ||
merger.OutputFile(output_file) | ||
|
||
for input_file in input_files: | ||
if os.path.exists(input_file): | ||
merger.AddFile(input_file) | ||
else: | ||
print(f"Fatal: {input_file} does not exist.") | ||
sys.exit(1) | ||
|
||
if not merger.Merge(): | ||
print("Error: Merging failed.") | ||
sys.exit(2) | ||
else: | ||
print(f"Successfully merged files into {output_file}") | ||
|
||
sys.exit(0) |