Skip to content

Commit 2bc29ef

Browse files
committed
More automated multitrial trials
1 parent 454d0e0 commit 2bc29ef

File tree

2 files changed

+53
-67
lines changed

2 files changed

+53
-67
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
BASE_TRIALS = (
4+
["min_narrow", "min_narrow2", "min_wide", "min_wide2"],
5+
["max_narrow", "max_narrow2", "max_wide", "max_wide2"],
6+
["fixed_sigma"],
7+
["fixed_mean"],
8+
["double_gauss"],
9+
["poly3"]
10+
)
11+
12+
13+
def generate_trials(trial_classes):
14+
combinations = [""]
15+
for trial_class in trial_classes:
16+
class_comb = []
17+
for cur_comb in combinations:
18+
for trial in trial_class:
19+
class_comb.append(cur_comb + "-" + trial)
20+
print(f"{cur_comb}-{trial}")
21+
combinations.extend(class_comb)
22+
return combinations
23+
24+
25+
combinations = generate_trials(BASE_TRIALS)

PWGHF/D2H/Macros/run-fitter-multitrial.sh

Lines changed: 28 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,52 @@
22

33
PERM_PATTERN="prompt"
44

5-
INPUT_DIR="/data8/majak/MLHEP/input-d2h-fitter-012025"
6-
INPUT_PATTERN="${INPUT_DIR}/projections-"
7-
INFILE="projections-${PERM_PATTERN}.root"
8-
dir="${INPUT_DIR}/${INFILE}"
9-
105
CONFIG="config_massfitter_${PERM_PATTERN}"
116
CONFIG_EXT="${CONFIG}.json"
7+
TRIAL_FILE="trials.txt"
128

139
FIXED_SIGMA="[0.0081, 0.0081, 0.0088, 0.0102, 0.0117, 0.0133, 0.0140, 0.0155, 0.0175, 0.0197, 0.0228, 0.0260]"
1410
FIXED_SIGMA_CUTVAR="[0.0097, 0.0082, 0.0092, 0.0104, 0.0116, 0.0134, 0.0145, 0.0162, 0.0182, 0.0204, 0.0230, 0.0263]"
1511
FIXED_SIGMA_GAUSS="[0.0080, 0.0080, 0.0087, 0.0088, 0.0098, 0.0101, 0.0116, 0.0141, 0.0145, 0.0150, 0.0135, 0.0118]"
1612
SECOND_SIGMA_GAUSS="[0.0134, 0.0134, 0.0088, 0.0164, 0.0199, 0.0184, 0.0207, 0.0319, 0.0313, 0.0320, 0.0320, 0.0320]"
1713
FIXED_MEAN="[2.286, 2.284, 2.285, 2.285, 2.285, 2.285, 2.285, 2.285, 2.285, 2.284, 2.285, 2.285]"
1814
FIXED_MEAN_PDG="[2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646, 2.28646]"
15+
# Note that MLHEP produces histomass in [2.10, 2.47]
16+
# For high pt, wide2 trials won't work
1917
MASS_MIN_WIDE="[2.206, 2.206, 2.19, 2.18, 2.17, 2.17, 2.17, 2.15, 2.09, 2.09, 2.09, 2.09]"
2018
MASS_MAX_WIDE="[2.37, 2.37, 2.38, 2.39, 2.41, 2.41, 2.41, 2.43, 2.47, 2.47, 2.47, 2.47]"
2119
MASS_MIN_NARROW="[2.226, 2.226, 2.21, 2.20, 2.19, 2.19, 2.19, 2.17, 2.11, 2.11, 2.11, 2.11]"
2220
MASS_MAX_NARROW="[2.35, 2.35, 2.36, 2.37, 2.39, 2.39, 2.39, 2.41, 2.45, 2.45, 2.45, 2.45]"
2321
GAUSS_SIGNAL="[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"
2422
POLY3_BKG="[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]"
23+
MASS_MIN_WIDE2="[2.196, 2.196, 2.18, 2.17, 2.16, 2.16, 2.16, 2.14, 2.08, 2.08, 2.08, 2.08]"
24+
MASS_MAX_WIDE2="[2.38, 2.38, 2.39, 2.40, 2.42, 2.42, 2.42, 2.44, 2.48, 2.48, 2.48, 2.48]"
25+
MASS_MIN_NARROW2="[2.236, 2.236, 2.22, 2.21, 2.20, 2.20, 2.20, 2.18, 2.12, 2.12, 2.12, 2.12]"
26+
MASS_MAX_NARROW2="[2.34, 2.34, 2.35, 2.36, 2.38, 2.38, 2.38, 2.40, 2.44, 2.44, 2.44, 2.44]"
2527

