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