1 #---------------------------------------------------------------------------------------
2 # Automate running of all routine GENIE MC validation tasks.
4 # Use the cron daemon to run this script every few minutes or so.
5 # It will monitor the progress, submit jobs as necessary, assemble the data outputs,
6 # run the validation checks and summarize the generator status.
9 # --version : genie version number
10 # [--user] : username, used for monitoring job progress, default: candreop
11 # [--ref-data-topdir] : path to output files from a previous production used for reference
12 # [--ref-data-label] :
13 # [--arch] : <SL4.x86_32, SL5.x86_64, SL6.x86_64, ...>, default: SL6.x86_64
14 # [--production] : default: routine_validation
15 # [--cycle] : default: 01
16 # [--batch-system] : <PBS, LSF>, default: PBS (currently works only for PBS)
17 # [--queue] : default: prod
18 # [--softw-topdir] : top level dir for softw installations, default: /opt/ppd/t2k/softw/GENIE/
19 # [--jobs-topdir] : top level dir for job files, default: /opt/ppd/t2k/softw/scratch/GENIE/
22 # Costas Andreopoulos <costas.andreopoulos \st stfc.ac.uk>
23 # University of Liverpool & STFC Rutherford Appleton Laboratory
26 # Copyright (c) 2003-2020, The GENIE Collaboration
27 # For the full text of the license visit http://copyright.genie-mc.org
28 #---------------------------------------------------------------------------------------
35 if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
36 if($_ eq '--user') { $user = $ARGV[$iarg+1]; }
37 if($_ eq '--ref-data-topdir') { $ref_topdir = $ARGV[$iarg+1]; }
38 if($_ eq '--ref-data-label') { $ref_label = $ARGV[$iarg+1]; }
39 if($_ eq '--arch') { $arch = $ARGV[$iarg+1]; }
40 if($_ eq '--production') { $production = $ARGV[$iarg+1]; }
41 if($_ eq '--cycle') { $cycle = $ARGV[$iarg+1]; }
42 if($_ eq '--batch-system') { $batch_system = $ARGV[$iarg+1]; }
43 if($_ eq '--queue') { $queue = $ARGV[$iarg+1]; }
44 if($_ eq '--softw-topdir') { $softw_topdir = $ARGV[$iarg+1]; }
45 if($_ eq '--jobs-topdir') { $jobs_topdir = $ARGV[$iarg+1]; }
48 die("** Aborting [Undefined GENIE version. Use the --version option]")
49 unless defined $genie_version;
51 $user = "candreop" unless defined $user;
52 $ref_label = "reference" unless defined $ref_label;
53 $arch = "SL6.x86_64" unless defined $arch;
54 $production = "routine_validation" unless defined $production;
55 $cycle = "01" unless defined $cycle;
56 $batch_system = "PBS" unless defined $batch_system;
57 $queue = "prod" unless defined $queue;
58 $softw_topdir = "/opt/ppd/t2k/softw/GENIE" unless defined $softw_topdir;
59 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
61 $out_data_dir = "$softw_topdir/data/stage/$genie_version-$production\_$cycle";
62 $inp_data_dir = "$softw_topdir/data/job_inputs/";
63 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
64 $genie_topdir = "$softw_topdir/generator/builds/$arch/$genie_version/";
65 $scripts_dir = "$genie_topdir/src/scripts/production/batch/";
66 $scripts_dir2 = "$genie_topdir/src/scripts/production/misc/";
67 $status_file = "$jobs_topdir/$genie_version-$production\_$cycle.status";
69 $std_args = "--version $genie_version " .
71 "--softw-topdir $softw_topdir " .
72 "--production $production " .
74 "--batch-system $batch_system " .
77 init_status_file($status_file);
79 $status = read_status_file($status_file);
80 print "Current status: $status \n";
83 # Create data directories
85 if($status eq "starting")
87 print "Need to create directory structure for output data \n";
88 mkpath ( $out_data_dir, {verbose => 1, mode=>0777});
89 mkpath ("$out_data_dir/xsec/", {verbose => 1, mode=>0777});
90 mkpath ("$out_data_dir/mctest/", {verbose => 1, mode=>0777});
91 mkpath ("$out_data_dir/mctest/ghep/", {verbose => 1, mode=>0777});
92 mkpath ("$out_data_dir/mctest/gst/", {verbose => 1, mode=>0777});
93 mkpath ("$out_data_dir/xsec_validation/", {verbose => 1, mode=>0777});
94 mkpath ("$out_data_dir/xsec_validation/ghep/", {verbose => 1, mode=>0777});
95 mkpath ("$out_data_dir/xsec_validation/gst/", {verbose => 1, mode=>0777});
96 mkpath ("$out_data_dir/hadronization/", {verbose => 1, mode=>0777});
97 mkpath ("$out_data_dir/hadronization/ghep/", {verbose => 1, mode=>0777});
98 mkpath ("$out_data_dir/intranuke/", {verbose => 1, mode=>0777});
99 mkpath ("$out_data_dir/intranuke/ghep/", {verbose => 1, mode=>0777});
100 mkpath ("$out_data_dir/reptest/", {verbose => 1, mode=>0777});
101 mkpath ("$out_data_dir/reptest/ghep/", {verbose => 1, mode=>0777});
102 mkpath ("$out_data_dir/flux/", {verbose => 1, mode=>0777});
103 mkpath ("$out_data_dir/geom/", {verbose => 1, mode=>0777});
104 mkpath ("$out_data_dir/reweight/", {verbose => 1, mode=>0777});
105 mkpath ("$out_data_dir/reports/", {verbose => 1, mode=>0777});
106 update_status_file($status_file,"done creating directory structure for output data");
111 # ......................................................................................
112 # Calculate neutrino-nucleon cross-section splines for use in subsequent calculations
113 # and MC sample generation jobs. Compare the calculated neutrino-nucleon cross-sections
114 # with reference calculations and generate report.
115 # ......................................................................................
121 if($status eq "done creating directory structure for output data")
123 print "Need to produce free-nucleon cross-section splines \n";
124 $cmd = "perl $scripts_dir/submit_vN_xsec_calc_jobs.pl $std_args --xsplset all";
125 execute_command($cmd);
126 update_status_file($status_file,"calculating neutrino-nucleon cross-section splines");
131 # Once all jobs are done, check for errors and merge all free-nucleon cross-section xml files
133 if($status eq "calculating neutrino-nucleon cross-section splines")
135 $njobs = num_of_jobs_running($user,"vNxscalc");
139 print "No neutrino-nucleon cross-section calculation job still running... \n";
141 # Make sure there is one output XML file for each input PBS script
142 print "Making sure all output files are present... \n";
143 my $ret = check_number_of_xml_and_pbs_files("$jobs_topdir/$genie_version-$production\_$cycle-xsec\_vN/");
145 print "The number of output XML files does not match the number of input PBS files. \n";
146 print "Some of the batch jobs have failed. \n";
147 print "Can not continue with validation runs unless this is sorted out.\n";
151 # Check log files for errors
152 print "Checking for errors... \n";
153 $nerr = `more $jobs_topdir/$genie_version-$production\_$cycle-xsec\_vN/*log | grep -i error | wc -l`
154 + `more $jobs_topdir/$genie_version-$production\_$cycle-xsec\_vN/*log | grep -i fatal | wc -l`;
157 print "I found $nerr errors in the neutrino-nucleon cross-section calculation job log-files. \n";
158 print "Can not continue with validation runs unless this is sorted out.\n";
162 # Merge all XML files to one and copy to standard locations
163 print "Merging all free nucleon cross-section XML files... \n";
164 $cmd = "source $genie_setup; " .
165 "gspladd -d $jobs_topdir/$genie_version-$production\_$cycle-xsec\_vN/ -o gxspl-vN-$genie_version.xml; " .
166 "cp gxspl-vN-$genie_version.xml $inp_data_dir/xspl/; " .
167 "cp gxspl-vN-$genie_version.xml $out_data_dir/xsec/; " .
168 "rm -f gxspl-vN-$genie_version.xml";
169 execute_command($cmd);
170 update_status_file($status_file,"done calculating neutrino-nucleon cross-section splines");
175 # Convert calculated cross-sections from XML to ROOT format
177 if($status eq "done calculating neutrino-nucleon cross-section splines")
179 print "Converting all free-nucleon cross-section files from XML to ROOT format... \n";
180 $batch_cmd = "source $genie_setup; " .
181 "gspl2root -p 12,-12,14,-14,16,-16 -t 1000010010,1000000010 -o xsec.root -f $inp_data_dir/xspl/gxspl-vN-$genie_version.xml; " .
182 "cp xsec.root $out_data_dir/xsec/";
183 $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name xsconv $std_args";
184 execute_command($cmd);
185 update_status_file($status_file,"converting neutrino-nucleon cross-section data to ROOT format");
190 # Compare calculated cross-sections with reference cross-sections and generate report
192 if($status eq "converting neutrino-nucleon cross-section data to ROOT format")
194 $njobs = num_of_jobs_running($user,"xsconv");
198 if (defined $ref_topdir)
200 print "Comparing free-nucleon cross-sections with reference calculation... \n";
201 $batch_cmd = "source $genie_setup; " .
202 "gvld_xsec_comp -f $out_data_dir/xsec/xsec.root,$genie_version -r $ref_topdir/xsec/xsec.root,$ref_label -o xsec.ps; " .
203 "ps2pdf14 xsec.ps; " .
204 "cp xsec.pdf $out_data_dir/reports/";
205 $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name xscomp $std_args";
206 execute_command($cmd);
208 update_status_file($status_file,"comparing neutrino-nucleon cross-sections with reference calculations");
213 # Check last report and make sure it is OK to continue
215 if($status eq "comparing neutrino-nucleon cross-sections with reference calculations")
217 $njobs = num_of_jobs_running($user,"xscomp");
226 update_status_file($status_file,"done comparing neutrino-nucleon cross-sections with reference calculations");
231 # ......................................................................................
232 # Calculate nuclear cross-sections needed for validation MC runs
233 # ......................................................................................
239 if($status eq "done comparing neutrino-nucleon cross-sections with reference calculations")
241 print "Need to produce nuclear cross-section splines \n";
242 $cmd = "perl $scripts_dir/submit_vA_xsec_calc_jobs.pl $std_args --config-file $scripts_dir/xsec_splines/genie_test.list";
243 execute_command($cmd);
244 update_status_file($status_file,"calculating neutrino-nucleus cross-section splines");
249 # Once all jobs are done, merge all nuclear cross-section xml files
251 if($status eq "calculating neutrino-nucleus cross-section splines")
253 $njobs = num_of_jobs_running($user,"vAxscalc");
257 print "No neutrino-nucleus cross-section calculation job still running... \n";
259 # Make sure there is one output XML file for each input PBS script
260 print "Making sure all output files are present... \n";
261 my $ret = check_number_of_xml_and_pbs_files("$jobs_topdir/$genie_version-$production\_$cycle-xsec\_vA\_genie\_test/");
263 print "The number of output XML files does not match the number of input PBS files. \n";
264 print "Some of the batch jobs have failed. \n";
265 print "Can not continue with validation runs unless this is sorted out.\n";
269 # Check log files for errors
270 print "Checking for errors... \n";
271 $nerr = `more $jobs_topdir/$genie_version-$production\_$cycle-xsec\_vA\_genie\_test/*log | grep -i error | wc -l`
272 + `more $jobs_topdir/$genie_version-$production\_$cycle-xsec\_vA\_genie\_test/*log | grep -i fatal | wc -l`;
275 print "I found $nerr errors in the neutrino-nucleus cross-section calculation job log-files. \n";
276 print "Can not continue with validation runs unless this is sorted out.\n";
278 # Lots of errors are printed our by numerical integrators but things look ok
279 # Disable exit for now since we will soon be removing all the old numerical algorithms
284 # Merge all XML files to one and copy to standard locations
285 print "Merging all neutrino-nucleus cross-section XML files... \n";
286 $cmd = "source $genie_setup; " .
287 "gspladd -d $jobs_topdir/$genie_version-$production\_$cycle-xsec\_vA\_genie\_test/ -o gxspl-vA-$genie_version.xml; " .
288 "cp gxspl-vA-$genie_version.xml $inp_data_dir/xspl/; " .
289 "cp gxspl-vA-$genie_version.xml $out_data_dir/xsec/; " .
290 "rm -f gxspl-vA-$genie_version.xml";
291 execute_command($cmd);
292 update_status_file($status_file,"done calculating neutrino-nucleus cross-section splines");
297 # ......................................................................................
298 # Submit test MC runs, scan the log files, run sanity checks on the event samples
299 # and compare with reference samples.
300 # ......................................................................................
306 if($status eq "done calculating neutrino-nucleus cross-section splines")
308 print "Generating standard neutrino MC jobs \n";
309 $cmd = "perl $scripts_dir/submit_standard_neutrino_mc_test_jobs.pl $std_args --run all";
310 execute_command($cmd);
311 update_status_file($status_file,"running standard neutrino MC jobs");
316 # Once test MC runs are completed, move all data files from the scratch area
318 if($status eq "running standard neutrino MC jobs")
320 $njobs = num_of_jobs_running($user,"mctest");
326 # Check log files for errors and make sure there is one output ROOT file for each input PBS script
328 print "Checking for errors... \n";
329 $nerr = `more $jobs_topdir/$genie_version-$production\_$cycle-mctest/*log | grep -i error | wc -l`
330 + `more $jobs_topdir/$genie_version-$production\_$cycle-mctest/*log | grep -i fatal | wc -l`;
333 print "I found $nerr errors in the standard neutrino MC job log-files. \n";
334 print "Can not continue with validation runs unless this is sorted out.\n";
337 print "Checking the number of output ROOT/GHEP files... \n";
338 opendir my $dir, "$jobs_topdir/$genie_version-$production\_$cycle-mctest/" or die "Can not open directory: $!";
339 my @evtfiles = grep { /.ghep.root$/ } readdir $dir;
341 my @pbsfiles = grep { /.pbs$/ } readdir $dir;
343 $num_evtfiles = @evtfiles;
344 $num_pbsfiles = @pbsfiles;
345 print "Found $num_evtfiles ROOT/GHEP event files and $num_pbsfiles PBS files. \n";
346 if($num_evtfiles != $num_pbsfiles)
348 print "The number of output event files doesn't match the number of input PBS files. \n";
349 print "Can not continue with validation runs unless this is sorted out.\n";
353 $cmd = "mv $jobs_topdir/$genie_version-$production\_$cycle-mctest/*ghep.root $out_data_dir/mctest/ghep/; " .
354 "mv $jobs_topdir/$genie_version-$production\_$cycle-mctest/*gst.root $out_data_dir/mctest/gst/";
355 execute_command($cmd);
356 update_status_file($status_file,"done running standard neutrino MC jobs");
361 # Run sanity checks on the test MC runs and generate reports
363 if($status eq "done running standard neutrino MC jobs")
365 print "Running sanity checks on the outputs of the the standard neutrino MC jobs ... \n";
366 opendir my $dir, "$out_data_dir/mctest/ghep/" or die "Can not open directory: $!";
367 my @files = grep { !/^\./ } readdir $dir;
372 "source $genie_setup; " .
373 "gvld_sample_scan -f $out_data_dir/mctest/ghep/$_ -o $_.log " .
374 "--add-event-printout-in-error-log --event-record-print-level 2 --max-num-of-errors-shown 10 " .
375 "--check-energy-momentum-conservation " .
376 "--check-charge-conservation " .
377 "--check-for-pseudoparticles-in-final-state " .
378 "--check-for-off-mass-shell-particles-in-final-state " .
379 "--check-for-num-of-final-state-nucleons-inconsistent-with-target " .
380 "--check-vertex-distribution " .
381 "--check-decayer-consistency; " .
382 "mv $_.log $out_data_dir/reports/";
383 $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name snchk-$ijob $std_args";
384 execute_command($cmd);
387 update_status_file($status_file,"running sanity checks on standard neutrino MC jobs");
392 # See the reports and make sure it is OK to continue
394 if($status eq "running sanity checks on standard neutrino MC jobs")
396 $njobs = num_of_jobs_running($user,"snchk");
401 print "Checking results sanity checks on the outputs of the the standard neutrino MC jobs ... \n";
407 update_status_file($status_file,"done running sanity checks on standard neutrino MC jobs");
412 # Compare the test MC samples with samples generated with a reference version of GENIE
414 if($status eq "done running sanity checks on standard neutrino MC jobs")
416 if (defined $ref_topdir)
418 opendir my $dir, "$out_data_dir/mctest/ghep/" or die "Can not open directory: $!";
419 my @files = grep { !/^\./ } readdir $dir;
425 "source $genie_setup; " .
426 "gvld_sample_comp -f $out_data_dir/mctest/ghep/$_ -r $ref_topdir/mctest/ghep/$_ -o x; " .
427 "mv x $out_data_dir/reports/";
428 $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name compmc-$ijob $std_args";
433 update_status_file($status_file,"comparing standard neutrino MC jobs with reference samples");
438 # ......................................................................................
439 # Repeatability test: Submit different jobs with same inputs and same seed and make sure
440 # that the generated samples are identical.
441 # ......................................................................................
444 if($status eq "comparing standard neutrino MC jobs with reference samples")
449 "source $genie_setup; " .
450 "gevgen -p 14 -t 1000260560 -e 0.1,50 -f '1/x' --seed 123456 --run 100 --cross-sections $inp_data_dir/xspl/gxspl-vA-$genie_version.xml; " .
451 "mv *ghep.root $out_data_dir/reptest/ghep/";
452 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name repmc1 $std_args";
453 execute_command($cmd);
459 "source $genie_setup; " .
460 "gevgen -p 14 -t 1000260560 -e 0.1,50 -f '1/x' --seed 123456 --run 101 --cross-sections $inp_data_dir/xspl/gxspl-vA-$genie_version.xml; " .
461 "mv *ghep.root $out_data_dir/reptest/ghep/";
462 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name repmc2 $std_args";
463 execute_command($cmd);
469 "source $genie_setup; " .
470 "gevgen -p 14 -t 1000260560 -e 0.1,50 -f '1/x' --seed 123456 --run 102 --cross-sections $inp_data_dir/xspl/gxspl-vA-$genie_version.xml; " .
471 "mv *ghep.root $out_data_dir/reptest/ghep/";
472 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name repmc2 $std_args";
473 execute_command($cmd);
476 update_status_file($status_file,"running jobs for MC repeatability test");
480 if($status eq "running jobs for MC repeatability test")
482 $njobs = num_of_jobs_running($user,"repmc");
489 "source $genie_setup; " .
490 "gvld_repeatability_test --first-sample $out_data_dir/reptest/ghep/gntp.100.ghep.root " .
491 " --second-sample $out_data_dir/reptest/ghep/gntp.101.ghep.root " .
492 " --add-event-printout-in-error-log --max-num-of-errors-shown 10 -o reptest_runs100vs101.log; " .
493 "mv reptest_runs100vs101.log $out_data_dir/reports/";
494 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name reptest1 $std_args";
495 execute_command($cmd);
500 "source $genie_setup; " .
501 "gvld_repeatability_test --first-sample $out_data_dir/reptest/ghep/gntp.100.ghep.root " .
502 " --second-sample $out_data_dir/reptest/ghep/gntp.102.ghep.root " .
503 " --add-event-printout-in-error-log --max-num-of-errors-shown 10 -o reptest_runs100vs102.log; " .
504 "mv reptest_runs100vs102.log $out_data_dir/reports/";
505 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name reptest2 $std_args";
506 execute_command($cmd);
509 update_status_file($status_file,"running MC repeatability test");
513 if($status eq "running MC repeatability test")
515 $njobs = num_of_jobs_running($user,"reptest");
521 # ... check log files and make sure it is OK to continue
524 update_status_file($status_file,"done running MC repeatability test");
529 # ......................................................................................
530 # Compare the neutrino cross-section model with world data
531 # ......................................................................................
537 if($status eq "done running MC repeatability test")
539 $njobs = num_of_jobs_running($user,"compmc");
543 print "Generating MC samples needed for comparing the cross-section model with data \n";
544 $cmd = "perl $scripts_dir/submit_neutrino_xsec_validation_mc_jobs.pl $std_args --nsubruns 1";
545 execute_command($cmd);
546 update_status_file($status_file,"running MC jobs for cross-section model validation");
551 # Once cross-section MC jobs are done, move all data files from the scratch area
553 if($status eq "running MC jobs for cross-section model validation")
555 $njobs = num_of_jobs_running($user,"xsecvld");
559 $cmd = "mv $jobs_topdir/$genie_version-$production\_$cycle-xsec_validation/*ghep.root $out_data_dir/xsec_validation/ghep/; " .
560 "mv $jobs_topdir/$genie_version-$production\_$cycle-xsec_validation/*gst.root $out_data_dir/xsec_validation/gst/";
561 execute_command($cmd);
562 update_status_file($status_file,"done running MC jobs for cross-section model validation");
567 # Run actual comparisons with cross-section data and compute error envelopes
569 if($status eq "done running MC jobs for cross-section model validation")
571 # Create an XML file list containing the generated MC files and cross-section files needed for data/MC comparisons
573 my $cmd = "perl $scripts_dir2/make_genie_sim_file_list.pl " .
574 "$out_data_dir/xsec_validation/ghep/:$out_data_dir/xsec/,$genie_version " .
575 "> $out_data_dir/xsec_validation/file_list.xml";
576 execute_command($cmd);
579 # Create an XML file list, as above, but include the reference samples too
580 if (defined $ref_topdir)
582 my $cmd = "perl $scripts_dir2/make_genie_sim_file_list.pl " .
583 "$out_data_dir/xsec_validation/ghep/:$out_data_dir/xsec/,$genie_version " .
584 "$ref_topdir/xsec_validation/ghep/:$ref_topdir/xsec/,$ref_label " .
585 "> $out_data_dir/xsec_validation/file_list_ref.xml";
586 execute_command($cmd);
589 # Submit a single job to generate all GENIE/data comparisons for the current version
592 "source $genie_setup; " .
593 "gvld_nu_xsec -g $out_data_dir/xsec_validation/file_list.xml -o genie_$genie_version-world_nu_xsec_data_comp-all; " .
594 "ps2pdf14 genie_$genie_version-world_nu_xsec_data_comp-all.ps; " .
595 "mv genie_$genie_version-world_nu_xsec_data_comp-all.pdf $out_data_dir/reports/; " .
596 "mv genie_$genie_version-world_nu_xsec_data_comp-all.root $out_data_dir/reports/; ";
597 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name xseccmp1 $std_args";
598 execute_command($cmd);
601 # Submit a single job to generate all GENIE/data comparisons for the current and reference versions
602 if (defined $ref_topdir)
605 "source $genie_setup; " .
606 "gvld_nu_xsec -g $out_data_dir/xsec_validation/file_list_ref.xml -o genie_$genie_version-world_nu_xsec_data_comp-all-withref; " .
607 "ps2pdf14 genie_$genie_version-world_nu_xsec_data_comp-all-withref.ps; " .
608 "mv genie_$genie_version-world_nu_xsec_data_comp-all-withref.pdf $out_data_dir/reports/";
609 "mv genie_$genie_version-world_nu_xsec_data_comp-all-withref.root $out_data_dir/reports/";
610 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name xseccmp2 $std_args";
611 execute_command($cmd);
615 # Submit jobs to generate GENIE/data comparisons for the current version
616 # and calculate error envelopes for the GENIE prediction. Because calculating error
617 # envelopes is CPU-intensive submit one job per each GENIE/data comparison.
620 "numuCC_all", "numubarCC_all",
621 "numuCC_lowE", "numubarCC_lowE", "numuCC_highE", "numubarCC_highE",
622 "numuCC_minos", "numubarCC_minos", "numuCC_sciboone", "r_minos",
623 "numuCCQE_all", "numuCCQE_deuterium", "numuCCQE_heavy_target",
624 "numuCCQE_nomad_nucleon", "numuCCQE_nomad_nuclear", "numuCCQE_miniboone_nuclear", "numuCCQE_all_12C_nuclear",
625 "numubarCCQE_all", "numubarCCQE_deuterium", "numubarCCQE_heavy_target",
626 "numubarCCQE_nomad_nucleon", "numubarCCQE_nomad_nuclear",
627 "numuCCppip", "numuCCnpip", "numuCCppi0", "numuCCn2pip", "numuCCppippi0", "numuCCppippim",
628 "numuCCpi0_numuCCQE_k2k",
629 "numuNCcohpi0_Ne20", "numuCCcohpip_Ne20", "numubarCCcohpim_Ne20", "numuNCcohpi0_Al27", "numuNCcohpi0_Si30", "numuCCcohpip_Si30", "numubarCCcohpim_Si30",
630 "numuCC_dilepton_ratio_worldavg", "numubarCC_dilepton_ratio_worldavg", "numuCC_charm_ratio_worldavg",
631 "numuCC_dilepton_cdhs", "numuCC_dilepton_nomad", "numuCC_dilepton_e744_e770", "numuCC_dilepton_e744", "numuCC_dilepton_fnal15ft", "numuCC_dilepton_gargamelle"
634 foreach (@comparisons) {
636 "source $genie_setup; " .
637 "gvld_nu_xsec -g $out_data_dir/xsec_validation/file_list.xml -o genie_$genie_version-world_nu_xsec_data_comp-$_; " .
638 "ps2pdf14 genie_$genie_version-world_nu_xsec_data_comp-$_.ps; " .
639 "mv genie_$genie_version-world_nu_xsec_data_comp-$_.pdf $out_data_dir/reports/";
640 "mv genie_$genie_version-world_nu_xsec_data_comp-$_.root $out_data_dir/reports/";
641 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name xseccmp-$_ $std_args";
642 execute_command($cmd);
645 update_status_file($status_file,"running cross-section model comparisons with data");
650 # ......................................................................................
651 # Compare the hadronization model with data
652 # ......................................................................................
656 # Run jobs needed for comparing the hadronization model with data
658 if($status eq "running cross-section model comparisons with data")
660 $njobs = num_of_jobs_running($user,"xseccmp");
665 print "Generating MC samples needed for comparing the hadronization model with data \n";
666 $cmd = "perl $scripts_dir/submit_hadronization_validation_mc_jobs.pl $std_args --nsubruns 1";
667 execute_command($cmd);
668 update_status_file($status_file,"running MC jobs for hadronization model validation");
673 # Once hadronization MC jobs are done, move all data files from the scratch area
675 if($status eq "running MC jobs for hadronization model validation")
677 $njobs = num_of_jobs_running($user,"hadro");
681 $cmd = "mv $jobs_topdir/$genie_version-$production\_$cycle-hadronization/*ghep.root $out_data_dir/hadronization/ghep/";
682 execute_command($cmd);
683 update_status_file($status_file,"done running MC jobs for hadronization model validation");
688 # Run actual comparisons with hadronization data
690 if($status eq "done running MC jobs for hadronization model validation")
692 # Create an XML file list containing the generated MC files
694 my $cmd = "perl $scripts_dir2/make_genie_sim_file_list.pl " .
695 "$out_data_dir/hadronization/ghep/,$genie_version " .
696 "> $out_data_dir/hadronization/file_list.xml";
697 execute_command($cmd);
700 # Create an XML file list as above but include the reference MC files, if any.
701 if (defined $ref_topdir)
703 my $cmd = "perl $scripts_dir2/make_genie_sim_file_list.pl " .
704 "$out_data_dir/hadronization/ghep/,$genie_version " .
705 "$ref_topdir/hadronization/ghep/,$ref_label " .
706 "> $out_data_dir/hadronization/file_list_ref.xml";
707 execute_command($cmd);
710 # Submit a single job to generate all GENIE/data comparisons for the current version
713 "source $genie_setup; " .
714 "gvld_hadronz_test -g $out_data_dir/hadronization/file_list.xml -o genie_$genie_version-hadronization_test.ps; " .
715 "ps2pdf14 genie_$genie_version-hadronization_test.ps; " .
716 "mv genie_$genie_version-hadronization_test.pdf $out_data_dir/reports/";
717 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name hadcmp1 $std_args";
718 execute_command($cmd);
721 # Submit a single job to generate all GENIE/data comparisons for the current and reference versions
722 if (defined $ref_topdir)
725 "source $genie_setup; " .
726 "gvld_hadronz_test -g $out_data_dir/hadronization/file_list_ref.xml -o genie_$genie_version-hadronization_test-withref.ps; " .
727 "ps2pdf14 genie_$genie_version-hadronization_test-withref.ps; " .
728 "mv genie_$genie_version-hadronization_test-withref.pdf $out_data_dir/reports/";
729 my $cmd = "perl $scripts_dir/submit.pl --cmd \'$batch_cmd\' --job-name hadcmp2 $std_args";
730 execute_command($cmd);
733 update_status_file($status_file,"running hadronization model comparisons with data");
738 # ......................................................................................
739 # Compare the intranuclear rescattering model with data
740 # ......................................................................................
750 # ......................................................................................
751 # Compare the structure function model with data
752 # ......................................................................................
760 # ......................................................................................
761 # Run event reweighting tests
762 # ......................................................................................
770 # ......................................................................................
771 # Run flux driver tests
772 # ......................................................................................
780 # ......................................................................................
781 # Run geometry navigation tests
782 # ......................................................................................
793 ########################################################################################
794 ########################################################################################
797 sub num_of_jobs_running
801 @myjobs = `qstat -u $user`;
805 if( /$user/ && /$jobtag/ ) {
807 print "Job still running: $_ \n";
810 print "Number of jobs still running or on the queue: $njobs \n";
820 print STF "starting";
825 sub update_status_file
847 print "Executing: $cmd \n";
848 my $ret = system("$cmd");
851 die "** Failed executing: $cmd \n";
855 sub check_number_of_xml_and_pbs_files
858 print "Searching for XML and PBS files in directory: $dirname \n";
859 opendir my $dir, $dirname or die "Can not open directory: $!";
860 my @xmlfiles = grep { /.xml$/ } readdir $dir;
862 my @pbsfiles = grep { /.pbs$/ } readdir $dir;
864 # print "XML files found: @xmlfiles \n";
865 # print "PBS files found: @pbsfiles \n";
866 $nxmlfiles = @xmlfiles;
867 $npbsfiles = @pbsfiles;
868 print "Found $nxmlfiles XML files and $npbsfiles PBS files. \n";
869 if($nxmlfiles != $npbsfiles)