submit-vld_mec.pl
Go to the documentation of this file.
1 #!/usr/bin/perl
2 
3 #-----------------------------------------------------------------------------------------------------------
4 # Submit jobs to generate the GENIE samples needed for tuning / validating the GENIE MEC generator.
5 #
6 # Syntax:
7 # perl submit-vld_mec.pl <options>
8 #
9 # Options:
10 # --version : GENIE version number
11 # --run : runs to submit (eg --run 19090 / --run 19090,18080 / -run all)
12 # [--model-enum] : physics model enumeration, default: 0
13 # [--nsubruns] : number of subruns per run, default: 1
14 # [--offset] : subrun offset (for augmenting existing sample), default: 0
15 # [--arch] : <SL4_32bit, SL5_64bit>, default: SL5_64bit
16 # [--production] : production name, default: <version>
17 # [--cycle] : cycle in current production, default: 01
18 # [--use-valgrind] : default: off
19 # [--batch-system] : <PBS, LSF, slurm>, default: PBS
20 # [--queue] : default: prod
21 # [--softw-topdir] : default: /opt/ppd/t2k/softw/GENIE
22 #
23 # Tested at the RAL/PPD Tier2 PBS batch farm.
24 #
25 # Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
26 # STFC, Rutherford Appleton Lab
27 #-----------------------------------------------------------------------------------------------------------
28 #
29 # EVENT SAMPLES:
30 #
31 # Run number key: ITTJJMxxx
32 # I : probe (1: numu, 2: numubar)
33 # TT : nuclear target (06: Carbon, 08: Oxygen, 26: Iron, 80: Water, 90: MiniBooNE target mix)
34 # JJ : flux setting (01: 1 GeV, 80: T2K/SK numu flux, 81: T2K/SK numubar flux, 90: MiniBooNE numu flux
35 # M : model enumeration
36 # xxx : sub-run ID, 000-999, 50k events each
37 #
38 #.............................................................................................
39 # run number | init state | event generator | flux
40 # | | list |
41 #.............................................................................................
42 #
43 # ...
44 # 10601Mxxx | numu + 12C | CCMEC+CCQE | 1 GeV monoenergetic
45 # 10801Mxxx | numu + 16O | CCMEC+CCQE | 1 GeV monoenergetic
46 # 12601Mxxx | numu + 56Fe | CCMEC+CCQE | 1 GeV monoenergetic
47 # 18080Mxxx | numu + H2O | CCMEC+CCQE | T2K/SK numu
48 # 28081Mxxx | numubar + H2O | CCMEC+CCQE | T2K/SK numubar
49 # 19090Mxxx | numu + MiniBooNE tgt mix | CCMEC+CCQE | MiniBooNE numu
50 # ...
51 #
52 #.............................................................................................
53 #
54 
55 use File::Path;
56 
57 # inputs
58 #
59 $iarg=0;
60 foreach (@ARGV) {
61  if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
62  if($_ eq '--run') { $runnu = $ARGV[$iarg+1]; }
63  if($_ eq '--model-enum') { $model_enum = $ARGV[$iarg+1]; }
64  if($_ eq '--nsubruns') { $nsubruns = $ARGV[$iarg+1]; }
65  if($_ eq '--offset') { $offset = $ARGV[$iarg+1]; }
66  if($_ eq '--arch') { $arch = $ARGV[$iarg+1]; }
67  if($_ eq '--production') { $production = $ARGV[$iarg+1]; }
68  if($_ eq '--cycle') { $cycle = $ARGV[$iarg+1]; }
69  if($_ eq '--use-valgrind') { $use_valgrind = $ARGV[$iarg+1]; }
70  if($_ eq '--batch-system') { $batch_system = $ARGV[$iarg+1]; }
71  if($_ eq '--queue') { $queue = $ARGV[$iarg+1]; }
72  if($_ eq '--softw-topdir') { $softw_topdir = $ARGV[$iarg+1]; }
73  $iarg++;
74 }
75 die("** Aborting [Undefined GENIE version. Use the --version option]")
76 unless defined $genie_version;
77 die("** Aborting [You need to specify which runs to submit. Use the --run option]")
78 unless defined $runnu;
79 
80 $model_enum = "0" unless defined $model_enum;
81 $nsubruns = 1 unless defined $nsubruns;
82 $offset = 0 unless defined $offset;
83 $use_valgrind = 0 unless defined $use_valgrind;
84 $arch = "SL5_64bit" unless defined $arch;
85 $production = "$genie_version" unless defined $production;
86 $cycle = "01" unless defined $cycle;
87 $batch_system = "PBS" unless defined $batch_system;
88 $queue = "prod" unless defined $queue;
89 $softw_topdir = "/opt/ppd/t2k/softw/GENIE" unless defined $softw_topdir;
90 $time_limit = "60:00:00";
91 $genie_setup = "$softw_topdir/builds/$arch/$genie_version-setup";
92 $flux_dir = "$softw_topdir/builds/$arch/$genie_version/data/flux/";
93 $jobs_dir = "$softw_topdir/scratch/vld\_mec-$production\_$cycle";
94 $mcseed = 210921029;
95 $nev_per_subrun = 50000;
96 
97 # inputs for event generation jobs
98 %evg_pdg_hash = (
99  '10601' => '14',
100  '10801' => '14',
101  '12601' => '14',
102  '18080' => '14',
103  '28081' => '-14',
104  '19090' => '14'
105 );
106 %evg_tgtpdg_hash = (
107  '10601' => '1000060120',
108  '10801' => '1000080160',
109  '12601' => '1000260560',
110  '18080' => '1000080160[0.889],1000010010[0.111]',
111  '28081' => '1000080160[0.889],1000010010[0.111]',
112  '19090' => '1000060120[0.857],1000010010[0.143]'
113 );
114 %evg_energy_hash = (
115  '10601' => '1',
116  '10801' => '1',
117  '12601' => '1',
118  '18080' => '0,5',
119  '28081' => '0,5',
120  '19090' => '0,5'
121 );
122 %evg_gevgl_hash = (
123  '10601' => 'CCMEC+CCQE',
124  '10801' => 'CCMEC+CCQE',
125  '12601' => 'CCMEC+CCQE',
126  '18080' => 'CCMEC+CCQE',
127  '28081' => 'CCMEC+CCQE',
128  '19090' => 'CCMEC+CCQE'
129 );
130 %evg_fluxopt_hash = (
131  '10601' => '',
132  '10801' => '',
133  '12601' => '',
134  '18080' => '-f $flux_dir/t2ksk.root[numu_flux]',
135  '28081' => '-f $flux_dir/t2ksk.root[numubar_flux]',
136  '19090' => '-f $flux_dir/miniboone-numu.data'
137 );
138 
139 # make the jobs directory
140 #
141 mkpath ($jobs_dir, {verbose => 1, mode=>0777});
142 
143 #
144 # submit event generation jobs
145 #
146 
147 # run loop
148 for my $curr_runnu (keys %evg_gevgl_hash) {
149 
150  # check whether to commit current run
151  if($runnu=~m/$curr_runnu/ || $runnu eq "all") {
152 
153  print "** submitting event generation run: $curr_runnu \n";
154 
155  #
156  # get runnu-dependent info
157  #
158  $probe = $evg_pdg_hash {$curr_runnu};
159  $tgt = $evg_tgtpdg_hash {$curr_runnu};
160  $en = $evg_energy_hash {$curr_runnu};
161  $gevgl = $evg_gevgl_hash {$curr_runnu};
162  $fluxopt = $evg_fluxopt_hash {$curr_runnu};
163 
164  # submit subruns
165  for($isubrun = 0; $isubrun < $nsubruns; $isubrun++) {
166 
167  # Run number key: ITTJJMxxx
168  $curr_subrunnu = 10000 * $curr_runnu + 1000 * $model_enum + $isubrun + $offset;
169  $curr_seed = $mcseed + $isubrun + $offset;
170  $fntemplate = "$jobs_dir/mec-$curr_subrunnu";
171  $grep_pipe = "grep -B 20 -A 30 -i \"warn\\|error\\|fatal\"";
172  $valgrind_cmd = "valgrind --tool=memcheck --error-limit=no --leak-check=yes --show-reachable=yes";
173  $evgen_cmd = "gevgen -n $nev_per_subrun -e $en -p $probe -t $tgt $fluxopt -r $curr_subrunnu --seed $curr_seed --event-generator-list $gevgl | $grep_pipe &> $fntemplate.evgen.log";
174  $conv_cmd = "gntpc -f gst -i gntp.$curr_subrunnu.ghep.root";
175 
176  print "@@ exec: $evgen_cmd \n";
177 
178  #
179  # submit
180  #
181 
182  # PBS case
183  if($batch_system eq 'PBS') {
184  $batch_script = "$fntemplate.pbs";
185  open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
186  print PBS "#!/bin/bash \n";
187  print PBS "#PBS -N mec-$curr_subrunnu \n";
188  print PBS "#PBS -l cput=$time_limit \n";
189  print PBS "#PBS -o $fntemplate.pbsout.log \n";
190  print PBS "#PBS -e $fntemplate.pbserr.log \n";
191  print PBS "source $genie_setup \n";
192  print PBS "cd $jobs_dir \n";
193  print PBS "$evgen_cmd \n";
194  print PBS "$conv_cmd \n";
195  close(PBS);
196  `qsub -q $queue $batch_script`;
197  } #PBS
198 
199  # LSF case
200  if($batch_system eq 'LSF') {
201  $batch_script = "$fntemplate.sh";
202  open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
203  print LSF "#!/bin/bash \n";
204  print LSF "#BSUB-j mec-$curr_subrunnu \n";
205  print LSF "#BSUB-q $queue \n";
206  print LSF "#BSUB-c $time_limit \n";
207  print LSF "#BSUB-o $fntemplate.lsfout.log \n";
208  print LSF "#BSUB-e $fntemplate.lsferr.log \n";
209  print LSF "source $genie_setup \n";
210  print LSF "cd $jobs_dir \n";
211  print LSF "$evgen_cmd \n";
212  print LSF "$conv_cmd \n";
213  close(LSF);
214  `qsub < $batch_script`;
215  } #LSF
216 
217  # slurm case
218  if($batch_system eq 'slurm') {
219  $batch_script = "$fntemplate.sh";
220  open(SLURM, ">$batch_script") or die("Can not create the SLURM batch script");
221  print SLURM "#!/bin/bash \n";
222  print SLURM "#SBATCH-p $queue \n";
223  print SLURM "#SBATCH-o $fntemplate.lsfout.log \n";
224  print SLURM "#SBATCH-e $fntemplate.lsferr.log \n";
225  print SLURM "source $genie_setup \n";
226  print SLURM "cd $jobs_dir \n";
227  print SLURM "$evgen_cmd \n";
228  print SLURM "$conv_cmd \n";
229  close(SLURM);
230  `sbatch --job-name=mec-$curr_subrunnu $batch_script`;
231  } #slurm
232 
233  } # loop over subruns
234  } #checking whether to submit current run
235 } # loop over runs
236