make_xml_mixerprod.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 LARVERSION=v06_15_00
4 
5 DOITSCRIPT=doit.sh
6 
7 IFS=""
8 function genfhicl {
9  echo "MCTest_mixer_gen.fcl"
10 }
11 function genxml {
12  echo "mixer_gen.xml"
13 }
14 function genname {
15  echo "mixer"
16 }
17 function g4fhicl {
18  echo "MCTest_mixer_g4_$1.fcl"
19 }
20 function g4xml {
21  echo "mixer_g4_$1.xml"
22 }
23 function g4name {
24  echo "mixer_$1"
25 }
26 function detsimfhicl {
27  echo "MCTest_mixer_detsim.fcl"
28 }
29 function detsimxml {
30  echo "mixer_detsim_$1.xml"
31 }
32 function detsimname {
33  echo "mixer_$1"
34 }
35 function overlayfhicl {
36  echo "MCTest_mixer_dataoverlay_mcscale$1.fcl"
37 }
38 function wrapoverlayfhicl {
39  echo "run_MCTest_mixer_dataoverlay_mcscale$1.fcl"
40 }
41 function overlayxml {
42  echo "mixer_dataoverlay_$1_mcscale$2.xml"
43 }
44 function overlayname {
45  echo "mixer_$1_mcscale$2"
46 }
47 function robustfhicl {
48  echo "MCTest_mixer_robust.fcl"
49 }
50 function robustxml {
51  echo "mixer_robust_$1_mcscale$2.xml"
52 }
53 function robustname {
54  echo "mixer_$1_mcscale$2"
55 }
56 function anafhicl {
57  echo "MCTest_mixer_ana_mcscale$1.fcl"
58 }
59 function anaxml {
60  echo "mixer_ana_$1_mcscale$2.xml"
61 }
62 function ananame {
63  echo "mixer_$1_mcscale$2"
64 }
65 function write_header {
66  cat <<EOF > $1
67 <?xml version="1.0"?>
68 <!DOCTYPE project [
69 <!ENTITY release "${LARVERSION}">
70 <!ENTITY file_type "mc">
71 <!ENTITY run_type "physics">
72 <!ENTITY name "$2">
73 <!ENTITY tag "mthiesse">
74 ]>
75 <project name="&name;">
76 <group>dune</group>
77 <numevents>100000000</numevents>
78 <os>SL6</os>
79 <resource>DEDICATED,OPPORTUNISTIC</resource>
80 <larsoft>
81  <tag>&release;</tag>
82  <qual>e10:prof</qual>
83  <local>/dune/app/users/mthiesse/larDev/${LARVERSION}.tar</local>
84 </larsoft>
85 <parameter name ="MCName">mixer</parameter>
86 <parameter name ="MCDetectorType">35t</parameter>
87 <parameter name ="MCGenerators">CRY_single</parameter>
88 EOF
89 }
90 function write_footer {
91  cat <<EOF >> $1
92 <filetype>&file_type;</filetype>
93 <runtype>&run_type;</runtype>
94 </project>
95 EOF
96 }
97 
98 declare -a gensubmitcommands
99 declare -a gencheckcommands
100 declare -a gencleancommands
101 declare -a genmakeupcommands
102 declare -a g4submitcommands
103 declare -a g4checkcommands
104 declare -a g4cleancommands
105 declare -a g4makeupcommands
106 declare -a detsimsubmitcommands
107 declare -a detsimcheckcommands
108 declare -a detsimcleancommands
109 declare -a detsimmakeupcommands
110 declare -a overlaysubmitcommands
111 declare -a overlaycheckcommands
112 declare -a overlaycleancommands
113 declare -a overlaymakeupcommands
114 declare -a robustsubmitcommands
115 declare -a robustcheckcommands
116 declare -a robustcheckanacommands
117 declare -a robustcleancommands
118 declare -a robustmakeupcommands
119 declare -a robusthaddcommands
120 declare -a anasubmitcommands
121 declare -a anacheckcommands
122 declare -a anacleancommands
123 declare -a anamakeupcommands
124 declare -a anahaddcommands
125 
126 write_header $(genxml) $(genname)
127 cat <<EOF >> $(genxml)
128 <stage name="gen">
129  <fcl>$(genfhicl)</fcl>
130  <outdir>/pnfs/dune/scratch/users/mthiesse/MC/&release;/gen/&name;</outdir>
131  <workdir>/pnfs/dune/scratch/users/mthiesse/MC/work/&release;/gen/&name;</workdir>
132  <output>MCTest_mixer_\${PROCESS}_%tc_gen.root</output>
133  <numjobs>1000</numjobs>
134  <datatier>generated</datatier>
135  <defname>&name;_&tag;_gen</defname>
136 </stage>
137 EOF
138 write_footer $(genxml)
139 
140 gensubmitcommands=(${gensubmitcommands[@]}
141  "echo 'Submitting $(genxml):';project.py --xml $(genxml) --stage gen --submit")
142 gencheckcommands=(${gencheckcommands[@]}
143  "echo 'Checking $(genxml):' > $(genname).out;project.py --xml $(genxml) --stage gen --check >> $(genname).out 2>&1 &")
144 gencleancommands=(${gencleancommands[@]}
145  "echo 'Cleaning $(genxml):';project.py --xml $(genxml) --stage gen --clean")
146 genmakeupcommands=(${genmakeupcommands[@]}
147  "echo 'Makeup $(genxml):';project.py --xml $(genxml) --stage gen --makeup")
148 
149 for item in "1ms" "2ms" "3ms" "5ms" "8ms";
150 do
151  set -- $item
152  elife=$1
153 
154  write_header $(g4xml $elife) $(g4name $elife)
155  cat <<EOF >> $(g4xml $elife)
156 <stage name="g4">
157  <fcl>$(pwd)/$(g4fhicl $elife)</fcl>
158  <inputlist>/pnfs/dune/scratch/users/mthiesse/MC/&release;/gen/$(genname)/files.list</inputlist>
159  <outdir>/pnfs/dune/scratch/users/mthiesse/MC/&release;/g4/&name;</outdir>
160  <workdir>/pnfs/dune/scratch/users/mthiesse/MC/work/&release;/g4/&name;</workdir>
161  <output>MCTest_mixer_\${PROCESS}_%tc_g4.root</output>
162  <numjobs>1000</numjobs>
163  <datatier>simulated</datatier>
164  <defname>&name;_&tag;_g4</defname>
165 </stage>
166 EOF
167  write_footer $(g4xml $elife)
168 
169  echo '#include "MCTest_mixer_g4.fcl"' > $(g4fhicl $elife)
170  echo 'services.DetectorPropertiesService.Electronlifetime: '${elife:0:1}000 >> $(g4fhicl $elife)
171 
172  g4submitcommands=(${g4submitcommands[@]}
173  "echo 'Submitting $(g4xml $elife):';project.py --xml $(g4xml $elife) --stage g4 --submit")
174  g4checkcommands=(${g4checkcommands[@]}
175  "echo 'Checking $(g4xml $elife):' > $(g4name $elife).out;project.py --xml $(g4xml $elife) --stage g4 --check >> $(g4name $elife).out 2>&1 &")
176  g4cleancommands=(${g4cleancommands[@]}
177  "echo 'Cleaning $(g4xml $elife):';project.py --xml $(g4xml $elife) --stage g4 --clean")
178  g4makeupcommands=(${g4makeupcommands[@]}
179  "echo 'Makeup $(g4xml $elife):';project.py --xml $(g4xml $elife) --stage g4 --makeup")
180 
181  write_header $(detsimxml $elife) $(detsimname $elife)
182  cat <<EOF >> $(detsimxml $elife)
183 <stage name="detsim">
184  <fcl>$(detsimfhicl)</fcl>
185  <inputlist>/pnfs/dune/scratch/users/mthiesse/MC/&release;/g4/$(g4name $elife)/files.list</inputlist>
186  <outdir>/pnfs/dune/scratch/users/mthiesse/MC/&release;/detsim/&name;</outdir>
187  <workdir>/pnfs/dune/scratch/users/mthiesse/MC/work/&release;/detsim/&name;</workdir>
188  <output>MCTest_mixer_\${PROCESS}_%tc_detsim.root</output>
189  <numjobs>1000</numjobs>
190  <datatier>detector-simulated</datatier>
191  <defname>&name;_&tag;_detsim</defname>
192 </stage>
193 EOF
194  write_footer $(detsimxml $elife)
195 
196  detsimsubmitcommands=(${detsimsubmitcommands[@]}
197  "echo 'Submitting $(detsimxml $elife):';project.py --xml $(detsimxml $elife) --stage detsim --submit | grep -v Adding")
198  detsimcheckcommands=(${detsimcheckcommands[@]}
199  "echo 'Checking $(detsimxml $elife):' > $(detsimname $elife).out;project.py --xml $(detsimxml $elife) --stage detsim --check >> $(detsimname $elife).out 2>&1 &")
200  detsimcleancommands=(${detsimcleancommands[@]}
201  "echo 'Cleaning $(detsimxml $elife):';project.py --xml $(detsimxml $elife) --stage detsim --clean")
202  detsimmakeupcommands=(${detsimmakeupcommands[@]}
203  "echo 'Makeup $(detsimxml $elife):';project.py --xml $(detsimxml $elife) --stage detsim --makeup")
204 
205  ##for otheritem in "0.5" "1.0" "1.5" "2.0";
206  for otheritem in "0.5" "1.0" "1.5" "2.0" "2.5" "3.0" "3.5" "4.0" "4.5" "5.0" "5.5" "6.0" "7.0" "8.0" "9.0" "10.0";
207  do
208  set -- $otheritem
209  scale=$1
210 
211  write_header $(overlayxml $elife $scale) $(overlayname $elife $scale)
212  cat <<EOF >> $(overlayxml $elife $scale)
213 <stage name="dataoverlay">
214  <fcl>$(pwd)/$(overlayfhicl $scale)</fcl>
215  <inputlist>/pnfs/dune/scratch/users/mthiesse/MC/&release;/detsim/$(detsimname $elife)/files.list</inputlist>
216  <outdir>/pnfs/dune/scratch/users/mthiesse/MC/&release;/dataoverlay/&name;</outdir>
217  <workdir>/pnfs/dune/scratch/users/mthiesse/MC/work/&release;/detsim/&name;</workdir>
218  <output>MCTest_mixer_\${PROCESS}_%tc_dataoverlay.root</output>
219  <numjobs>1000</numjobs>
220  <datatier>detector-simulated</datatier>
221  <defname>&name;_&tag;_dataoverlay</defname>
222 </stage>
223 EOF
224  write_footer $(overlayxml $elife $scale)
225 
226  echo '#include "MCTest_mixer_dataoverlay.fcl"' > $(overlayfhicl $scale)
227  echo 'physics.filters.mixer.detail.DefaultMCRawDigitScale: '$scale >> $(overlayfhicl $scale)
228 
229  overlaysubmitcommands=(${overlaysubmitcommands[@]}
230  "echo 'Submitting $(overlayxml $elife $scale):';
231 DATETIME=\$(date +'%Y-%m-%d_%H-%M-%S');
232 DEFNAME='goodruns_35ton_sliced_mthiesse';
233 PROJECTNAME=mthiesse_\${DEFNAME}_${elife}_mcscale${scale}_\${DATETIME};
234 samweb -e dune -v start-project --defname=\$DEFNAME \$PROJECTNAME;
235 echo 'physics.filters.mixer.detail.SamProject: \"'\$PROJECTNAME'\"' >> $(overlayfhicl $scale);
236 project.py --xml $(overlayxml $elife $scale) --stage dataoverlay --submit")
237  overlaycheckcommands=(${overlaycheckcommands[@]}
238  "echo 'Checking $(overlayxml $elife $scale):' > $(overlayname $elife $scale).out;project.py --xml $(overlayxml $elife $scale) --stage dataoverlay --check >> $(overlayname $elife $scale).out 2>&1 &")
239  overlaycleancommands=(${overlaycleancommands[@]}
240  "echo 'Cleaning $(overlayxml $elife $scale):';project.py --xml $(overlayxml $elife $scale) --stage dataoverlay --clean")
241  overlaymakeupcommands=(${overlaymakeupcommands[@]}
242  "echo 'Makeup $(overlayxml $elife $scale):';project.py --xml $(overlayxml $elife $scale) --stage dataoverlay --makeup")
243 
244  write_header $(robustxml $elife $scale) $(robustname $elife $scale)
245  cat <<EOF >> $(robustxml $elife $scale)
246 <stage name="robust">
247  <fcl>$(robustfhicl)</fcl>
248  <inputlist>/pnfs/dune/scratch/users/mthiesse/MC/&release;/dataoverlay/$(overlayname $elife $scale)/files.list</inputlist>
249  <outdir>/pnfs/dune/scratch/users/mthiesse/MC/&release;/robust/&name;</outdir>
250  <workdir>/pnfs/dune/scratch/users/mthiesse/MC/work/&release;/robust/&name;</workdir>
251  <output>MCTest_mixer_\${PROCESS}_%tc_robust.root</output>
252  <numjobs>1000</numjobs>
253  <datatier>full-reconstructed</datatier>
254  <defname>&name;_&tag;_robust</defname>
255 </stage>
256 EOF
257  write_footer $(robustxml $elife $scale)
258 
259  robustsubmitcommands=(${robustsubmitcommands[@]}
260  "echo 'Submitting $(robustxml $elife $scale):';project.py --xml $(robustxml $elife $scale) --stage robust --submit")
261  robustcheckcommands=(${robustcheckcommands[@]}
262  "echo 'Checking $(robustxml $elife $scale):' > $(robustname $elife $scale).out;project.py --xml $(robustxml $elife $scale) --stage robust --check >> $(robustname $elife $scale).out 2>&1 &")
263  robustcheckanacommands=(${robustcheckanacommands[@]}
264  "echo 'Checking $(robustxml $elife $scale) histogram files:' > $(robustname $elife $scale)_hist.out;project.py --xml $(robustxml $elife $scale) --stage robust --checkana >> $(robustname $elife $scale)_hist.out 2>&1 &")
265  robustcleancommands=(${robustcleancommands[@]}
266  "echo 'Cleaning $(robustxml $elife $scale):';project.py --xml $(robustxml $elife $scale) --stage robust --clean")
267  robustmakeupcommands=(${robustmakeupcommands[@]}
268  "echo 'Makeup $(robustxml $elife $scale):';project.py --xml $(robustxml $elife $scale) --stage robust --makeup")
269  robusthaddcommands=(${robusthaddcommands[@]}
270  "hadd -f -k /dune/data/users/mthiesse/robust_$(robustname $elife $scale)_hist.root @/pnfs/dune/scratch/users/mthiesse/MC/${LARVERSION}/robust/$(robustname $elife $scale)/filesana.list")
271 
272  write_header $(anaxml $elife $scale) $(ananame $elife $scale)
273  cat <<EOF >> $(anaxml $elife $scale)
274 <stage name="ana">
275  <fcl>$(pwd)/$(anafhicl $scale)</fcl>
276  <inputlist>/pnfs/dune/scratch/users/mthiesse/MC/&release;/robust/$(robustname $elife $scale)/files.list</inputlist>
277  <outdir>/pnfs/dune/scratch/users/mthiesse/MC/&release;/ana/&name;</outdir>
278  <workdir>/pnfs/dune/scratch/users/mthiesse/MC/work/&release;/ana/&name;</workdir>
279  <TFileName>MCTest_mixer_\${PROCESS}_%tc_ana_hist.root</TFileName>
280  <numjobs>1000</numjobs>
281  <datatier>full-reconstructed</datatier>
282  <defname>&name;_&tag;_ana</defname>
283 </stage>
284 EOF
285  write_footer $(anaxml $elife $scale)
286 
287  echo '#include "MCTest_mixer_ana.fcl"' > $(anafhicl $scale)
288  echo 'physics.analyzers.robustmcana.PreviousMCScale: '$scale >> $(anafhicl $scale)
289 
290  anasubmitcommands=(${anasubmitcommands[@]}
291  "echo 'Submitting $(anaxml $elife $scale):';project.py --xml $(anaxml $elife $scale) --stage ana --submit")
292  anacheckcommands=(${anacheckcommands[@]}
293  "echo 'Checking $(anaxml $elife $scale):' > $(ananame $elife $scale).out;project.py --xml $(anaxml $elife $scale) --stage ana --checkana >> $(ananame $elife $scale).out 2>&1 &")
294  anacleancommands=(${anacleancommands[@]}
295  "echo 'Cleaning $(anaxml $elife $scale):';project.py --xml $(anaxml $elife $scale) --stage ana --clean")
296  anamakeupcommands=(${anamakeupcommands[@]}
297  "echo 'Makeup $(anaxml $elife $scale):';project.py --xml $(anaxml $elife $scale) --stage ana --makeup")
298  anahaddcommands=(${anahaddcommands[@]}
299  "hadd -f -k /dune/data/users/mthiesse/ana_$(ananame $elife $scale)_hist.root @/pnfs/dune/scratch/users/mthiesse/MC/${LARVERSION}/ana/$(ananame $elife $scale)/filesana.list")
300 
301  done
302 done
303 
304 echo "#!/bin/bash" > $DOITSCRIPT
305 echo "kx509;voms-proxy-init -noregen -rfc -voms dune:/dune/Role=Analysis;" >> $DOITSCRIPT
306 echo "function submit_gen {" >> $DOITSCRIPT
307 for ((i=0; i < ${#gensubmitcommands[@]}; i++)); do
308  echo "${gensubmitcommands[$i]}" >> $DOITSCRIPT
309 done
310 echo "}
311 function check_gen {" >> $DOITSCRIPT
312 for ((i=0; i < ${#gencheckcommands[@]}; i++)); do
313  echo "${gencheckcommands[$i]}" >> $DOITSCRIPT
314 done
315 echo "}
316 function clean_gen {" >> $DOITSCRIPT
317 for ((i=0; i < ${#gencleancommands[@]}; i++)); do
318  echo "${gencleancommands[$i]}" >> $DOITSCRIPT
319 done
320 echo "}
321 function makeup_gen {" >> $DOITSCRIPT
322 for ((i=0; i < ${#genmakeupcommands[@]}; i++)); do
323  echo "${genmakeupcommands[$i]}" >> $DOITSCRIPT
324 done
325 echo "}
326 function submit_g4 {" >> $DOITSCRIPT
327 for ((i=0; i < ${#g4submitcommands[@]}; i++)); do
328  echo "${g4submitcommands[$i]}" >> $DOITSCRIPT
329 done
330 echo "}
331 function check_g4 {" >> $DOITSCRIPT
332 for ((i=0; i < ${#g4checkcommands[@]}; i++)); do
333  echo "${g4checkcommands[$i]}" >> $DOITSCRIPT
334 done
335 echo "}
336 function clean_g4 {" >> $DOITSCRIPT
337 for ((i=0; i < ${#g4cleancommands[@]}; i++)); do
338  echo "${g4cleancommands[$i]}" >> $DOITSCRIPT
339 done
340 echo "}
341 function makeup_g4 {" >> $DOITSCRIPT
342 for ((i=0; i < ${#g4makeupcommands[@]}; i++)); do
343  echo "${g4makeupcommands[$i]}" >> $DOITSCRIPT
344 done
345 echo "}
346 function submit_detsim {" >> $DOITSCRIPT
347 for ((i=0; i < ${#detsimsubmitcommands[@]}; i++)); do
348  echo "${detsimsubmitcommands[$i]}" >> $DOITSCRIPT
349 done
350 echo "}
351 function check_detsim {" >> $DOITSCRIPT
352 for ((i=0; i < ${#detsimcheckcommands[@]}; i++)); do
353  echo "${detsimcheckcommands[$i]}" >> $DOITSCRIPT
354 done
355 echo "}
356 function clean_detsim {" >> $DOITSCRIPT
357 for ((i=0; i < ${#detsimcleancommands[@]}; i++)); do
358  echo "${detsimcleancommands[$i]}" >> $DOITSCRIPT
359 done
360 echo "}
361 function makeup_detsim {" >> $DOITSCRIPT
362 for ((i=0; i < ${#detsimmakeupcommands[@]}; i++)); do
363  echo "${detsimmakeupcommands[$i]}" >> $DOITSCRIPT
364 done
365 echo "}
366 function submit_dataoverlay {" >> $DOITSCRIPT
367 for ((i=0; i < ${#overlaysubmitcommands[@]}; i++)); do
368  echo "${overlaysubmitcommands[$i]}" >> $DOITSCRIPT
369 done
370 echo "}
371 function check_dataoverlay {" >> $DOITSCRIPT
372 for ((i=0; i < ${#overlaycheckcommands[@]}; i++)); do
373  echo "${overlaycheckcommands[$i]}" >> $DOITSCRIPT
374 done
375 echo "}
376 function clean_dataoverlay {" >> $DOITSCRIPT
377 for ((i=0; i < ${#overlaycleancommands[@]}; i++)); do
378  echo "${overlaycleancommands[$i]}" >> $DOITSCRIPT
379 done
380 echo "}
381 function makeup_dataoverlay {" >> $DOITSCRIPT
382 for ((i=0; i < ${#overlaymakeupcommands[@]}; i++)); do
383  echo "${overlaymakeupcommands[$i]}" >> $DOITSCRIPT
384 done
385 echo "}
386 function submit_robust {" >> $DOITSCRIPT
387 for ((i=0; i < ${#robustsubmitcommands[@]}; i++)); do
388  echo "${robustsubmitcommands[$i]}" >> $DOITSCRIPT
389 done
390 echo "}
391 function check_robust {" >> $DOITSCRIPT
392 for ((i=0; i < ${#robustcheckcommands[@]}; i++)); do
393  echo "${robustcheckcommands[$i]}" >> $DOITSCRIPT
394 done
395 echo "}
396 function checkana_robust {" >> $DOITSCRIPT
397 for ((i=0; i < ${#robustcheckanacommands[@]}; i++)); do
398  echo "${robustcheckanacommands[$i]}" >> $DOITSCRIPT
399 done
400 echo "}
401 function clean_robust {" >> $DOITSCRIPT
402 for ((i=0; i < ${#robustcleancommands[@]}; i++)); do
403  echo "${robustcleancommands[$i]}" >> $DOITSCRIPT
404 done
405 echo "}
406 function makeup_robust {" >> $DOITSCRIPT
407 for ((i=0; i < ${#robustmakeupcommands[@]}; i++)); do
408  echo "${robustmakeupcommands[$i]}" >> $DOITSCRIPT
409 done
410 echo "}
411 function hadd_robust {" >> $DOITSCRIPT
412 for ((i=0; i < ${#robusthaddcommands[@]}; i++)); do
413  echo "${robusthaddcommands[$i]}" >> $DOITSCRIPT
414 done
415 echo "}
416 function submit_ana {" >> $DOITSCRIPT
417 for ((i=0; i < ${#anasubmitcommands[@]}; i++)); do
418  echo "${anasubmitcommands[$i]}" >> $DOITSCRIPT
419 done
420 echo "}
421 function check_ana {" >> $DOITSCRIPT
422 for ((i=0; i < ${#anacheckcommands[@]}; i++)); do
423  echo "${anacheckcommands[$i]}" >> $DOITSCRIPT
424 done
425 echo "}
426 function clean_ana {" >> $DOITSCRIPT
427 for ((i=0; i < ${#anacleancommands[@]}; i++)); do
428  echo "${anacleancommands[$i]}" >> $DOITSCRIPT
429 done
430 echo "}
431 function makeup_ana {" >> $DOITSCRIPT
432 for ((i=0; i < ${#anamakeupcommands[@]}; i++)); do
433  echo "${anamakeupcommands[$i]}" >> $DOITSCRIPT
434 done
435 echo "}
436 function hadd_ana {" >> $DOITSCRIPT
437 for ((i=0; i < ${#anahaddcommands[@]}; i++)); do
438  echo "${anahaddcommands[$i]}" >> $DOITSCRIPT
439 done
440 echo "}" >> $DOITSCRIPT
441 
442 
443 unset gensubmitcommands
444 unset gencheckcommands
445 unset gencleancommands
446 unset genmakeupcommands
447 unset g4submitcommands
448 unset g4checkcommands
449 unset g4cleancommands
450 unset g4makeupcommands
451 unset detsimsubmitcommands
452 unset detsimcheckcommands
453 unset detsimcleancommands
454 unset detsimmakeupcommands
455 unset overlaysubmitcommands
456 unset overlaycheckcommands
457 unset overlaycleancommands
458 unset overlaymakeupcommands
459 unset robustsubmitcommands
460 unset robustcheckcommands
461 unset robustcheckanacommands
462 unset robustcleancommands
463 unset robustmakeupcommands
464 unset robusthaddcommands
465 unset anasubmitcommands
466 unset anacheckcommands
467 unset anacleancommands
468 unset anamakeupcommands
469 unset anahaddcommands