1 #--------------------------------------------------------------------------------------------------
2 # Submit a GENIE/SK event generation job using a JNUBEAM ntuple-based neutrino flux description.
5 # shell$ perl submit_t2k_superk_fntp_mc_jobs.pl <options>
8 # --version : GENIE version
9 # --flux-run : Input flux run number
10 # [--flux-version] : JNUBEAM flux version, <07a, 10a, 10b, 10c, ...>, default: 10c
11 # [--flux-config] : JNUBEAM config, <nominal, yshift2mm,...>, default: nominal
12 # [--flux-file-prefix] : JNUBEAM flux file prefix, default: nu.sk_horn250ka.
13 # [--flux-file-suffix] : JNUBEAM flux file suffix, default: .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/
24 # shell$ perl submit_t2k_superk_fntp_mc_jobs.pl --flux-run 180 \
25 # --version v2.4.0 --production mdc0 --cycle 01
27 # Costas Andreopoulos <costas.andreopoulos \st stfc.ac.uk>
28 # University of Liverpool & STFC Rutherford Appleton Laboratory
31 # Copyright (c) 2003-2020, The GENIE Collaboration
32 # For the full text of the license visit http://copyright.genie-mc.org
33 #--------------------------------------------------------------------------------------------------
43 if($_ eq '--version') { $genie_version = $ARGV[$iarg+1]; }
44 if($_ eq '--flux-run') { $flux_run = $ARGV[$iarg+1]; }
45 if($_ eq '--flux-version') { $flux_version = $ARGV[$iarg+1]; }
46 if($_ eq '--flux-config') { $flux_config = $ARGV[$iarg+1]; }
47 if($_ eq '--flux-file-prefix') { $flux_file_prefix = $ARGV[$iarg+1]; }
48 if($_ eq '--flux-file-suffix') { $flux_file_suffix = $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 run number. Use the --flux-run option]")
60 unless defined $flux_run;
61 die("** Aborting [Undefined GENIE version. Use the --version option]")
62 unless defined $genie_version;
64 $use_valgrind = 0 unless defined $use_valgrind;
65 $arch = "SL6.x86_64" unless defined $arch;
66 $production = "$genie_version" unless defined $production;
67 $cycle = "01" unless defined $cycle;
68 $batch_system = "PBS" unless defined $batch_system;
69 $queue = "prod" unless defined $queue;
70 $softw_topdir = "/opt/ppd/t2k/softw/GENIE" unless defined $softw_topdir;
71 $flux_version = "10c" unless defined $flux_version;
72 $flux_config = "nominal" unless defined $flux_config;
73 $flux_file_prefix = "nu.sk_horn250ka." unless defined $flux_file_prefix;
74 $flux_file_suffix = ".root" unless defined $flux_file_suffix;
75 $jobs_topdir = "/opt/ppd/t2k/scratch/GENIE/" unless defined $jobs_topdir;
77 $mcrun_base = 10000000;
78 $mcseed_base = 210921029;
79 $time_limit = "25:00:00";
80 $inputs_dir = "$softw_topdir/data/job_inputs";
81 $genie_setup = "$softw_topdir/generator/builds/$arch/$genie_version-setup";
82 $geom_tgt_mix = "1000080160[0.8879],1000010010[0.1121]";
83 $xspl_file = "$inputs_dir/xspl/gxspl-t2k-$genie_version.xml";
84 $flux_dir = "$inputs_dir/t2k_flux/$flux_version/sk/$flux_config";
85 $flux_file = "$flux_dir/$flux_file_prefix$flux_run$flux_file_suffix";
87 $job_dir = "$jobs_topdir/skmc-$production\_$cycle";
88 $file_prefix = "genie_sk";
89 $mcrun = $mcrun_base + $flux_run;
90 $mcseed = $mcseed_base + $flux_run;
92 die("** Aborting [Can not find GENIE setup script: ..... $genie_setup]")
93 unless -e $genie_setup;
94 die("** Aborting [Can not find flux file: .............. $flux_file]")
96 die("** Aborting [Can not find xsec file: .............. $xspl_file]")
99 # make the jobs directory
101 mkpath ($job_dir, {verbose => 1, mode=>0777});
103 print "@@@ Will submit job with MC run number = $mcrun (seed number = $mcseed)\n";
105 # form event generation and file conversion commands
107 $fntemplate = "$job_dir/skjob-$mcrun";
108 $ghep_file = "$file_prefix.$production\_$cycle.$mcrun.ghep.root";
109 #$grep_pipe = "grep -B 50 -A 50 -i \"warn\\|error\\|fatal\"";
110 $grep_pipe = "grep -B 50 -A 50 -i fatal";
111 $valgrind_cmd = "valgrind --tool=memcheck --error-limit=no --leak-check=yes --show-reachable=yes";
112 $evgen_opt = "-g $geom_tgt_mix -f $flux_file,$flux_det_loc -r $mcrun --seed $mcseed -n $nevents --cross-sections $xspl_file";
113 $evgen_cmd = "gevgen_t2k $evgen_opt | $grep_pipe &> $fntemplate.evgen.log";
114 $frenm_cmd = "mv gntp.$mcrun.ghep.root $ghep_file";
115 $fconv_cmd = "gntpc -f t2k_tracker -i $ghep_file --seed $mcseed &> $fntemplate.conv.log";
117 print "@@@ exec: $evgen_cmd \n";
124 if($batch_system eq 'PBS') {
125 $batch_script = "$fntemplate.pbs";
126 open(PBS, ">$batch_script") or die("Can not create the PBS batch script");
127 print PBS "#!/bin/bash \n";
128 print PBS "#PBS -N $mcrun\_sk-$production-$cycle \n";
129 print PBS "#PBS -l cput=$time_limit \n";
130 print PBS "#PBS -o $fntemplate.pbsout.log \n";
131 print PBS "#PBS -e $fntemplate.pbserr.log \n";
132 print PBS "source $genie_setup \n";
133 print PBS "cd $job_dir \n";
134 print PBS "$evgen_cmd \n";
135 print PBS "$frenm_cmd \n";
136 print PBS "$fconv_cmd \n";
138 `qsub -q $queue $batch_script`;
142 if($batch_system eq 'LSF') {
143 $batch_script = "$fntemplate.sh";
144 open(LSF, ">$batch_script") or die("Can not create the LSF batch script");
145 print LSF "#!/bin/bash \n";
146 print LSF "#BSUB-j $mcrun\_sk-$production-$cycle \n";
147 print LSF "#BSUB-q $queue \n";
148 print LSF "#BSUB-c $time_limit \n";
149 print LSF "#BSUB-o $fntemplate.lsfout.log \n";
150 print LSF "#BSUB-e $fntemplate.lsferr.log \n";
151 print LSF "source $genie_setup \n";
152 print LSF "cd $job_dir \n";
153 print LSF "$evgen_cmd \n";
154 print LSF "$frenm_cmd \n";
155 print LSF "$fconv_cmd \n";
157 `bsub < $batch_script`;