ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/DBTools/scripts/osusub
(Generate patch)

Comparing UserCode/OSUT3Analysis/DBTools/scripts/osusub (file contents):
Revision 1.12 by ahart, Mon Feb 4 04:14:43 2013 UTC vs.
Revision 1.14 by ahart, Fri Feb 8 11:49:43 2013 UTC

# Line 16 | Line 16 | our $db = Mysql->connect ("cmshead", "nt
16  
17   my %opt;
18   Getopt::Long::Configure ("bundling");
19 < GetOptions (\%opt, "help|h");
19 > GetOptions (\%opt, "maxEvents|m=s", "help|h");
20   my $argc = @ARGV;
21  
22   printHelp () if $opt{"help"};
# Line 52 | Line 52 | if (-e $directory)
52    }
53   mkdir $directory;
54   my $nFiles = outputRunList ($dataset, $directory);
55 < my $realNJobs = 0;
56 < $realNJobs = ceil ($nFiles / ceil ($nFiles / $nJobs)) if $nFiles;
57 < outputPset ($directory, $dataset);
58 < outputCondor ($directory, $realNJobs, $nJobs, $dataset);
55 > my $realNJobs = $nJobs;
56 > $realNJobs = ceil ($nFiles / ceil ($nFiles / $realNJobs)) if $nFiles;
57 > my $eventsPerJob = -1;
58 > $eventsPerJob = ceil ($opt{"maxEvents"} / $realNJobs) if $opt{"maxEvents"} && $opt{"maxEvents"} >= 0;
59 > my $realMaxEvents = $eventsPerJob * $realNJobs;
60 > outputPset ($directory, $dataset, $opt{"maxEvents"}, $eventsPerJob);
61 > outputCondor ("$ENV{'CMSSW_BASE'}/src/OSUT3Analysis/DBTools/data/condor.sub", $directory, $realNJobs, $dataset);
62   copy ($config, "$directory/userConfig_cfg.py");
63   chdir $directory;
64 < print "Submitting $realNJobs jobs to run on $nFiles files.\n";
64 > print "Submitting $realNJobs jobs to run on $realMaxEvents events in $nFiles files.\n" if $realMaxEvents >= 0;
65 > print "Submitting $realNJobs jobs to run on all events in $nFiles files.\n" if $realMaxEvents < 0;
66   system ("condor_submit condor.sub");
67  
68   sub
# Line 66 | Line 70 | outputPset
70   {
71    my $workingDir = shift;
72    my $dataset = shift;
73 +  my $nEvents = shift;
74 +  my $eventsPerJob = shift;
75  
76    open (PSET, ">$workingDir/config_cfg.py");
77  
# Line 83 | Line 89 | outputPset
89    if ($dataset)
90      {
91        print PSET "pset.process.source.fileNames = cms.untracked.vstring (osusub.runList)\n";
92 <      print PSET "pset.process.maxEvents.input = cms.untracked.int32 (-1)\n";
92 >      print PSET "pset.process.maxEvents.input = cms.untracked.int32 ($eventsPerJob)\n" if $eventsPerJob < 0;
93      }
94 +  print PSET "pset.process.maxEvents.input = cms.untracked.int32 ($eventsPerJob)\n" if $eventsPerJob >= 0;
95    print PSET "process = pset.process\n";
96  
97    close (PSET);
# Line 208 | Line 215 | getLocation
215   sub
216   outputCondor
217   {
218 +  my $condorFileName = shift;
219    my $workingDir = shift;
212  my $realNJobs = shift;
220    my $nJobs = shift;
221    my $dataset = shift;
222  
223    my $cmsRun = `which cmsRun`;
224 <  open (SUB, ">$workingDir/condor.sub");
224 >  my $condorFile = "";
225  
226 <  print SUB "Executable              = $cmsRun\n";
227 <  print SUB "Universe                = vanilla\n";
228 <  print SUB "Getenv                  = True\n";
229 <  print SUB "Arguments               = config_cfg.py True $realNJobs \$(Process) $dataset\n" if $dataset;
230 <  print SUB "Arguments               = config_cfg.py True $realNJobs \$(Process) NULL\n" if !$dataset;
231 <  print SUB "\n";
232 <  print SUB "Output                  = condor_\$(Process).out\n";
233 <  print SUB "Error                   = condor_\$(Process).err\n";
234 <  print SUB "Log                     = condor_\$(Process).log\n";
235 <  print SUB "\n";
236 <  print SUB "+IsLocalJob             = true\n";
237 <  print SUB "Rank                    = TARGET.IsLocalSlot\n";
238 <  print SUB "\n";
239 <  print SUB "Queue $nJobs\n";
226 >  if (!(-e $condorFileName))
227 >    {
228 >      $condorFile .= "Executable              = $cmsRun\n";
229 >      $condorFile .= "Universe                = vanilla\n";
230 >      $condorFile .= "Getenv                  = True\n";
231 >      $condorFile .= "Arguments               = config_cfg.py True $nJobs \$(Process) $dataset\n" if $dataset;
232 >      $condorFile .= "Arguments               = config_cfg.py True $nJobs \$(Process) NULL\n" if !$dataset;
233 >      $condorFile .= "\n";
234 >      $condorFile .= "Output                  = condor_\$(Process).out\n";
235 >      $condorFile .= "Error                   = condor_\$(Process).err\n";
236 >      $condorFile .= "Log                     = condor_\$(Process).log\n";
237 >      $condorFile .= "\n";
238 >      $condorFile .= "+IsLocalJob             = true\n";
239 >      $condorFile .= "Rank                    = TARGET.IsLocalSlot\n";
240 >      $condorFile .= "\n";
241 >      $condorFile .= "Queue $nJobs\n";
242 >    }
243 >  else
244 >    {
245 >      open (SUB, "<$condorFileName");
246 >      my @condorFile = <SUB>;
247 >      close (SUB);
248 >      $condorFile = join ("", @condorFile);
249 >      $condorFile =~ s/\$cmsRun/$cmsRun/g;
250 >      $condorFile =~ s/\$nJobs/$nJobs/g;
251 >      $condorFile =~ s/\$dataset/$dataset/g if $dataset;
252 >      $condorFile =~ s/\$dataset/NULL/g if !$dataset;
253 >    }
254  
255 +  open (SUB, ">$workingDir/condor.sub");
256 +  print SUB $condorFile;
257    close (SUB);
258   }
259  
# Line 244 | Line 267 | printHelp
267    print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n";
268    print "\n";
269    printf "%-29s%s\n", "  -h, --help", "print this help message";
270 +  printf "%-29s%s\n", "  -m, --maxEvents N", "only run over N events in the dataset; default is";
271 +  printf "%-29s%s\n", " ", "to run over all events";
272    print "\n";
273    print "The optional first argument must be either a DATASET registered in the Tier 3\n";
274    print "ntuple database or a LOCATION which exists on disk. CONFIG must be a valid\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines