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