-
Notifications
You must be signed in to change notification settings - Fork 0
/
particleSim.sh
executable file
·148 lines (131 loc) · 4.29 KB
/
particleSim.sh
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
#!/bin/bash
function rep_str()
{
pos=$1
ostr=$2
ostrlen=${#ostr}
vu=${ostr:pos:1}
vl=`echo "${vu}" | tr '[:upper:]' '[:lower:]'`
v1=${ostr:0:pos}
v3=${ostr:pos+1:ostrlen}
nstr=${v1}${vl}${v3}
echo ${nstr}
}
targName=("D" "C" "Fe" "Pb")
targType=("lt" "st" "st" "st")
targA=( 2 12 56 207)
targZ=( 1 6 26 82)
targZpos=( -30 -25 -25 -25)
targVG2=( 1 2 2 2)
Nevts=
pid=
bkg=
targ=
SIMINDIR=
tarA="${targA[$targ]}"
tarZ="${targZ[$targ]}"
tarZpos="${targZpos[$targ]}"
tarVG2="${targVG2[$targ]}"
tarName="${targName[$targ]}"
tarType="${targType[$targ]}"
leptobosfile=lepto${tarName}.A00
leptologfile=lepto${tarName}.log
leptoinfile=lepto${tarName}.txt
ffreadfile="ffread_eg2${tarName}_${tarType}.gsim"
gsimbosfile=gsim${tarName}.A00
gsimlogfile=gsim${tarName}.log
gppbosfile=gpp${tarName}.A00
gppntpfile=gpp${tarName}.hbook
gpplogfile=gpp${tarName}.log
tclfile=recsis${tarName}.tcl
rechisfile=recsis${tarName}_histos.hbook
recntpfile=recsis${tarName}.hbook
recbosfile=recsis${tarName}.A00
reclogfile=recsis${tarName}.log
recsislogfile=recsis${tarName}_log.log
recrootfile=recsis${tarName}.root
wrdstlogfile=WriteRootDst${tarName}.log
#Part 1: Setting environment variables
echo
echo "%%% Setting environment variables... %%%"
export SIMINDIR=${HOME}/simulations
source ${SIMINDIR}/set_env.sh
echo "%%% Environment variables ready. %%%"
echo
#Part 2: start lepto process
echo
echo "%%% Running LEPTO... %%%"
echo "${Nevts} ${tarA} ${tarZ} ${pid}" > ./lepto.txt
if [[ "$bkg" == "0" ]]; then
${SIMINDIR}/Lepto64Sim/bin/lepto.exe | ${SIMINDIR}/leptotxt.pl | ${SOFT}/txt2part_src/bin/txt2part.exe -o${leptobosfile} 2>&1 | tee ${leptologfile} # only omegas
elif [[ "$bkg" == "1" ]]; then
${SIMINDIR}/Lepto64Sim/bin/lepto_bkg.exe | ${SIMINDIR}/leptotxt.pl | ${SOFT}/txt2part_src/bin/txt2part.exe -o${leptobosfile} 2>&1 | tee ${leptologfile} # no omegas
elif [[ "$bkg" == "2" ]]; then
${SIMINDIR}/Lepto64Sim/bin/lepto_bkg_v2.exe | ${SIMINDIR}/leptotxt.pl | ${SOFT}/txt2part_src/bin/txt2part.exe -o${leptobosfile} 2>&1 | tee ${leptologfile} # no omegas, no etas
fi
mv lepto.txt ${leptoinfile}
echo "%%% LEPTO ended. %%%"
echo
#Part 3: start gsim process
echo
echo "%%% Running GSIM... %%%"
sed -i "s/TGTP/TGTP ${tarA}/g" ${ffreadfile}
sed -i "s/VEG2/VEG2 ${tarVG2}/g" ${ffreadfile}
sed -i "s/TRIG/TRIG ${Nevts}/g" ${ffreadfile}
${CLAS_BIN}/gsim_bat -ffread ${ffreadfile} -mcin ${leptobosfile} -bosout ${gsimbosfile} 2>&1 | tee ${gsimlogfile}
if [ -f "${gsimbosfile}.A00" ]; then
mv "${gsimbosfile}.A00" ${gsimbosfile}
fi
echo "%%% GSIM ready. %%%"
echo
##Part 4: start gpp process
echo
echo "%%% Running GPP... %%%"
export CLAS_CALDB_RUNINDEX=calib_user.RunindexLorenzo
${CLAS_BIN}/gpp -P0x1f -Y -o${gppbosfile} -a1.2 -b0.86 -c0.87 -f1. -R41147 ${gsimbosfile} 2>&1 | tee ${gpplogfile}
if [ -f gpp.hbook ]; then
mv gpp.hbook ${gppntpfile}
fi
echo "%%% GPP ended. %%%"
echo
#Part 5: recsis process
echo
echo "%%% Running USER_ANA %%%"
export CLAS_CALDB_RUNINDEX="calib.RunIndex"
sed -i "s|inputfile|inputfile ${gppbosfile};|g" ${tclfile}
sed -i "s|setc chist_filename|setc chist_filename ${recntpfile};|g" ${tclfile}
sed -i "s|setc log_file_name|setc log_file_name ${reclogfile};|g" ${tclfile}
sed -i "s|outputfile|outputfile ${recbosfile} PROC1 2047;|g" ${tclfile}
sed -i "s|set TargetPos(3)|set TargetPos(3) ${tarZpos};|g" ${tclfile}
sed -i "s|go|go ${Nevts};|g" ${tclfile}
${CLAS_BIN}/user_ana -t ${tclfile} 2>&1 | tee ${recsislogfile}
echo "%%% USER_ANA ended. %%%"
echo
#Part 6: convert recsis ntuple name to upper case
echo
echo "%%% Check USER_ANA output %%%"
if [ ! -f ${recntpfile} ]; then
new_recntpfile=$(rep_str 6 "${recntpfile}")
if [ -f ${new_recntpfile} ]; then
mv ${new_recntpfile} ${recntpfile}
fi
fi
if [ -f histo.hbook ]; then
mv histo.hbook ${rechisfile}
fi
echo "%%% Check USER_ANA output ended %%%"
echo
#Part 7: start ClasTool process
echo
echo "%%% Running WRITE_ROOT_DST... %%%"
${CLAS_BIN}/WriteRootDst_b2r ${recbosfile} -GSIM -o ${recrootfile} 2>&1 | tee ${wrdstlogfile}
echo "%%% WRITE_ROOT_DST ended %%%"
echo
#Part 8: remove trash files
echo
echo "%%% Removing trash files... %%%"
GLOBIGNORE=${recrootfile}
rm -v *
unset GLOBIGNORE
echo "%%% Everything ready, sir! %%%"
echo