Separating run-dependent mapping data from data, which are not
[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
8CHECKS=1 # will perform checks
9NEVENTS=100 # will simulate 100 events
32bf5f82 10
5f3519d9 11#RECOPTIONS="SAVEDIGITS NOFASTDECODERS" # reconstruction options with non-high performance decoders
aefc4e02 12RECOPTIONS="SAVEDIGITS" # default reconstruction options
13SIMCONFIG="$ALICE_ROOT/MUON/Config.C" # default simulation configuration file
14OUTDIR=""
fa701981 15CURDIR=`pwd`
fa701981 16
745f6baf 17#RUN=0 # run number for OCDB access
aefc4e02 18SEED=1234567 # random number generator seed
19SIMDIR="generated" # sub-directory where to move simulated files prior to reco
20DUMPEVENT=5 # event to be dump on files
21
22# next try to see if there are options of this script that want to change the
23# defaults
24
25EXIT=0
26
27while getopts "SRX:srxn:p:d:c:" option
28do
29 case $option in
30 R ) RECONSTRUCTION=1;;
31 S ) SIMULATION=1;;
32 X )
33 CHECKS=1
34 DUMPEVENT=$OPTARG
35 ;;
36 r ) RECONSTRUCTION=0;;
37 s ) SIMULATION=0;;
38 x ) CHECKS=0;;
39 c ) SIMCONFIG=$OPTARG;;
40 d ) OUTDIR=$OPTARG;;
41 n ) NEVENTS=$OPTARG;;
42 p ) RECOPTIONS=$OPTARG;;
43 * ) echo "Unimplemented option chosen."
44 EXIT=1
45 ;;
46 esac
47done
48
49if [ ! -n "$OUTDIR" ]; then
50 OUTDIR="$CURDIR/test_out.$NEVENTS"
51fi
52
53# look if there are some leftover options
54shift $(($OPTIND - 1))
55
56if [ $# -gt 0 ] || [ "$EXIT" -eq 1 ]; then
57 echo "ERROR : extra option not recognized"
58 echo "Usage: `basename $0` options (-SRXsrxn:p:d:c:)"
59 echo " -S (-s) perform (or not) simulation (default is do it, i.e -S)"
60 echo " -R (-r) perform (or not) reconstruction (default is do it, i.e. -R)"
61 echo " -X event (-x) perform (or not) checks and dumps (default is do it for event $DUMPEVENT, i.e. -X $DUMPEVENT)"
62 echo " -n nevents (int) number of events to simulate (default $NEVENTS)"
63 echo " -p recoptions (quotified string) reconstruction options to use (default \"$RECOPTIONS\")"
64 echo " -d full path to output directory (default $OUTDIR)"
65 echo " -c full path to configuration file for simulation (default $SIMCONFIG)"
66 exit 4;
67fi
68
69# printout the options
70echo "sim $SIMULATION rec $RECONSTRUCTION check $CHECKS"
71if [ "$SIMULATION" -eq 1 ]; then
72 echo "$NEVENTS events will be simulated, using the config found at $SIMCONFIG"
73fi
74if [ "$RECONSTRUCTION" -eq 1 ]; then
75echo "Reconstruction options to be used : $RECOPTIONS"
76fi
77echo "Output directory will be : $OUTDIR"
78
79if [ "$SIMULATION" -eq 1 ]; then
80
81 rm -fr $OUTDIR
82 mkdir $OUTDIR
83
84fi
85
86cp $ALICE_ROOT/MUON/.rootrc $ALICE_ROOT/MUON/rootlogon.C \
87 $ALICE_ROOT/MUON/runReconstruction.C $ALICE_ROOT/MUON/runSimulation.C $OUTDIR
88
fa701981 89cd $OUTDIR
90
aefc4e02 91###############################################################################
92#
93# Performing SIMULATION
94#
95###############################################################################
fa701981 96
aefc4e02 97if [ "$SIMULATION" -eq 1 ]; then
fa701981 98
aefc4e02 99 echo "Running simulation ..."
858e5b75 100
0d2fa09b 101 aliroot -l -b -q runSimulation.C\($SEED,$NEVENTS,\""$SIMCONFIG"\"\) >& $OUTDIR/testSim.out
aefc4e02 102
103 echo "Moving generated files to $SIMDIR"
104 mkdir $OUTDIR/$SIMDIR
08c70401 105 mv $OUTDIR/*QA*.root $OUTDIR/*.log $OUTDIR/$SIMDIR
aefc4e02 106 mv $OUTDIR/MUON*.root $OUTDIR/Kinematics*.root $OUTDIR/galice.root $OUTDIR/TrackRefs*.root $OUTDIR/$SIMDIR
fa701981 107
aefc4e02 108fi
fa701981 109
aefc4e02 110###############################################################################
111#
112# Performing RECONSTRUCTION
113#
114###############################################################################
115
116if [ "$RECONSTRUCTION" -eq 1 ]; then
117
0d2fa09b 118 rm -f galice.root AliESD*.root *QA*.root
aefc4e02 119
120 echo "Running reconstruction ..."
121
122 cd $OUTDIR
123
0d2fa09b 124 aliroot -l -b -q runReconstruction\.C\($SEED,\""$OUTDIR/raw.root"\",\""$RECOPTIONS"\"\) >& $OUTDIR/testReco.out
aefc4e02 125
126fi
858e5b75 127
aefc4e02 128###############################################################################
129#
130# Performing CHECKS (and dumps)
131#
132###############################################################################
32bf5f82 133
aefc4e02 134if [ "$CHECKS" -eq 1 ]; then
8dc57946 135
029d450d 136 if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
32bf5f82 137
aefc4e02 138 echo "Running efficiency ..."
139
140 aliroot -b >& $OUTDIR/testResults.out << EOF
141 .L $ALICE_ROOT/MUON/MUONefficiency.C+
142 // no argument assumes Upsilon but MUONefficiency(443) works on Jpsi
143 MUONefficiency("$OUTDIR/$SIMDIR/galice.root");
144 .q
145EOF
146
029d450d 147 if [ -f "$OUTDIR/galice.root" ]; then
aefc4e02 148
149 echo "Running Trigger efficiency ..."
150 aliroot -b >& $OUTDIR/testTriggerResults.out << EOF
151 .L $ALICE_ROOT/MUON/MUONTriggerEfficiency.C+
152 MUONTriggerEfficiency("$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", 1);
153 .q
8dc57946 154EOF
858e5b75 155
029d450d 156 if [ -f "$OUTDIR/AliESDs.root" ]; then
157
158 echo "Running check ..."
159 aliroot -b >& $OUTDIR/testCheck.out << EOF
160 gSystem->Load("libMUONevaluation");
161 .L $ALICE_ROOT/MUON/MUONCheck.C+
162 MUONCheck(0, $NEVENTS-1, "$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", "$OUTDIR/AliESDs.root");
163 .q
aefc4e02 164EOF
029d450d 165 fi
aefc4e02 166 fi
167 fi
168
169 echo "Running dumps for selected event ($DUMPEVENT) ..."
170
171 if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
0d2fa09b 172 aliroot -l -b << EOF
07be5a4f 173 AliCDBManager* man = AliCDBManager::Instance();
174 man->SetDefaultStorage("local://$ALICE_ROOT");
aefc4e02 175 AliMUONMCDataInterface mcdSim("$OUTDIR/$SIMDIR/galice.root");
176 mcdSim.DumpKine($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.kine
177 mcdSim.DumpHits($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.hits
178 mcdSim.DumpTrackRefs($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trackrefs
179 mcdSim.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.simdigits
180 mcdSim.DumpSDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.sdigits
181 .q
182EOF
183 else
184 echo "$OUTDIR/$SIMDIR/galice.root is not there. Skipping sim dumps"
185 fi
186
187 if [ -f "$OUTDIR/galice.root" ]; then
0d2fa09b 188 aliroot -l -b << EOF
07be5a4f 189 AliCDBManager* man = AliCDBManager::Instance();
190 man->SetDefaultStorage("local://$ALICE_ROOT");
aefc4e02 191 AliMUONDataInterface dRec("$OUTDIR/galice.root");
192 dRec.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.recdigits
193 dRec.DumpRecPoints($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.recpoints
aefc4e02 194 dRec.DumpTrigger($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trigger
195 .q
196EOF
197 else
198 echo "$OUTDIR/galice.root is not there. Skipping rec dumps"
199 fi
200fi
32bf5f82 201
fa701981 202echo "Finished"
aefc4e02 203echo "... see results in $OUTDIR"
fa701981 204
205cd $CURDIR