2628
CENTRAL_TRIAL="-cheb"
2729

28-
TRIALS=(
29-
"-fixed_sigma"
30-
"-fixed_mean"
31-
"-narrow_range"
32-
"-wide_range"
33-
"-double_gauss"
34-
"-poly3"
35-
"-fixed_sigma-fixed_mean"
36-
"-fixed_sigma-narrow_range"
37-
"-fixed_sigma-wide_range"
38-
"-fixed_sigma-double_gauss"
39-
"-fixed_sigma-poly3"
40-
"-fixed_mean-narrow_range"
41-
"-fixed_mean-wide_range"
42-
"-fixed_mean-double_gauss"
43-
"-fixed_mean-poly3"
44-
"-narrow_range-double_gauss"
45-
"-narrow_range-poly3"
46-
"-wide_range-double_gauss"
47-
"-wide_range-poly3"
48-
"-double_gauss-poly3"
49-
"-fixed_sigma-fixed_mean-narrow_range"
50-
"-fixed_sigma-fixed_mean-wide_range"
51-
"-fixed_sigma-fixed_mean-double_gauss"
52-
"-fixed_sigma-fixed_mean-poly3"
53-
"-fixed_sigma-narrow_range-double_gauss"
54-
"-fixed_sigma-narrow_range-poly3"
55-
"-fixed_sigma-wide_range-double_gauss"
56-
"-fixed_sigma-wide_range-poly3"
57-
"-fixed_sigma-double_gauss-poly3"
58-
"-fixed_mean-narrow_range-double_gauss"
59-
"-fixed_mean-narrow_range-poly3"
60-
"-fixed_mean-wide_range-double_gauss"
61-
"-fixed_mean-wide_range-poly3"
62-
"-fixed_mean-double_gauss-poly3"
63-
"-narrow_range-double_gauss-poly3"
64-
"-wide_range-double_gauss-poly3"
65-
"-fixed_sigma-fixed_mean-narrow_range-double_gauss"
66-
"-fixed_sigma-fixed_mean-narrow_range-poly3"
67-
"-fixed_sigma-fixed_mean-wide_range-double_gauss"
68-
"-fixed_sigma-fixed_mean-wide_range-poly3"
69-
"-fixed_sigma-fixed_mean-double_gauss-poly3"
70-
"-fixed_sigma-narrow_range-double_gauss-poly3"
71-
"-fixed_sigma-wide_range-double_gauss-poly3"
72-
"-fixed_mean-narrow_range-double_gauss-poly3"
73-
"-fixed_mean-wide_range-double_gauss-poly3"
74-
"-fixed_sigma-fixed_mean-narrow_range-double_gauss-poly3"
75-
"-fixed_sigma-fixed_mean-wide_range-double_gauss-poly3"
76-
)
30+
python generate_trials.py > ${TRIAL_FILE}
7731

78-
for ind_tr in "${!TRIALS[@]}" ; do
79-
trial=${TRIALS[ind_tr]}
80-
echo $trial
32+
while IFS="" read -r trial || [ -n "$trial" ] ; do
33+
echo "${trial}"
8134

8235
RESDIR="results_${PERM_PATTERN}${CENTRAL_TRIAL}${trial}"
83-
RESPATH="/data8/majak/d2h-fitter/0125/${RESDIR}"
36+
RESPATH="/data8/majak/d2h-fitter/0325/${RESDIR}"
8437
mkdir "${RESPATH}"
8538

8639
CUR_CFG="${CONFIG}${trial}.json"
8740
cp "${CONFIG_EXT}" "${CUR_CFG}"
8841

89-
sed -i "s/%indir%/${INPUT_DIR//\//\\/}/g" "${CUR_CFG}" || exit 1
90-
sed -i "s/%infile%/${INFILE}/g" "${CUR_CFG}" || exit 1
9142
sed -i "s/%outdir%/${RESPATH//\//\\/}/g" "${CUR_CFG}" || exit 1
9243

