]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis/Run.sh
Mior fixes
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis / Run.sh
1 #!/bin/sh 
2
3 nev=10000
4 noanal=0
5 nodraw=0
6 rebin=1
7 vzmin=-10
8 vzmax=10
9 type=
10 cms=900
11
12 usage()
13 {
14 cat<<EOF
15 Usage: $0 [OPTIONS]
16
17 Run analysis and visualize it using HHD analysis code 
18
19 Options:
20         -h,--help               This help                  
21         -N,--no-analysis        Do not analyse, just draw  ($noanal)
22         -D,--no-draw            Do not draw, just analysis ($nodraw)
23         -n,--events N           Number of events           ($nev)
24         -r,--rebin N            Rebin by N                 ($rebin)
25         -v,--vz-min CM          Minimum value of vz        ($vzmin)
26         -V,--vz-max CM          Maximum value of vz        ($vzmax)
27         -t,--trigger TYPE       Select trigger TYPE        ($type)
28         -e,--energy CMS         Center of mass energy      ($cms)
29
30 TYPE is one of 
31  
32   INEL  
33   INEL>0
34   NSD 
35 EOF
36 }
37
38 while test $# -gt 0 ; do
39     case $1 in 
40         -h|--help)           usage            ; exit 0;; 
41         -n|--events)         nev=$2           ; shift ;; 
42         -N|--no-analysis)    noanal=$((($noanal+1)%2))   ;; 
43         -D|--no-draw)        nodraw=$((($nodraw+1)%2))   ;; 
44         -r|--rebin)          rebin=$2         ; shift ;; 
45         -v|--vz-min)         vzmin=$2         ; shift ;; 
46         -V|--vz-max)         vzmax=$2         ; shift ;; 
47         -e|--energy)         cms=$2           ; shift ;;
48         -t|--type)           type="$2"        ; shift ;;
49         *) echo "$0: Unknown option '$1'" >> /dev/stderr ; exit 1 ;;
50     esac
51     shift
52 done 
53
54 base=`printf hhd_%07d $nev` 
55
56 keep_file()
57 {
58     file=$1
59     if test -f $file ; then 
60         mv $file ${file}.keep 
61     fi
62 }
63 restore_file()
64 {
65     file=$1
66     if test -f ${file}.keep ; then 
67         mv ${file}.keep ${file}
68     fi
69 }
70
71 if test $noanal -lt 1 ; then 
72     keep_file AnalysisResult.root
73     keep_file AliAODs.root 
74
75     aliroot -l -b -q -x RunManager.C\(\".\",$nev\) 2>&1 | tee $base.log 
76
77     if test ! -f AnalysisResults.root ; then 
78         echo "Analysis failed" 
79         restore_file AnalysisResult.root
80         restore_file AliAODs.root 
81         exit 1
82     fi
83     echo "Analysis done"
84     rm -f event_stat.root EventStat_temp.root outputs_valid
85     mv AnalysisResults.root ${base}_hists.root
86     if test -f AliAODs.root ; then 
87         mv AliAODs.root     ${base}_aods.root
88     fi
89     restore_file AnalysisResult.root
90     restore_file AliAODs.root 
91 fi
92
93
94 if test $nodraw -lt 1 ; then
95     rm -f fmd_dNdeta_mult.root
96
97     samp=0
98     tt=`echo $type | tr '[a-z]' '[A-Z]'` 
99     case "x$tt" in 
100         "xINEL")   n="inel";    s=""    ; samp=0 ;; 
101         "xINEL>0") n="inelgt0"; s="_NSD"; samp=4 ; echo "Using NSD for $tt";; 
102         "xNSD")    n="nsd";     s="_NSD"; samp=4 ;; 
103         *) echo "Unknown type $tt" > /dev/stderr ; exit 1 ;; 
104     esac
105             
106     aliroot -l -b -q -x \
107         $ALICE_ROOT/PWG2/FORWARD/analysis/drawdNdeta.C\(\"${base}_hists.root\",$samp,$rebin,$vzmin,$vzmax,1,$cms\)
108     tmin=`printf %+03d $vzmin | tr '+-' 'pm'` 
109     tmax=`printf %+03d $vzmax | tr '+-' 'pm'` 
110     out=`printf "hhd_%04dGeV_%s-%scm_rb%02d_%s.root" $cms $tmin $tmax $rebin $n`
111     mv fmd_dNdeta_mult${s}.root $out
112
113     mv fmdana.png `basename $out .root`.png 
114 fi
115 #
116 # EOF
117 #