]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AlirootRun_MUONtest.sh
Fixing bug in generating error messages, where the wrong DDL was being indicated.
[u/mrichter/AliRoot.git] / MUON / AlirootRun_MUONtest.sh
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=100 # will simulate 100 events
12
13 #RECOPTIONS="SAVEDIGITS NOFASTDECODERS" # reconstruction options with non-high performance decoders
14 RECOPTIONS="SAVEDIGITS" # default reconstruction options
15 SIMCONFIG="$ALICE_ROOT/MUON/Config.C" # default simulation configuration file
16 OUTDIR=""
17 CURDIR=`pwd`
18
19 #RUN=0 # run number for OCDB access
20 SEED=1234567 # random number generator seed
21 SIMDIR="generated" # sub-directory where to move simulated files prior to reco
22 DUMPEVENT=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  
27 EXIT=0
28
29 while getopts "SRZX:srxzn:tg:p:d:c:" option
30 do
31   case $option in
32     R ) RECONSTRUCTION=1;;
33     S ) SIMULATION=1;;
34     X ) 
35     CHECKS=1
36     DUMPEVENT=$OPTARG
37     ;;
38     Z ) RAW=1;;
39     r ) RECONSTRUCTION=0;;
40     s ) SIMULATION=0;;
41     x ) CHECKS=0;;
42     t ) SLASHTMP=0;;
43     z ) RAW=0;;
44     c ) SIMCONFIG=$OPTARG;;
45     d ) OUTDIR=$OPTARG;;
46     n ) NEVENTS=$OPTARG;;
47     g ) SEED=$OPTARG;;
48     p ) RECOPTIONS=$OPTARG;; 
49     *     ) echo "Unimplemented option chosen."
50     EXIT=1
51     ;;
52   esac
53 done
54
55 if [ ! -n "$OUTDIR" ]; then
56   OUTDIR="$CURDIR/test_out.$NEVENTS"
57 fi
58
59 # look if there are some leftover options
60 shift $(($OPTIND - 1))
61
62 if [ $# -gt 0 ] || [ "$EXIT" -eq 1 ]; then
63   echo "ERROR : extra option not recognized"
64   echo "Usage: `basename $0` options (-SRXsrxn:tg:p:d:c:)"
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)"
68   echo "       -Z (-z) perform reconstruction from raw data (from digits) (default is from raw data, i.e. -Z)"
69   echo "       -n nevents (int) number of events to simulate (default $NEVENTS)"
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)"
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;
76 fi
77
78 # printout the options
79 echo "sim $SIMULATION rec $RECONSTRUCTION check $CHECKS"
80 if [ "$SIMULATION" -eq 1 ]; then
81   echo "$NEVENTS events will be simulated, using the config found at $SIMCONFIG"
82 fi
83 if [ "$RECONSTRUCTION" -eq 1 ]; then
84 echo "Reconstruction options to be used : $RECOPTIONS"
85 if [ "$RAW" -eq 0 ]; then
86 echo "Will reconstruct from digits only (not from raw data)"
87 fi
88 fi
89 echo "Output directory will be : $OUTDIR"
90
91 if [ "$SIMULATION" -eq 1 ]; then
92
93   rm -fr $OUTDIR
94   mkdir $OUTDIR
95
96 fi
97
98 # Copy *ALL* the macros we need in the output directory, not to mess
99 # with our source dir in any way.
100 cp $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
108
109 cd $OUTDIR
110
111 if [ "$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
125 fi
126
127 ###############################################################################
128
129 # Update CTP in OCDB for MUON Trigger
130 #
131 ###############################################################################
132
133 if [ ! -f $ALICE_ROOT/OCDB/GRP/CTP/Config/Run0_999999999_v0_s1.root ]; then
134
135   echo "Updating GRP CTP config  ..."
136
137   aliroot -b >& $OUTDIR/updateCDBCTPConfig.out << EOF
138   .L UpdateCDBCTPConfig.C+
139   UpdateCDBCTPConfig();
140   .q
141 EOF
142   
143 fi
144
145
146 ###############################################################################
147
148 # Performing SIMULATION
149 #
150 ###############################################################################
151
152 if [ "$SIMULATION" -eq 1 ]; then
153
154   echo "Running simulation  ..."
155
156   aliroot -l -b -q runSimulation.C\($SEED,$NEVENTS,\""$SIMCONFIG"\"\) >& $OUTDIR/testSim.out 
157
158   mkdir $OUTDIR/$SIMDIR
159
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   
170 fi
171
172 ###############################################################################
173
174 # Performing RECONSTRUCTION
175 #
176 ###############################################################################
177
178 if [ "$RECONSTRUCTION" -eq 1 ]; then
179
180   if [ "$RAW" -eq 1 ]; then
181     rm -f galice.root 
182   fi  
183   
184   rm -f AliESD*.root *QA*.root
185   
186   echo "Running reconstruction  ..."
187
188   cd $OUTDIR
189   
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
195
196     aliroot -l -b -q runReconstruction\.C\($SEED,\"""\",\""$RECOPTIONS"\"\) >& $OUTDIR/testReco.out
197   
198   fi
199   
200 fi
201
202 ###############################################################################
203
204 # Performing CHECKS (and dumps)
205 #
206 ###############################################################################
207
208 if [ "$CHECKS" -eq 1 ]; then
209
210   if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
211
212     echo "Running efficiency  ..."
213
214     aliroot -b >& $OUTDIR/testResults.out << EOF
215     .L MUONefficiency.C+
216     // no argument assumes Upsilon but MUONefficiency(443) works on Jpsi
217     MUONefficiency("$OUTDIR/$SIMDIR/galice.root");
218     .q
219 EOF
220
221   if [ -f "$OUTDIR/galice.root" ]; then
222
223       echo "Running Trigger efficiency  ..."
224       aliroot -b >& $OUTDIR/testTriggerResults.out << EOF
225       .L MUONTriggerEfficiency.C+
226       MUONTriggerEfficiency("$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", 1);
227       .q
228 EOF
229
230       if [ -f "$OUTDIR/AliESDs.root" ]; then
231
232         echo "Running check ..."
233         aliroot -b >& $OUTDIR/testCheck.out << EOF
234         gSystem->Load("libMUONevaluation");
235         .L MUONCheck.C+
236         MUONCheck(0, $NEVENTS-1, "$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", "$OUTDIR/AliESDs.root"); 
237         .q
238 EOF
239       fi
240     fi
241   fi
242
243   echo "Running dumps for selected event ($DUMPEVENT) ..."
244
245   if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
246     aliroot -l -b  << EOF
247     AliCDBManager* man = AliCDBManager::Instance();
248     man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
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
256 EOF
257   else
258     echo "$OUTDIR/$SIMDIR/galice.root is not there. Skipping sim dumps"
259   fi
260
261   if [ -f "$OUTDIR/galice.root" ]; then
262     aliroot -l -b << EOF
263     AliCDBManager* man = AliCDBManager::Instance();
264     man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
265     AliMUONDataInterface dRec("$OUTDIR/galice.root");
266     dRec.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.recdigits
267     dRec.DumpRecPoints($DUMPEVENT);  > $OUTDIR/dump.$DUMPEVENT.recpoints
268     dRec.DumpTrigger($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trigger
269     .q
270 EOF
271   else
272     echo "$OUTDIR/galice.root is not there. Skipping rec dumps"
273   fi
274 fi
275
276 echo "Finished"  
277 echo "... see results in $OUTDIR"
278
279 cd $CURDIR