All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
make_xml_mcc0.75.sh
Go to the documentation of this file.
1 #! /bin/bash
2 #----------------------------------------------------------------------
3 #
4 # Name: make_xml_mcc0.75.sh
5 #
6 # Purpose: Make xml files for mcc 0.75. 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_mcc0.75.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/sbndcode release.
20 # -u|--user <user> - Use users/<user> as working and output directories
21 # (default is to use sbndpro).
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 
32 
33  echo "Making ${newxml}"
34 
35  cat <<EOF > $newxml
36 <?xml version="1.0"?>
37 
38 <!-- Production Project -->
39 
40 <!DOCTYPE project [
41 <!ENTITY release "$rel">
42 <!ENTITY file_type "mc">
43 <!ENTITY run_type "physics">
44 <!ENTITY name "$newprj">
45 <!ENTITY tag "mcc0.75">
46 ]>
47 
48 <project name="&name;">
49 
50  <!-- Project size -->
51  <numevents>$nev</numevents>
52 
53  <!-- Operating System -->
54  <os>SL6</os>
55 
56  <!-- Batch resources -->
57  <resource>DEDICATED,OPPORTUNISTIC</resource>
58 
59  <!-- Larsoft information -->
60  <larsoft>
61  <tag>&release;</tag>
62  <qual>${qual}</qual>
63 EOF
64  if [ x$local != x ]; then
65  echo "local=$local"
66  echo " <local>${local}</local>" >> $newxml
67  fi
68 cat <<EOF >> $newxml
69  </larsoft>
70 
71  <!-- Project stages -->
72 
73  <stage name="gen">
74  <fcl>$genfcl</fcl>
75  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/gen</outdir>
76  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/gen</workdir>
77  <numjobs>$njob1</numjobs>
78  <datatier>generated</datatier>
79  <defname>&name;_&tag;_gen</defname>
80  </stage>
81 
82  <stage name="g4">
83  <fcl>$g4fcl</fcl>
84  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/g4</outdir>
85  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/g4</workdir>
86  <numjobs>$njob1</numjobs>
87  <datatier>simulated</datatier>
88  <defname>&name;_&tag;_g4</defname>
89  </stage>
90 
91  <stage name="detsim">
92  <fcl>$detsimfcl</fcl>
93  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/detsim</outdir>
94  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/detsim</workdir>
95  <numjobs>$njob2</numjobs>
96  <datatier>detector-simulated</datatier>
97  <defname>&name;_&tag;_detsim</defname>
98  </stage>
99 
100  <stage name="reco">
101  <fcl>$recofcl</fcl>
102  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/reco</outdir>
103  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/reco</workdir>
104  <numjobs>$njob2</numjobs>
105  <datatier>reconstructed</datatier>
106  <defname>&name;_&tag;_reco</defname>
107  </stage>
108 
109  <stage name="anatree">
110  <fcl>$anatreefcl</fcl>
111  <outdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/&name;/anatree</outdir>
112  <workdir>/pnfs/sbnd/persistent/${userdir}/&tag;/&release;/work/&name;/anatree</workdir>
113  <numjobs>$njob2</numjobs>
114  <targetsize>8000000000</targetsize>
115  <datatier>reconstructed</datatier>
116  <defname>&name;_&tag;</defname>
117  </stage>
118 
119  <!-- file type -->
120  <filetype>&file_type;</filetype>
121 
122  <!-- run type -->
123  <runtype>&run_type;</runtype>
124 
125 </project>
126 EOF
127 }
128 
129 function set_default_fcl {
130  # G4
131  g4fcl=standard_g4_sbnd.fcl
132 
133  # Detsim (optical + tpc).
134  detsimfcl=standard_detsim_sbnd.fcl
135 
136  # Reco
137  recofcl=standard_reco_sbnd_basic.fcl
138 
139  # Anatree
140  anatreefcl=standard_anatree_sbnd.fcl
141 }
142 
143 
144 #Parse arguments.
145 
146 rel=v00_07_00
147 userdir=sbndpro
148 qual=e9:prof
149 userbase=$userdir
150 nevarg=0
151 nevjob=100
152 nevgjobarg=0
153 local=''
154 
155 while [ $# -gt 0 ]; do
156  case "$1" in
157 
158  # User directory.
159 
160  -h|--help )
161  echo "Usage: make_xml_mcc0.75.sh [-h|--help] [-r <release>] [-q <qual>] [-u|--user <user>] [--local <dir|tar>] [--nev <n>] [--nevjob <n>] [--nevgjob <n>]"
162  exit
163  ;;
164 
165  # Release.
166 
167  -r )
168  if [ $# -gt 1 ]; then
169  rel=$2
170  shift
171  fi
172  ;;
173 
174  # Qualifier.
175 
176  -q)
177  if [ $# -gt 1 ]; then
178  qual=$2
179  shift
180  fi
181  ;;
182 
183 
184  # User.
185 
186  -u|--user )
187  if [ $# -gt 1 ]; then
188  userdir=users/$2
189  userbase=$2
190  shift
191  fi
192  ;;
193 
194  # Local release.
195 
196  --local )
197  if [ $# -gt 1 ]; then
198  local=$2
199  shift
200  fi
201  ;;
202 
203  # Total number of events.
204 
205  --nev )
206  if [ $# -gt 1 ]; then
207  nevarg=$2
208  shift
209  fi
210  ;;
211 
212  # Number of events per job.
213 
214  --nevjob )
215  if [ $# -gt 1 ]; then
216  nevjob=$2
217  shift
218  fi
219  ;;
220 
221  # Number of events per gen/g4 job.
222 
223  --nevgjob )
224  if [ $# -gt 1 ]; then
225  nevgjobarg=$2
226  shift
227  fi
228  ;;
229 
230  esac
231  shift
232 done
233 
234 # Get qualifier.
235 
236 #qual=e9
237 
238 # Delete existing xml files.
239 
240 rm -f *.xml
241 
242 # Loop over existing generator fcl files.
243 
244 find $SBNDCODE_DIR/source/fcl/gen -name \*.fcl | while read fcl
245 do
246  if ! echo $fcl | grep -q common; then
247  newprj=`basename $fcl .fcl`
248  newxml=${newprj}.xml
249  filt=1
250 
251  # Make xml file.
252 
253 
254 
255  # Set number of gen/g4 events per job.
256 
257  nevgjob=$nevgjobarg
258  if [ $nevgjob -eq 0 ]; then
259  if echo $newprj | grep -q dirt; then
260  if echo $newprj | grep -q cosmic; then
261  nevgjob=200
262  else
263  nevgjob=2000
264  fi
265  else
267  fi
268  fi
269 
270  # Set number of events.
271 
272  nev=$nevarg
273  if [ $nev -eq 0 ]; then
274  if [ $newprj = prodgenie_bnb_nu_cosmic_sbnd ]; then
275  nev=50000
276  elif [ $newprj = prodgenie_bnb_nu_sbnd ]; then
277  nev=20000
278  elif [ $newprj = prodgenie_bnb_nue_cosmic_sbnd ]; then
279  nev=20000
280  elif [ $newprj = prodgenie_bnb_nue_sbnd ]; then
281  nev=20000
282  elif [ $newprj = prodcosmics_sbnd ]; then
283  nev=20000
284  else
285  nev=10000
286  fi
287  fi
288  nev=$(( $nev * $filt ))
289 
290  # Calculate the number of worker jobs.
291 
292  njob1=$(( $nev / $nevgjob )) # Pre-filter (gen, g4)
293  njob2=$(( $nev / $nevjob / $filt )) # Post-filter (detsim and later)
294  if [ $njob1 -lt $njob2 ]; then
295  njob1=$njob2
296  fi
297 
298 
299 
300  # Define the generator-level fcl
301  genfcl=`basename $fcl`
302  #Assume that we are going to produce this sample with the default fcls
303  makedefaultsample=true
304  #Loop over the MCCSTATEMENTs in this fcl file to figure out what alternative samples need making
305  grep "MCCSTATEMENT" $fcl |
306  { #being the moron I am, I forgot that a while loop uses a subshell. I want to maybe
307  #change the value of makedefaultsample and check it outside of the loop. So
308  #complete hack; wrap from here to the final makedefaultsample check in braces
309  #so it is all in the same subshell. Basically not having the braces means that
310  #makedefaultsample will evaluate to true outside of this while loop
311  while read mccstatement
312  do
313  #At time of writing, the MCCSTATEMENT should define an altnerative set of fcl files to
314  #process this particular sample through. Technically each MCCSTATEMENT line is a
315  #comma separated list of fcl files and a name for the alternative project. The first element in the
316  #comma separated list is a pair of statements separated by white space, the second of the pair is the
317  #name of the project. All subsequent elements in the list are also pairs separated by white space.
318  #The first element defines which stage to change the fcl file and can have the following names: G4:
319  #DETSIM: RECO: and ANATREE:.
320 
321  #It is also possible that one of the statement lines asks us not to make the default sample path
322  #Check for this and set the flag to false if necessary
323  if echo $mccstatement | grep -q SKIPDEFAULT; then
324  makedefaultsample=false
325  #There shouldn't be anything else useful on this line so continue to the next statement
326  continue
327  fi
328 
329  #For each new MCCSTATEMENT line we should initially reset the fcl files
330  set_default_fcl
331  #Also reset the project name to that of the default sample as otherwise the new project names keep
332  #getting appended to the previous new project name
333  newprj=`basename $fcl .fcl`
334  newxml=${newprj}.xml
335 
336  #Delimit the MCCSTATEMENT line on the commas
337  IFS=','
338  statementarray=($mccstatement)
339  unset IFS
340  for statementelement in "${statementarray[@]}"
341  do
342  #The statementelement should be a string pair basically with a key and a value. This time
343  #separated by whitespace
344  pair=($statementelement)
345  key=${pair[0]}
346  value=${pair[1]}
347  if echo $key | grep -q MCCSTATEMENT; then
348  newprj="${newprj}_${value}"
349  newxml=${newprj}.xml
350  elif echo $key | grep -q G4; then
351  g4fcl=$value
352  elif echo $key | grep -q DETSIM; then
353  detsimfcl=$value
354  elif echo $key | grep -q RECO; then
355  recofcl=$value
356  elif echo $key | grep -q ANATREE; then
357  anatreefcl=$value
358  else echo "ISSUE WITH MCCSTATEMENT IN $newprj. CAN NOT FIND THE SET STATEMENTS (MCCSTATEMENT G4 DETSIM RECO OR ANATREE)"
359  fi
360  done
361  #make an XML file for each MCCSTATEMENT line
363 
364  done
365  #if we still want to make the default file then make the XML
366  if [ "$makedefaultsample"=true ] ; then
367 
368  newprj=`basename $fcl .fcl` #reset the newprj back to the default project
369  newxml=${newprj}.xml
370  set_default_fcl
372  fi
373  } #while loop subshell
374  fi
375 
376 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