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