]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/Run.sh
More code clean up.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / Run.sh
1 #!/bin/bash 
2
3 ana=$ALICE_ROOT/PWG2/FORWARD/analysis2
4 nev=10000
5 noanal=0
6 nodraw=0
7 rebin=1
8 vzmin=-10
9 vzmax=10
10 batch=0
11 gdb=0
12 proof=0
13 type=
14 cms=900
15 hhd=1
16 comp=1
17 anal=0
18 term=0
19 tit=
20
21 usage()
22 {
23 cat<<EOF
24 Usage: $0 [OPTIONS]
25
26 Do Pass1 and Pass2 on ESD files in current directory.  
27
28 Options:
29         -h,--help               This help                  
30         -n,--events N           Number of events           ($nev)
31         -1,--pass1              Run only pass 1, no draw   ($nodraw)
32         -2,--pass2              Run only pass 2, just draw ($noanal)
33         -r,--rebin N            Rebin by N                 ($rebin)
34         -v,--vz-min CM          Minimum value of vz        ($vzmin)
35         -V,--vz-max CM          Maximum value of vz        ($vzmax)
36         -t,--trigger TYPE       Select trigger TYPE        ($type)
37         -e,--energy CMS         Center of mass energy      ($cms)
38         -b,--batch              Do batch processing        ($batch)
39         -P,--proof              Run in PROOF(Lite) mode    ($proof)
40         -A,--analyse-only       Run only analysis          ($anal)
41         -T,--terminate-only     Run only terminate         ($term)
42         -S,--title STRING       Set the title string       ($tit)
43         -g,--gdb                Run in GDB mode            ($gdb)
44         -H,--hhd                Do comparison to HHD       ($hhd)
45         -O,--other              Do comparison to other     ($comp)
46
47 TYPE is a comma or space separated list of 
48  
49   INEL        Inelastic triggers (V0A|V0C|SPD)
50   INEL>0      As above + N_ch > 0 in -0.5<eta<+0.5
51   NSD         Non-single diffractive ((VOA&VOC)|N_ch > 5 -1.9<eta<+1.9)
52
53 EOF
54 }
55
56 toggle()
57 {
58     echo $((($1+1)%2))
59 }
60
61
62 while test $# -gt 0 ; do
63     case $1 in 
64         -h|--help)           usage            ; exit 0;; 
65         -n|--events)         nev=$2           ; shift ;; 
66         -2|--pass2)          noanal=`toggle $noanal`   ;; 
67         -1|--pass1)          nodraw=`toggle $nodraw`   ;; 
68         -b|--batch)          batch=`toggle $batch`   ;; 
69         -P|--proof)          proof=`toggle $proof`   ;; 
70         -A|--analyse-only)   anal=`toggle $anal`   ;; 
71         -T|--terminate-only) term=`toggle $term`   ;; 
72         -g|--gdb)            gdb=`toggle $gdb`   ;; 
73         -H|--hhd)            hhd=`toggle $hhd`   ;; 
74         -O|--other)          other=`toggle $other`   ;; 
75         -r|--rebin)          rebin=$2         ; shift ;; 
76         -v|--vz-min)         vzmin=$2         ; shift ;; 
77         -V|--vz-max)         vzmax=$2         ; shift ;; 
78         -e|--energy)         cms=$2           ; shift ;;
79         -S|--title)          tit="$2"         ; shift ;;
80         -t|--type)           
81             if test "x$type" = "x" ; then type=$2 ; else type="$type|$2"; fi
82             shift ;;
83         *) echo "$0: Unknown option '$1'" >> /dev/stderr ; exit 1 ;;
84     esac
85     shift
86 done 
87
88 base=`printf dndeta_%07d $nev`
89 opts="-l -x"
90 redir=
91 if test $batch -gt 0 ; then 
92     opts="-l -b -q -x" 
93     redir="2>&1 | tee ${base}.log"
94     echo "redir=$redir"
95 fi 
96 if test $noanal -lt 1 ; then 
97     rm -f AnalysisResult.root AliAODs.root
98     rm -f fmdana.png
99     
100     # Setup analysis flags
101     af=0
102     if test $proof -gt 0 ; then 
103         af=2 
104     else 
105         if test $anal -gt 0 ; then 
106             af=8
107         elif test $term -gt 0 ; then 
108             af=16
109         else 
110             af=4
111         fi
112     fi
113
114     if test $gdb -gt 0 ; then 
115         export PROOF_WRAPPERCMD="gdb -batch -x $ALICE_ROOT/PWG2/FORWARD/analysis2/gdb_cmds --args"
116     fi
117     echo "Running aliroot ${opts} ${ana}/Pass1.C\(\".\",$nev,$af\) $redir"
118     if test $batch -gt 0 ; then 
119         aliroot $opts ${ana}/Pass1.C\(\".\",$nev,$af\) 2>&1 | tee ${base}.log
120     else 
121         aliroot $opts ${ana}/Pass1.C\(\".\",$nev,$af\)
122     fi
123     rm -f event_stat.root \
124         EventStat_temp.root \
125         outputs_valid \
126         `printf %09d.stat $nev` 
127     if test ! -f AnalysisResults.root || test ! -f AliAODs.root ; then 
128         echo "Analysis failed" 
129         exit 1
130     fi
131     echo "Analysis done"
132 fi
133
134 if test $nodraw -lt 1 ; then
135     rm -f result.root 
136     if test "x$tit" = "x" ; then 
137         tit="$nev events, v_{z}#in[$vzmin,$vzmax], $type"
138     fi
139     tit=`echo $tit | tr ' ' '@'` 
140     aliroot ${opts} ${ana}/Pass2.C\(\"AliAODs.root\",\"$type\",$cms,$vzmin,$vzmax,$rebin,\"$tit\",$hhd,$comp\)
141 fi
142
143
144 #
145 # EOF
146 #