Skip to content

Commit 636e8e0

Browse files
authored
Update LUT maker script (#101)
- Add parallel processing
1 parent 188605a commit 636e8e0

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

examples/scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ create_luts.C
2020
fwdRes/fwdRes.C
2121
lutWrite*.cc
2222
*.hepmc
23+
HistoManager.h

examples/scripts/create_luts.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ RMIN=100.
66
WRITER_PATH=$DELPHESO2_ROOT/lut/
77
OUT_PATH=.
88
OUT_TAG=
9+
PARALLEL_JOBS=1
910
PARTICLES="0 1 2 3 4"
1011

1112
# Get the options
1213
while getopts ":t:B:R:p:o:T:P:h" option; do
1314
case $option in
1415
h) # display Help
1516
echo "Script to generate LUTs from LUT writer, arguments:"
16-
echo "Syntax: ./create_luts.sh [-h|t|B|R|p|o|T|P]"
17+
echo "Syntax: ./create_luts.sh [-h|t|B|R|p|o|T|P|j]"
1718
echo "options:"
1819
echo "-t tag of the LUT writer [default]"
1920
echo "-B Magnetic field in T [0.5]"
@@ -22,6 +23,7 @@ while getopts ":t:B:R:p:o:T:P:h" option; do
2223
echo "-o Output path where to write the LUTs [.]"
2324
echo "-T Tag to append to LUTs [\"\"]"
2425
echo "-P Particles to consider [\"0 1 2 3 4\"]"
26+
echo "-j Number of parallel processes to use [1]"
2527
echo "-h Show this help"
2628
exit
2729
;;
@@ -68,15 +70,19 @@ function do_copy() {
6870
}
6971

7072
do_copy "${WRITER_PATH}/lutWrite.$WHAT.cc" "lut writer"
73+
do_copy "${WRITER_PATH}/DetectorK/HistoManager.h"
7174
do_copy "${WRITER_PATH}/DetectorK/DetectorK.cxx"
7275
do_copy "${WRITER_PATH}/DetectorK/DetectorK.h"
7376
do_copy "${WRITER_PATH}/lutWrite.cc"
74-
do_copy "${WRITER_PATH}/lutCovm.hh"
75-
cp -r "${WRITER_PATH}/fwdRes" .
77+
if [[ -z ${DELPHESO2_ROOT} ]]; then
78+
do_copy "${WRITER_PATH}/lutCovm.hh"
79+
fi
80+
cp -r "${WRITER_PATH}/fwdRes" .
7681

7782
echo " --- creating LUTs: config = ${WHAT}, field = ${FIELD} T, min tracking radius = ${RMIN} cm"
7883

79-
for i in $PARTICLES; do
84+
function do_lut_for_particle() {
85+
i=${1}
8086
root -l -b <<EOF
8187
.L DetectorK.cxx+
8288
.L lutWrite.${WHAT}.cc
@@ -105,8 +111,20 @@ for i in $PARTICLES; do
105111
}
106112
107113
EOF
114+
115+
}
116+
117+
root -l -b <<EOF
118+
.L DetectorK.cxx+
119+
EOF
120+
121+
for i in ${PARTICLES}; do
122+
((i=i%PARALLEL_JOBS)); ((i++==0)) && wait
123+
do_lut_for_particle "${i}" &
108124
done
109125

126+
wait
127+
110128
# Checking that the output LUTs are OK
111129
NullSize=""
112130
P=(el mu pi ka pr de tr he3)

0 commit comments

Comments
 (0)