4 |
|
use Mysql; |
5 |
|
use File::Copy; |
6 |
|
use Getopt::Long; |
7 |
< |
sub printHelp; |
7 |
> |
use POSIX; |
8 |
|
|
9 |
+ |
sub printHelp; |
10 |
|
sub outputPset; |
11 |
|
sub outputRunList; |
12 |
|
sub getLocation; |
13 |
|
sub outputCondor; |
14 |
|
|
15 |
< |
our $db; |
15 |
> |
our $db = Mysql->connect ("cmshead", "ntuple", "osuT3User"); |
16 |
|
|
17 |
|
my %opt; |
18 |
|
Getopt::Long::Configure ("bundling"); |
33 |
|
exit; |
34 |
|
} |
35 |
|
mkdir $ARGV[2]; |
36 |
< |
outputRunList ($ARGV[0], $ARGV[2]); |
36 |
> |
my $nFiles = outputRunList ($ARGV[0], $ARGV[2]); |
37 |
> |
my $nJobs = $ARGV[3]; |
38 |
> |
my $realNJobs = ceil ($nFiles / ceil ($nFiles / $nJobs)); |
39 |
|
outputPset ($ARGV[2]); |
40 |
< |
outputCondor ($ARGV[2], $ARGV[3]); |
40 |
> |
outputCondor ($ARGV[2], $realNJobs); |
41 |
|
copy ($ARGV[1], "$ARGV[2]/userConfig_cfg.py"); |
42 |
|
chdir $ARGV[2]; |
43 |
+ |
print "Submitting $realNJobs jobs to run on $nFiles files.\n"; |
44 |
|
system ("condor_submit condor.sub"); |
45 |
|
|
46 |
|
sub |
74 |
|
my $dataset = shift; |
75 |
|
my $workingDir = shift; |
76 |
|
|
77 |
< |
my ($location, $nFiles, $status) = getLocation ($dataset); |
77 |
> |
my ($location, $nFiles, $status, $crossSection) = getLocation ($dataset); |
78 |
|
if ($status ne "present") |
79 |
|
{ |
80 |
|
print "This dataset is not marked as present on the Tier 3!\n"; |
105 |
|
} |
106 |
|
print RUNLIST "]"; |
107 |
|
close (RUNLIST); |
108 |
+ |
if ($crossSection && $crossSection >= 0.0) |
109 |
+ |
{ |
110 |
+ |
open (CROSS_SECTION, ">$workingDir/crossSectionInPicobarn.txt"); |
111 |
+ |
print CROSS_SECTION "$crossSection\n"; |
112 |
+ |
close (CROSS_SECTION); |
113 |
+ |
} |
114 |
+ |
|
115 |
+ |
return $nFiles; |
116 |
|
} |
117 |
|
|
118 |
|
sub |
121 |
|
my $dataset = shift; |
122 |
|
|
123 |
|
my $results; |
124 |
< |
$db = Mysql->connect ("cmshead", "ntuple", "osuT3User"); |
125 |
< |
my $query = "select user,creationTime,location,nFiles,status from ntuple where dataset='$dataset' order by lastUpdateTime"; |
124 |
> |
my $queryDataset = $dataset; |
125 |
> |
$queryDataset =~ s/\*/%/g; |
126 |
> |
$queryDataset =~ s/(.*)/%$1%/g; |
127 |
> |
my $query = "select dataset,user,creationTime,location,nFiles,status,crossSectionInPicobarn from ntuple where dataset like '$queryDataset' and status='present' order by creationTime"; |
128 |
|
$db->selectdb ("ntuple"); |
129 |
|
$results = $db->query ($query); |
130 |
|
if ($results->numrows () == 1) |
131 |
|
{ |
132 |
|
my @row = $results->fetchrow (); |
133 |
< |
return ($row[2], $row[3], $row[4]); |
133 |
> |
return ($row[3], $row[4], $row[5], $row[6]); |
134 |
|
} |
135 |
|
if ($results->numrows () == 0) |
136 |
|
{ |
143 |
|
for (my $i = 1; $i <= $results->numrows (); $i++) |
144 |
|
{ |
145 |
|
my @row = $results->fetchrow (); |
146 |
< |
$map{"$i"} = [$row[2], $row[3], $row[4]]; |
147 |
< |
print "($i) created by $row[0] on $row[1]\n"; |
146 |
> |
$map{"$i"} = [$row[3], $row[4], $row[5], $row[6]]; |
147 |
> |
printf "(%2d) $row[0]\n", $i; |
148 |
> |
print " created by $row[1] on $row[2]\n"; |
149 |
|
} |
150 |
|
print "\nWhich dataset would you like to use?: "; |
151 |
|
my $response = <STDIN>; |
156 |
|
exit; |
157 |
|
} |
158 |
|
|
159 |
< |
return ($map{$response}[0], $map{$response}[1], $map{$response}[2]); |
159 |
> |
return ($map{$response}[0], $map{$response}[1], $map{$response}[2], $map{$response}[3]); |
160 |
|
} |
161 |
|
|
162 |
|
sub |
188 |
|
my $exeName = $0; |
189 |
|
$exeName =~ s/^.*\/([^\/]*)$/$1/; |
190 |
|
|
191 |
< |
print "Usage: $exeName [OPTION] DATASET CONFIG DIRECTORY NJOBS\n"; |
191 |
> |
print "Usage: $exeName [OPTION]... DATASET CONFIG DIRECTORY NJOBS\n"; |
192 |
|
print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n"; |
193 |
|
print "\n"; |
194 |
|
printf "%-29s%s\n", " -h, --help", "print this help message"; |