make_xml_mcc6.0.sh
Go to the documentation of this file.
1 #! /bin/bash
2 #----------------------------------------------------------------------
3 #
4 # Name: make_xml_mcc.sh
5 #
6 # Purpose: Make xml files for mcc. This script loops over all
7 # generator-level fcl files in the source area of the currently
8 # setup version of dunetpc (that is, under
9 # $DUNETPC_DIR/source/fcl/dune35t/gen), and makes a corresponding xml
10 # project file in the local directory.
11 #
12 # Usage:
13 #
14 # make_xml_mcc4.0.sh [-h|--help] [-r <release>] [-u|--user <user>] [--local <dir|tar>] [--nev <n>] [--nevjob <n>] [--nevgjob <n>]
15 #
16 # Options:
17 #
18 # -h|--help - Print help.
19 # -r <release> - Use the specified larsoft/dunetpc release.
20 # -u|--user <user> - Use users/<user> as working and output directories
21 # (default is to use lbnepro).
22 # --local <dir|tar> - Specify larsoft local directory or tarball (xml
23 # tag <local>...</local>).
24 # --nev <n> - Specify number of events for all samples. Otherwise
25 # use hardwired defaults.
26 # --nevjob <n> - Specify the default number of events per job.
27 # --nevgjob <n> - Specify the maximum number of events per gen/g4 job.
28 #
29 #----------------------------------------------------------------------
30 
31 # Parse arguments.
32 
33 rel=v05_09_01
34 userdir=dunepro
35 userbase=$userdir
36 nevarg=0
37 nevjob=0
38 nevjobarg=0
39 local=''
40 
41 while [ $# -gt 0 ]; do
42  case "$1" in
43 
44  # User directory.
45 
46  -h|--help )
47  echo "Usage: make_xml_mcc.sh [-h|--help] [-r <release>] [-u|--user <user>] [--local <dir|tar>] [--nev <n>] [--nevjob <n>] [--nevgjob <n>]"
48  exit
49  ;;
50 
51  # Release.
52 
53  -r )
54  if [ $# -gt 1 ]; then
55  rel=$2
56  shift
57  fi
58  ;;
59 
60  # User.
61 
62  -u|--user )
63  if [ $# -gt 1 ]; then
64  userdir=users/$2
65  userbase=$2
66  shift
67  fi
68  ;;
69 
70  # Local release.
71 
72  --local )
73  if [ $# -gt 1 ]; then
74  local=$2
75  shift
76  fi
77  ;;
78 
79  # Total number of events.
80 
81  --nev )
82  if [ $# -gt 1 ]; then
83  nevarg=$2
84  shift
85  fi
86  ;;
87 
88  # Number of events per job.
89 
90  --nevjob )
91  if [ $# -gt 1 ]; then
92  nevjobarg=$2
93  shift
94  fi
95  ;;
96 
97  esac
98  shift
99 done
100 
101 # Get qualifier.
102 
103 qual=e9
104 ver=`echo $rel | cut -c2-3`
105 if [ $ver -gt 2 ]; then
106  qual=e9
107 fi
108 
109 # Delete existing xml files.
110 
111 rm -f *.xml
112 
113 find $DUNETPC_DIR/source/fcl/dune35t/gen $DUNETPC_DIR/source/fcl/dunefd/gen $DUNETPC_DIR/source/fcl/protodune/gen -name \*.fcl | while read fcl
114 do
115  if ! echo $fcl | grep -q 'common\|protoDUNE_gensingle'; then
116  newprj=`basename $fcl .fcl`
117  newxml=${newprj}.xml
118  generator=SingleGen
119  if echo $newprj | grep -q cosmics; then
120  generator=CRY
121  fi
122  if echo $newprj | grep -q AntiMuonCutEvents; then
123  generator=TextFileGen
124  fi
125  if echo $newprj | grep -q genie; then
126  generator=GENIE
127  fi
128  if echo $newprj | grep -q MUSUN; then
129  generator=MUSUN
130  fi
131  if echo $newprj | grep -q supernova; then
132  generator=SNNueAr40CCGen
133  fi
134 
135  detector=35t
136  if echo $newprj | grep -q dune10kt; then
137  detector=10kt
138  fi
139  if echo $newprj | grep -q protoDune; then
140  detector=protoDune
141  fi
142 
143  # Make xml file.
144 
145  echo "Making ${newprj}.xml"
146 
147  # Generator
148 
149  genfcl=`basename $fcl`
150 
151  # G4
152 
153  g4fcl=standard_g4_dune35t.fcl
154 
155  # Detsim (optical + tpc).
156 
157  detsimfcl=standard_detsim_dune35t.fcl
158 
159  # Reco 2D
160 
161 # reco2dfcl=standard_reco_uboone_2D.fcl
162 
163  # Reco 3D
164 
165 # reco3dfcl=standard_reco_uboone_3D.fcl
166 
167  # Reco
168  recofcl=standard_reco_dune35t.fcl
169 
170  # Merge/Analysis
171 
172  mergefcl=standard_ana_dune35t.fcl
173 
174  if echo $newprj | grep -q protonpi0; then
175  g4fcl=standard_g4_dune35t_protonpi0.fcl
176  fi
177 
178  if echo $newprj | grep -q countermu; then
179  g4fcl=standard_g4_dune35t_countermu.fcl
180  fi
181 
182 # if echo $newprj | grep -q 'pi0\|gamma'; then
183 # recofcl=reco_dune35t_blur.fcl
184 # mergefcl=ana_energyCalib.fcl
185 # fi
186 
187 # if echo $newprj | grep -q 'piminus'; then
188 # recofcl=emhits.fcl
189 # mergefcl=standard_merge_dune35t.fcl
190 # fi
191 
192  if echo $newprj | grep -q milliblock; then
193  detsimfcl=standard_detsim_dune35t_milliblock.fcl
194  recofcl=standard_reco_dune35t_milliblock.fcl
195  mergefcl=standard_ana_dune35t_milliblock.fcl
196  fi
197 
198  if echo $newprj | grep -q dune10kt; then
199  g4fcl=standard_g4_dune10kt.fcl
200  detsimfcl=standard_detsim_dune10kt.fcl
201  recofcl=standard_reco_dune10kt.fcl
202  mergefcl=standard_ana_dune10kt.fcl
203  fi
204 
205  if echo $newprj | grep -q 'dune10kt_workspace\|dune10kt_r10deg_workspace'; then
206  g4fcl=standard_g4_dune10kt_workspace.fcl
207  detsimfcl=standard_detsim_dune10kt_workspace.fcl
208  recofcl=standard_reco_dune10kt_workspace.fcl
209  mergefcl=standard_ana_dune10kt_workspace.fcl
210  if echo $newprj | grep -q genie; then
211  recofcl=standard_reco_dune10kt_nu_workspace.fcl
212  fi
213  fi
214 
215  if echo $newprj | grep -q dune10kt_3mmpitch_workspace; then
216  g4fcl=standard_g4_dune10kt_3mmpitch_workspace.fcl
217  detsimfcl=standard_detsim_dune10kt_3mmpitch_workspace.fcl
218  recofcl=standard_reco_dune10kt_3mmpitch_workspace.fcl
219  mergefcl=standard_ana_dune10kt_3mmpitch_workspace.fcl
220  if echo $newprj | grep -q genie; then
221  recofcl=standard_reco_dune10kt_3mmpitch_nu_workspace.fcl
222  fi
223  fi
224 
225  if echo $newprj | grep -q dune10kt_45deg_workspace; then
226  g4fcl=standard_g4_dune10kt_45deg_workspace.fcl
227  detsimfcl=standard_detsim_dune10kt_45deg_workspace.fcl
228  recofcl=standard_reco_dune10kt_45deg_workspace.fcl
229  mergefcl=standard_ana_dune10kt_45deg_workspace.fcl
230  if echo $newprj | grep -q genie; then
231  recofcl=standard_reco_dune10kt_45deg_nu_workspace.fcl
232  fi
233  fi
234 
235  if echo $newprj | grep -q 'dune10kt_1x2x6\|dune10kt_r90deg_1x2x6'; then
236  g4fcl=standard_g4_dune10kt_1x2x6.fcl
237  detsimfcl=standard_detsim_dune10kt_1x2x6.fcl
238  recofcl=standard_reco_dune10kt_1x2x6.fcl
239  mergefcl=standard_ana_dune10kt_1x2x6.fcl
240  if echo $newprj | grep -q genie; then
241  recofcl=standard_reco_dune10kt_nu_1x2x6.fcl
242  fi
243  fi
244 
245  if echo $newprj | grep -q dune10kt_3mmpitch_1x2x6; then
246  g4fcl=standard_g4_dune10kt_3mmpitch_1x2x6.fcl
247  detsimfcl=standard_detsim_dune10kt_3mmpitch_1x2x6.fcl
248  recofcl=standard_reco_dune10kt_3mmpitch_1x2x6.fcl
249  mergefcl=standard_ana_dune10kt_3mmpitch_1x2x6.fcl
250  if echo $newprj | grep -q genie; then
251  recofcl=standard_reco_dune10kt_3mmpitch_nu_1x2x6.fcl
252  fi
253  fi
254 
255  if echo $newprj | grep -q dune10kt_45deg_1x2x6; then
256  g4fcl=standard_g4_dune10kt_45deg_1x2x6.fcl
257  detsimfcl=standard_detsim_dune10kt_45deg_1x2x6.fcl
258  recofcl=standard_reco_dune10kt_45deg_1x2x6.fcl
259  mergefcl=standard_ana_dune10kt_45deg_1x2x6.fcl
260  if echo $newprj | grep -q genie; then
261  recofcl=standard_reco_dune10kt_45deg_nu_1x2x6.fcl
262  fi
263  fi
264 
265  if echo $newprj | grep -q protoDune; then
266  g4fcl=protoDUNE_g4single.fcl
267  detsimfcl=protoDUNE_detsim_single.fcl
268  recofcl=protoDUNE_reco.fcl
269  mergefcl=protoDUNE_ana.fcl
270  fi
271 
272 
273  # Set number of events per job.
274  nevjob=$nevjobarg
275  if [ $nevjob -eq 0 ]; then
276  if [ $newprj = prodcosmics_dune35t_milliblock ]; then
277  nevjob=100
278  elif [ $newprj = prodcosmics_dune35t_onewindow ]; then
279  nevjob=100
280  elif [ $newprj = AntiMuonCutEvents_LSU_dune35t ]; then
281  nevjob=100
282  elif [ $newprj = prodcosmics_dune35t_milliblock_countermu ]; then
283  nevjob=10000
284  elif [ $newprj = prodcosmics_dune35t_milliblock_protonpi0 ]; then
285  nevjob=100
286  else
287  nevjob=100
288  fi
289  fi
290 
291  # Set number of events.
292 
293  nev=$nevarg
294  if [ $nev -eq 0 ]; then
295  if [ $newprj = prodcosmics_dune35t_milliblock ]; then
296  nev=10000
297  elif [ $newprj = prodcosmics_dune35t_onewindow ]; then
298  nev=10000
299  elif [ $newprj = AntiMuonCutEvents_LSU_dune35t ]; then
300  nev=10000
301  elif [ $newprj = prodcosmics_dune35t_milliblock_countermu ]; then
302  nev=10000000
303  elif [ $newprj = prodcosmics_dune35t_milliblock_protonpi0 ]; then
304  nev=100000
305  elif echo $newprj | grep -q dune10kt; then
306  if echo $newprj | grep -q genie; then
307  nev=100000
308  else
309  nev=10000
310  fi
311  elif echo $newprj | grep -q protoDune; then
312  nev=30000
313  else
314  nev=10000
315  fi
316  fi
317 
318  # Calculate the number of worker jobs.
319 
320  njob=$(( $nev / $nevjob ))
321 # echo $newprj, $nev, $nevjob, $njob
322  cat <<EOF > $newxml
323 <?xml version="1.0"?>
324 
325 <!-- Production Project -->
326 
327 <!DOCTYPE project [
328 <!ENTITY release "$rel">
329 <!ENTITY file_type "mc">
330 <!ENTITY run_type "physics">
331 <!ENTITY name "$newprj">
332 <!ENTITY tag "mcc6.0">
333 ]>
334 
335 <project name="&name;">
336 
337  <!-- Group -->
338  <group>dune</group>
339 
340  <!-- Project size -->
341  <numevents>$nev</numevents>
342 
343  <!-- Operating System -->
344  <os>SL6</os>
345 
346  <!-- Batch resources -->
347  <resource>DEDICATED,OPPORTUNISTIC</resource>
348 
349  <!-- Larsoft information -->
350  <larsoft>
351  <tag>&release;</tag>
352  <qual>${qual}:prof</qual>
353 EOF
354  echo "local=$local"
355  if [ x$local != x ]; then
356  echo " <local>${local}</local>" >> $newxml
357  fi
358  cat <<EOF >> $newxml
359  </larsoft>
360 
361  <!-- dune35t metadata parameters -->
362 
363  <parameter name ="MCName">${newprj}</parameter>
364  <parameter name ="MCDetectorType">${detector}</parameter>
365  <parameter name ="MCGenerators">${generator}</parameter>
366 
367  <!-- Project stages -->
368 
369  <stage name="gen">
370  <fcl>$genfcl</fcl>
371 EOF
372  if echo $newprj | grep -q AntiMuonCutEvents_LSU_dune35t; then
373  echo " <inputmode>textfile</inputmode>" >> $newxml
374  echo " <inputlist>/dune/data2/users/jti3/txtfiles/AntiMuonCutEvents_LSU_100.txt</inputlist>" >> $newxml
375  fi
376  cat <<EOF >> $newxml
377  <outdir>/pnfs/dune/persistent/${userdir}/&release;/gen/&name;</outdir>
378  <workdir>/dune/app/users/${userbase}/work/&release;/gen/&name;</workdir>
379  <output>${newprj}_\${PROCESS}_%tc_gen.root</output>
380  <numjobs>$njob</numjobs>
381  <datatier>generated</datatier>
382  <defname>&name;_&tag;_gen</defname>
383  </stage>
384 
385  <stage name="g4">
386  <fcl>$g4fcl</fcl>
387  <outdir>/pnfs/dune/persistent/${userdir}/&release;/g4/&name;</outdir>
388  <workdir>/dune/app/users/${userbase}/work/&release;/g4/&name;</workdir>
389  <numjobs>$njob</numjobs>
390  <datatier>simulated</datatier>
391  <defname>&name;_&tag;_g4</defname>
392  </stage>
393 
394 EOF
395  if [ x$detsimfcl != x ]; then
396  cat <<EOF >> $newxml
397  <stage name="detsim">
398  <fcl>$detsimfcl</fcl>
399  <outdir>/pnfs/dune/persistent/${userdir}/&release;/detsim/&name;</outdir>
400  <workdir>/dune/app/users/${userbase}/work/&release;/detsim/&name;</workdir>
401  <numjobs>$njob</numjobs>
402  <datatier>detector-simulated</datatier>
403  <defname>&name;_&tag;_detsim</defname>
404  </stage>
405 
406 EOF
407  fi
408  cat <<EOF >> $newxml
409  <stage name="reco">
410  <fcl>$recofcl</fcl>
411  <outdir>/pnfs/dune/persistent/${userdir}/&release;/reco/&name;</outdir>
412  <workdir>/dune/app/users/${userbase}/work/&release;/reco/&name;</workdir>
413  <numjobs>$njob</numjobs>
414  <datatier>full-reconstructed</datatier>
415  <defname>&name;_&tag;_reco</defname>
416  </stage>
417 
418  <stage name="mergeana">
419  <fcl>$mergefcl</fcl>
420  <outdir>/pnfs/dune/persistent/${userdir}/&release;/mergeana/&name;</outdir>
421  <output>&name;_\${PROCESS}_%tc_merged.root</output>
422  <workdir>/dune/app/users/${userbase}/work/&release;/mergeana/&name;</workdir>
423  <numjobs>$njob</numjobs>
424  <targetsize>8000000000</targetsize>
425  <datatier>full-reconstructed</datatier>
426  <defname>&name;_&tag;</defname>
427  </stage>
428 
429  <!-- file type -->
430  <filetype>&file_type;</filetype>
431 
432  <!-- run type -->
433  <runtype>&run_type;</runtype>
434 
435 </project>
436 EOF
437 
438  fi
439 
440 done