make_xml_mcc7.1.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=v06_04_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>]"
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=e10
104 ver=`echo $rel | cut -c2-3`
105 if [ $ver -gt 2 ]; then
106  qual=e10
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  if echo $newprj | grep -q prodndk; then
135  generator=NDKGen
136  fi
137 
138  detector=35t
139  if echo $newprj | grep -q dune10kt; then
140  detector=10kt
141  fi
142  if echo $newprj | grep -q protoDune; then
143  detector=protoDune
144  fi
145 
146  # Make xml file.
147 
148  echo "Making ${newprj}.xml"
149 
150  # Generator
151 
152  genfcl=`basename $fcl`
153 
154  # G4
155 
156  g4fcl=standard_g4_dune35t.fcl
157 
158  # Detsim (optical + tpc).
159 
160  detsimfcl=standard_detsim_dune35t.fcl
161 
162  # Reco 2D
163 
164 # reco2dfcl=standard_reco_uboone_2D.fcl
165 
166  # Reco 3D
167 
168 # reco3dfcl=standard_reco_uboone_3D.fcl
169 
170  # Reco
171  recofcl=standard_reco_dune35t.fcl
172 
173  # Merge/Analysis
174 
175  mergefcl=standard_ana_dune35t.fcl
176 
177  if echo $newprj | grep -q protonpi0; then
178  g4fcl=standard_g4_dune35t_protonpi0.fcl
179  fi
180 
181  if echo $newprj | grep -q countermu; then
182  g4fcl=standard_g4_dune35t_countermu.fcl
183  fi
184 
185 # if echo $newprj | grep -q 'pi0\|gamma'; then
186 # recofcl=reco_dune35t_blur.fcl
187 # mergefcl=ana_energyCalib.fcl
188 # fi
189 
190 # if echo $newprj | grep -q 'piminus'; then
191 # recofcl=emhits.fcl
192 # mergefcl=standard_merge_dune35t.fcl
193 # fi
194 
195  if echo $newprj | grep -q milliblock; then
196  detsimfcl=standard_detsim_dune35t_milliblock.fcl
197  recofcl=standard_reco_dune35t_milliblock.fcl
198  mergefcl=standard_ana_dune35t_milliblock.fcl
199  fi
200 
201  if echo $newprj | grep -q dune10kt; then
202  g4fcl=standard_g4_dune10kt.fcl
203  detsimfcl=standard_detsim_dune10kt.fcl
204  recofcl=standard_reco_dune10kt.fcl
205  mergefcl=standard_ana_dune10kt.fcl
206  fi
207 
208  if echo $newprj | grep -q 'dune10kt_workspace\|dune10kt_r10deg_workspace'; then
209  g4fcl=standard_g4_dune10kt_workspace.fcl
210  detsimfcl=standard_detsim_dune10kt_workspace.fcl
211  recofcl=standard_reco_dune10kt_workspace.fcl
212  mergefcl=standard_ana_dune10kt_workspace.fcl
213  if echo $newprj | grep -q genie; then
214  recofcl=standard_reco_dune10kt_nu_workspace.fcl
215  fi
216  fi
217 
218  if echo $newprj | grep -q dune10kt_3mmpitch_workspace; then
219  g4fcl=standard_g4_dune10kt_3mmpitch_workspace.fcl
220  detsimfcl=standard_detsim_dune10kt_3mmpitch_workspace.fcl
221  recofcl=standard_reco_dune10kt_3mmpitch_workspace.fcl
222  mergefcl=standard_ana_dune10kt_3mmpitch_workspace.fcl
223  if echo $newprj | grep -q genie; then
224  recofcl=standard_reco_dune10kt_3mmpitch_nu_workspace.fcl
225  fi
226  fi
227 
228  if echo $newprj | grep -q dune10kt_45deg_workspace; then
229  g4fcl=standard_g4_dune10kt_45deg_workspace.fcl
230  detsimfcl=standard_detsim_dune10kt_45deg_workspace.fcl
231  recofcl=standard_reco_dune10kt_45deg_workspace.fcl
232  mergefcl=standard_ana_dune10kt_45deg_workspace.fcl
233  if echo $newprj | grep -q genie; then
234  recofcl=standard_reco_dune10kt_45deg_nu_workspace.fcl
235  fi
236  fi
237 
238  if echo $newprj | grep -q 'dune10kt_1x2x6\|dune10kt_r90deg_1x2x6'; then
239  g4fcl=standard_g4_dune10kt_1x2x6.fcl
240  detsimfcl=standard_detsim_dune10kt_1x2x6.fcl
241  recofcl=standard_reco_dune10kt_1x2x6.fcl
242  mergefcl=standard_ana_dune10kt_1x2x6.fcl
243  if echo $newprj | grep -q genie; then
244  recofcl=standard_reco_dune10kt_nu_1x2x6.fcl
245  fi
246  if echo $newprj | grep -q 'supernova\|marley'; then
247  g4fcl=supernova_g4_dune10kt_1x2x6.fcl
248  fi
249  fi
250 
251  if echo $newprj | grep -q dune10kt_3mmpitch_1x2x6; then
252  g4fcl=standard_g4_dune10kt_3mmpitch_1x2x6.fcl
253  detsimfcl=standard_detsim_dune10kt_3mmpitch_1x2x6.fcl
254  recofcl=standard_reco_dune10kt_3mmpitch_1x2x6.fcl
255  mergefcl=standard_ana_dune10kt_3mmpitch_1x2x6.fcl
256  if echo $newprj | grep -q genie; then
257  recofcl=standard_reco_dune10kt_3mmpitch_nu_1x2x6.fcl
258  fi
259  if echo $newprj | grep -q 'supernova\|marley'; then
260  g4fcl=supernova_g4_dune10kt_3mmpitch_1x2x6.fcl
261  fi
262  fi
263 
264  if echo $newprj | grep -q dune10kt_45deg_1x2x6; then
265  g4fcl=standard_g4_dune10kt_45deg_1x2x6.fcl
266  detsimfcl=standard_detsim_dune10kt_45deg_1x2x6.fcl
267  recofcl=standard_reco_dune10kt_45deg_1x2x6.fcl
268  mergefcl=standard_ana_dune10kt_45deg_1x2x6.fcl
269  if echo $newprj | grep -q genie; then
270  recofcl=standard_reco_dune10kt_45deg_nu_1x2x6.fcl
271  fi
272  if echo $newprj | grep -q 'supernova\|marley'; then
273  g4fcl=supernova_g4_dune10kt_45deg_1x2x6.fcl
274  fi
275  fi
276 
277  if echo $newprj | grep -q protoDune; then
278  g4fcl=protoDUNE_g4single.fcl
279  detsimfcl=protoDUNE_detsim_single.fcl
280  recofcl=protoDUNE_reco.fcl
281  mergefcl=protoDUNE_ana.fcl
282  fi
283 
284 
285  # Set number of events per job.
286  nevjob=$nevjobarg
287  if [ $nevjob -eq 0 ]; then
288  if [ $newprj = prodcosmics_dune35t_milliblock ]; then
289  nevjob=100
290  elif [ $newprj = prodcosmics_dune35t_onewindow ]; then
291  nevjob=100
292  elif [ $newprj = AntiMuonCutEvents_LSU_dune35t ]; then
293  nevjob=100
294  elif [ $newprj = prodcosmics_dune35t_milliblock_countermu ]; then
295  nevjob=10000
296  elif [ $newprj = prodcosmics_dune35t_milliblock_protonpi0 ]; then
297  nevjob=100
298  else
299  nevjob=100
300  fi
301  fi
302 
303  # Set number of events.
304 
305  nev=$nevarg
306  if [ $nev -eq 0 ]; then
307  if [ $newprj = prodcosmics_dune35t_milliblock ]; then
308  nev=10000
309  elif [ $newprj = prodcosmics_dune35t_onewindow ]; then
310  nev=10000
311  elif [ $newprj = AntiMuonCutEvents_LSU_dune35t ]; then
312  nev=10000
313  elif [ $newprj = prodcosmics_dune35t_milliblock_countermu ]; then
314  nev=10000000
315  elif [ $newprj = prodcosmics_dune35t_milliblock_protonpi0 ]; then
316  nev=100000
317  elif echo $newprj | grep -q dune10kt; then
318  if echo $newprj | grep -q genie; then
319  nev=100000
320  else
321  nev=10000
322  fi
323  elif echo $newprj | grep -q protoDune; then
324  nev=30000
325  else
326  nev=10000
327  fi
328  fi
329 
330  # Calculate the number of worker jobs.
331 
332  njob=$(( $nev / $nevjob ))
333 # echo $newprj, $nev, $nevjob, $njob
334  cat <<EOF > $newxml
335 <?xml version="1.0"?>
336 
337 <!-- Production Project -->
338 
339 <!DOCTYPE project [
340 <!ENTITY release "$rel">
341 <!ENTITY file_type "mc">
342 <!ENTITY run_type "physics">
343 <!ENTITY name "$newprj">
344 <!ENTITY tag "mcc7.1">
345 ]>
346 
347 <project name="&name;">
348 
349  <!-- Group -->
350  <group>dune</group>
351 
352  <!-- Project size -->
353  <numevents>$nev</numevents>
354 
355  <!-- Operating System -->
356  <os>SL6</os>
357 
358  <!-- Batch resources -->
359  <resource>DEDICATED,OPPORTUNISTIC</resource>
360 
361  <!-- Larsoft information -->
362  <larsoft>
363  <tag>&release;</tag>
364  <qual>${qual}:prof</qual>
365 EOF
366  echo "local=$local"
367  if [ x$local != x ]; then
368  echo " <local>${local}</local>" >> $newxml
369  fi
370  cat <<EOF >> $newxml
371  </larsoft>
372 
373  <!-- dune35t metadata parameters -->
374 
375  <parameter name ="MCName">${newprj}</parameter>
376  <parameter name ="MCDetectorType">${detector}</parameter>
377  <parameter name ="MCGenerators">${generator}</parameter>
378 
379  <!-- Project stages -->
380 
381  <stage name="gen">
382  <fcl>$genfcl</fcl>
383 EOF
384  if echo $newprj | grep -q AntiMuonCutEvents_LSU_dune35t; then
385  echo " <inputmode>textfile</inputmode>" >> $newxml
386  echo " <inputlist>/dune/data2/users/jti3/txtfiles/AntiMuonCutEvents_LSU_100.txt</inputlist>" >> $newxml
387  fi
388  cat <<EOF >> $newxml
389  <outdir>/pnfs/dune/scratch/${userdir}/&release;/gen/&name;</outdir>
390  <workdir>/dune/app/users/${userbase}/work/&release;/gen/&name;</workdir>
391  <output>${newprj}_\${PROCESS}_%tc_gen.root</output>
392  <numjobs>$njob</numjobs>
393  <datatier>generated</datatier>
394  <defname>&name;_&tag;_gen</defname>
395  </stage>
396 
397  <stage name="g4">
398  <fcl>$g4fcl</fcl>
399  <outdir>/pnfs/dune/scratch/${userdir}/&release;/g4/&name;</outdir>
400  <workdir>/dune/app/users/${userbase}/work/&release;/g4/&name;</workdir>
401  <numjobs>$njob</numjobs>
402  <datatier>simulated</datatier>
403  <defname>&name;_&tag;_g4</defname>
404  </stage>
405 
406 EOF
407  if [ x$detsimfcl != x ]; then
408  cat <<EOF >> $newxml
409  <stage name="detsim">
410  <fcl>$detsimfcl</fcl>
411  <outdir>/pnfs/dune/scratch/${userdir}/&release;/detsim/&name;</outdir>
412  <workdir>/dune/app/users/${userbase}/work/&release;/detsim/&name;</workdir>
413  <numjobs>$njob</numjobs>
414  <datatier>detector-simulated</datatier>
415  <defname>&name;_&tag;_detsim</defname>
416  </stage>
417 
418 EOF
419  fi
420  cat <<EOF >> $newxml
421  <stage name="reco">
422  <fcl>$recofcl</fcl>
423  <outdir>/pnfs/dune/scratch/${userdir}/&release;/reco/&name;</outdir>
424  <workdir>/dune/app/users/${userbase}/work/&release;/reco/&name;</workdir>
425  <numjobs>$njob</numjobs>
426  <datatier>full-reconstructed</datatier>
427  <defname>&name;_&tag;_reco</defname>
428  </stage>
429 
430  <stage name="mergeana">
431  <fcl>$mergefcl</fcl>
432  <outdir>/pnfs/dune/scratch/${userdir}/&release;/mergeana/&name;</outdir>
433  <output>&name;_\${PROCESS}_%tc_merged.root</output>
434  <workdir>/dune/app/users/${userbase}/work/&release;/mergeana/&name;</workdir>
435  <numjobs>$njob</numjobs>
436  <targetsize>8000000000</targetsize>
437  <datatier>full-reconstructed</datatier>
438  <defname>&name;_&tag;</defname>
439  </stage>
440 
441  <!-- file type -->
442  <filetype>&file_type;</filetype>
443 
444  <!-- run type -->
445  <runtype>&run_type;</runtype>
446 
447 </project>
448 EOF
449 
450  fi
451 
452 done