4 # first declare default values
7 MACROPATH=$ALICE_ROOT/MUON/macros
9 SIMULATION=1 # will perform simulation
10 RECONSTRUCTION=1 # will perform reconstruction
11 RAW=1 # will reconstruct from raw data
12 CHECKS=1 # will perform checks
13 SLASHTMP=1 #will use /tmp to put the temporary raw data
14 NEVENTS=50 # will simulate 100 events
16 #RECOPTIONS="SAVEDIGITS NOFASTDECODERS" # reconstruction options with non-high performance decoders
17 RECOPTIONS="SAVEDIGITS" # default reconstruction options
18 MC="" # G3 Simulation with old Config.C
19 #MC="g3" # G3 Simulation (with new config macros)
20 #MC="g4" # G4 Simulation (with new config macros)
25 #RUN=0 # run number for OCDB access
26 SEED=1234567 # random number generator seed
27 SIMDIR="generated" # sub-directory where to move simulated files prior to reco
28 DUMPEVENT=5 # event to be dump on files (set to negative to skip dumps)
30 SIMCONFIG="$MACROPATH/"$MC"Config.C"
31 EMBEDWITH="" # no embedding by default
32 REALISTIC=0 # ideal simulation by default
34 # next try to see if there are options of this script that want to change the
39 while getopts "SRZX:srxzn:tg:p:d:c:e:b:" option
42 R ) RECONSTRUCTION=1;;
49 r ) RECONSTRUCTION=0;;
54 c ) SIMCONFIG=$OPTARG;;
58 p ) RECOPTIONS=$OPTARG;;
59 e ) EMBEDWITH=$OPTARG;;
64 * ) echo "Unimplemented option chosen."
70 if [ ! -n "$OUTDIR" ]; then
71 if [ "$MC" = "" ]; then
72 OUTDIR=$CURDIR"/test_out."$NEVENTS
74 OUTDIR=$CURDIR"/"$MC"_test_out."$NEVENTS
78 # look if there are some leftover options
79 shift $(($OPTIND - 1))
81 if [ $# -gt 0 ] || [ "$EXIT" -eq 1 ]; then
82 echo "ERROR : extra option not recognized"
83 echo "Usage: `basename $0` options (-SRXsrxn:tg:p:d:c:)"
84 echo " -S (-s) perform (or not) simulation (default is do it, i.e -S)"
85 echo " -R (-r) perform (or not) reconstruction (default is do it, i.e. -R)"
86 echo " -X event (-x) perform (or not) checks and dumps (default is do it for event $DUMPEVENT, i.e. -X $DUMPEVENT)"
87 echo " -Z (-z) perform reconstruction from raw data (from digits) (default is from raw data, i.e. -Z)"
88 echo " -n nevents (int) number of events to simulate (default $NEVENTS)"
89 echo " -t will use OUTDIR as a tmp directory to generate raw data "
90 echo " -g seed (uint) seed to be used in simulation (default $SEED)"
91 echo " -p recoptions (quotified string) reconstruction options to use (default \"$RECOPTIONS\")"
92 echo " -d full path to output directory (default $OUTDIR)"
93 echo " -c full path to configuration file for simulation (default $SIMCONFIG)"
94 echo " -e full path to a galice.root file relating to SDigits to be merged (embedding)"
95 echo " -b runnumber (int) make a realistic simulation using runnumber as anchor (default 0=ideal simulation)"
100 # printout the options
101 echo "sim $SIMULATION rec $RECONSTRUCTION check $CHECKS"
102 if [ "$SIMULATION" -eq 1 ]; then
103 echo "$NEVENTS events will be simulated, using the config found at $SIMCONFIG"
105 if [ -n "$EMBEDWITH" ]; then
106 echo "Will embed simulation with $EMBEDWITH"
108 if [ "$REALISTIC" -gt 0 ]; then
109 echo "Will use anchor run $REALISTIC"
111 if [ "$RECONSTRUCTION" -eq 1 ]; then
112 echo "Reconstruction options to be used : $RECOPTIONS"
113 if [ "$RAW" -eq 0 ]; then
114 echo "Will reconstruct from digits only (not from raw data)"
117 echo "Output directory will be : $OUTDIR"
119 if [ "$SIMULATION" -eq 1 ]; then
126 # Copy *ALL* the macros we need in the output directory, not to mess
127 # with our source dir in any way.
128 cp $MACROPATH/.rootrc \
129 $MACROPATH/rootlogon.C \
130 $MACROPATH/runReconstruction.C \
131 $MACROPATH/runSimulation.C \
132 $MACROPATH/UpdateCDBCTPConfig.C \
133 $MACROPATH/MUONefficiency.C \
134 $MACROPATH/MUONTriggerEfficiency.C \
135 $MACROPATH/MUONCheck.C \
140 if [ "$SLASHTMP" -eq 0 ]; then
144 mkdir ./tmp/mdc1/tags
149 chmod 777 ./tmp/mdc1/tags
151 export ALIMDC_RAWDB1=./tmp/mdc1
152 export ALIMDC_RAWDB2=./tmp/mdc2
153 export ALIMDC_TAGDB=./tmp/mdc1/tags
156 ###############################################################################
158 # Update CTP in OCDB for MUON Trigger
160 ###############################################################################
162 if [ ! -f $ALICE_ROOT/OCDB/GRP/CTP/Config/Run0_999999999_v0_s1.root ]; then
164 echo "Updating GRP CTP config ..."
166 aliroot -b > $OUTDIR/updateCDBCTPConfig.out 2>&1 << EOF
167 .L UpdateCDBCTPConfig.C++g
168 UpdateCDBCTPConfig();
175 ###############################################################################
177 # Performing SIMULATION
179 ###############################################################################
181 if [ "$SIMULATION" -eq 1 ]; then
183 echo "Running simulation ..."
185 aliroot -l -b -q runSimulation.C\($SEED,$NEVENTS,\""$SIMCONFIG"\"\,\""$EMBEDWITH"\"\,$REALISTIC\) > $OUTDIR/testSim.out 2>&1
187 mkdir $OUTDIR/$SIMDIR
189 if [ "$RAW" -eq 1 ]; then
190 if [ "$REALISTIC" -eq 0 ]; then # we can not move for realistic simulations as we need e.g. kinematics to propagate the simulated vertex to the reco.
191 echo "Moving generated files to $SIMDIR"
192 mv $OUTDIR/*QA*.root $OUTDIR/*.log $OUTDIR/$SIMDIR
193 mv $OUTDIR/MUON*.root $OUTDIR/TrackRefs*.root $OUTDIR/$SIMDIR
194 mv $OUTDIR/Kinematics*.root $OUTDIR/galice.root $OUTDIR/$SIMDIR
197 echo "Copying generated files to $SIMDIR"
198 cp $OUTDIR/*QA*.root $OUTDIR/*.log $OUTDIR/$SIMDIR
199 cp $OUTDIR/MUON*.root $OUTDIR/Kinematics*.root $OUTDIR/galice.root $OUTDIR/TrackRefs*.root $OUTDIR/$SIMDIR
202 # save geometry file in a separate directory
203 if [ "$MC" = "g3" ]; then
204 rm -fr $OUTDIR/geometry
205 mkdir $OUTDIR/geometry
206 cp $OUTDIR/geometry.root $OUTDIR/geometry
209 # copy input geometry file in a current directory
210 if [ "$MC" = "g4" ]; then
211 cp $OUTDIR/geometry/geometry.root $OUTDIR
214 cp $OUTDIR/geometry.root $OUTDIR/$SIMDIR/geometry.root
218 ###############################################################################
220 # Performing RECONSTRUCTION
222 ###############################################################################
224 if [ "$RECONSTRUCTION" -eq 1 ]; then
226 if [ "$RAW" -eq 1 ]; then
227 if [ "$REALISTIC" -eq 0 ]; then
232 if [ "$REALISTIC" -ne 0 ]; then
236 rm -f AliESD*.root *QA*.root
238 echo "Running reconstruction ..."
244 if [ -n "$EMBEDWITH" ]; then
248 if [ "$REALISTIC" -gt 0 ]; then
252 if [ "$RAW" -eq 1 ]; then
254 aliroot -l -b -q runReconstruction\.C\($SEED,\""$OUTDIR/raw.root"\",\""$RECOPTIONS"\",$RAWOCDB\) > $OUTDIR/testReco.out 2>&1
258 aliroot -l -b -q runReconstruction\.C\($SEED,\"""\",\""$RECOPTIONS"\",$RAWOCDB\) > $OUTDIR/testReco.out 2>&1
264 ###############################################################################
266 # Performing CHECKS (and dumps)
268 ###############################################################################
270 if [ "$CHECKS" -eq 1 ]; then
272 if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
274 echo "Running efficiency ..."
276 aliroot -b > $OUTDIR/testResults.out 2>&1 << EOF
277 .L MUONefficiency.C++g
278 // no argument assumes Upsilon but MUONefficiency(443) works on Jpsi
279 MUONefficiency("$OUTDIR/$SIMDIR/galice.root");
283 if [ -f "$OUTDIR/galice.root" ]; then
285 echo "Running Trigger efficiency ..."
286 aliroot -b > $OUTDIR/testTriggerResults.out 2>&1 << EOF
287 .L MUONTriggerEfficiency.C++g
288 MUONTriggerEfficiency("$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", 1);
292 if [ -f "$OUTDIR/AliESDs.root" ]; then
294 echo "Running check ..."
295 aliroot -b > $OUTDIR/testCheck.out 2>&1 << EOF
296 gSystem->Load("libMUONevaluation");
298 MUONCheck(0, $NEVENTS-1, "$OUTDIR/$SIMDIR/galice.root", "$OUTDIR/galice.root", "$OUTDIR/AliESDs.root");
305 if [ "$DUMPEVENT" -ge 0 ]; then
307 echo "Running dumps for selected event ($DUMPEVENT) ..."
309 if [ -f "$OUTDIR/$SIMDIR/galice.root" ]; then
311 AliCDBManager* man = AliCDBManager::Instance();
312 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
313 AliMUONMCDataInterface mcdSim("$OUTDIR/$SIMDIR/galice.root");
314 mcdSim.DumpKine($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.kine
315 mcdSim.DumpHits($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.hits
316 mcdSim.DumpTrackRefs($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trackrefs
317 mcdSim.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.simdigits
318 mcdSim.DumpSDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.sdigits
322 echo "$OUTDIR/$SIMDIR/galice.root is not there. Skipping sim dumps"
325 if [ -f "$OUTDIR/galice.root" ]; then
327 AliCDBManager* man = AliCDBManager::Instance();
328 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
329 AliMUONDataInterface dRec("$OUTDIR/galice.root");
330 dRec.DumpDigits($DUMPEVENT,true); > $OUTDIR/dump.$DUMPEVENT.recdigits
331 dRec.DumpRecPoints($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.recpoints
332 dRec.DumpTrigger($DUMPEVENT); > $OUTDIR/dump.$DUMPEVENT.trigger
336 echo "$OUTDIR/galice.root is not there. Skipping rec dumps"
343 echo "... see results in $OUTDIR"