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