3 #-----------------------------------------------------------------------------------------------------------
4 # Script to submit jobs used for evaluating neutrino interaction systematics.
7 # perl submit_systematic_param_scan_1d.pl <options>
10 # --version : GENIE version number.
11 # --input-events : Input event file.
12 # --syst : Systematics for which to submit weight calculation jobs,
13 # eg `--syst MaCCQE', `--syst MaCCQE,MFP_pi', `--syst all' etc.
14 # Alternatively you can use `predefined' lists, eg `--syst standard-t2k-analysis-list'
15 # [--nevents] : Event numbers to process.
16 # To process the first 10000 events, type `--nevents 10000'.
17 # To process the 3000 events between 1000 and 4999, type `--nevents 1000,4999'.
18 # [--output-weights] : Output weight file. Default: weights_<name of systematic>.root
19 # [--arch] : <SL4.x86_32, SL5.x86_64, SL6.x86_64, ...>, default: SL6.x86_64
20 # [--production] : Production name. Default: <version>
21 # [--cycle] : Cycle in current production. Default: 01
22 # [--use-valgrind] : Use Valgrind? Default: off
23 # [--batch-system] : Batch system: <PBS, LSF, slurm, none>. Default: PBS
24 # [--queue] : Batch queue. Default: prod
25 # [--softw-topdir] : top level dir for softw installations, default: /opt/ppd/t2k/softw/GENIE/
26 # [--jobs-topdir] : top level dir for job files, default: /opt/ppd/t2k/softw/scratch/GENIE/
29 # Costas Andreopoulos <costas.andreopoulos \st stfc.ac.uk>
30 # University of Liverpool & STFC Rutherford Appleton Laboratory
33 # Copyright (c) 2003-2020, The GENIE Collaboration
34 # For the full text of the license visit http://copyright.genie-mc.org
35 #-----------------------------------------------------------------------------------------------------------
44 if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
45 if($_ eq '--syst') { $syst = $ARGV[$iarg+1]; }
46 if($_ eq '--input-events') { $input_events = $ARGV[$iarg+1]; }
47 if($_ eq '--nevents') { $nevents = $ARGV[$iarg+1]; }
48 if($_ eq '--output-weights') { $output_weights = $ARGV[$iarg+1]; }
49 if($_ eq '--arch') { $arch = $ARGV[$iarg+1]; }
50 if($_ eq '--production') { $production = $ARGV[$iarg+1]; }
51 if($_ eq '--cycle') { $cycle = $ARGV[$iarg+1]; }
52 if($_ eq '--use-valgrind') { $use_valgrind = $ARGV[$iarg+1]; }
53 if($_ eq '--batch-system') { $batch_system = $ARGV[$iarg+1]; }
54 if($_ eq '--queue') { $queue = $ARGV[$iarg+1]; }
55 if($_ eq '--softw-topdir') { $softw_topdir = $ARGV[$iarg+1]; }
56 if($_ eq '--jobs-topdir') { $jobs_topdir = $ARGV[$iarg+1]; }
59 die("** Aborting [Undefined GENIE version. Use the --version option]")
60 unless defined $genie_version;
61 die("** Aborting [You need to specify which systematics to study. Use the --syst option]")
63 die("** Aborting [You need to specify an input event file. Use the --input-events option]")
64 unless defined $input-events;
66 $use_valgrind = 0 unless defined $use_valgrind;
67 $arch = "SL6.x86_64" unless defined $arch;
68 $production = "$genie_version" unless defined $production;
69 $cycle = "01" unless defined $cycle;
70 $batch_system = "PBS" unless defined $batch_system;
71 $queue = "prod" unless defined $queue;
72 $softw_topdir = "/opt/ppd/t2k/softw/GENIE" unless defined $softw_topdir;
73 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
74 $time_limit = "60:00:00";
75 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
76 $jobs_dir = "$jobs_topdir/rwght1scan-$production\_$cycle";
77 $gexec = "grwght1scan";
84 'MaCCQEshape' => '11',
85 'VecFFCCQEshape' => '11',
87 'MaCCRESshape' => '11',
88 'MvCCRESshape' => '11',
92 'MaNCRESshape' => '11',
93 'MvNCRESshape' => '11',
98 'NonRESBGvpCC1pi' => '3',
99 'NonRESBGvpCC2pi' => '3',
100 'NonRESBGvpNC1pi' => '3',
101 'NonRESBGvpNC2pi' => '3',
102 'NonRESBGvnCC1pi' => '3',
103 'NonRESBGvnCC2pi' => '3',
104 'NonRESBGvnNC1pi' => '3',
105 'NonRESBGvnNC2pi' => '3',
106 'NonRESBGvbarpCC1pi' => '3',
107 'NonRESBGvbarpCC2pi' => '3',
108 'NonRESBGvbarpNC1pi' => '3',
109 'NonRESBGvbarpNC2pi' => '3',
110 'NonRESBGvbarnCC1pi' => '3',
111 'NonRESBGvbarnCC2pi' => '3',
112 'NonRESBGvbarnNC1pi' => '3',
113 'NonRESBGvbarnNC2pi' => '3',
118 'AhtBYshape' => '11',
119 'BhtBYshape' => '11',
120 'CV1uBYshape' => '11',
121 'CV2uBYshape' => '11',
123 'RnubarnuCC' => '11',
124 'DISNuclMod' => '11',
134 'FrPiProd_pi' => '11',
139 'FrPiProd_N' => '11',
140 'CCQEPauliSupViaKF' => '11',
141 'CCQEMomDistroFGtoSF' => '11',
142 'RDecBR1gamma' => '3',
144 'Theta_Delta2Npi' => '7'
147 %used_in_t2k_analysis = (
152 'MaCCQEshape' => '0',
153 'VecFFCCQEshape' => '1',
155 'MaCCRESshape' => '0',
156 'MvCCRESshape' => '0',
160 'MaNCRESshape' => '0',
161 'MvNCRESshape' => '0',
166 'NonRESBGvpCC1pi' => '1',
167 'NonRESBGvpCC2pi' => '0',
168 'NonRESBGvpNC1pi' => '1',
169 'NonRESBGvpNC2pi' => '0',
170 'NonRESBGvnCC1pi' => '1',
171 'NonRESBGvnCC2pi' => '0',
172 'NonRESBGvnNC1pi' => '1',
173 'NonRESBGvnNC2pi' => '0',
174 'NonRESBGvbarpCC1pi' => '0',
175 'NonRESBGvbarpCC2pi' => '0',
176 'NonRESBGvbarpNC1pi' => '0',
177 'NonRESBGvbarpNC2pi' => '0',
178 'NonRESBGvbarnCC1pi' => '0',
179 'NonRESBGvbarnCC2pi' => '0',
180 'NonRESBGvbarnNC1pi' => '0',
181 'NonRESBGvbarnNC2pi' => '0',
188 'CV1uBYshape' => '0',
189 'CV2uBYshape' => '0',
202 'FrPiProd_pi' => '1',
208 'CCQEPauliSupViaKF' => '1',
209 'CCQEMomDistroFGtoSF' => '1',
210 'RDecBR1gamma' => '1',
212 'Theta_Delta2Npi' => '1'
215 # make the jobs directory
217 mkpath ($jobs_dir, {verbose => 1, mode=>0777});
220 # submit weight calculation jobs
224 for my $curr_syst (keys %def_ntwkdials) {
226 # check whether to commit weight calculation run for current systematic
227 # print "checking whether to submit job for systematic: $curr_syst \n";
229 $using_a_std_analysis_syst_list =
230 ($syst eq "standard-t2k-analysis-list");
231 $syst_used_in_given_analysis =
232 ($syst eq "standard-t2k-analysis-list" && $used_in_t2k_analysis{$curr_syst} eq '1');
235 ((($syst=~m/$curr_syst/) || ($syst eq "all")) && ! $using_a_std_analysis_syst_list) ||
236 $syst_used_in_given_analysis;
239 print "** submitting weight calculation job \n";
241 $fntemplate = "$jobs_dir/syst-$curr_syst";
242 $grep_pipe = "grep -B 20 -A 30 -i \"warn\\|error\\|fatal\"";
243 $valgrind_cmd = "valgrind --tool=memcheck --error-limit=no --leak-check=yes --show-reachable=yes";
244 $ntwkdials = $def_ntwkdials{$curr_syst};
245 $genie_cmd = "$gexec -f $input_events -s $curr_syst -t $ntwkdials";
246 $genie_cmd = "$genie_cmd -n $nevents" if defined $nevents; # add optional argument
247 $genie_cmd = "$genie_cmd -o $output_weights" if defined $output_weights; # add optional argument
248 $genie_cmd = "$genie_cmd | $grep_pipe &> $fntemplate.log";
250 print "@@ exec: $genie_cmd \n";
257 if($batch_system eq 'PBS') {
258 $batch_script = "$fntemplate.pbs";
259 open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
260 print PBS "#!/bin/bash \n";
261 print PBS "#PBS -N syst-$curr_syst \n";
262 print PBS "#PBS -l cput=$time_limit \n";
263 print PBS "#PBS -o $fntemplate.pbsout.log \n";
264 print PBS "#PBS -e $fntemplate.pbserr.log \n";
265 print PBS "source $genie_setup \n";
266 print PBS "cd $jobs_dir \n";
267 print PBS "$genie_cmd \n";
269 `qsub -q $queue $batch_script`;
273 if($batch_system eq 'LSF') {
274 $batch_script = "$fntemplate.sh";
275 open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
276 print LSF "#!/bin/bash \n";
277 print LSF "#BSUB-j syst-$curr_syst \n";
278 print LSF "#BSUB-q $queue \n";
279 print LSF "#BSUB-c $time_limit \n";
280 print LSF "#BSUB-o $fntemplate.lsfout.log \n";
281 print LSF "#BSUB-e $fntemplate.lsferr.log \n";
282 print LSF "source $genie_setup \n";
283 print LSF "cd $jobs_dir \n";
284 print LSF "$genie_cmd \n";
286 `qsub < $batch_script`;
290 if($batch_system eq 'slurm') {
291 my $time_lim = `sinfo -h -p batch -o %l`;
292 my ($days, $hours, $remainder) = $time_lim =~ /([0]+)-([0-9]+):(.*)/;
293 my $newhours = $days * 24 + $hours;
294 my $new_time_lim = "$newhours:$remainder";
295 $time_limit = $new_time_lim lt $time_limit ? $new_time_lim : $time_limit;
296 $batch_script = "$fntemplate.sh";
297 open(SLURM, ">$batch_script") or die("Can not create the SLURM batch script");
298 print SLURM "#!/bin/bash \n";
299 print SLURM "#SBATCH-p $queue \n";
300 print SLURM "#SBATCH-o $fntemplate.lsfout.log \n";
301 print SLURM "#SBATCH-e $fntemplate.lsferr.log \n";
302 print SLURM "#SBATCH-t $time_limit \n";
303 print SLURM "source $genie_setup \n";
304 print SLURM "cd $jobs_dir \n";
305 print SLURM "$genie_cmd \n";
307 `sbatch --job-name=syst-$curr_syst $batch_script`;
310 # no batch system, run jobs interactively
311 if($batch_system eq 'none') {
312 system("source $genie_setup; cd $jobs_dir; $genie_cmd");
315 } #checking whether to submit current systematic
316 } # loop over systematics