submit_t2k_superk_fhst_mc_jobs.pl
Go to the documentation of this file.
1 #----------------------------------------------------------------------------------------------------
2 # Submit a GENIE/SK event generation job using a histogram-based neutrino flux description
3 #
4 # Syntax:
5 # shell% perl submit_t2k_superk_fhst_mc_jobs.pl <options>
6 #
7 # Options:
8 # --version : GENIE version
9 # --run : 1,2,3,...
10 # --neutrino : numu, numubar, nue, nuebar, nuesig
11 # [--flux-version] : JNUBEAM flux version, <07a, 10a, 10c, 11a...>, default: 11a
12 # [--flux-config] : JNUBEAM config, <nominal, yshift2mm,...>, default: nominal
13 # [--flux-hist-file] : JNUBEAM flux histogram file, default: sk_flux_histograms.root
14 # [--arch] : <SL4.x86_32, SL5.x86_64, SL6.x86_64, ...>, default: SL6.x86_64
15 # [--production] : default: <version>
16 # [--cycle] : default: 01
17 # [--use-valgrind] : default: off
18 # [--batch-system] : <PBS, LSF>, default: PBS
19 # [--queue] : default: prod
20 # [--softw-topdir] : top level dir for softw installations, default: /opt/ppd/t2k/softw/GENIE
21 # [--jobs-topdir] : top level dir for job files, default: /opt/ppd/t2k/scratch/GENIE/
22 #
23 # Example:
24 # shell& perl submit_t2k_superk_fhst_mc_jobs.pl --run 180 --neutrino numubar --version v2.5.1
25 #
26 # Author:
27 # Costas Andreopoulos <costas.andreopoulos \st stfc.ac.uk>
28 # University of Liverpool & STFC Rutherford Appleton Laboratory
29 #
30 # Copyright:
31 # Copyright (c) 2003-2020, The GENIE Collaboration
32 # For the full text of the license visit http://copyright.genie-mc.org
33 #----------------------------------------------------------------------------------------------------
34 
35 #!/usr/bin/perl
36 
37 use File::Path;
38 
39 # inputs
40 #
41 $iarg=0;
42 foreach (@ARGV) {
43  if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
44  if($_ eq '--run' ) { $run = $ARGV[$iarg+1]; }
45  if($_ eq '--neutrino') { $neutrino = $ARGV[$iarg+1]; }
46  if($_ eq '--flux-version') { $flux_version = $ARGV[$iarg+1]; }
47  if($_ eq '--flux-config') { $flux_config = $ARGV[$iarg+1]; }
48  if($_ eq '--flux-hist-file') { $flux_hist_file = $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]; }
57  $iarg++;
58 }
59 die("** Aborting [Undefined run number. Use the --run option]")
60 unless defined $run;
61 die("** Aborting [Undefined neutrino type. Use the --neutrino option]")
62 unless defined $neutrino;
63 die("** Aborting [Undefined GENIE version. Use the --version option]")
64 unless defined $genie_version;
65 
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 $flux_version = "11a" unless defined $flux_version;
74 $flux_config = "nominal" unless defined $flux_config;
75 $flux_hist_file = "sk_flux_histograms.root" unless defined $flux_hist_file;
76 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
77 $nevents = "2000";
78 $time_limit = "05:00:00";
79 $inputs_dir = "$softw_topdir/data/job_inputs";
80 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
81 $geom_tgt_mix = "1000080160[0.8879],1000010010[0.1121]";
82 $xspl_file = "$inputs_dir/xspl/gxspl-t2k-$genie_version.xml";
83 $flux_file = "$inputs_dir/t2k_flux/$flux_version/sk/$flux_config/$flux_hist_file";
84 $job_dir = "$jobs_topdir/skmc-$production\_$cycle-$neutrino";
85 $file_prefix = "genie_sk";
86 
87 %mcseed_base = ( 'numu' => '183221029',
88  'numubar' => '283221029',
89  'nue' => '383221029',
90  'nuebar' => '383221029',
91  'nuesig' => '483221029' );
92 %mcrun_base = ( 'numu' => '10000000',
93  'numubar' => '10000000',
94  'nue' => '10000000',
95  'nuebar' => '10000000',
96  'nuesig' => '10000000' );
97 %nu_pdg_code = ( 'numu' => '14',
98  'numubar' => '-14',
99  'nue' => '12',
100  'nuebar' => '-12',
101  'nuesig' => '12' );
102 %flux_hist_name = ( 'numu' => 'numu_flux',
103  'numubar' => 'numubar_flux',
104  'nue' => 'nue_flux',
105  'nuebar' => 'nuebar_flux',
106  'nuesig' => 'numu_flux' );
107 
108 die("** Aborting [Can not find GENIE setup script: ..... $genie_setup]")
109 unless -e $genie_setup;
110 die("** Aborting [Can not find flux file: .............. $flux_file]")
111 unless -e $flux_file;
112 die("** Aborting [Can not find xsec file: .............. $xspl_file]")
113 unless -e $xspl_file;
114 
115 # make the jobs directory
116 #
117 mkpath ($job_dir, {verbose => 1, mode=>0777});
118 
119 # form mcrun, mcseed numbers
120 #
121 $mcrun = $run + $mcrun_base {$neutrino};
122 $mcseed = $run + $mcseed_base {$neutrino};
123 
124 print "@@@ Will submit job with MC run number = $mcrun (seed number = $mcseed)\n";
125 
126 # get neutrino code and flux histogram name
127 #
128 $nu = $nu_pdg_code {$neutrino};
129 $hst = $flux_hist_name {$neutrino};
130 
131 # form event generation and file conversion commands
132 #
133 $fntemplate = "$job_dir/skjob-$mcrun";
134 $ghep_file = "$file_prefix.$production\_$cycle.$neutrino.$mcrun.ghep.root";
135 #$grep_pipe = "grep -B 50 -A 50 -i \"warn\\|error\\|fatal\"";
136 $grep_pipe = "grep -B 50 -A 50 -i fatal";
137 $valgrind_cmd = "valgrind --tool=memcheck --error-limit=no --leak-check=yes --show-reachable=yes";
138 $evgen_opt = "-g $geom_tgt_mix -f $flux_file,$nu\[$hst\] -r $mcrun --seed $mcseed -n $nevents --cross-sections $xspl_file";
139 $evgen_cmd = "gevgen_t2k $evgen_opt | $grep_pipe &> $fntemplate.evgen.log";
140 $frenm_cmd = "mv gntp.$mcrun.ghep.root $ghep_file";
141 $fconv_cmd = "gntpc -f t2k_tracker -i $ghep_file --seed $mcseed";
142 
143 print "@@@ exec: $evgen_cmd \n";
144 
145 #
146 # submit
147 #
148 
149 # PBS case
150 if($batch_system eq 'PBS') {
151  $batch_script = "$fntemplate.pbs";
152  open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
153  print PBS "#!/bin/bash \n";
154  print PBS "#PBS -N $mcrun\_sk-$production-$cycle \n";
155  print PBS "#PBS -l cput=$time_limit \n";
156  print PBS "#PBS -o $fntemplate.pbsout.log \n";
157  print PBS "#PBS -e $fntemplate.pbserr.log \n";
158  print PBS "source $genie_setup \n";
159  print PBS "cd $job_dir \n";
160  print PBS "$evgen_cmd \n";
161  print PBS "$frenm_cmd \n";
162  print PBS "$fconv_cmd \n";
163  close(PBS);
164  `qsub -q $queue $batch_script`;
165 }
166 
167 # LSF case
168 if($batch_system eq 'LSF') {
169  $batch_script = "$fntemplate.sh";
170  open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
171  print LSF "#!/bin/bash \n";
172  print LSF "#BSUB-j $mcrun\_sk-$production-$cycle \n";
173  print LSF "#BSUB-q $queue \n";
174  print LSF "#BSUB-c $time_limit \n";
175  print LSF "#BSUB-o $fntemplate.lsfout.log \n";
176  print LSF "#BSUB-e $fntemplate.lsferr.log \n";
177  print LSF "source $genie_setup \n";
178  print LSF "cd $job_dir \n";
179  print LSF "$evgen_cmd \n";
180  print LSF "$frenm_cmd \n";
181  print LSF "$fconv_cmd \n";
182  close(LSF);
183  `bsub < $batch_script`;
184 }