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