Skip to content

Commit 5abb30e

Browse files
committed
Make the embedding check work in parallel over detectors
1 parent 245fb95 commit 5abb30e

1 file changed

Lines changed: 54 additions & 18 deletions

File tree

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
set -x
32

43
# Script verifying pileup / embedding features of digitizers
54
# It is a basic and fully automatic status check of what should
@@ -12,24 +11,29 @@ set -x
1211
# 3) we digitize with trivial embedding: background and signal events are the same
1312
# and check whether the output digits have multiple labels --> checks embedding
1413

15-
dets=( ITS TPC TOF EMC HMP MCH MID MFT FV0 FT0 FDD TRD PHS CPV ZDC )
16-
generators=( boxgen boxgen boxgen boxgen hmpidgun fwpigen fwpigen fwpigen fddgen fddgen fddgen boxgen boxgen boxgen boxgen )
14+
dets=( ITS TPC TOF EMC HMP MCH MID MFT FV0 FT0 FDD TRD PHS CPV ZDC )
15+
generators=( boxgen boxgen boxgen boxgen hmpidgun fwpigen fwpigen fwpigen fddgen fddgen fddgen boxgen boxgen boxgen zdcgen )
1716

18-
for idx in "${!dets[@]}"; do
19-
d=${dets[$idx]}
20-
gen=${generators[$idx]}
21-
# we put the detector plus pipe and magnet as materials
22-
o2-sim-serial -m PIPE MAG ${d} -g ${gen} -n 1 --seed 1 -o o2sim${d} > simlog${d} 2>&1
23-
24-
# we duplicate the events/hits a few times in order to have a sufficient
25-
# condition for pileup
26-
f=4
27-
origin="o2sim${d}.root"
28-
target="o2sim${d}_${f}.root"
29-
root -q -b -l ${O2_ROOT}/share/macro/duplicateHits.C\(\"${origin}\",\"${target}\",${f}\)
30-
31-
unlink o2sim.root
32-
unlink o2sim_grp.root
17+
simtask() {
18+
d=$1 # detector
19+
gen=$2 # generator
20+
21+
# we execute the simulation in different directiories to achieve isolation and race-conditions
22+
[[ ! -d "$d" ]] && mkdir ${d}
23+
cd ${d}
24+
25+
# we put the detector plus pipe and magnet as materials
26+
o2-sim-serial -m PIPE MAG ${d} -g ${gen} -n 1 --configKeyValues "BoxGun.number=300" --seed 1 -o o2sim${d} > simlog${d} 2>&1
27+
28+
# we duplicate the events/hits a few times in order to have a sufficient
29+
# condition for pileup
30+
f=4
31+
origin="o2sim${d}.root"
32+
target="o2sim${d}_${f}.root"
33+
root -q -b -l ${O2_ROOT}/share/macro/duplicateHits.C\(\"${origin}\",\"${target}\",${f}\)
34+
35+
[[ -f "o2sim.root" ]] && unlink o2sim.root
36+
[[ -f "o2sim_grp.root" ]] && unlink o2sim_grp.root
3337
ln -s ${target} o2sim.root
3438
ln -s o2sim${d}_grp.root o2sim_grp.root
3539

@@ -40,10 +44,42 @@ for idx in "${!dets[@]}"; do
4044

4145
# digitize with extreme bunch crossing as well as with embedding the signal onto itself
4246
o2-sim-digitizer-workflow --onlyDet ${d} --interactionRate 1e9 -b --tpc-lanes 1 --simFileS o2sim.root > digilog${d} 2>&1
47+
}
48+
49+
checktask() {
50+
d=$1
4351

4452
# find newly created digitfile
4553
digitfile=`ls -lt *digi*.root | head -n 1 | awk '//{print $9}'`
4654

4755
root -q -b -l ${O2_ROOT}/share/macro/analyzeDigitLabels.C\(\"${digitfile}\",\"${d}\"\)
56+
}
57+
58+
59+
CORESPERSOCKET=`lscpu | grep "Core(s) per socket" | awk '{print $4}'`
60+
SOCKETS=`lscpu | grep "Socket(s)" | awk '{print $2}'`
61+
N=`bc <<< "${CORESPERSOCKET}*${SOCKETS}"`
62+
echo "Detected ${N} CPU cores"
63+
64+
# parallel part
65+
for idx in "${!dets[@]}"; do
66+
67+
# parallelize in bunch of N
68+
((i=i%N)); ((i++==0)) && wait
69+
70+
d=${dets[$idx]}
71+
gen=${generators[$idx]}
72+
73+
simtask $d $gen &
74+
done
75+
wait
76+
77+
# checkpart
78+
for idx in "${!dets[@]}"; do
79+
80+
d=${dets[$idx]}
4881

82+
cd ${d}
83+
checktask $d
84+
cd ..
4985
done

0 commit comments

Comments
 (0)