make_xml_mcc2.0.sh
Go to the documentation of this file.
1 #! /bin/bash
2 #----------------------------------------------------------------------
3 #
4 # Name: make_xml_mcc2.0.sh
5 #
6 # Purpose: Make xml files for mcc 2.0. This script loops over all
7 # generator-level fcl files in the source area of the currently
8 # setup version of lbnecode (that is, under
9 # $LBNECODE_DIR/source/fcl/lbne35t/gen), and makes a corresponding xml
10 # project file in the local directory.
11 #
12 # Usage:
13 #
14 # make_xml_mcc2.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/lbnecode 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_00_01
34 userdir=lbnepro
35 userbase=$userdir
36 nevarg=0
37 nevjob=0
38 nevgjobarg=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_mcc5.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  nevjob=$2
93  shift
94  fi
95  ;;
96 
97  # Number of events per gen/g4 job.
98 
99  --nevgjob )
100  if [ $# -gt 1 ]; then
101  nevgjobarg=$2
102  shift
103  fi
104  ;;
105 
106  esac
107  shift
108 done
109 
110 # Get qualifier.
111 
112 qual=e5
113 ver=`echo $rel | cut -c2-3`
114 if [ $ver -gt 2 ]; then
115  qual=e6
116 fi
117 
118 # Delete existing xml files.
119 
120 rm -f *.xml
121 
122 find $LBNECODE_DIR/source/fcl/lbne35t/gen -name \*.fcl | while read fcl
123 do
124  if ! echo $fcl | grep -q common; then
125  newprj=`basename $fcl .fcl`
126  newxml=${newprj}.xml
127  filt=1
128  generator=SingleGen
129  if echo $newprj | grep -q cosmics; then
130  generator=CRY
131  fi
132  if echo $newprj | grep -q AntiMuonCutEvents; then
133  generator=TextFileGen
134  fi
135 
136  # Make xml file.
137 
138  echo "Making ${newprj}.xml"
139 
140  # Generator
141 
142  genfcl=`basename $fcl`
143 
144  # G4
145 
146  g4fcl=standard_g4_lbne35t.fcl
147 
148  # Detsim (optical + tpc).
149 
150  detsimfcl=standard_detsim_lbne35t.fcl
151  if echo $newprj | grep -q milliblock; then
152  detsimfcl=standard_detsim_lbne35t_milliblock.fcl
153  fi
154  # Reco 2D
155 
156 # reco2dfcl=standard_reco_uboone_2D.fcl
157 
158  # Reco 3D
159 
160 # reco3dfcl=standard_reco_uboone_3D.fcl
161 
162  # Reco
163  recofcl=standard_reco_lbne35t.fcl
164  if echo $newprj | grep -q milliblock; then
165  recofcl=standard_reco_lbne35t_milliblock.fcl
166  fi
167 
168  # Merge/Analysis
169 
170  mergefcl=standard_ana_lbne35t.fcl
171 
172  # Set number of events per job.
173  if [ $nevjob -eq 0 ]; then
174  if [ $newprj = prodcosmics_lbne35t_milliblock ]; then
175  nevjob=100
176  elif [ $newprj = prodcosmics_lbne35t_onewindow ]; then
177  nevjob=100
178  elif [ $newprj = AntiMuonCutEvents_LSU_lbne35t ]; then
179  nevjob=100
180  else
181  nevjob=100
182  fi
183  fi
184  # Set number of gen/g4 events per job.
185 
186  nevgjob=$nevgjobarg
187  if [ $nevgjob -eq 0 ]; then
188  if echo $newprj | grep -q dirt; then
189  if echo $newprj | grep -q cosmic; then
190  nevgjob=200
191  else
192  nevgjob=2000
193  fi
194  else
195  nevgjob=nevjob
196  fi
197  fi
198 
199  # Set number of events.
200 
201  nev=$nevarg
202  if [ $nev -eq 0 ]; then
203  if [ $newprj = prodcosmics_lbne35t_milliblock ]; then
204  nev=1000
205  elif [ $newprj = prodcosmics_lbne35t_onewindow ]; then
206  nev=10000
207  elif [ $newprj = AntiMuonCutEvents_LSU_lbne35t ]; then
208  nev=10000
209  else
210  nev=10000
211  fi
212  fi
213  nev=$(( $nev * $filt ))
214 
215  # Calculate the number of worker jobs.
216 
217  njob1=$(( $nev / $nevgjob )) # Pre-filter (gen, g4)
218  njob2=$(( $nev / $nevjob / $filt )) # Post-filter (detsim and later)
219  if [ $njob1 -lt $njob2 ]; then
220  njob1=$njob2
221  fi
222 
223  cat <<EOF > $newxml
224 <?xml version="1.0"?>
225 
226 <!-- Production Project -->
227 
228 <!DOCTYPE project [
229 <!ENTITY release "$rel">
230 <!ENTITY file_type "mc">
231 <!ENTITY run_type "physics">
232 <!ENTITY name "$newprj">
233 <!ENTITY tag "mcc2.0">
234 ]>
235 
236 <project name="&name;">
237 
238  <!-- Group -->
239  <group>lbne</group>
240 
241  <!-- Project size -->
242  <numevents>$nev</numevents>
243 
244  <!-- Operating System -->
245  <os>SL6</os>
246 
247  <!-- Batch resources -->
248  <resource>DEDICATED,OPPORTUNISTIC</resource>
249 
250  <!-- Larsoft information -->
251  <larsoft>
252  <tag>&release;</tag>
253  <qual>${qual}:prof</qual>
254 EOF
255  echo "local=$local"
256  if [ x$local != x ]; then
257  echo " <local>${local}</local>" >> $newxml
258  fi
259  cat <<EOF >> $newxml
260  </larsoft>
261 
262  <!-- lbne35t metadata parameters -->
263 
264  <parameter name ="MCName">${newprj}</parameter>
265  <parameter name ="MCDetectorType">35t</parameter>
266  <parameter name ="MCGenerators">${generator}</parameter>
267 
268  <!-- Project stages -->
269 
270  <stage name="gen">
271  <fcl>$genfcl</fcl>
272 EOF
273  if echo $newprj | grep -q AntiMuonCutEvents_LSU_lbne35t; then
274  echo " <inputmode>textfile</inputmode>" >> $newxml
275  echo " <inputlist>/lbne/data2/users/jti3/txtfiles/AntiMuonCutEvents_LSU_100.txt</inputlist>" >> $newxml
276  fi
277  cat <<EOF >> $newxml
278  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/gen/&name;</outdir>
279  <workdir>/lbne/app/users/${userbase}/&release;/gen/&name;</workdir>
280  <logdir>/lbne/data/${userdir}/log/&release;/gen/&name;</logdir>
281  <output>${newprj}_\${PROCESS}_%tc_gen.root</output>
282  <numjobs>$njob1</numjobs>
283  <datatier>generated</datatier>
284  <defname>&name;_&tag;_gen</defname>
285  </stage>
286 
287  <stage name="g4">
288  <fcl>$g4fcl</fcl>
289  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/g4/&name;</outdir>
290  <workdir>/lbne/app/users/${userbase}/&release;/g4/&name;</workdir>
291  <logdir>/lbne/data/${userdir}/log/&release;/g4/&name;</logdir>
292  <numjobs>$njob1</numjobs>
293  <datatier>simulated</datatier>
294  <defname>&name;_&tag;_g4</defname>
295  </stage>
296 
297 EOF
298  if [ x$detsimfcl != x ]; then
299  cat <<EOF >> $newxml
300  <stage name="detsim">
301  <fcl>$detsimfcl</fcl>
302  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/detsim/&name;</outdir>
303  <workdir>/lbne/app/users/${userbase}/&release;/detsim/&name;</workdir>
304  <logdir>/lbne/data/${userdir}/log/&release;/detsim/&name;</logdir>
305  <numjobs>$njob2</numjobs>
306  <datatier>detector-simulated</datatier>
307  <defname>&name;_&tag;_detsim</defname>
308  </stage>
309 
310 EOF
311  fi
312  if [ x$optsimfcl != x ]; then
313  cat <<EOF >> $newxml
314  <stage name="optsim">
315  <fcl>$optsimfcl</fcl>
316  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/optsim/&name;</outdir>
317  <workdir>/lbne/app/users/${userbase}/&release;/optsim/&name;</workdir>
318  <numjobs>$njob2</numjobs>
319  <datatier>optical-simulated</datatier>
320  <defname>&name;_&tag;_optsim</defname>
321  </stage>
322 
323 EOF
324  fi
325  if [ x$tpcsimfcl != x ]; then
326  cat <<EOF >> $newxml
327  <stage name="tpcsim">
328  <fcl>$tpcsimfcl</fcl>
329  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/tpcsim/&name;</outdir>
330  <workdir>/lbne/app/users/${userbase}/&release;/tpcsim/&name;</workdir>
331  <numjobs>$njob2</numjobs>
332  <datatier>tpc-simulated</datatier>
333  <defname>&name;_&tag;_tpcsim</defname>
334  </stage>
335 
336 EOF
337  fi
338  cat <<EOF >> $newxml
339  <stage name="reco">
340  <fcl>$recofcl</fcl>
341  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/reco/&name;</outdir>
342  <workdir>/lbne/app/users/${userbase}/&release;/reco/&name;</workdir>
343  <logdir>/lbne/data/${userdir}/log/&release;/reco/&name;</logdir>
344  <numjobs>$njob2</numjobs>
345  <datatier>full-reconstructed</datatier>
346  <defname>&name;_&tag;_reco</defname>
347  </stage>
348 
349  <stage name="mergeana">
350  <fcl>$mergefcl</fcl>
351  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/mergeana/&name;</outdir>
352  <workdir>/lbne/app/users/${userbase}/&release;/mergeana/&name;</workdir>
353  <logdir>/lbne/data/${userdir}/log/&release;/mergeana/&name;</logdir>
354  <numjobs>$njob2</numjobs>
355  <targetsize>8000000000</targetsize>
356  <datatier>full-reconstructed</datatier>
357  <defname>&name;_&tag;</defname>
358  </stage>
359 
360  <!-- file type -->
361  <filetype>&file_type;</filetype>
362 
363  <!-- run type -->
364  <runtype>&run_type;</runtype>
365 
366 </project>
367 EOF
368 
369  fi
370 
371 done