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