make_xml_protodune_mcc8.0.sh
Go to the documentation of this file.
1 #! /bin/bash
2 #----------------------------------------------------------------------
3 #
4 # Name: make_xml_protodune_mcc8.0.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 # This is for Dorota's samples, so there's a lot of special one-off logic in here.
12 #
13 # Usage:
14 #
15 # make_xml_protodune_mcc8.0.sh [-h|--help] [-r <release>] [-u|--user <user>] [--local <dir|tar>] [--nev <n>] [--nevjob <n>] [--nevgjob <n>]
16 #
17 # Options:
18 #
19 # -h|--help - Print help.
20 # -r <release> - Use the specified larsoft/dunetpc release.
21 # -u|--user <user> - Use users/<user> as working and output directories
22 # (default is to use lbnepro).
23 # --local <dir|tar> - Specify larsoft local directory or tarball (xml
24 # tag <local>...</local>).
25 # --nev <n> - ignored
26 # --nevjob <n> - ignored
27 # --nevgjob <n> - Specify the maximum number of events per gen/g4 job.
28 #
29 #----------------------------------------------------------------------
30 
31 # Parse arguments.
32 
33 rs=v06_18_01_01
34 rr1=v06_18_01_01
35 userdir=dunepro
36 userbase=$userdir
37 nevarg=0
38 nevjob=100
39 nevjobarg=100
40 ls=''
41 lr1=''
42 lr2=''
43 tag=mcc8.0
44 
45 recolifetime=8h
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 
76  # All stages release.
77 
78  -r|--release )
79  if [ $# -gt 1 ]; then
80  rs=$2
81  rr1=$2
82  shift
83  fi
84  ;;
85 
86  # User.
87 
88  -u|--user )
89  if [ $# -gt 1 ]; then
90  userdir=users/$2
91  userbase=$2
92  shift
93  fi
94  ;;
95 
96  # Local simulation release.
97 
98  -ls )
99  if [ $# -gt 1 ]; then
100  ls=$2
101  shift
102  fi
103  ;;
104 
105  # Local reconstruction release.
106 
107  -lr1 )
108  if [ $# -gt 1 ]; then
109  lr1=$2
110  shift
111  fi
112  ;;
113 
114  -lr2 )
115  if [ $# -gt 1 ]; then
116  lr2=$2
117  shift
118  fi
119  ;;
120 
121  # Local release.
122 
123  --local )
124  if [ $# -gt 1 ]; then
125  ls=$2
126  lr1=$2
127  lr2=$2
128  shift
129  fi
130  ;;
131 
132  # Total number of events.
133 
134  --nev )
135  if [ $# -gt 1 ]; then
136  nevarg=$2
137  shift
138  fi
139  ;;
140 
141  # Number of events per job.
142 
143  --nevjob )
144  if [ $# -gt 1 ]; then
145  nevjobarg=$2
146  shift
147  fi
148  ;;
149 
150  # Sample tag.
151 
152  -t|--tag )
153  if [ $# -gt 1 ]; then
154  tag=$2
155  shift
156  fi
157  ;;
158 
159  esac
160  shift
161 done
162 
163 # Get qualifier.
164 
165 qual=e10
166 ver=`echo $rs | cut -c2-3`
167 echo ver=$ver
168 if [ $ver -gt 2 ]; then
169  qual=e10
170 fi
171 
172 # Delete existing xml files.
173 
174 rm -f *.xml
175 
176 for topname in beamcosmics singlep
177 do
178  find $DUNETPC_DIR/source/fcl/protodune/mcc/mcc8/$topname -name "gen*.fcl" | while read fcl
179  do
180  if [ $topname == beamcosmics ]; then
181  if echo $fcl | grep -q -v beam_2GeV; then
182  continue
183  fi
184  fi
185 
186  find $DUNETPC_DIR/source/fcl/protodune/mcc/mcc8/$topname -name "*g4*.fcl" | while read g4fcl_v
187  do
188 
189  if echo $g4fcl_v | grep -q 6ms; then
190  continue
191  fi
192 
193 # find $DUNETPC_DIR/source/fcl/protodune/mcc/mcc8/$topname -name "*detsim*.fcl" ; find $DUNETPC_DIR/source/fcl/protodune/detsim/protoDUNE_detsim.fcl | while read detsimfcl_v
194  for detsimfcl_v in $(find $DUNETPC_DIR/source/fcl/protodune/mcc/mcc8/$topname -name "*detsim*.fcl" ; find $DUNETPC_DIR/source/fcl/protodune/detsim/protoDUNE_detsim.fcl);
195  do
196 
197  if [ $topname == singlep ]; then
198  if echo $detsimfcl_v | grep -q noise; then
199  continue
200  fi
201  else
202  if echo $detsimfcl_v | grep -q -v noise; then
203  continue
204  fi
205  fi
206 
207 # echo " Looping " $fcl $g4fcl_v $detsimfcl_v $recofcl1_v $mergefcl_v
208 
209  genbasename=`basename $fcl .fcl`
210  g4basename=`basename $g4fcl_v .fcl`
211  detsimbasename=`basename $detsimfcl_v .fcl`
212 
213  detsimtrimname=`echo $detsimbasename | sed -e "s/3ms_//g"`
214 
215  newprj_1=${genbasename}${g4basename}${detsimtrimname}
216 
217 # trim the project name down so it doesn't have extraneous or duplicate information
218 
219  newprj=ProtoDUNE`echo $newprj_1 | sed -e "s/gen_//" | sed -e "s/protoDune//g" | sed -e "s/protoDUNE//g" | sed -e "s/_detsim//g" | sed -e "s/_g4//g" | sed -e "s/_bc//g"`
220  newxml=${newprj}.xml
221  samprj=${newprj}
222  if [ $userbase != dunepro ]; then
223  samprj=${userbase}_$newprj
224  fi
225  generator=SingleGen
226  if echo $newprj | grep -q cosmics; then
227  generator=CORSIKA
228  fi
229  if echo $newprj | grep -q AntiMuonCutEvents; then
230  generator=TextFileGen
231  fi
232  if echo $newprj | grep -q genie; then
233  generator=GENIE
234  fi
235  if echo $newprj | grep -q MUSUN; then
236  generator=MUSUN
237  fi
238  if echo $newprj | grep -q supernova; then
239  generator=SNNueAr40CCGen
240  fi
241  if echo $newprj | grep -q prodndk; then
242  generator=NDKGen
243  fi
244  if echo $newprj | grep -q prodmarley; then
245  generator=MARLEY
246  fi
247  if echo $newprj | grep -q prodbackground_ar39; then
248  generator=RadioGen
249  fi
250 
251  detector=protoDune
252 
253 
254  # Generator
255 
256  genfcl=`basename $fcl`
257  if [ $topname == beamcosmics ]; then
258  genfcl=/dune/app/users/tjyang/xml/gen_protoDune_beam_2GeVc_cosmics.fcl
259  fi
260 
261  # G4
262 
263  g4fcl=`basename $g4fcl_v`
264 
265  # Detsim (optical + tpc).
266 
267  detsimfcl=`basename $detsimfcl_v`
268 
269 
270  # Reco default
271  recofcl1=''
272  if echo $topname | grep -q singlep; then
273  recofcl1=reco_protoDune_3ms.fcl
274  fi
275 
276  # Set number of events.
277  nev=10000
278 
279  # Set number of events per job.
280  nevjob=100
281 
282  # default memory limit
283 
284  memlimit=2000
285 
286  # special logic for Dorota
287 
288  if [ $topname == beamcosmics ]; then
289  memlimit=4000
290  nevjob=10
291  if echo $g4fcl_v | grep -q sce; then
292  if echo $detsimfcl_v | grep -q low; then
293  recofcl1=protoDUNE_reco.fcl
294  nev=1000
295  recolifetime=24h
296  elif echo $detsimfcl_v | grep -q med; then
297  recofcl1=''
298  nev=1000
299  elif echo $detsimfcl_v | grep -q high; then
300  continue
301  else
302  echo Ununderstood detsim: $detsimfcl_v
303  fi
304  else
305  if echo $detsimfcl_v | grep -q low; then
306  if echo $g4fcl_v | grep -q 1ms; then
307  recofcl1=''
308  nev=1000
309  elif echo $g4fcl_v | grep -q 3ms; then
310  recofcl1=protoDUNE_reco.fcl
311  nev=1000
312  recolifetime=24h
313  else
314  echo Unexpected g4 option: $g4fcl_v with low noise no SCE beam cosmics
315  exit
316  fi
317 
318  elif echo $detsimfcl_v | grep -q med; then
319  if echo $g4fcl_v | grep -q 1ms; then
320  recofcl1=''
321  nev=1000
322  elif echo $g4fcl_v | grep -q 3ms; then
323  recofcl1=''
324  nev=1000
325  else
326  echo Unexpected g4 option: $g4fcl_v with med noise no SCE beam cosmics
327  exit
328  fi
329 
330  elif echo $detsimfcl_v | grep -q high; then
331  if echo $g4fcl_v | grep -q 1ms; then
332  recofcl1=''
333  nev=1000
334  elif echo $g4fcl_v | grep -q 3ms; then
335  recofcl1=''
336  nev=1000
337  else
338  echo Unexpected g4 option: $g4fcl_v with med noise no SCE beam cosmics
339  exit
340  fi
341  else
342  echo Unexpected $detsimfcl_v noise option
343  exit
344  fi
345  fi
346  fi
347 
348  # Merge/Analysis
349 
350  mergefcl=protoDUNE_ana.fcl
351 
352 
353  # Calculate the number of worker jobs.
354 
355  njob=$(( $nev / $nevjob ))
356 
357  # Make xml file.
358 
359  echo "Making ${newprj}.xml"
360 # echo " " $fcl $g4fcl $detsimfcl $recofcl1 $mergefcl
361 
362 # echo $newprj, $nev, $nevjob, $njob
363 
364  cat <<EOF > $newxml
365 <?xml version="1.0"?>
366 
367 <!-- Production Project -->
368 
369 <!DOCTYPE project [
370  <!ENTITY relsim "$rs">
371  <!ENTITY relreco "$rr1">
372  <!ENTITY file_type "mc">
373  <!ENTITY run_type "physics">
374  <!ENTITY name "$samprj">
375  <!ENTITY tag "$tag">
376  ]>
377 
378 <job>
379 
380 <project name="&name;">
381 
382 <!-- Group -->
383 <group>dune</group>
384 
385 <!-- Project size -->
386 <numevents>$nev</numevents>
387 
388 <!-- Operating System -->
389 <os>SL6</os>
390 
391 <!-- Batch resources -->
392 <resource>DEDICATED,OPPORTUNISTIC</resource>
393 
394 <!-- metadata parameters -->
395 
396 <parameter name ="MCName">${samprj}</parameter>
397 <parameter name ="MCDetectorType">${detector}</parameter>
398 <parameter name ="MCGenerators">${generator}</parameter>
399 
400 <!-- Larsoft information -->
401 <larsoft>
402 <tag>&relsim;</tag>
403 <qual>${qual}:prof</qual>
404 EOF
405  if [ x$ls != x ]; then
406  echo "ls=$ls"
407  echo " <local>${ls}</local>" >> $newxml
408  fi
409  cat <<EOF >> $newxml
410 </larsoft>
411 
412 <stage name="detsim">
413 <fcl>$genfcl</fcl>
414 <fcl>$g4fcl</fcl>
415 <fcl>$detsimfcl</fcl>
416 <outdir>/pnfs/dune/persistent/${userdir}/&relsim;/detsim/&name;</outdir>
417 <workdir>/pnfs/dune/scratch/${userdir}/work/&relsim;/detsim/&name;</workdir>
418 <output>${newprj}_\${PROCESS}_%tc_detsim.root</output>
419 <numjobs>$njob</numjobs>
420 <jobsub>--memory=$memlimit</jobsub>
421 <datatier>detector-simulated</datatier>
422 <defname>&name;_&tag;_detsim</defname>
423 </stage>
424 
425 EOF
426 if [ x$recofcl1 != x ]; then
427 cat <<EOF >> $newxml
428 
429 <stage name="reco">
430 <fcl>$recofcl1</fcl>
431 <outdir>/pnfs/dune/scratch/${userdir}/&relreco;/reco/&name;</outdir>
432 <workdir>/pnfs/dune/scratch/${userdir}/work/&relreco;/reco/&name;</workdir>
433 <numjobs>$njob</numjobs>
434 <datatier>full-reconstructed</datatier>
435 <defname>&name;_&tag;_reco</defname>
436 <jobsub>--memory=$memlimit --expected-lifetime=$recolifetime</jobsub>
437 </stage>
438 
439 <stage name="mergeana">
440 <fcl>$mergefcl</fcl>
441 <outdir>/pnfs/dune/scratch/${userdir}/&relreco;/mergeana/&name;</outdir>
442 <output>&name;_\${PROCESS}_%tc_merged.root</output>
443 <workdir>/pnfs/dune/scratch/${userdir}/work/&relreco;/mergeana/&name;</workdir>
444 <numjobs>$njob</numjobs>
445 <jobsub>--memory=$memlimit</jobsub>
446 <targetsize>8000000000</targetsize>
447 <datatier>full-reconstructed</datatier>
448 <defname>&name;_&tag;</defname>
449 <jobsub>--expected-lifetime=$recolifetime</jobsub>
450 </stage>
451 EOF
452 fi
453 
454 cat <<EOF >> $newxml
455 <filetype>&file_type;</filetype>
456 <runtype>&run_type;</runtype>
457 </project>
458 </job>
459 EOF
460  done
461  done
462  done
463 done