]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AlirootRun_MUONtest.sh
In AliMUONSt1GeometryBuilderV: fixing overlap
[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 CHECKS=1 # will perform checks
9 NEVENTS=100 # will simulate 100 events
10
11 #RECOPTIONS="SAVEDIGITS NOFASTDECODERS" # reconstruction options with non-high performance decoders
12 RECOPTIONS="SAVEDIGITS" # default reconstruction options
13 SIMCONFIG="$ALICE_ROOT/MUON/Config.C" # default simulation configuration file
14 OUTDIR=""
15 CURDIR=`pwd`
16
17 #RUN=0 # run number for OCDB access
18 SEED=1234567 # random number generator seed
19 SIMDIR="generated" # sub-directory where to move simulated files prior to reco
20 DUMPEVENT=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  
25 EXIT=0
26
27 while getopts "SRX:srxn:p:d:c:" option
28 do
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
47 done
48
49 if [ ! -n "$OUTDIR" ]; then
50   OUTDIR="$CURDIR/test_out.$NEVENTS"
51 fi
52
53 # look if there are some leftover options
54 shift $(($OPTIND - 1))
55
56 if [ $# -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;
67 fi
68
69 # printout the options
70 echo "sim $SIMULATION rec $RECONSTRUCTION check $CHECKS"
71 if [ "$SIMULATION" -eq 1 ]; then
72   echo "$NEVENTS events will be simulated, using the config found at $SIMCONFIG"
73 fi
74 if [ "$RECONSTRUCTION" -eq 1 ]; then
75 echo "Reconstruction options to be used : $RECOPTIONS"
76 fi
77 echo "Output directory will be : $OUTDIR"
78
79 if [ "$SIMULATION" -eq 1 ]; then
80
81   rm -fr $OUTDIR
82   mkdir $OUTDIR
83
84 fi
85
86 cp $ALICE_ROOT/MUON/.rootrc $ALICE_ROOT/MUON/rootlogon.C \
87   $ALICE_ROOT/MUON/runReconstruction.C $ALICE_ROOT/MUON/runSimulation.C $OUTDIR
88
89 cd $OUTDIR
90
91 ###############################################################################
92
93 # Performing SIMULATION
94 #
95 ###############################################################################
96
97 if [ "$SIMULATION" -eq 1 ]; then
98
99   echo "Running simulation  ..."
100
101   aliroot -l -b -q runSimulation.C\($SEED,$NEVENTS,\""$SIMCONFIG"\"\) >& $OUTDIR/testSim.out 
102   
103   echo "Moving generated files to $SIMDIR"
104   mkdir $OUTDIR/$SIMDIR
105   mv $OUTDIR/*QA*.root $OUTDIR/*.log $OUTDIR/$SIMDIR
106   mv $OUTDIR/MUON*.root $OUTDIR/Kinematics*.root $OUTDIR/galice.root $OUTDIR/TrackRefs*.root $OUTDIR/$SIMDIR
107
108 fi
109
110 ###############################################################################
111
112 # Performing RECONSTRUCTION
113 #
114 ###############################################################################
115
116 if [ "$RECONSTRUCTION" -eq 1 ]; then
117
118   rm -f galice.root AliESD*.root *QA*.root
119
120   echo "Running reconstruction  ..."
121
122   cd $OUTDIR
123   
124   aliroot -l -b -q runReconstruction\.C\($SEED,\""$OUTDIR/raw.root"\",\""$RECOPTIONS"\"\) >& $OUTDIR/testReco.out
125
126 fi
127
128 ###############################################################################
129
130 # Performing CHECKS (and dumps)
131 #
132 ###############################################################################
133
134 if [ "$CHECKS" -eq 1 ]; then
135
136   if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
137
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
145 EOF
146
147   if [ -f "$OUTDIR/galice.root" ]; then
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
154 EOF
155
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
164 EOF
165       fi
166     fi
167   fi
168
169   echo "Running dumps for selected event ($DUMPEVENT) ..."
170
171   if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
172     aliroot -l -b  << EOF
173     AliCDBManager* man = AliCDBManager::Instance();
174     man->SetDefaultStorage("local://$ALICE_ROOT");
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
182 EOF
183   else
184     echo "$OUTDIR/$SIMDIR/galice.root is not there. Skipping sim dumps"
185   fi
186
187   if [ -f "$OUTDIR/galice.root" ]; then
188     aliroot -l -b << EOF
189     AliCDBManager* man = AliCDBManager::Instance();
190     man->SetDefaultStorage("local://$ALICE_ROOT");
191     AliMUONDataInterface dRec("$OUTDIR/galice.root");
192     dRec.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.recdigits
193     dRec.DumpRecPoints($DUMPEVENT);  > $OUTDIR/dump.$DUMPEVENT.recpoints
194     dRec.DumpTrigger($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trigger
195     .q
196 EOF
197   else
198     echo "$OUTDIR/galice.root is not there. Skipping rec dumps"
199   fi
200 fi
201
202 echo "Finished"  
203 echo "... see results in $OUTDIR"
204
205 cd $CURDIR