make_xml_mcc.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 rs=v06_16_00
34 rr1=v06_16_00
35 rr2=v06_16_00
36 userdir=scratch/dunepro
37 userbase=dunepro
38 nevarg=0
39 nevjob=0
40 nevjobarg=0
41 ls=''
42 lr1=''
43 lr2=''
44 tag=devel
45 splitreco=0
46 
47 while [ $# -gt 0 ]; do
48  case "$1" in
49 
50  # User directory.
51 
52  -h|--help )
53  echo "Usage: make_xml_mcc.sh [-h|--help] [-r <release>] [-t|--tag <tag>] [-u|--user <user>] [--local <dir|tar>] [--nev <n>] [--nevjob <n>]"
54  exit
55  ;;
56 
57  # Simulation release.
58 
59  -rs )
60  if [ $# -gt 1 ]; then
61  rs=$2
62  shift
63  fi
64  ;;
65 
66  # Reconstruction 1 release.
67 
68  -rr1 )
69  if [ $# -gt 1 ]; then
70  rr1=$2
71  shift
72  fi
73  ;;
74 
75  # Reconstruction 1 release.
76 
77  -rr2 )
78  if [ $# -gt 1 ]; then
79  rr2=$2
80  splitreco=1
81  shift
82  fi
83  ;;
84 
85  # All stages release.
86 
87  -r|--release )
88  if [ $# -gt 1 ]; then
89  rs=$2
90  rr1=$2
91  rr2=$2
92  shift
93  fi
94  ;;
95 
96  # User.
97 
98  -u|--user )
99  if [ $# -gt 1 ]; then
100  userdir=scratch/users/$2
101  userbase=$2
102  shift
103  fi
104  ;;
105 
106  # Local simulation release.
107 
108  -ls )
109  if [ $# -gt 1 ]; then
110  ls=$2
111  shift
112  fi
113  ;;
114 
115  # Local reconstruction release.
116 
117  -lr1 )
118  if [ $# -gt 1 ]; then
119  lr1=$2
120  shift
121  fi
122  ;;
123 
124  -lr2 )
125  if [ $# -gt 1 ]; then
126  lr2=$2
127  shift
128  fi
129  ;;
130 
131  # Local release.
132 
133  --local )
134  if [ $# -gt 1 ]; then
135  ls=$2
136  lr1=$2
137  lr2=$2
138  shift
139  fi
140  ;;
141 
142  # Total number of events.
143 
144  --nev )
145  if [ $# -gt 1 ]; then
146  nevarg=$2
147  shift
148  fi
149  ;;
150 
151  # Number of events per job.
152 
153  --nevjob )
154  if [ $# -gt 1 ]; then
155  nevjobarg=$2
156  shift
157  fi
158  ;;
159 
160  # Sample tag.
161 
162  -t|--tag )
163  if [ $# -gt 1 ]; then
164  tag=$2
165  shift
166  fi
167  ;;
168 
169  esac
170  shift
171 done
172 
173 # Get qualifier.
174 
175 quals=e14
176 if [[ $rs < 'v06_32_00' ]]; then
177  quals=e10
178 fi
179 
180 qualr1=e14
181 if [[ $rr1 < 'v06_32_00' ]]; then
182  qualr1=e10
183 fi
184 
185 qualr2=e14
186 if [[ $rr2 < 'v06_32_00' ]]; then
187  qualr2=e10
188 fi
189 
190 echo $quals $qualr1 $qualr2
191 
192 # Delete existing xml files.
193 
194 rm -f *.xml
195 
196 find $DUNETPC_DIR/source/fcl/dune35t/gen $DUNETPC_DIR/source/fcl/dunefd/gen $DUNETPC_DIR/source/fcl/protodune/gen -name \*.fcl | while read fcl
197 do
198  if ! echo $fcl | grep -q 'common\|protoDUNE_gensingle'; then
199  newprj=`basename $fcl .fcl`
200  newxml=${newprj}_${tag}.xml
201  samprj=${newprj}
202  if [ $userbase != dunepro ]; then
203  samprj=${userbase}_$newprj
204  fi
205  generator=SingleGen
206  if echo $newprj | grep -q cosmics; then
207  generator=CRY
208  fi
209  if echo $newprj | grep -q AntiMuonCutEvents; then
210  generator=TextFileGen
211  fi
212  if echo $newprj | grep -q genie; then
213  generator=GENIE
214  fi
215  if echo $newprj | grep -q MUSUN; then
216  generator=MUSUN
217  fi
218  if echo $newprj | grep -q supernova; then
219  generator=SNNueAr40CCGen
220  fi
221  if echo $newprj | grep -q prodndk; then
222  generator=NDKGen
223  fi
224  if echo $newprj | grep -q prodmarley; then
225  generator=MARLEY
226  fi
227  if echo $newprj | grep -q prodbackground_ar39; then
228  generator=RadioGen
229  fi
230 
231  detector=35t
232  if echo $newprj | grep -q dune10kt; then
233  detector=10kt
234  fi
235  if echo $newprj | grep -q protoDune; then
236  detector=protoDune
237  fi
238 
239  # Make xml file.
240 
241  echo "Making ${newxml}"
242 
243  # Generator
244 
245  genfcl=`basename $fcl`
246 
247  # G4
248 
249  g4fcl=standard_g4_dune35t.fcl
250 
251  # Detsim (optical + tpc).
252 
253  detsimfcl=standard_detsim_dune35t.fcl
254 
255  # Reco 2D
256 
257 # reco2dfcl=standard_reco_uboone_2D.fcl
258 
259  # Reco 3D
260 
261 # reco3dfcl=standard_reco_uboone_3D.fcl
262 
263  # Reco
264  recofcl1=standard_reco_dune35tsim.fcl
265  recofcl2=''
266 
267  # Merge/Analysis
268 
269  mergefcl=standard_ana_dune35t.fcl
270  caffcl=''
271 
272  if echo $newprj | grep -q protonpi0; then
273  g4fcl=standard_g4_dune35t_protonpi0.fcl
274  fi
275 
276  if echo $newprj | grep -q countermu; then
277  g4fcl=standard_g4_dune35t_countermu.fcl
278  fi
279 
280 # if echo $newprj | grep -q 'pi0\|gamma'; then
281 # recofcl1=reco_dune35t_blur.fcl
282 # mergefcl=ana_energyCalib.fcl
283 # fi
284 
285 # if echo $newprj | grep -q 'piminus'; then
286 # recofcl1=emhits.fcl
287 # mergefcl=standard_merge_dune35t.fcl
288 # fi
289 
290  if echo $newprj | grep -q milliblock; then
291  detsimfcl=standard_detsim_dune35t_milliblock.fcl
292  recofcl1=standard_reco_dune35t_milliblock.fcl
293  mergefcl=standard_ana_dune35t_milliblock.fcl
294  fi
295 
296  if echo $newprj | grep -q dune10kt; then
297  g4fcl=standard_g4_dune10kt.fcl
298  detsimfcl=standard_detsim_dune10kt.fcl
299  recofcl1=standard_reco_dune10kt.fcl
300  mergefcl=standard_ana_dune10kt.fcl
301  fi
302 
303  if echo $newprj | grep -q 'dune10kt_1x2x6\|dune10kt_r90deg_1x2x6'; then
304  g4fcl=standard_g4_dune10kt_1x2x6.fcl
305  detsimfcl=standard_detsim_dune10kt_1x2x6.fcl
306  recofcl1=standard_reco_dune10kt_1x2x6.fcl
307  mergefcl=standard_ana_dune10kt_1x2x6.fcl
308  if echo $newprj | grep -q 'genie_nu\|genie_anu'; then
309  recofcl1=standard_reco_dune10kt_nu_1x2x6.fcl
310  if [ $splitreco -eq 1 ]; then
311  recofcl1=standard_reco1_dune10kt_nu_1x2x6.fcl
312  recofcl2=standard_reco2_dune10kt_nu_1x2x6.fcl
313  fi
314  fi
315  if echo $newprj | grep -q 'supernova\|marley'; then
316  g4fcl=supernova_g4_dune10kt_1x2x6.fcl
317  fi
318  if echo $newprj | grep -q '_nu'; then
319  caffcl=select_ana_dune10kt_nu.fcl
320  fi
321  if echo $newprj | grep -q '_anu'; then
322  caffcl=select_ana_dune10kt_anu.fcl
323  fi
324  fi
325 
326  if echo $newprj | grep -q dune10kt_3mmpitch_1x2x6; then
327  g4fcl=standard_g4_dune10kt_3mmpitch_1x2x6.fcl
328  detsimfcl=standard_detsim_dune10kt_3mmpitch_1x2x6.fcl
329  recofcl1=standard_reco_dune10kt_3mmpitch_1x2x6.fcl
330  mergefcl=standard_ana_dune10kt_3mmpitch_1x2x6.fcl
331  if echo $newprj | grep -q 'genie_nu\|genie_anu'; then
332  recofcl1=standard_reco_dune10kt_3mmpitch_nu_1x2x6.fcl
333  if [ $splitreco -eq 1 ]; then
334  recofcl1=standard_reco1_dune10kt_3mmpitch_nu_1x2x6.fcl
335  recofcl2=standard_reco2_dune10kt_3mmpitch_nu_1x2x6.fcl
336  fi
337  fi
338  if echo $newprj | grep -q 'supernova\|marley'; then
339  g4fcl=supernova_g4_dune10kt_3mmpitch_1x2x6.fcl
340  fi
341  fi
342 
343  if echo $newprj | grep -q dune10kt_45deg_1x2x6; then
344  g4fcl=standard_g4_dune10kt_45deg_1x2x6.fcl
345  detsimfcl=standard_detsim_dune10kt_45deg_1x2x6.fcl
346  recofcl1=standard_reco_dune10kt_45deg_1x2x6.fcl
347  mergefcl=standard_ana_dune10kt_45deg_1x2x6.fcl
348  if echo $newprj | grep -q 'genie_nu\|genie_anu'; then
349  recofcl1=standard_reco_dune10kt_45deg_nu_1x2x6.fcl
350  if [ $splitreco -eq 1 ]; then
351  recofcl1=standard_reco1_dune10kt_45deg_nu_1x2x6.fcl
352  recofcl2=standard_reco2_dune10kt_45deg_nu_1x2x6.fcl
353  fi
354  fi
355  if echo $newprj | grep -q 'supernova\|marley'; then
356  g4fcl=supernova_g4_dune10kt_45deg_1x2x6.fcl
357  fi
358  fi
359 
360  if echo $newprj | grep -q protoDune; then
361  g4fcl=protoDUNE_g4single.fcl
362  detsimfcl=protoDUNE_detsim_single.fcl
363  recofcl1=protoDUNE_reco.fcl
364  mergefcl=protoDUNE_ana.fcl
365  fi
366 
367  if echo $newprj | grep -q dphase; then
368  g4fcl=standard_g4_dune10kt_dp.fcl
369  detsimfcl=standard_detsim_dune10kt_dp.fcl
370  recofcl1=standard_reco_dune10ktdphase.fcl
371  mergefcl=standard_ana_dune10kt_dp.fcl
372  fi
373 
374 
375 
376  # Set number of events per job.
377  nevjob=$nevjobarg
378  if [ $nevjob -eq 0 ]; then
379  if [ $newprj = prodcosmics_dune35t_milliblock ]; then
380  nevjob=100
381  elif [ $newprj = prodcosmics_dune35t_onewindow ]; then
382  nevjob=100
383  elif [ $newprj = AntiMuonCutEvents_LSU_dune35t ]; then
384  nevjob=100
385  elif [ $newprj = prodcosmics_dune35t_milliblock_countermu ]; then
386  nevjob=10000
387  elif [ $newprj = prodcosmics_dune35t_milliblock_protonpi0 ]; then
388  nevjob=100
389  else
390  nevjob=100
391  fi
392  fi
393 
394  # Set number of events.
395 
396  nev=$nevarg
397  if [ $nev -eq 0 ]; then
398  if [ $newprj = prodcosmics_dune35t_milliblock ]; then
399  nev=10000
400  elif [ $newprj = prodcosmics_dune35t_onewindow ]; then
401  nev=10000
402  elif [ $newprj = AntiMuonCutEvents_LSU_dune35t ]; then
403  nev=10000
404  elif [ $newprj = prodcosmics_dune35t_milliblock_countermu ]; then
405  nev=10000000
406  elif [ $newprj = prodcosmics_dune35t_milliblock_protonpi0 ]; then
407  nev=100000
408  elif echo $newprj | grep -q dune10kt; then
409  if echo $newprj | grep -q 'genie_nu\|genie_anu'; then
410  nev=1000000
411  if echo $newprj | grep -q dphase; then
412  nev=10000
413  fi
414  else
415  nev=10000
416  fi
417  elif echo $newprj | grep -q protoDune; then
418  nev=30000
419  else
420  nev=10000
421  fi
422  fi
423 
424  # Calculate the number of worker jobs.
425 
426  njob=$(( $nev / $nevjob ))
427 # echo $newprj, $nev, $nevjob, $njob
428  cat <<EOF > $newxml
429 <?xml version="1.0"?>
430 
431 <!-- Production Project -->
432 
433 <!DOCTYPE project [
434 <!ENTITY relsim "$rs">
435 <!ENTITY relreco1 "$rr1">
436 <!ENTITY relreco2 "$rr2">
437 <!ENTITY file_type "mc">
438 <!ENTITY run_type "physics">
439 <!ENTITY name "$samprj">
440 <!ENTITY tag "$tag">
441 ]>
442 
443 <job>
444 
445 <project name="&name;">
446 
447  <!-- Group -->
448  <group>dune</group>
449 
450  <!-- Project size -->
451  <numevents>$nev</numevents>
452 
453  <!-- Operating System -->
454  <os>SL6</os>
455 
456  <!-- Batch resources -->
457  <resource>DEDICATED,OPPORTUNISTIC</resource>
458 
459  <!-- metadata parameters -->
460 
461  <parameter name ="MCName">${samprj}</parameter>
462  <parameter name ="MCDetectorType">${detector}</parameter>
463  <parameter name ="MCGenerators">${generator}</parameter>
464 
465  <!-- Larsoft information -->
466  <larsoft>
467  <tag>&relsim;</tag>
468  <qual>${quals}:prof</qual>
469 EOF
470  if [ x$ls != x ]; then
471  echo "ls=$ls"
472  echo " <local>${ls}</local>" >> $newxml
473  fi
474  cat <<EOF >> $newxml
475  </larsoft>
476 
477  <!-- Project stages -->
478 
479  <stage name="detsim">
480  <fcl>$genfcl</fcl>
481  <fcl>$g4fcl</fcl>
482  <fcl>$detsimfcl</fcl>
483 EOF
484  if echo $newprj | grep -q AntiMuonCutEvents_LSU_dune35t; then
485  echo " <inputmode>textfile</inputmode>" >> $newxml
486  echo " <inputlist>/pnfs/dune/persistent/dunepro/AntiMuonCutEvents_LSU_100.txt</inputlist>" >> $newxml
487  fi
488  cat <<EOF >> $newxml
489  <outdir>/pnfs/dune/${userdir}/&relsim;/detsim/&name;</outdir>
490  <workdir>/pnfs/dune/${userdir}/work/&relsim;/detsim/&name;</workdir>
491  <output>${newprj}_\${PROCESS}_%tc_detsim.root</output>
492  <numjobs>$njob</numjobs>
493  <datatier>detector-simulated</datatier>
494  <defname>&name;_&tag;_detsim</defname>
495  </stage>
496 
497  <!-- file type -->
498  <filetype>&file_type;</filetype>
499 
500  <!-- run type -->
501  <runtype>&run_type;</runtype>
502 
503 </project>
504 EOF
505  if [ x$recofcl2 == x ]; then
506  cat <<EOF >> $newxml
507 
508 <project name="&name;_reco">
509 
510  <!-- Project size -->
511  <numevents>$nev</numevents>
512 
513  <!-- Operating System -->
514  <os>SL6</os>
515 
516  <!-- Batch resources -->
517  <resource>DEDICATED,OPPORTUNISTIC</resource>
518 
519  <!-- metadata parameters -->
520 
521  <parameter name ="MCName">${samprj}</parameter>
522  <parameter name ="MCDetectorType">${detector}</parameter>
523  <parameter name ="MCGenerators">${generator}</parameter>
524 
525  <!-- Larsoft information -->
526  <larsoft>
527  <tag>&relreco1;</tag>
528  <qual>${qualr1}:prof</qual>
529 EOF
530  if [ x$lr1 != x ]; then
531  echo "lr1=$lr1"
532  echo " <local>${lr1}</local>" >> $newxml
533  fi
534  cat <<EOF >> $newxml
535  </larsoft>
536 
537  <!-- Project stages -->
538  <stage name="reco">
539  <jobsub>--expected-lifetime=24h</jobsub>
540  <fcl>$recofcl1</fcl>
541  <outdir>/pnfs/dune/${userdir}/&relreco1;/reco/&name;</outdir>
542  <workdir>/pnfs/dune/${userdir}/work/&relreco1;/reco/&name;</workdir>
543  <numjobs>$njob</numjobs>
544  <datatier>full-reconstructed</datatier>
545  <defname>&name;_&tag;_reco</defname>
546  </stage>
547 
548  <stage name="mergeana">
549 EOF
550  if [ x$caffcl != x ]; then
551  echo " <jobsub>--memory=4000 --expected-lifetime=24h</jobsub>" >> $newxml
552  echo " <fcl>$caffcl</fcl>" >> $newxml
553  fi
554 cat <<EOF >> $newxml
555  <fcl>$mergefcl</fcl>
556  <outdir>/pnfs/dune/${userdir}/&relreco1;/mergeana/&name;</outdir>
557  <output>&name;_\${PROCESS}_%tc_merged.root</output>
558  <workdir>/pnfs/dune/${userdir}/work/&relreco1;/mergeana/&name;</workdir>
559  <numjobs>$njob</numjobs>
560  <targetsize>8000000000</targetsize>
561  <datatier>full-reconstructed</datatier>
562  <defname>&name;_&tag;</defname>
563  </stage>
564 EOF
565  else
566 cat <<EOF >> $newxml
567 
568 <project name="&name;_reco1">
569 
570  <!-- Project size -->
571  <numevents>$nev</numevents>
572 
573  <!-- Operating System -->
574  <os>SL6</os>
575 
576  <!-- Batch resources -->
577  <resource>DEDICATED,OPPORTUNISTIC</resource>
578 
579  <!-- metadata parameters -->
580 
581  <parameter name ="MCName">${samprj}</parameter>
582  <parameter name ="MCDetectorType">${detector}</parameter>
583  <parameter name ="MCGenerators">${generator}</parameter>
584 
585  <!-- Larsoft information -->
586  <larsoft>
587  <tag>&relreco1;</tag>
588  <qual>${qualr1}:prof</qual>
589 EOF
590  if [ x$lr1 != x ]; then
591  echo "lr1=$lr1"
592  echo " <local>${lr1}</local>" >> $newxml
593  fi
594  cat <<EOF >> $newxml
595  </larsoft>
596 
597  <!-- Project stages -->
598  <stage name="reco1">
599  <fcl>$recofcl1</fcl>
600  <outdir>/pnfs/dune/${userdir}/&relreco1;/reco1/&name;</outdir>
601  <workdir>/pnfs/dune/${userdir}/work/&relreco1;/reco1/&name;</workdir>
602  <numjobs>$njob</numjobs>
603  <datatier>hit-reconstructed</datatier>
604  <defname>&name;_&tag;_reco1</defname>
605  </stage>
606 
607  <!-- file type -->
608  <filetype>&file_type;</filetype>
609 
610  <!-- run type -->
611  <runtype>&run_type;</runtype>
612 
613 </project>
614 
615 <project name="&name;_reco2">
616 
617  <!-- Project size -->
618  <numevents>$nev</numevents>
619 
620  <!-- Operating System -->
621  <os>SL6</os>
622 
623  <!-- Batch resources -->
624  <resource>DEDICATED,OPPORTUNISTIC</resource>
625 
626  <!-- metadata parameters -->
627 
628  <parameter name ="MCName">${samprj}</parameter>
629  <parameter name ="MCDetectorType">${detector}</parameter>
630  <parameter name ="MCGenerators">${generator}</parameter>
631 
632  <!-- Larsoft information -->
633  <larsoft>
634  <tag>&relreco2;</tag>
635  <qual>${qualr2}:prof</qual>
636 EOF
637  if [ x$lr2 != x ]; then
638  echo "lr2=$lr2"
639  echo " <local>${lr2}</local>" >> $newxml
640  fi
641  cat <<EOF >> $newxml
642  </larsoft>
643 
644  <!-- Project stages -->
645  <stage name="reco2">
646  <jobsub>--expected-lifetime=24h</jobsub>
647  <fcl>$recofcl2</fcl>
648  <outdir>/pnfs/dune/${userdir}/&relreco2;/reco2/&name;</outdir>
649  <workdir>/pnfs/dune/${userdir}/work/&relreco2;/reco2/&name;</workdir>
650  <numjobs>$njob</numjobs>
651  <datatier>full-reconstructed</datatier>
652  <defname>&name;_&tag;_reco2</defname>
653  </stage>
654 
655  <stage name="mergeana">
656 EOF
657  if [ x$caffcl != x ]; then
658  echo " <jobsub>--memory=4000 --expected-lifetime=24h</jobsub>" >> $newxml
659  echo " <fcl>$caffcl</fcl>" >> $newxml
660  fi
661 cat <<EOF >> $newxml
662  <fcl>$mergefcl</fcl>
663  <outdir>/pnfs/dune/${userdir}/&relreco2;/mergeana/&name;</outdir>
664  <output>&name;_\${PROCESS}_%tc_merged.root</output>
665  <workdir>/pnfs/dune/${userdir}/work/&relreco2;/mergeana/&name;</workdir>
666  <numjobs>$njob</numjobs>
667  <targetsize>8000000000</targetsize>
668  <datatier>full-reconstructed</datatier>
669  <defname>&name;_&tag;</defname>
670  </stage>
671 EOF
672  fi
673 
674  cat <<EOF >> $newxml
675 
676  <!-- file type -->
677  <filetype>&file_type;</filetype>
678 
679  <!-- run type -->
680  <runtype>&run_type;</runtype>
681 
682 </project>
683 </job>
684 
685 EOF
686  fi
687 done