]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # $Id$ | |
3 | ||
4 | # first declare default values | |
5 | ||
6 | SIMULATION=1 # will perform simulation | |
7 | RECONSTRUCTION=1 # will perform reconstruction | |
8 | RAW=1 # will reconstruct from raw data | |
9 | CHECKS=1 # will perform checks | |
10 | SLASHTMP=1 #will use /tmp to put the temporary raw data | |
11 | NEVENTS=50 # will simulate 100 events | |
12 | ||
13 | #RECOPTIONS="SAVEDIGITS NOFASTDECODERS" # reconstruction options with non-high performance decoders | |
14 | RECOPTIONS="SAVEDIGITS" # default reconstruction options | |
15 | MC="" # G3 Simulation with old Config.C | |
16 | #MC="g3" # G3 Simulation (with new config macros) | |
17 | #MC="g4" # G4 Simulation (with new config macros) | |
18 | ||
19 | OUTDIR="" | |
20 | CURDIR=`pwd` | |
21 | ||
22 | #RUN=0 # run number for OCDB access | |
23 | SEED=1234567 # random number generator seed | |
24 | SIMDIR="generated" # sub-directory where to move simulated files prior to reco | |
25 | DUMPEVENT=5 # event to be dump on files (set to negative to skip dumps) | |
26 | ||
27 | SIMCONFIG="$ALICE_ROOT/MUON/"$MC"Config.C" | |
28 | EMBEDWITH="" # no embedding by default | |
29 | REALISTIC=0 # ideal simulation by default | |
30 | ||
31 | # next try to see if there are options of this script that want to change the | |
32 | # defaults | |
33 | ||
34 | EXIT=0 | |
35 | ||
36 | while getopts "SRZX:srxzn:tg:p:d:c:e:b:" option | |
37 | do | |
38 | case $option in | |
39 | R ) RECONSTRUCTION=1;; | |
40 | S ) SIMULATION=1;; | |
41 | X ) | |
42 | CHECKS=1 | |
43 | DUMPEVENT=$OPTARG | |
44 | ;; | |
45 | Z ) RAW=1;; | |
46 | r ) RECONSTRUCTION=0;; | |
47 | s ) SIMULATION=0;; | |
48 | x ) CHECKS=0;; | |
49 | t ) SLASHTMP=0;; | |
50 | z ) RAW=0;; | |
51 | c ) SIMCONFIG=$OPTARG;; | |
52 | d ) OUTDIR=$OPTARG;; | |
53 | n ) NEVENTS=$OPTARG;; | |
54 | g ) SEED=$OPTARG;; | |
55 | p ) RECOPTIONS=$OPTARG;; | |
56 | e ) EMBEDWITH=$OPTARG;; | |
57 | b ) | |
58 | REALISTIC=$OPTARG | |
59 | RAW=0 | |
60 | ;; | |
61 | * ) echo "Unimplemented option chosen." | |
62 | EXIT=1 | |
63 | ;; | |
64 | esac | |
65 | done | |
66 | ||
67 | if [ ! -n "$OUTDIR" ]; then | |
68 | if [ "$MC" = "" ]; then | |
69 | OUTDIR=$CURDIR"/test_out."$NEVENTS | |
70 | else | |
71 | OUTDIR=$CURDIR"/"$MC"_test_out."$NEVENTS | |
72 | fi | |
73 | fi | |
74 | ||
75 | # look if there are some leftover options | |
76 | shift $(($OPTIND - 1)) | |
77 | ||
78 | if [ $# -gt 0 ] || [ "$EXIT" -eq 1 ]; then | |
79 | echo "ERROR : extra option not recognized" | |
80 | echo "Usage: `basename $0` options (-SRXsrxn:tg:p:d:c:)" | |
81 | echo " -S (-s) perform (or not) simulation (default is do it, i.e -S)" | |
82 | echo " -R (-r) perform (or not) reconstruction (default is do it, i.e. -R)" | |
83 | echo " -X event (-x) perform (or not) checks and dumps (default is do it for event $DUMPEVENT, i.e. -X $DUMPEVENT)" | |
84 | echo " -Z (-z) perform reconstruction from raw data (from digits) (default is from raw data, i.e. -Z)" | |
85 | echo " -n nevents (int) number of events to simulate (default $NEVENTS)" | |
86 | echo " -t will use OUTDIR as a tmp directory to generate raw data " | |
87 | echo " -g seed (uint) seed to be used in simulation (default $SEED)" | |
88 | echo " -p recoptions (quotified string) reconstruction options to use (default \"$RECOPTIONS\")" | |
89 | echo " -d full path to output directory (default $OUTDIR)" | |
90 | echo " -c full path to configuration file for simulation (default $SIMCONFIG)" | |
91 | echo " -e full path to a galice.root file relating to SDigits to be merged (embedding)" | |
92 | echo " -b runnumber (int) make a realistic simulation using runnumber as anchor (default 0=ideal simulation)" | |
93 | exit 4; | |
94 | fi | |
95 | ||
96 | ||
97 | # printout the options | |
98 | echo "sim $SIMULATION rec $RECONSTRUCTION check $CHECKS" | |
99 | if [ "$SIMULATION" -eq 1 ]; then | |
100 | echo "$NEVENTS events will be simulated, using the config found at $SIMCONFIG" | |
101 | fi | |
102 | if [ -n "$EMBEDWITH" ]; then | |
103 | echo "Will embed simulation with $EMBEDWITH" | |
104 | fi | |
105 | if [ "$REALISTIC" -gt 0 ]; then | |
106 | echo "Will use anchor run $REALISTIC" | |
107 | fi | |
108 | if [ "$RECONSTRUCTION" -eq 1 ]; then | |
109 | echo "Reconstruction options to be used : $RECOPTIONS" | |
110 | if [ "$RAW" -eq 0 ]; then | |
111 | echo "Will reconstruct from digits only (not from raw data)" | |
112 | fi | |
113 | fi | |
114 | echo "Output directory will be : $OUTDIR" | |
115 | ||
116 | if [ "$SIMULATION" -eq 1 ]; then | |
117 | ||
118 | rm -fr $OUTDIR | |
119 | mkdir $OUTDIR | |
120 | ||
121 | fi | |
122 | ||
123 | # Copy *ALL* the macros we need in the output directory, not to mess | |
124 | # with our source dir in any way. | |
125 | cp $ALICE_ROOT/MUON/.rootrc \ | |
126 | $ALICE_ROOT/MUON/rootlogon.C \ | |
127 | $ALICE_ROOT/MUON/runReconstruction.C $ALICE_ROOT/MUON/runSimulation.C \ | |
128 | $ALICE_ROOT/MUON/UpdateCDBCTPConfig.C \ | |
129 | $ALICE_ROOT/MUON/MUONefficiency.C \ | |
130 | $ALICE_ROOT/MUON/MUONTriggerEfficiency.C \ | |
131 | $ALICE_ROOT/MUON/MUONCheck.C \ | |
132 | $OUTDIR | |
133 | ||
134 | cd $OUTDIR | |
135 | ||
136 | if [ "$SLASHTMP" -eq 0 ]; then | |
137 | mkdir ./tmp | |
138 | mkdir ./tmp/mdc1 | |
139 | mkdir ./tmp/mdc2 | |
140 | mkdir ./tmp/mdc1/tags | |
141 | ||
142 | chmod 777 ./tmp | |
143 | chmod 777 ./tmp/mdc1 | |
144 | chmod 777 ./tmp/mdc2 | |
145 | chmod 777 ./tmp/mdc1/tags | |
146 | ||
147 | export ALIMDC_RAWDB1=./tmp/mdc1 | |
148 | export ALIMDC_RAWDB2=./tmp/mdc2 | |
149 | export ALIMDC_TAGDB=./tmp/mdc1/tags | |
150 | fi | |
151 | ||
152 | ############################################################################### | |
153 | # | |
154 | # Update CTP in OCDB for MUON Trigger | |
155 | # | |
156 | ############################################################################### | |
157 | ||
158 | if [ ! -f $ALICE_ROOT/OCDB/GRP/CTP/Config/Run0_999999999_v0_s1.root ]; then | |
159 | ||
160 | echo "Updating GRP CTP config ..." | |
161 | ||
162 | aliroot -b > $OUTDIR/updateCDBCTPConfig.out 2>&1 << EOF | |
163 | .L UpdateCDBCTPConfig.C++g | |
164 | UpdateCDBCTPConfig(); | |
165 | .q | |
166 | EOF | |
167 | ||
168 | fi | |
169 | ||
170 | ||
171 | ############################################################################### | |
172 | # | |
173 | # Performing SIMULATION | |
174 | # | |
175 | ############################################################################### | |
176 | ||
177 | if [ "$SIMULATION" -eq 1 ]; then | |
178 | ||
179 | echo "Running simulation ..." | |
180 | ||
181 | aliroot -l -b -q runSimulation.C\($SEED,$NEVENTS,\""$SIMCONFIG"\"\,\""$EMBEDWITH"\"\,$REALISTIC\) > $OUTDIR/testSim.out 2>&1 | |
182 | ||
183 | mkdir $OUTDIR/$SIMDIR | |
184 | ||
185 | if [ "$RAW" -eq 1 ]; then | |
186 | if [ "$REALISTIC" -eq 0 ]; then # we can not move for realistic simulations as we need e.g. kinematics to propagate the simulated vertex to the reco. | |
187 | echo "Moving generated files to $SIMDIR" | |
188 | mv $OUTDIR/*QA*.root $OUTDIR/*.log $OUTDIR/$SIMDIR | |
189 | mv $OUTDIR/MUON*.root $OUTDIR/TrackRefs*.root $OUTDIR/$SIMDIR | |
190 | mv $OUTDIR/Kinematics*.root $OUTDIR/galice.root $OUTDIR/$SIMDIR | |
191 | fi | |
192 | else | |
193 | echo "Copying generated files to $SIMDIR" | |
194 | cp $OUTDIR/*QA*.root $OUTDIR/*.log $OUTDIR/$SIMDIR | |
195 | cp $OUTDIR/MUON*.root $OUTDIR/Kinematics*.root $OUTDIR/galice.root $OUTDIR/TrackRefs*.root $OUTDIR/$SIMDIR | |
196 | fi | |
197 | ||
198 | # save geometry file in a separate directory | |
199 | if [ "$MC" = "g3" ]; then | |
200 | rm -fr $ALICE_ROOT/MUON/geometry | |
201 | mkdir $ALICE_ROOT/MUON/geometry | |
202 | cp $OUTDIR/geometry.root $ALICE_ROOT/MUON/geometry | |
203 | fi | |
204 | ||
205 | # copy input geometry file in a current directory | |
206 | if [ "$MC" = "g4" ]; then | |
207 | cp $ALICE_ROOT/MUON/geometry/geometry.root $OUTDIR | |
208 | fi | |
209 | ||
210 | cp $OUTDIR/geometry.root $OUTDIR/$SIMDIR/geometry.root | |
211 | ||
212 | fi | |
213 | ||
214 | ############################################################################### | |
215 | # | |
216 | # Performing RECONSTRUCTION | |
217 | # | |
218 | ############################################################################### | |
219 | ||
220 | if [ "$RECONSTRUCTION" -eq 1 ]; then | |
221 | ||
222 | if [ "$RAW" -eq 1 ]; then | |
223 | if [ "$REALISTIC" -eq 0 ]; then | |
224 | rm -f galice.root | |
225 | fi | |
226 | fi | |
227 | ||
228 | if [ "$REALISTIC" -ne 0 ]; then | |
229 | rm -f geometry.root | |
230 | fi | |
231 | ||
232 | rm -f AliESD*.root *QA*.root | |
233 | ||
234 | echo "Running reconstruction ..." | |
235 | ||
236 | cd $OUTDIR | |
237 | ||
238 | RAWOCDB=kFALSE | |
239 | ||
240 | if [ -n "$EMBEDWITH" ]; then | |
241 | RAWOCDB=kTRUE | |
242 | fi | |
243 | ||
244 | if [ "$REALISTIC" -gt 0 ]; then | |
245 | RAWOCDB=kTRUE | |
246 | fi | |
247 | ||
248 | if [ "$RAW" -eq 1 ]; then | |
249 | ||
250 | aliroot -l -b -q runReconstruction\.C\($SEED,\""$OUTDIR/raw.root"\",\""$RECOPTIONS"\",$RAWOCDB\) > $OUTDIR/testReco.out 2>&1 | |
251 | ||
252 | else | |
253 | ||
254 | aliroot -l -b -q runReconstruction\.C\($SEED,\"""\",\""$RECOPTIONS"\",$RAWOCDB\) > $OUTDIR/testReco.out 2>&1 | |
255 | ||
256 | fi | |
257 | ||
258 | fi | |
259 | ||
260 | ############################################################################### | |
261 | # | |
262 | # Performing CHECKS (and dumps) | |
263 | # | |
264 | ############################################################################### | |
265 | ||
266 | if [ "$CHECKS" -eq 1 ]; then | |
267 | ||
268 | if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then | |
269 | ||
270 | echo "Running efficiency ..." | |
271 | ||
272 | aliroot -b > $OUTDIR/testResults.out 2>&1 << EOF | |
273 | .L MUONefficiency.C++g | |
274 | // no argument assumes Upsilon but MUONefficiency(443) works on Jpsi | |
275 | MUONefficiency("$OUTDIR/$SIMDIR/galice.root"); | |
276 | .q | |
277 | EOF | |
278 | ||
279 | if [ -f "$OUTDIR/galice.root" ]; then | |
280 | ||
281 | echo "Running Trigger efficiency ..." | |
282 | aliroot -b > $OUTDIR/testTriggerResults.out 2>&1 << EOF | |
283 | .L MUONTriggerEfficiency.C++g | |
284 | MUONTriggerEfficiency("$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", 1); | |
285 | .q | |
286 | EOF | |
287 | ||
288 | if [ -f "$OUTDIR/AliESDs.root" ]; then | |
289 | ||
290 | echo "Running check ..." | |
291 | aliroot -b > $OUTDIR/testCheck.out 2>&1 << EOF | |
292 | gSystem->Load("libMUONevaluation"); | |
293 | .L MUONCheck.C++g | |
294 | MUONCheck(0, $NEVENTS-1, "$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", "$OUTDIR/AliESDs.root"); | |
295 | .q | |
296 | EOF | |
297 | fi | |
298 | fi | |
299 | fi | |
300 | ||
301 | if [ "$DUMPEVENT" -ge 0 ]; then | |
302 | ||
303 | echo "Running dumps for selected event ($DUMPEVENT) ..." | |
304 | ||
305 | if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then | |
306 | aliroot -l -b << EOF | |
307 | AliCDBManager* man = AliCDBManager::Instance(); | |
308 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
309 | AliMUONMCDataInterface mcdSim("$OUTDIR/$SIMDIR/galice.root"); | |
310 | mcdSim.DumpKine($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.kine | |
311 | mcdSim.DumpHits($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.hits | |
312 | mcdSim.DumpTrackRefs($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trackrefs | |
313 | mcdSim.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.simdigits | |
314 | mcdSim.DumpSDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.sdigits | |
315 | .q | |
316 | EOF | |
317 | else | |
318 | echo "$OUTDIR/$SIMDIR/galice.root is not there. Skipping sim dumps" | |
319 | fi | |
320 | ||
321 | if [ -f "$OUTDIR/galice.root" ]; then | |
322 | aliroot -l -b << EOF | |
323 | AliCDBManager* man = AliCDBManager::Instance(); | |
324 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
325 | AliMUONDataInterface dRec("$OUTDIR/galice.root"); | |
326 | dRec.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.recdigits | |
327 | dRec.DumpRecPoints($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.recpoints | |
328 | dRec.DumpTrigger($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trigger | |
329 | .q | |
330 | EOF | |
331 | else | |
332 | echo "$OUTDIR/galice.root is not there. Skipping rec dumps" | |
333 | fi | |
334 | fi | |
335 | ||
336 | fi | |
337 | ||
338 | echo "Finished" | |
339 | echo "... see results in $OUTDIR" | |
340 | ||
341 | cd $CURDIR |