-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathrundpg.sh
More file actions
executable file
·170 lines (145 loc) · 4.28 KB
/
rundpg.sh
File metadata and controls
executable file
·170 lines (145 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash
#
# This script shows how to start the DPG simulation machinery starting EPOS4
# automatically while using the FIFOs generated internally by GeneratorHepMC
# This script works only with O2sim version starting from the 20/09/2024
set -x
if [ ! "${EPOS4_ROOT}" ]; then
echo "This needs EPOS4 loaded; alienv enter ..."
exit 1
fi
# 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
cmd="$PWD/epos.sh"
NEV=-1
more=""
optns="example"
TF=1
eCM=-1
JOBS=2
HEPMC=""
HQ=false
if [ -z "$EPO4VSN" ]; then
echo "Error: EPOS4 version not found"
exit 7
fi
if [ "$EPO4VSN" == "4.0.0" ]; then
HEPMC=";HepMC.version=2"
else
HEPMC=";HepMC.version=3"
fi
usage()
{
cat <<EOF
Usage: $0 [OPTIONS]
Options:
-m,--more CONFIG More configurations ($more)
-n,--nevents EVENTS Number of events ($nev)
-i,--input INPUT Options file fed to EPOS4 ($optns)
-j,--jobs JOBS Number of jobs ($JOBS)
-h,--help Print these instructions
-e,--ecm ENERGY Center-of-Mass energy
-t,--tf TF Timeframes ($TF)
-hq HQ Enable EPOS4HQ
-- Rest of command line sent to o2-sim
COMMAND must be quoted if it contains spaces or other special
characters
Below follows the help output of o2dpg_sim_workflow
EOF
}
if [ "$#" -lt 2 ]; then
echo "Running with default values"
fi
while test $# -gt 0 ; do
case $1 in
-m|--more) more="$2" ; shift ;;
-n|--nevents) NEV=$2 ; shift ;;
-i|--input) optns=$2 ; shift ;;
-j|--jobs) JOBS=$2 ; shift ;;
-e|--ecm) eCM=$2 ; shift ;;
-hq) HQ=true ; shift ;;
-h|--help) usage; ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py --help ; exit 0 ;;
-t|--tf) TF=$2 ; shift ;;
--) shift ; break ;;
*) echo "Unknown option '$1', did you forget '--'?" >/dev/stderr
exit 3
;;
esac
shift
done
echo "Options file: $optns"
if [ ! -f $optns.optns ]; then
echo "Error: Options file $optns.optns not found"
exit 4
fi
# Set number of events in optns file
if [ ! $NEV -eq -1 ]; then
echo "Setting number of events to $NEV"
if grep -Fq "nfull" $optns.optns; then
sed -i "/nfull/c\set nfull $NEV" $optns.optns
else
echo "set nfull $NEV" >> $optns.optns
fi
else
echo "Number of events not set, checking optns file..."
if grep -Fq "nfull" $optns.optns; then
NEV=$(grep -F "nfull" $optns.optns | awk '{print $3}')
echo "Number of events set to $NEV"
else
echo "Error: Number of events not set in EPOS4"
exit 5
fi
fi
# Set ECM
if [ ! $eCM -eq -1 ]; then
echo "Setting eCM to $eCM"
if grep -Fq "ecms" $optns.optns; then
sed -i "/ecms/c\set ecms $eCM" $optns.optns
else
echo "set ecms $eCM" >> $optns.optns
fi
else
echo "Energy not set, checking optns file..."
if grep -Fq "ecms" $optns.optns; then
eCM=$(grep -F "ecms" $optns.optns | awk '{print $3}')
echo "Energy set to $eCM"
else
echo "Error: eCM not set in EPOS4"
exit 6
fi
fi
# Set HQ mode
if [ "$HQ" = true ]; then
echo "Setting HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 1" $optns.optns
else
echo "set ihq 1" >> $optns.optns
fi
if [ -z "$EPO4HQVSN" ]; then
echo "Error: EPOS4HQ version not found"
exit 7
else
HEPMC=";HepMC.version=3"
fi
else
echo "Turning OFF HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 0" $optns.optns
else
echo "set ihq 0" >> $optns.optns
fi
fi
# Copy options file in each timeframe folder
for i in $(seq 1 $TF); do
if [ ! -d tf$i ]; then
mkdir tf$i
fi
cp $optns.optns tf$i/$optns.optns
done
# create workflow
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM $eCM -ns $NEV -gen hepmc -tf $TF -j $JOBS -seed $RANDOM \
-interactionRate 500000 -confKey "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none$HEPMC;${more}"
# Run workflow
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt aod --stdout-on-failure