]>
Commit | Line | Data |
---|---|---|
b7a6aa91 | 1 | #!/bin/bash |
2 | # | |
3 | # BEGIN_MANUAL | |
4 | # Script to help do PWGLF-Forward analsysis using ProofLite | |
5 | # ========================================================= | |
6 | # First, one need to figure out what to analyse. We assume we have | |
7 | # the ESDs from a real run in some directory - possibly in | |
8 | # sub-directories, and similar for the MC data. | |
9 | # | |
10 | # Then, one needs to run this script in set-up mode e.g., | |
11 | # | |
12 | # $0 --what=setup \ | |
13 | # --name=LHC10c \ | |
14 | # --run=118560 \ | |
15 | # --real-dir=/data/alice/data/pp/lhc10c/000118560/pass3 \ | |
16 | # --real-pattern=AliESDs_*.root \ | |
17 | # --mc-dir=/data/alice/data/pp/lhc10c/sim/lhc13d4/118560 \ | |
18 | # --mc-pattern=root_archive.zip@AliESDs.root | |
19 | # | |
20 | # Note, all the settings are written to the file .config in the | |
21 | # current directory, so you do not need to give the parameters at | |
22 | # subsequent steps. Note, you need a valid AliEn token to at this | |
23 | # point to get the acceptance corrections. The run number specified | |
24 | # is only used for getting the acceptance correction. | |
25 | # | |
26 | # Note, the use of the ZIP archives root_archive.zip and the sub-part | |
27 | # specification @AliESDs.root for MC data. | |
28 | # | |
29 | # Next, we need to generate the corrections. Do | |
30 | # | |
31 | # $0 --what=corr | |
32 | # | |
33 | # and wait for the jobs to finish and terminate. Next, we need to | |
34 | # extract and upload the corrections to our local corrections folder | |
35 | # | |
36 | # $0 --what=corr --step=upload | |
37 | # $0 --what=corr --step=draw | |
38 | # | |
39 | # If you already have the corrections, you can pass the option | |
40 | # --corrections in the setup phase and skip this step. | |
41 | # | |
42 | # Now we can submit our AOD generation jobs. Do | |
43 | # | |
44 | # $0 --what=aod | |
45 | # | |
46 | # and wait for the jobs to finish and terminate. If you need to pass | |
47 | # additional options to the train, one can do so after the special | |
48 | # option -- e.g., to limit the number of events to 100000, do | |
49 | # | |
50 | # $0 --what=aod -- --events=100000 | |
51 | # | |
52 | # Next, we need to draw the summary results | |
53 | # | |
54 | # $0 --what=aod --step=draw | |
55 | # | |
56 | # Now, we should do the dN/deta analysis. Do | |
57 | # | |
58 | # $0 --what=dndeta | |
59 | # | |
60 | # and wait for the jobs to finish and terminate. Again, additional | |
61 | # options to the train can be passed after --. If you passed the | |
62 | # option --sys=1 in the setup phase, then this will run 3 jobs for | |
63 | # real and MC each - one for INEL, INEL>0, and NSD (V0-AND). Next, we | |
64 | # need to draw the summary and final plot | |
65 | # | |
66 | # $0 --what=dndeta --step=draw | |
67 | # | |
68 | # To generate the P(Nch) data, do | |
69 | # | |
70 | # $0 --what=multdists | |
71 | # $0 --what=multdists --step=draw | |
72 | # | |
73 | # To collect all PDFs into a single directory do | |
74 | # | |
75 | # $0 --what=collect | |
76 | # | |
77 | # Enjoy. | |
78 | # | |
79 | # Comments, questions, bugs, flames, suggestions, etc. should be sent | |
80 | # to Christian Holm Christensen <cholm@nbi.dk> | |
81 | # | |
82 | # END_MANUAL | |
83 | if test ! -f $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh ; then | |
84 | echo "baseAnalysis not found!" > /dev/stderr | |
85 | exit 1 | |
86 | fi | |
87 | . $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh | |
88 | ||
89 | run= | |
90 | serv= | |
91 | real_ds= | |
92 | mc_ds= | |
93 | my_real_ds= | |
94 | my_mc_ds= | |
95 | nwrkrs=0 | |
96 | par=0 | |
97 | batch=0 | |
98 | # === Various functions ============================================== | |
99 | ||
100 | ||
101 | # === Implement base functions ======================================= | |
102 | # --- Usage ---------------------------------------------------------- | |
103 | setup_usage() | |
104 | { | |
105 | cat <<EOF | |
106 | -r,--run=NUMBER Specify run number ($run) | |
107 | -d,--real-ds=NAME Data set of real data ($real_ds) | |
108 | -D,--mc-ds=NAME Data set of MC data ($mc_dir) | |
109 | -P,--server=ADDRESS Proof server ($serv) | |
110 | -W,--workers=N Number of workers ($nwrks) | |
111 | -a,--par Use par files ($par) | |
112 | -b,--batch Do not show GUI | |
113 | EOF | |
114 | } | |
115 | # --- handle setup options ------------------------------------------- | |
116 | handle_setup_option() | |
117 | { | |
118 | local arg="$1" | |
119 | local opt="$2" | |
120 | # echo "Handle arg=$arg opt=$opt" | |
121 | case $arg in | |
122 | -r|--run) run=$opt ;; | |
123 | -d|--real-ds) real_ds=$opt ;; | |
124 | -D|--mc-ds) mc_ds=$opt ;; | |
125 | -W|--workers) nwrks=${opt} ;; | |
126 | -P|--server) serv=${opt} ;; | |
127 | -a|--par) par=1 ;; | |
128 | *) echo "$0: [SETUP] Unknown option $arg" ; exit 1 ;; | |
129 | esac | |
130 | } | |
131 | ||
132 | # --- Get the grid home dir ------------------------------------------ | |
133 | outputs() | |
134 | { | |
135 | # We should get the PROOF group and user name here | |
136 | # l=`id -n -g`/`id -n -u` | |
137 | l=`aliroot -l -b <<EOF | |
138 | gSystem->RedirectOutput("/dev/null"); | |
139 | TProof::Reset("$serv", false); | |
140 | TProof::Open("$serv"); | |
141 | gSystem->RedirectOutput(0); | |
142 | Printf("%s/%s", gProof->GetGroup(), gProof->GetUser()); | |
143 | EOF` | |
144 | my_real_ds="/$l/${name}_aod_${now}" | |
145 | my_mc_ds="/$l/${name}_mcaod_${now}" | |
146 | } | |
147 | # --- Dump the setup ------------------------------------------------- | |
148 | dump_setup() | |
149 | { | |
150 | local out=$1 | |
151 | cat >> ${out} <<-EOF | |
152 | # Run analysed | |
153 | run=${run} | |
154 | # Real data | |
155 | real_ds=${real_ds} | |
156 | mc_ds=${mc_ds} | |
157 | # Output | |
158 | my_real_ds=${my_real_ds} | |
159 | my_mc_ds=${my_mc_ds} | |
160 | serv=${serv} | |
161 | nwrks=${nwrks} | |
162 | par=${par} | |
163 | batch=${batch} | |
164 | EOF | |
165 | } | |
166 | ||
167 | # ---- Get run number to use for Acceptance map ---------------------- | |
168 | run_for_acc() | |
169 | { | |
170 | if test x$run = "x" || test $run -lt 1; then | |
171 | echo "No run for acceptance correction specified" > /dev/stderr | |
172 | exit 1 | |
173 | fi | |
174 | echo $run | |
175 | } | |
176 | # --- Run set-ups ---------------------------------------------------- | |
177 | setup() | |
178 | { | |
179 | echo "Calling _setup with $@" | |
180 | _setup $@ | |
181 | } | |
182 | ||
183 | # --- Check settings ------------------------------------------------- | |
184 | check_setup() | |
185 | { | |
186 | if test "x$run" = "x" || test $run -lt 1 ; then | |
187 | echo "Run not specified, or invalid ($run)" > /dev/stderr | |
188 | exit 1 | |
189 | fi | |
190 | if test "x$real_ds" = "x" ; then | |
191 | echo "No real data set specified" > /dev/stderr | |
192 | exit 1 | |
193 | fi | |
194 | if test "x$mc_ds" = "x" ; then | |
195 | echo "No MC data set specified" > /dev/stderr | |
196 | # exit 1 | |
197 | fi | |
198 | } | |
199 | ||
200 | ||
201 | ||
202 | # --- Show the setup ------------------------------------------------- | |
203 | print_setup() | |
204 | { | |
205 | cat <<-EOF | |
206 | Run: ${run} | |
207 | Real data set: | |
208 | Data set: ${real_ds} | |
209 | Output: ${my_real_ds} | |
210 | MC data: | |
211 | Data set: ${mc_ds} | |
212 | Output: ${my_mc_ds} | |
213 | Use PAR files: ${par} | |
214 | Number of workers: ${nwrks} | |
215 | Server: ${serv} | |
216 | EOF | |
217 | } | |
218 | ||
219 | # --- Make URI ------------------------------------------------------- | |
220 | url_opts() | |
221 | { | |
222 | local mc=$1 ; shift | |
223 | local type=$1 ; shift | |
224 | local trig=$1 ; shift | |
225 | local uopt="mode=default" | |
226 | local tree=esdTree | |
227 | ||
228 | local inp=${real_ds} | |
229 | local oup=`basename ${my_real_ds}` | |
230 | if test $mc -gt 0 ; then | |
231 | inp=${mc_ds} | |
232 | oup=`basename ${my_mc_ds}` | |
233 | fi | |
234 | ||
235 | case $type in | |
236 | *aod) | |
237 | uopt="${uopt}&dsname=${oup}" | |
238 | ;; | |
239 | *dndeta|*multdists) | |
240 | tree=aodTree | |
241 | # Modify for input dir for our files | |
242 | inp=$my_real_ds | |
243 | if test $mc -gt 0 ; then | |
244 | inp=$my_mc_ds | |
245 | fi | |
246 | ;; | |
247 | esac | |
248 | if test x$inp = x; then | |
249 | echo "No input for $nme, giving up" > /dev/stderr | |
250 | return | |
251 | fi | |
252 | if test $mc -gt 0; then | |
253 | uopt="${uopt}&mc" | |
254 | fi | |
255 | if test $par -gt 0 ; then | |
256 | uopt="${uopt}&par=tasks" | |
257 | fi | |
258 | if test x$uuopts != x ; then | |
259 | uopt="${uopt}&${uuopts}" | |
260 | fi | |
261 | if test "x$nwrks" != "x" && test $nwrks -gt 0 ; then | |
262 | uopt="${uopt}&workers=${nwrks}" | |
263 | fi | |
264 | case $server in | |
265 | alice-caf.cern.ch) uopts="${uopts}&reset=hard" ;; | |
266 | esac | |
267 | ||
268 | # PROOF-lite URL form: | |
269 | # | |
270 | # lite://<datadir_or_list>[?<options>][#<treeName] | |
271 | # | |
272 | # Options: | |
273 | # clear=PKGS Clear packages ','-separated | |
274 | # mc Assume simulation input | |
275 | # mode=default|rec|sim AliROOT mode | |
276 | # par=tasks|all Use par files | |
277 | # pattern=GLOB File name pattern | |
278 | # recursive Recursive scan [true] | |
279 | # reset=soft|hard Reset cluster [hard] | |
280 | # workers=N[x] Number of workers to use [8] | |
281 | # wrapper=CMD Wrapper command [] | |
282 | ||
283 | url="proof://${serv}/${inp}?${uopt}#${tree}" | |
284 | ||
285 | } | |
286 | ||
287 | # --- Run the train -------------------------------------------------- | |
288 | # Usage: | |
289 | # | |
290 | allAboard() | |
291 | { | |
292 | local type=$1 ; shift | |
293 | local trig=$1 ; shift | |
294 | local lopts= | |
295 | if test $batch -gt 0 ; then | |
296 | lopts="--batch" | |
297 | fi | |
298 | _allAboard "$type" "$trig" $lopts $@ | |
299 | } | |
300 | ||
301 | # === Procedual code ================================================= | |
302 | runIt $@ | |
303 | ||
304 | # | |
305 | # EOF | |
306 | # | |
307 |