forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_embedding_pileup.sh
More file actions
executable file
·88 lines (67 loc) · 2.87 KB
/
Copy pathcheck_embedding_pileup.sh
File metadata and controls
executable file
·88 lines (67 loc) · 2.87 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
#!/bin/bash
# Script verifying pileup / embedding features of digitizers
# It is a basic and fully automatic status check of what should
# work
# The approach is the following:
# 1) for each detector we simulate event sequences that leave (identical) hits
# 2) we digitize the events with the same collision time assigned to both of them
# and check whether the output digits have multiple labels --> checks pileup
# 3) we digitize with trivial embedding: background and signal events are the same
# and check whether the output digits have multiple labels --> checks embedding
dets=( ITS TPC TOF EMC HMP MCH MID MFT FV0 FT0 FDD TRD PHS CPV ZDC )
generators=( boxgen boxgen boxgen boxgen hmpidgun fwpigen fwpigen fwpigen fddgen fddgen fddgen boxgen boxgen boxgen zdcgen )
simtask() {
d=$1 # detector
gen=$2 # generator
# we execute the simulation in different directiories to achieve isolation and race-conditions
[[ ! -d "$d" ]] && mkdir ${d}
cd ${d}
# we put the detector plus pipe and magnet as materials
o2-sim -j 1 -m PIPE MAG ${d} -g ${gen} -n 1 --configKeyValues "BoxGun.number=300" --seed 1 -o o2sim${d} > simlog${d} 2>&1
# we duplicate the events/hits a few times in order to have a sufficient
# condition for pileup
f=4
origin="o2sim${d}"
target="o2sim${d}_${f}"
root -q -b -l ${O2_ROOT}/share/macro/duplicateHits.C\(\"${origin}\",\"${target}\",${f}\)
# need to link the geometryfile
ln -s "${origin}_geometry.root" "${target}_geometry.root"
# verify that we have hits
NUMHITS=`root -q -b -l ${O2_ROOT}/share/macro/analyzeHits.C\(\"$target\"\) | grep "${d}" | awk '//{print $2}'`
MSG="Found ${NUMHITS} hits for ${d}"
echo $MSG
# digitize with extreme bunch crossing as well as with embedding the signal onto itself
o2-sim-digitizer-workflow --onlyDet ${d} --interactionRate 1e9 -b --tpc-lanes 1 --sims ${target},${target} > digilog${d} 2>&1
}
checktask() {
d=$1
# find newly created digitfile
digitfile=`ls -lt *digi*.root | head -n 1 | awk '//{print $9}'`
root -q -b -l ${O2_ROOT}/share/macro/analyzeDigitLabels.C\(\"${digitfile}\",\"${d}\"\)
}
if [ "$(uname)" == "Darwin" ]; then
CORESPERSOCKET=`system_profiler SPHardwareDataType | grep "Total Number of Cores:" | awk '{print $5}'`
SOCKETS=`system_profiler SPHardwareDataType | grep "Number of Processors:" | awk '{print $4}'`
else
# Do something under GNU/Linux platform
CORESPERSOCKET=`lscpu | grep "Core(s) per socket" | awk '{print $4}'`
SOCKETS=`lscpu | grep "Socket(s)" | awk '{print $2}'`
fi
N=`bc <<< "${CORESPERSOCKET}*${SOCKETS}"`
echo "Detected ${N} CPU cores"
# parallel part
for idx in "${!dets[@]}"; do
# parallelize in bunch of N
((i=i%N)); ((i++==0)) && wait
d=${dets[$idx]}
gen=${generators[$idx]}
simtask $d $gen &
done
wait
# checkpart
for idx in "${!dets[@]}"; do
d=${dets[$idx]}
cd ${d}
checktask $d
cd ..
done