make_xml_mcc3.0.sh
Go to the documentation of this file.
1 #! /bin/bash
2 #----------------------------------------------------------------------
3 #
4 # Name: make_xml_mcc3.0.sh
5 #
6 # Purpose: Make xml files for mcc 3.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_mcc3.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_12_00
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_mcc3.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=e7
113 ver=`echo $rel | cut -c2-3`
114 if [ $ver -gt 2 ]; then
115  qual=e7
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  if echo $newprj | grep -q milliblock; then
172  mergefcl=standard_ana_lbne35t_milliblock.fcl
173  fi
174 
175  # Set number of events per job.
176  if [ $nevjob -eq 0 ]; then
177  if [ $newprj = prodcosmics_lbne35t_milliblock ]; then
178  nevjob=100
179  elif [ $newprj = prodcosmics_lbne35t_onewindow ]; then
180  nevjob=100
181  elif [ $newprj = AntiMuonCutEvents_LSU_lbne35t ]; then
182  nevjob=100
183  else
184  nevjob=100
185  fi
186  fi
187  # Set number of gen/g4 events per job.
188 
189  nevgjob=$nevgjobarg
190  if [ $nevgjob -eq 0 ]; then
191  if echo $newprj | grep -q dirt; then
192  if echo $newprj | grep -q cosmic; then
193  nevgjob=200
194  else
195  nevgjob=2000
196  fi
197  else
198  nevgjob=nevjob
199  fi
200  fi
201 
202  # Set number of events.
203 
204  nev=$nevarg
205  if [ $nev -eq 0 ]; then
206  if [ $newprj = prodcosmics_lbne35t_milliblock ]; then
207  nev=1000
208  elif [ $newprj = prodcosmics_lbne35t_onewindow ]; then
209  nev=10000
210  elif [ $newprj = AntiMuonCutEvents_LSU_lbne35t ]; then
211  nev=10000
212  else
213  nev=10000
214  fi
215  fi
216  nev=$(( $nev * $filt ))
217 
218  # Calculate the number of worker jobs.
219 
220  njob1=$(( $nev / $nevgjob )) # Pre-filter (gen, g4)
221  njob2=$(( $nev / $nevjob / $filt )) # Post-filter (detsim and later)
222  if [ $njob1 -lt $njob2 ]; then
223  njob1=$njob2
224  fi
225 
226  cat <<EOF > $newxml
227 <?xml version="1.0"?>
228 
229 <!-- Production Project -->
230 
231 <!DOCTYPE project [
232 <!ENTITY release "$rel">
233 <!ENTITY file_type "mc">
234 <!ENTITY run_type "physics">
235 <!ENTITY name "$newprj">
236 <!ENTITY tag "mcc3.0">
237 ]>
238 
239 <project name="&name;">
240 
241  <!-- Group -->
242  <group>lbne</group>
243 
244  <!-- Project size -->
245  <numevents>$nev</numevents>
246 
247  <!-- Operating System -->
248  <os>SL6</os>
249 
250  <!-- Batch resources -->
251  <resource>DEDICATED,OPPORTUNISTIC</resource>
252 
253  <!-- Larsoft information -->
254  <larsoft>
255  <tag>&release;</tag>
256  <qual>${qual}:prof</qual>
257 EOF
258  echo "local=$local"
259  if [ x$local != x ]; then
260  echo " <local>${local}</local>" >> $newxml
261  fi
262  cat <<EOF >> $newxml
263  </larsoft>
264 
265  <!-- lbne35t metadata parameters -->
266 
267  <parameter name ="MCName">${newprj}</parameter>
268  <parameter name ="MCDetectorType">35t</parameter>
269  <parameter name ="MCGenerators">${generator}</parameter>
270 
271  <!-- Project stages -->
272 
273  <stage name="gen">
274  <fcl>$genfcl</fcl>
275 EOF
276  if echo $newprj | grep -q AntiMuonCutEvents_LSU_lbne35t; then
277  echo " <inputmode>textfile</inputmode>" >> $newxml
278  echo " <inputlist>/lbne/data2/users/jti3/txtfiles/AntiMuonCutEvents_LSU_100.txt</inputlist>" >> $newxml
279  fi
280  cat <<EOF >> $newxml
281  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/gen/&name;</outdir>
282  <workdir>/lbne/app/users/${userbase}/&release;/gen/&name;</workdir>
283  <logdir>/lbne/data/${userdir}/log/&release;/gen/&name;</logdir>
284  <output>${newprj}_\${PROCESS}_%tc_gen.root</output>
285  <numjobs>$njob1</numjobs>
286  <datatier>generated</datatier>
287  <defname>&name;_&tag;_gen</defname>
288  </stage>
289 
290  <stage name="g4">
291  <fcl>$g4fcl</fcl>
292  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/g4/&name;</outdir>
293  <workdir>/lbne/app/users/${userbase}/&release;/g4/&name;</workdir>
294  <logdir>/lbne/data/${userdir}/log/&release;/g4/&name;</logdir>
295  <numjobs>$njob1</numjobs>
296  <datatier>simulated</datatier>
297  <defname>&name;_&tag;_g4</defname>
298  </stage>
299 
300 EOF
301  if [ x$detsimfcl != x ]; then
302  cat <<EOF >> $newxml
303  <stage name="detsim">
304  <fcl>$detsimfcl</fcl>
305  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/detsim/&name;</outdir>
306  <workdir>/lbne/app/users/${userbase}/&release;/detsim/&name;</workdir>
307  <logdir>/lbne/data/${userdir}/log/&release;/detsim/&name;</logdir>
308  <numjobs>$njob2</numjobs>
309  <datatier>detector-simulated</datatier>
310  <defname>&name;_&tag;_detsim</defname>
311  </stage>
312 
313 EOF
314  fi
315  cat <<EOF >> $newxml
316  <stage name="reco">
317  <fcl>$recofcl</fcl>
318  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/reco/&name;</outdir>
319  <workdir>/lbne/app/users/${userbase}/&release;/reco/&name;</workdir>
320  <logdir>/lbne/data/${userdir}/log/&release;/reco/&name;</logdir>
321  <numjobs>$njob2</numjobs>
322  <datatier>full-reconstructed</datatier>
323  <defname>&name;_&tag;_reco</defname>
324  </stage>
325 
326  <stage name="mergeana">
327  <fcl>$mergefcl</fcl>
328  <outdir>/pnfs/lbne/scratch/${userdir}/&release;/mergeana/&name;</outdir>
329  <workdir>/lbne/app/users/${userbase}/&release;/mergeana/&name;</workdir>
330  <logdir>/lbne/data/${userdir}/log/&release;/mergeana/&name;</logdir>
331  <numjobs>$njob2</numjobs>
332  <!--<targetsize>8000000000</targetsize>-->
333  <datatier>full-reconstructed</datatier>
334  <defname>&name;_&tag;</defname>
335  </stage>
336 
337  <!-- file type -->
338  <filetype>&file_type;</filetype>
339 
340  <!-- run type -->
341  <runtype>&run_type;</runtype>
342 
343 </project>
344 EOF
345 
346  fi
347 
348 done