21 |
|
|
22 |
|
my %opt; |
23 |
|
Getopt::Long::Configure ("bundling"); |
24 |
< |
GetOptions (\%opt, "comment|c=s", "format|f=s", "pyConfig|p=s", "crabCfg|b=s", "jsonFile|j=s", "lumiSummary|s=s", "location|l=s", "name|n=s", "fileList|t=s", "release|r=s", "other|o", "recipe|e=s", "help|h"); |
24 |
> |
GetOptions (\%opt, "comment|c=s", "format|f=s", "pyConfig|p=s", "crabCfg|b=s", "jsonFile|j=s", "lumiSummary|s=s", "location|l=s", "name|n=s", "fileList|t=s", "release|r=s", "other|o", "recipe|e=s", "globalTag|g=s", "configName|i=s", "xSection|x=s", "help|h"); |
25 |
|
my $argc = @ARGV; |
26 |
|
|
27 |
|
printHelp ($ARGV[0]) if $opt{"help"}; |
42 |
|
print "The Python config and ntuple release must be given!\n"; |
43 |
|
exit; |
44 |
|
} |
45 |
– |
if ($opt{"location"} && locationExists ($opt{"location"})) |
46 |
– |
{ |
47 |
– |
print "This location is already registered in the database!\n"; |
48 |
– |
exit; |
49 |
– |
} |
45 |
|
if ($ARGV[0] eq "uploadRelease") |
46 |
|
{ |
47 |
|
my $parentDir = "./$opt{'release'}"; |
81 |
|
$status = "" if $ARGV[0] eq "update"; |
82 |
|
$status = "deprecated" if $ARGV[0] eq "deprecate"; |
83 |
|
$opt{"format"} = "BEAN" if $ARGV[0] eq "create" && !$opt{"format"}; |
84 |
< |
dbUpdate ($id, $fullDataset, "$ENV{'USER'}\@$ENV{'HOSTNAME'}", $opt{"format"}, $opt{"location"}, $opt{"name"}, $opt{"fileList"}, $status, $opt{"comment"}, $opt{"pyConfig"}, $opt{"crabCfg"}, $opt{"jsonFile"}, $opt{"lumiSummary"}, $opt{"release"}) if !$opt{"other"}; |
84 |
> |
if ($opt{"location"} && locationExists ($id, $opt{"location"})) |
85 |
> |
{ |
86 |
> |
print "This location is already registered in the database!\n"; |
87 |
> |
exit; |
88 |
> |
} |
89 |
> |
dbUpdate ($id, $fullDataset, "$ENV{'USER'}\@$ENV{'HOSTNAME'}", $opt{"format"}, $opt{"location"}, $opt{"name"}, $opt{"fileList"}, $status, $opt{"comment"}, $opt{"pyConfig"}, $opt{"crabCfg"}, $opt{"jsonFile"}, $opt{"lumiSummary"}, $opt{"release"}, $opt{"globalTag"}, $opt{"configName"}, $opt{"xSection"}) if !$opt{"other"}; |
90 |
|
dbUpdateOther ($id, $opt{"comment"}, "$ENV{'USER'}\@$ENV{'HOSTNAME'}") if $opt{"other"}; |
91 |
|
dbDelete ($id) if $ARGV[0] eq "deleteEntry" && !$opt{"other"}; |
92 |
|
dbDeleteOther ($id) if $ARGV[0] eq "deleteEntry" && $opt{"other"}; |
191 |
|
my $jsonFileName = shift; |
192 |
|
my $lumiSummaryName = shift; |
193 |
|
my $release = shift; |
194 |
+ |
my $globalTag = shift; |
195 |
+ |
my $configName = shift; |
196 |
+ |
my $xSection = shift; |
197 |
|
|
198 |
|
my $user = $userAndHost; |
199 |
|
$user =~ s/@.*$//g; |
265 |
|
close (LUMI_SUMMARY); |
266 |
|
$lumiSummary = join ("", @lumiSummary); |
267 |
|
} |
268 |
< |
if ($release) |
266 |
< |
{ |
267 |
< |
my $query = "select id from ntupleRelease where name='$release'"; |
268 |
< |
$db->selectdb ("ntuple"); |
269 |
< |
my $results = $db->query ($query); |
270 |
< |
if ($results->numrows () != 1) |
271 |
< |
{ |
272 |
< |
print "Ntuple release \"$release\" not found!\n"; |
273 |
< |
exit; |
274 |
< |
} |
275 |
< |
} |
268 |
> |
$release .= ".$configName" if $configName; |
269 |
|
($nFiles, $size) = sizeOfDataset ($dataset, $location, $fileList); |
270 |
|
my $fullLocation = $location; |
271 |
|
$fullLocation = "$ENV{'PWD'}/$location" if !($location =~ m/^\//); |
283 |
|
$status = addSlashes ($status); |
284 |
|
$comment = addSlashes ($comment); |
285 |
|
$release = addSlashes ($release); |
286 |
+ |
$globalTag = addSlashes ($globalTag); |
287 |
|
|
288 |
|
my $results; |
289 |
|
my $query; |
308 |
|
my $id = 1; |
309 |
|
$id = $row[0] + 1 if $results->numrows (); |
310 |
|
|
311 |
< |
$query = "insert into ntuple (id, dataset, creationTime, lastUpdateTime, lastUpdateUser, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version) values ($id, '$dataset', now(), now(), '$userAndHost', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release')"; |
311 |
> |
$query = "insert into ntuple (id, dataset, creationTime, lastUpdateTime, lastUpdateUser, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version, globalTag, crossSectionInPicobarn) values ($id, '$dataset', now(), now(), '$userAndHost', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release', '$globalTag', $xSection)" if $xSection; |
312 |
> |
$query = "insert into ntuple (id, dataset, creationTime, lastUpdateTime, lastUpdateUser, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version, globalTag) values ($id, '$dataset', now(), now(), '$userAndHost', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release', '$globalTag')" if !$xSection; |
313 |
|
} |
314 |
|
if ($id > 0) |
315 |
|
{ |
346 |
|
$values .= ", jsonFile='$jsonFile'" if $jsonFile; |
347 |
|
$values .= ", lumiSummary='$lumiSummary'" if $lumiSummary; |
348 |
|
$values .= ", version='$release'" if $release; |
349 |
+ |
$values .= ", globalTag='$globalTag'" if $globalTag; |
350 |
+ |
$values .= ", crossSectionInPicobarn=$xSection" if $xSection; |
351 |
|
|
352 |
|
$values =~ s/^, //; |
353 |
|
$query = "update ntuple set $values where id=$id"; |
411 |
|
printf "%-29s%s\n", " -b, --crabCfg FILE", "CRAB config used to submit ntuple jobs"; |
412 |
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry"; |
413 |
|
printf "%-29s%s\n", " -f, --format FORMAT", "ntuple format (default: BEAN)"; |
414 |
+ |
printf "%-29s%s\n", " -g, --globalTag TAG", "global tag"; |
415 |
+ |
printf "%-29s%s\n", " -i, --configName NAME", "name of config used to produce ntuples"; |
416 |
|
printf "%-29s%s\n", " -j, --jsonFile FILE", "JSON file used for this dataset"; |
417 |
|
printf "%-29s%s\n", " -l, --location DIRECTORY", "directory containing the ntuples"; |
418 |
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python config used to produce ntuples"; |
419 |
|
printf "%-29s%s\n", " -r, --release NAME", "ntuple release used to produce ntuples"; |
420 |
|
printf "%-29s%s\n", " -s, --lumiSummary FILE", "lumiSummary.json reported by CRAB"; |
421 |
+ |
printf "%-29s%s\n", " -x, --xSection XSEC", "cross section in picobarns for the sample"; |
422 |
|
} |
423 |
|
elsif ($command eq "createOther") |
424 |
|
{ |
437 |
|
printf "%-29s%s\n", " -b, --crabCfg FILE", "CRAB config used to submit ntuple jobs"; |
438 |
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry"; |
439 |
|
printf "%-29s%s\n", " -f, --format FORMAT", "ntuple format"; |
440 |
+ |
printf "%-29s%s\n", " -g, --globalTag TAG", "global tag"; |
441 |
+ |
printf "%-29s%s\n", " -i, --configName NAME", "name of config used to produce ntuples"; |
442 |
|
printf "%-29s%s\n", " -j, --jsonFile FILE", "JSON file used for this dataset"; |
443 |
|
printf "%-29s%s\n", " -l, --location DIRECTORY", "directory containing the ntuples"; |
444 |
|
printf "%-29s%s\n", " -n, --name NAME", "rename the entry"; |
446 |
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python config used to produce ntuples"; |
447 |
|
printf "%-29s%s\n", " -r, --release NAME", "ntuple release used to produce ntuples"; |
448 |
|
printf "%-29s%s\n", " -s, --lumiSummary FILE", "lumiSummary.json reported by CRAB"; |
449 |
+ |
printf "%-29s%s\n", " -x, --xSection XSEC", "cross section in picobarns for the sample"; |
450 |
|
} |
451 |
|
elsif ($command eq "finish") |
452 |
|
{ |
500 |
|
} |
501 |
|
elsif ($command eq "uploadConfig") |
502 |
|
{ |
503 |
< |
print "Usage: $exeName -p FILE -r DIRECTORY [OPTION]... uploadConfig NAME\n"; |
503 |
> |
print "Usage: $exeName -p FILE -r RELEASE [OPTION]... uploadConfig NAME\n"; |
504 |
|
print "Creates an entry in the database for a customized Python configuration file.\n"; |
505 |
|
print "\n"; |
506 |
|
print "Mandatory arguments to long options are mandatory for short options too.\n"; |
592 |
|
print "$recipeName does not exist!\n"; |
593 |
|
exit; |
594 |
|
} |
595 |
< |
move ($release, "/home/hart/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped"; |
595 |
> |
move ($release, "/home/osucms/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped"; |
596 |
|
open (PY_CONFIG, "<$psetName"); |
597 |
|
my @pset = <PY_CONFIG>; |
598 |
|
close (PY_CONFIG); |
636 |
|
print "Ntuple release \"$release\" not found!\n"; |
637 |
|
exit; |
638 |
|
} |
636 |
– |
if (!(-e "/home/hart/public_html/releases/$release.tar.gz")) |
637 |
– |
{ |
638 |
– |
print "Release is in the database but no package exists!\n"; |
639 |
– |
exit; |
640 |
– |
} |
639 |
|
if ($pyConfigName) |
640 |
|
{ |
641 |
|
my @row = $results->fetchrow (); |
643 |
|
print PY_CONFIG $row[1]; |
644 |
|
close (PY_CONFIG); |
645 |
|
} |
646 |
< |
copy ("/home/hart/public_html/releases/$release.tar.gz", "$release.tar.gz"); |
646 |
> |
`wget "http://cmshead.mps.ohio-state.edu/~osucms/releases/$release.tar.gz"`; |
647 |
|
} |
648 |
|
|
649 |
|
sub |
744 |
|
sub |
745 |
|
locationExists |
746 |
|
{ |
747 |
+ |
my $id = shift; |
748 |
|
my $location = shift; |
749 |
|
|
750 |
|
$location =~ s/^(.*)\/+$/$1/; |
751 |
< |
my $query = "select id from ntuple where location like '$location%'"; |
751 |
> |
my $query = "select id from ntuple where location like '$location%' and id!=$id"; |
752 |
|
$db->selectdb ("ntuple"); |
753 |
|
my $results = $db->query ($query); |
754 |
|
return 1 if $results->numrows (); |
762 |
|
$location =~ s/^\/data\/se\/store\/(.*)$/\/store\/$1/; |
763 |
|
} |
764 |
|
|
765 |
< |
my $query = "select id from ntuple where location like '$location%'"; |
765 |
> |
my $query = "select id from ntuple where location like '$location%' and id!=$id"; |
766 |
|
$db->selectdb ("ntuple"); |
767 |
|
my $results = $db->query ($query); |
768 |
|
return 1 if $results->numrows (); |