]>
Commit | Line | Data |
---|---|---|
f8b7a926 | 1 | #!/bin/bash |
2 | ||
3 | # set job and simulation variables as : | |
4 | # ./Run.sh --run <x> | |
5 | ||
6 | # | |
66ff3038 | 7 | # --- Function to run a command and check return code --------------- |
f8b7a926 | 8 | function runcommand() |
9 | { | |
10 | echo -e "\n" | |
11 | echo -e "\n" >&2 | |
12 | ||
13 | local type=$1 | |
14 | local scr=$2 | |
15 | local log=$3 | |
16 | ||
17 | echo "* $type : $scr" | |
18 | echo "* $type : $scr" >&2 | |
ee275c29 | 19 | date |
20 | echo "Starting ${type} ${scr}" >> $log | |
21 | date >> $log | |
66ff3038 | 22 | if test $noact -gt 0 ; then |
23 | echo "Would execute aliroot -b -q -x $scr" | |
24 | sleep 1 | |
25 | return 0 | |
26 | fi | |
ee275c29 | 27 | |
f8b7a926 | 28 | time aliroot -b -q -x $scr 2> /dev/stdout | tee -a $log |
29 | local ext=$? | |
30 | local exp=${5-0} | |
31 | ||
32 | if test -f syswatch.log ; then | |
33 | mv syswatch.log `basename $log .log`watch.log | |
34 | fi | |
35 | ||
36 | if [ "$ext" -ne "$exp" ]; then | |
37 | echo "*! $scr failed with exitcode $ext, expecting $exp" | |
38 | echo "*! $scr failed with exitcode $ext, expecting $exp" >&2 | |
39 | echo "$scr failed with exitcode $ext, expecting $exp" \ | |
40 | > validation_error.message | |
41 | exit ${4-$ext} | |
42 | else | |
43 | echo "* $scr finished with the expected exit code ($exp), moving on" | |
44 | echo "* $scr finished with the expected exit code ($exp), moving on" >&2 | |
45 | fi | |
ee275c29 | 46 | |
47 | echo "End of ${type} ${scr}" >> $log | |
48 | date >> $log | |
49 | echo "Disk usage in kB per file:" >> $log | |
50 | du -sk * | sort -n -r >> $log | |
51 | echo "Total disk usage: " >> $log | |
52 | du -sh . >> $log | |
53 | ||
f8b7a926 | 54 | } |
55 | ||
66ff3038 | 56 | |
57 | # --- Function to clean up rec-points -------------------------------- | |
f8b7a926 | 58 | function cleanRecPoints() |
59 | { | |
60 | local alsoITS=${1-1} | |
61 | if test $alsoITS -gt 0 ; then | |
62 | rm -f *.RecPoints.root | |
63 | return; | |
64 | fi | |
65 | for i in *.RecPoints.root ; do | |
66 | if test ! -f $i ; then continue ; fi | |
67 | case $i in | |
68 | ITS*) ;; | |
69 | *) rm -f $i ;; | |
70 | esac | |
71 | done | |
72 | } | |
73 | ||
66ff3038 | 74 | # --- Default values of variables ------------------------------------ |
f8b7a926 | 75 | # Define the pt hard bin arrays |
76 | pthardbin_loweredges=( 0 5 11 21 36 57 84 117 152 191 234 ) | |
77 | pthardbin_higheredges=( 5 11 21 36 57 84 117 152 191 234 -1) | |
78 | ||
66ff3038 | 79 | CONFIG_SEED=$((ALIEN_PROC_ID%1000000000)) |
80 | CONFIG_BACKEND=geant3 | |
81 | CONFIG_RUN_TYPE="default" | |
f8b7a926 | 82 | CONFIG_BMIN="" |
83 | CONFIG_BMAX="" | |
84 | CONFIG_QUENCHING="" | |
85 | DC_RUN="" | |
86 | DC_EVENT="1" | |
87 | number=0 | |
66ff3038 | 88 | runAODTrain=1 |
89 | runQATrain=1 | |
90 | runCheck=1 | |
91 | noact=0 | |
f8b7a926 | 92 | |
66ff3038 | 93 | # --- Process command line options ----------------------------------- |
94 | processOptions() | |
95 | { | |
96 | while test $# -gt 0 ; do | |
97 | option="$1" | |
98 | if test "x$option" = "x" ; then continue ; fi | |
99 | case $option in | |
100 | --*) option=`echo $option | sed 's/^--//'` ;; | |
101 | *) ;; | |
102 | esac | |
103 | shift | |
104 | ||
105 | case $option in | |
106 | run) DC_RUN="$1"; shift ;; | |
107 | event) DC_EVENT="$1"; shift ;; | |
108 | backend) CONFIG_BACKEND="$1"; shift ;; | |
109 | process) CONFIG_RUN_TYPE="$1"; shift ;; | |
110 | field) : ; shift ;; # No-op | |
111 | energy) : ; shift ;; # No-op | |
112 | physicslist) : ; shift ;; # No-op | |
113 | bmin) CONFIG_BMIN="$1"; shift ;; | |
114 | bmax) CONFIG_BMAX="$1"; shift ;; | |
115 | pthardbin) : ; shift ;; # No-op | |
116 | quench) CONFIG_QUENCHING="$1"; shift ;; | |
117 | sdd) : ;; # No-op | |
118 | number) number="$1"; shift ;; | |
119 | qa) runQATrain=1 ;; | |
120 | aod) runAODTrain=1 ;; | |
121 | check) runCheck=1 ;; | |
122 | no-aod) runAODTrain=0 ;; | |
123 | no-qa) runQATrain=0 ;; | |
124 | no-check) runCheck=0 ;; | |
125 | no-action) noact=1 ;; | |
126 | *) echo "Unkown option: $option" >&2 | |
127 | esac | |
128 | done | |
129 | } | |
f8b7a926 | 130 | |
66ff3038 | 131 | # --- Process options ------------------------------------------------ |
132 | processOptions `echo $@ | tr ':' ' '` | |
f8b7a926 | 133 | |
66ff3038 | 134 | # --- Set the sed ---------------------------------------------------- |
f8b7a926 | 135 | if [ "$CONFIG_SEED" -eq 0 ]; then |
136 | CONFIG_SEED=$(((DC_RUN*100000+DC_EVENT)%1000000000)) | |
137 | echo "* MC Seed is $CONFIG_SEED (based on run / counter : $DC_RUN / $DC_EVENT)" | |
138 | else | |
139 | echo "* MC Seed is $CONFIG_SEED (based on AliEn job ID)" | |
140 | fi | |
141 | ||
142 | if [ "$CONFIG_SEED" -eq 0 ]; then | |
143 | echo "*! WARNING! Seeding variable for MC is 0 !" >&2 | |
144 | fi | |
145 | ||
66ff3038 | 146 | # --- Move some files out of the way --------------------------------- |
f8b7a926 | 147 | mkdir -p input |
148 | test -f galice.root && mv galice.root ./input/galice.root | |
149 | test -f Kinematics && mv Kinematics.root ./input/Kinematics.root | |
150 | ls input | |
151 | ||
66ff3038 | 152 | # --- Export some setting to the environment ------------------------- |
f8b7a926 | 153 | export CONFIG_SEED \ |
154 | CONFIG_RUN_TYPE \ | |
155 | CONFIG_BMIN \ | |
156 | CONFIG_BMAX \ | |
157 | CONFIG_QUENCHING \ | |
158 | DC_RUN \ | |
159 | DC_EVENT | |
f8b7a926 | 160 | export ALIMDC_RAWDB1="./mdc1" |
161 | export ALIMDC_RAWDB2="./mdc2" | |
162 | export ALIMDC_TAGDB="./mdc1/tag" | |
163 | export ALIMDC_RUNDB="./mdc1/meta" | |
164 | ||
66ff3038 | 165 | # --- Special for geant 4 -------------------------------------------- |
f8b7a926 | 166 | if [ -f "$G4INSTALL/bin/geant4.sh" ]; then |
167 | echo "* Sourcing G4 environment from $G4INSTALL/bin/geant4.sh" | |
168 | source $G4INSTALL/bin/geant4.sh | |
169 | fi | |
170 | ||
66ff3038 | 171 | # --- Print our set-up ----------------------------------------------- |
f8b7a926 | 172 | cat <<EOF |
173 | ||
174 | SIMRUN: Setup | |
175 | Seed: $CONFIG_SEED | |
176 | Run: $DC_RUN | |
177 | Events: $DC_EVENT | |
178 | Event generator: $CONFIG_RUN_TYPE | |
179 | Serial #: $number | |
180 | Impact parameter: ${CONFIG_BMIN}-${CONFIG_BMAX} | |
181 | Quenching: $CONFIG_QUENCHING | |
182 | Run QA: $runQATrain | |
183 | Run AOD $runAODTrain | |
184 | ||
185 | Content of current directory: | |
186 | EOF | |
187 | ls -l | |
188 | ||
189 | echo "SIMRUN: Now read to process" | |
190 | ||
ee275c29 | 191 | # --- Run simulation (out: hits, digits, sdigits) -------------------- |
f8b7a926 | 192 | runcommand "SIMULATION" "Simulate.C($DC_EVENT,$DC_RUN)" sim.log 5 |
ee275c29 | 193 | rm -f *.Hits.root |
15cb4a2b | 194 | type=`echo $CONFIG_RUN_TYPE | tr '[A-Z]' '[a-z]'` |
195 | case x$type in | |
196 | lego*) | |
197 | rm -f *.Digits.root *.SDigits.root | |
198 | cleanRecPoints 1 | |
199 | exit 0 | |
200 | ;; | |
201 | esac | |
ee275c29 | 202 | |
203 | # --- Run reconstruction (in: digits, sdigits, raw out: ESDs) -------- | |
f8b7a926 | 204 | runcommand "RECONSTRUCTION" "Reconstruct.C($DC_RUN)" rec.log 10 |
ee275c29 | 205 | rm -f *.Digits.root *.SDigits.root |
206 | cleanRecPoints 0 | |
207 | ||
208 | # --- Create tags (in: ESDs) ----------------------------------------- | |
f8b7a926 | 209 | runcommand "TAG" "Tag.C" tag.log 50 |
ee275c29 | 210 | |
211 | # --- Run the check -------------------------------------------------- | |
212 | if test $runCheck -gt 0 ; then | |
213 | runcommand "CHECK" "Check.C" check.log 60 | |
214 | fi | |
215 | ||
216 | # --- Possibly run QA analysis --------------------------------------- | |
f8b7a926 | 217 | if test $runQATrain -gt 0 ; then |
218 | runcommand "QA" "QA.C($DC_RUN)" qa.log 100 | |
219 | fi | |
ee275c29 | 220 | |
221 | # --- Possibly run AOD analysis -------------------------------------- | |
f8b7a926 | 222 | if test $runAODTrain -gt 0 ; then |
223 | runcommand "AOD" "AOD.C($DC_RUN)" aod.log 100 | |
224 | fi | |
225 | ||
f8b7a926 | 226 | |
227 | exit 0 | |
228 | # | |
229 | # EOF | |
230 | # | |
231 |