9344
IFS='-' read -ra SINGLE_TRIALS <<< "${trial}"
9445
echo "Trial combination: "
9546
for i in "${!SINGLE_TRIALS[@]}" ; do
9647
if [[ ${SINGLE_TRIALS[i]} == "" ]]; then
9748
continue
98-
fi
99-
49+
fi
50+
10051
echo "${SINGLE_TRIALS[i]} "
10152

10253
if [[ ${SINGLE_TRIALS[i]} == "fixed_sigma" ]]; then
@@ -105,12 +56,22 @@ for ind_tr in "${!TRIALS[@]}" ; do
10556
elif [[ ${SINGLE_TRIALS[i]} == "fixed_mean" ]]; then
10657
sed -i "s/\"FixMean\":.*$/\"FixMean\": true,/" "${CUR_CFG}" || exit 1
10758
sed -i "s/\"FixMeanManual.*$/\"FixMeanManual\": ${FIXED_MEAN},/" "${CUR_CFG}" || exit 1
108-
elif [[ ${SINGLE_TRIALS[i]} == "wide_range" ]]; then
59+
elif [[ ${SINGLE_TRIALS[i]} == "min_wide" ]]; then
10960
sed -i "s/\"MassMin.*$/\"MassMin\": ${MASS_MIN_WIDE},/" "${CUR_CFG}" || exit 1
61+
elif [[ ${SINGLE_TRIALS[i]} == "max_wide" ]]; then
11062
sed -i "s/\"MassMax.*$/\"MassMax\": ${MASS_MAX_WIDE},/" "${CUR_CFG}" || exit 1
111-
elif [[ ${SINGLE_TRIALS[i]} == "narrow_range" ]]; then
63+
elif [[ ${SINGLE_TRIALS[i]} == "min_narrow" ]]; then
11264
sed -i "s/\"MassMin.*$/\"MassMin\": ${MASS_MIN_NARROW},/" "${CUR_CFG}" || exit 1
65+
elif [[ ${SINGLE_TRIALS[i]} == "max_narrow" ]]; then
11366
sed -i "s/\"MassMax.*$/\"MassMax\": ${MASS_MAX_NARROW},/" "${CUR_CFG}" || exit 1
67+
elif [[ ${SINGLE_TRIALS[i]} == "min_wide2" ]]; then
68+
sed -i "s/\"MassMin.*$/\"MassMin\": ${MASS_MIN_WIDE2},/" "${CUR_CFG}" || exit 1
69+
elif [[ ${SINGLE_TRIALS[i]} == "max_wide2" ]]; then
70+
sed -i "s/\"MassMax.*$/\"MassMax\": ${MASS_MAX_WIDE2},/" "${CUR_CFG}" || exit 1
71+
elif [[ ${SINGLE_TRIALS[i]} == "min_narrow2" ]]; then
72+
sed -i "s/\"MassMin.*$/\"MassMin\": ${MASS_MIN_NARROW2},/" "${CUR_CFG}" || exit 1
73+
elif [[ ${SINGLE_TRIALS[i]} == "max_narrow2" ]]; then
74+
sed -i "s/\"MassMax.*$/\"MassMax\": ${MASS_MAX_NARROW2},/" "${CUR_CFG}" || exit 1
11475
elif [[ ${SINGLE_TRIALS[i]} == "double_gauss" ]]; then
11576
sed -i "s/\"SgnFunc.*$/\"SgnFunc\": ${GAUSS_SIGNAL},/" "${CUR_CFG}" || exit 1
11677
sed -i "s/\"FixSigma\":.*$/\"FixSigma\": true,/" "${CUR_CFG}" || exit 1
@@ -120,11 +81,11 @@ for ind_tr in "${!TRIALS[@]}" ; do
12081
elif [[ ${SINGLE_TRIALS[i]} == "poly3" ]]; then
12182
sed -i "s/\"BkgFunc.*$/\"BkgFunc\": ${POLY3_BKG},/" "${CUR_CFG}" || exit 1
12283
fi
123-
84+
12485
done
12586

12687
echo ""
12788
echo ""
12889

129-
root -b -l -q -x "HFInvMassFitter.cxx" runMassFitter.C\(\"${CUR_CFG}\"\)
130-
done
90+
#root -b -l -q -x "HFInvMassFitter.cxx" runMassFitter.C\(\"${CUR_CFG}\"\)
91+
done < ${TRIAL_FILE}

0 commit comments

Comments
 (0)