6 |
|
use Getopt::Long; |
7 |
|
use POSIX; |
8 |
|
use Term::ANSIColor; |
9 |
+ |
use Cwd 'abs_path'; |
10 |
|
|
11 |
|
sub printHelp; |
12 |
|
sub outputPset; |
18 |
|
|
19 |
|
my %opt; |
20 |
|
Getopt::Long::Configure ("bundling"); |
21 |
< |
GetOptions (\%opt, "label|l=s", "maxEvents|m=s", "help|h"); |
21 |
> |
GetOptions (\%opt, "dataset|d=s", "label|l=s", "maxEvents|m=s", "process|p=s", "help|h"); |
22 |
|
my $argc = @ARGV; |
23 |
|
|
24 |
|
printHelp () if $opt{"help"}; |
59 |
|
my $eventsPerJob = -1; |
60 |
|
$eventsPerJob = ceil ($opt{"maxEvents"} / $realNJobs) if $opt{"maxEvents"} && $opt{"maxEvents"} >= 0; |
61 |
|
my $realMaxEvents = $eventsPerJob * $realNJobs; |
62 |
< |
outputPset ($directory, $dataset, $opt{"maxEvents"}, $eventsPerJob); |
62 |
> |
outputPset ($directory, $dataset, $opt{"maxEvents"}, $eventsPerJob, $opt{"process"}); |
63 |
> |
$dataset = $opt{"dataset"} if $opt{"dataset"}; |
64 |
|
outputCondor ("$ENV{'CMSSW_BASE'}/src/OSUT3Analysis/DBTools/data/condor.sub", $directory, $realNJobs, $dataset, $opt{"label"}); |
65 |
|
copy ($config, "$directory/userConfig_cfg.py"); |
66 |
|
chdir $directory; |
75 |
|
my $dataset = shift; |
76 |
|
my $nEvents = shift; |
77 |
|
my $eventsPerJob = shift; |
78 |
+ |
my $process = shift; |
79 |
+ |
|
80 |
+ |
$process =~ s/[^[:alnum:]]//g; |
81 |
|
|
82 |
|
open (PSET, ">$workingDir/config_cfg.py"); |
83 |
|
|
99 |
|
} |
100 |
|
print PSET "pset.process.maxEvents.input = cms.untracked.int32 ($eventsPerJob)\n" if $eventsPerJob >= 0; |
101 |
|
print PSET "process = pset.process\n"; |
102 |
+ |
print PSET "process.setName_ (process.name_ () + '$process')\n" if $process; |
103 |
|
|
104 |
|
close (PSET); |
105 |
|
} |
116 |
|
my $status; |
117 |
|
my $crossSection; |
118 |
|
my $isLocation = 0; |
119 |
< |
$isLocation = 1 if -e $dataset; |
120 |
< |
if (!$isLocation) |
119 |
> |
my $isRunList = 0; |
120 |
> |
$isLocation = 1 if -d $dataset; |
121 |
> |
$isRunList = 1 if -f $dataset; |
122 |
> |
$location = $dataset if $isLocation; |
123 |
> |
if (!$isLocation && !$isRunList) |
124 |
|
{ |
125 |
|
($location, $nFiles, $status, $crossSection) = getLocation ($dataset); |
126 |
|
if ($status ne "present") |
137 |
|
exit; |
138 |
|
} |
139 |
|
} |
140 |
+ |
my @files; |
141 |
+ |
if (!$isRunList) |
142 |
+ |
{ |
143 |
+ |
opendir (LOCATION, $location); |
144 |
+ |
@files = readdir (LOCATION); |
145 |
+ |
closedir (LOCATION); |
146 |
+ |
} |
147 |
|
else |
148 |
|
{ |
149 |
< |
$location = $dataset; |
149 |
> |
open (RUNLIST, $dataset); |
150 |
> |
while (my $file = <RUNLIST>) |
151 |
> |
{ |
152 |
> |
push (@files, abs_path ($file)); |
153 |
> |
} |
154 |
> |
close (RUNLIST); |
155 |
|
} |
156 |
< |
opendir (LOCATION, $location); |
157 |
< |
my @files = readdir (LOCATION); |
137 |
< |
closedir (LOCATION); |
138 |
< |
if (!$isLocation && @files - 2 != $nFiles) |
156 |
> |
$nFiles = @files - 2 if $isLocation || $isRunList; |
157 |
> |
if (@files - 2 != $nFiles) |
158 |
|
{ |
159 |
|
print "Number of files does not match database entry!\n"; |
160 |
|
print "Continue anyway? (y/N): "; |
162 |
|
$response =~ s/\n//g; |
163 |
|
exit if !$response || lc ($response) ne "y"; |
164 |
|
} |
146 |
– |
elsif ($isLocation) |
147 |
– |
{ |
148 |
– |
$nFiles = @files - 2; |
149 |
– |
} |
165 |
|
open (RUNLIST, ">$workingDir/runList.py"); |
166 |
|
print RUNLIST "runList = [\n"; |
167 |
|
for (my $i = 0; $i < @files; $i++) |
168 |
|
{ |
169 |
|
next if $files[$i] eq "."; |
170 |
|
next if $files[$i] eq ".."; |
171 |
< |
print RUNLIST "'file:$location/$files[$i]'"; |
171 |
> |
print RUNLIST "'file:" . abs_path ("$location/$files[$i]") . "'"; |
172 |
|
print RUNLIST "," if $i + 1 != @files; |
173 |
|
print RUNLIST "\n"; |
174 |
|
} |
297 |
|
my $exeName = $0; |
298 |
|
$exeName =~ s/^.*\/([^\/]*)$/$1/; |
299 |
|
|
300 |
< |
print "Usage: $exeName [OPTION]... [DATASET | LOCATION] CONFIG DIRECTORY NJOBS\n"; |
300 |
> |
print "Usage: $exeName [OPTION]... [DATASET | LOCATION | LIST] CONFIG DIRECTORY NJOBS\n"; |
301 |
|
print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n"; |
302 |
|
print "\n"; |
303 |
+ |
printf "%-29s%s\n", " -d, --dataset DATASET", "override the dataset name"; |
304 |
|
printf "%-29s%s\n", " -h, --help", "print this help message"; |
305 |
|
printf "%-29s%s\n", " -l, --label LABEL", "give the dataset a short label"; |
306 |
|
printf "%-29s%s\n", " -m, --maxEvents N", "only run over N events in the dataset; default is"; |
307 |
+ |
printf "%-29s%s\n", " -p, --process PROCESS", "suffix for the process name"; |
308 |
|
printf "%-29s%s\n", " ", "to run over all events"; |
309 |
|
print "\n"; |
310 |
|
print "The optional first argument must be either a DATASET registered in the Tier 3\n"; |
311 |
< |
print "ntuple database or a LOCATION which exists on disk. CONFIG must be a valid\n"; |
312 |
< |
print "CMSSW python configuration which can be used with cmsRun. DIRECTORY is a\n"; |
313 |
< |
print "working directory that is created and in which all output, both from the CMSSW\n"; |
314 |
< |
print "jobs and from Condor, is placed. Finally, NJOBS is the number of Condor jobs\n"; |
315 |
< |
print "that will be created.\n"; |
311 |
> |
print "ntuple database, a LOCATION which exists on disk, or a text file containing a\n"; |
312 |
> |
print "LIST of files to run over. CONFIG must be a valid CMSSW python configuration\n"; |
313 |
> |
print "which can be used with cmsRun. DIRECTORY is a working directory that is created\n"; |
314 |
> |
print " and in which all output, both from the CMSSW jobs and from Condor, is placed.\n"; |
315 |
> |
print "Finally, NJOBS is the number of Condor jobs that will be created.\n"; |
316 |
|
|
317 |
|
exit; |
318 |
|
} |