All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
make_xml_mcp.sh
Go to the documentation of this file.
1 #! /bin/bash
2 #----------------------------------------------------------------------
3 #
4 # Name: make_xml_mcp.sh
5 #
6 # Purpose: Make xml files for a Monte Carlo Production (MCP). This script loops over all
7 # generator-level fcl files in the source area of the currently
8 # setup version of sbndcode (that is, under
9 # $SBNDCODE_DIR/source/fcl/gen), and makes a corresponding xml
10 # project file in the local directory.
11 #
12 # Usage:
13 #
14 # make_xml_mcp.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 # --name <name> - The name of the production e.g. mcp1.0
20 # -r <release> - Use the specified larsoft/sbndcode release.
21 # -u|--user <user> - Use users/<user> as working and output directories
22 # (default is to use sbndpro).
23 # --local <dir|tar> - Specify larsoft local directory or tarball (xml
24 # tag <local>...</local>).
25 # --nev <n> - Specify number of events for all samples. Otherwise
26 # use hardwired defaults.
27 # --nevjob <n> - Specify the default number of events per job.
28 # --nevgjob <n> - Specify the maximum number of events per gen/g4 job.
29 #
30 #----------------------------------------------------------------------
31 
33 
34  echo "Making ${newxml}"
35 
36  cat <<EOF > $newxml
37 <?xml version="1.0"?>
38 
39 <!-- Production Project -->
40 
41 <!DOCTYPE project [
42 <!ENTITY release "$rel">
43 <!ENTITY file_type "mc">
44 <!ENTITY run_type "physics">
45 <!ENTITY name "$newprj">
46 <!ENTITY tag "$tag">
47 ]>
48 
49 <project name="&name;">
50 
51  <!-- Project size -->
52  <numevents>$nev</numevents>
53 
54  <!-- Operating System -->
55  <os>SL6</os>
56 
57  <!-- Batch resources -->
58  <resource>DEDICATED,OPPORTUNISTIC</resource>
59 
60  <!-- Larsoft information -->
61  <larsoft>
62  <tag>&release;</tag>
63  <qual>${qual}</qual>
64 EOF
65  if [ x$local != x ]; then
66  echo "local=$local"
67  echo " <local>${local}</local>" >> $newxml
68  fi
69 cat <<EOF >> $newxml
70  </larsoft>
71 
72  <!-- Project stages -->
73 
74  <stage name="gen">
75  <fcl>$genfcl</fcl>
76  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/gen</outdir>
77  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/gen</workdir>
78  <numjobs>$njob1</numjobs>
79  <datatier>generated</datatier>
80  <defname>&name;_&tag;_gen</defname>
81  </stage>
82 
83  <stage name="g4">
84  <fcl>$g4fcl</fcl>
85  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/g4</outdir>
86  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/g4</workdir>
87  <numjobs>$njob1</numjobs>
88  <datatier>simulated</datatier>
89  <defname>&name;_&tag;_g4</defname>
90  </stage>
91 
92  <stage name="detsim">
93  <fcl>$detsimfcl</fcl>
94  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/detsim</outdir>
95  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/detsim</workdir>
96  <numjobs>$njob2</numjobs>
97  <datatier>detector-simulated</datatier>
98  <defname>&name;_&tag;_detsim</defname>
99  </stage>
100 
101  <stage name="reco">
102  <fcl>$recofcl</fcl>
103  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/reco</outdir>
104  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/reco</workdir>
105  <numjobs>$njob2</numjobs>
106  <datatier>reconstructed</datatier>
107  <defname>&name;_&tag;_reco</defname>
108  </stage>
109 
110  <stage name="anatree">
111  <fcl>$anatreefcl</fcl>
112  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/anatree</outdir>
113  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/anatree</workdir>
114  <numjobs>$njob2</numjobs>
115  <targetsize>8000000000</targetsize>
116  <datatier>reconstructed</datatier>
117  <defname>&name;_&tag;</defname>
118  </stage>
119 
120  <!-- file type -->
121  <filetype>&file_type;</filetype>
122 
123  <!-- run type -->
124  <runtype>&run_type;</runtype>
125 
126 </project>
127 EOF
128 }
129 
130 function set_default_fcl {
131  # G4
132  g4fcl=standard_g4_sbnd.fcl
133 
134  # Detsim (optical + tpc).
135  detsimfcl=standard_detsim_sbnd.fcl
136 
137  # Reco
138  recofcl=standard_reco_sbnd_basic.fcl
139 
140  # Anatree
141  anatreefcl=standard_anatree_sbnd.fcl
142 }
143 
144 
145 #Parse arguments.
146 
147 tag=mcp1.0
148 rel=v00_07_00
149 userdir=sbndpro
150 qual=e9:prof
151 userbase=$userdir
152 nevarg=0
153 nevjob=100
154 nevgjobarg=0
155 local=''
156 
157 while [ $# -gt 0 ]; do
158  case "$1" in
159 
160  # User directory.
161 
162  -h|--help )
163  echo "Usage: make_xml_mcp.sh [-h|--help] [--name <prodution name e.g. mcp1.0>] [-r <release>] [-q <qual>] [-u|--user <user>] [--local <dir|tar>] [--nev <n>] [--nevjob <n>] [--nevgjob <n>]"
164  exit
165  ;;
166 
167  # name.
168 
169  --name )
170  if [ $# -gt 1 ]; then
171  tag=$2
172  shift
173  fi
174  ;;
175 
176 
177  # Release.
178 
179  -r )
180  if [ $# -gt 1 ]; then
181  rel=$2
182  shift
183  fi
184  ;;
185 
186  # Qualifier.
187 
188  -q)
189  if [ $# -gt 1 ]; then
190  qual=$2
191  shift
192  fi
193  ;;
194 
195 
196  # User.
197 
198  -u|--user )
199  if [ $# -gt 1 ]; then
200  userdir=users/$2
201  userbase=$2
202  shift
203  fi
204  ;;
205 
206  # Local release.
207 
208  --local )
209  if [ $# -gt 1 ]; then
210  local=$2
211  shift
212  fi
213  ;;
214 
215  # Total number of events.
216 
217  --nev )
218  if [ $# -gt 1 ]; then
219  nevarg=$2
220  shift
221  fi
222  ;;
223 
224  # Number of events per job.
225 
226  --nevjob )
227  if [ $# -gt 1 ]; then
228  nevjob=$2
229  shift
230  fi
231  ;;
232 
233  # Number of events per gen/g4 job.
234 
235  --nevgjob )
236  if [ $# -gt 1 ]; then
237  nevgjobarg=$2
238  shift
239  fi
240  ;;
241 
242  esac
243  shift
244 done
245 
246 # Get qualifier.
247 
248 #qual=e9
249 
250 # Delete existing xml files.
251 
252 rm -f *.xml
253 
254 # Loop over existing generator fcl files.
255 
256 find $SBNDCODE_DIR/source/fcl/gen -name \*.fcl | while read fcl
257 do
258  if ! echo $fcl | grep -q common; then
259  newprj=`basename $fcl .fcl`
260  newxml=${newprj}.xml
261  filt=1
262 
263  # Make xml file.
264 
265 
266 
267  # Set number of gen/g4 events per job.
268 
269  nevgjob=$nevgjobarg
270  if [ $nevgjob -eq 0 ]; then
271  if echo $newprj | grep -q dirt; then
272  if echo $newprj | grep -q cosmic; then
273  nevgjob=200
274  else
275  nevgjob=2000
276  fi
277  else
279  fi
280  fi
281 
282  # Set number of events.
283 
284  nev=$nevarg
285  if [ $nev -eq 0 ]; then
286  if [ $newprj = prodgenie_bnb_nu_cosmic_sbnd ]; then
287  nev=50000
288  elif [ $newprj = prodgenie_bnb_nu_sbnd ]; then
289  nev=20000
290  elif [ $newprj = prodgenie_bnb_nue_cosmic_sbnd ]; then
291  nev=20000
292  elif [ $newprj = prodgenie_bnb_nue_sbnd ]; then
293  nev=20000
294  elif [ $newprj = prodcosmics_sbnd ]; then
295  nev=20000
296  else
297  nev=10000
298  fi
299  fi
300  nev=$(( $nev * $filt ))
301 
302  # Calculate the number of worker jobs.
303 
304  njob1=$(( $nev / $nevgjob )) # Pre-filter (gen, g4)
305  njob2=$(( $nev / $nevjob / $filt )) # Post-filter (detsim and later)
306  if [ $njob1 -lt $njob2 ]; then
307  njob1=$njob2
308  fi
309 
310 
311 
312  # Define the generator-level fcl
313  genfcl=`basename $fcl`
314  #Assume that we are going to produce this sample with the default fcls
315  makedefaultsample=true
316  #Loop over the MCCSTATEMENTs in this fcl file to figure out what alternative samples need making
317  grep "MCCSTATEMENT" $fcl |
318  { #being the moron I am, I forgot that a while loop uses a subshell. I want to maybe
319  #change the value of makedefaultsample and check it outside of the loop. So
320  #complete hack; wrap from here to the final makedefaultsample check in braces
321  #so it is all in the same subshell. Basically not having the braces means that
322  #makedefaultsample will evaluate to true outside of this while loop
323  while read mccstatement
324  do
325  #At time of writing, the MCCSTATEMENT should define an altnerative set of fcl files to
326  #process this particular sample through. Technically each MCCSTATEMENT line is a
327  #comma separated list of fcl files and a name for the alternative project. The first element in the
328  #comma separated list is a pair of statements separated by white space, the second of the pair is the
329  #name of the project. All subsequent elements in the list are also pairs separated by white space.
330  #The first element defines which stage to change the fcl file and can have the following names: G4:
331  #DETSIM: RECO: and ANATREE:.
332 
333  #It is also possible that one of the statement lines asks us not to make the default sample path
334  #Check for this and set the flag to false if necessary
335  if echo $mccstatement | grep -q SKIPDEFAULT; then
336  makedefaultsample=false
337  #There shouldn't be anything else useful on this line so continue to the next statement
338  continue
339  fi
340 
341  #For each new MCCSTATEMENT line we should initially reset the fcl files
342  set_default_fcl
343  #Also reset the project name to that of the default sample as otherwise the new project names keep
344  #getting appended to the previous new project name
345  newprj=`basename $fcl .fcl`
346  newxml=${newprj}.xml
347 
348  #Delimit the MCCSTATEMENT line on the commas
349  IFS=','
350  statementarray=($mccstatement)
351  unset IFS
352  for statementelement in "${statementarray[@]}"
353  do
354  #The statementelement should be a string pair basically with a key and a value. This time
355  #separated by whitespace
356  pair=($statementelement)
357  key=${pair[0]}
358  value=${pair[1]}
359  if echo $key | grep -q MCCSTATEMENT; then
360  newprj="${newprj}_${value}"
361  newxml=${newprj}.xml
362  elif echo $key | grep -q G4; then
363  g4fcl=$value
364  elif echo $key | grep -q DETSIM; then
365  detsimfcl=$value
366  elif echo $key | grep -q RECO; then
367  recofcl=$value
368  elif echo $key | grep -q ANATREE; then
369  anatreefcl=$value
370  else echo "ISSUE WITH MCCSTATEMENT IN $newprj. CAN NOT FIND THE SET STATEMENTS (MCCSTATEMENT G4 DETSIM RECO OR ANATREE)"
371  fi
372  done
373  #make an XML file for each MCCSTATEMENT line
375 
376  done
377  #if we still want to make the default file then make the XML
378  if [ "$makedefaultsample"=true ] ; then
379 
380  newprj=`basename $fcl .fcl` #reset the newprj back to the default project
381  newxml=${newprj}.xml
382  set_default_fcl
384  fi
385  } #while loop subshell
386  fi
387 
388 done
process_name standard_reco_uboone fcl
see a below echo or echo I(indirect symbol).'echo" If the symbol is local (non-external)
opportunistic OPPORTUNISTIC
Definition: submit_lar.sh:296
then newprj
process_name opflash particleana ie x
process_name can override from command line with o or output proton mvapid_weights muon_all_BDT weights xml
Definition: runPID.fcl:28
then nevgjobarg
do source
* file
Definition: file_to_url.sh:69
#define the
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
then nevgjob
then nevjob
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
shift
Definition: fcl_checks.sh:26
function print_xml_to_file
process_name gaushit a
then qual
while getopts h
then local
process_name standard_reco_uboone reco
then if echo $newprj grep q dirt
then userdir
then njob1
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more information
then shift fi
esac shift done rm f *xml find $SBNDCODE_DIR source fcl gen name *fcl while read fcl do if!echo $fcl grep q common
then nevarg
physics filters filter
then nev
then detsimfcl
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then g4fcl
then filt
BEGIN_PROLOG cosmic
stream1 can override from command line with o or output services user sbnd
then echo fcl name
pnfs
Definition: file_to_url.sh:60
temporary value
esac echo uname r
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true