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.13 by ahart, Fri Feb 8 09:17:45 2013 UTC vs.
Revision 1.16 by ahart, Thu Apr 25 18:17:33 2013 UTC

# Line 16 | Line 16 | our $db = Mysql->connect ("cmshead", "nt
16  
17   my %opt;
18   Getopt::Long::Configure ("bundling");
19 < GetOptions (\%opt, "maxEvents|m=s", "help|h");
19 > GetOptions (\%opt, "label|l=s", "maxEvents|m=s", "help|h");
20   my $argc = @ARGV;
21  
22   printHelp () if $opt{"help"};
# Line 58 | Line 58 | 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 ($directory, $realNJobs, $dataset);
61 > outputCondor ("$ENV{'CMSSW_BASE'}/src/OSUT3Analysis/DBTools/data/condor.sub", $directory, $realNJobs, $dataset, $opt{"label"});
62   copy ($config, "$directory/userConfig_cfg.py");
63   chdir $directory;
64   print "Submitting $realNJobs jobs to run on $realMaxEvents events in $nFiles files.\n" if $realMaxEvents >= 0;
# Line 177 | Line 177 | getLocation
177    my $queryDataset = $dataset;
178    $queryDataset =~ s/\*/%/g;
179    $queryDataset =~ s/(.*)/%$1%/g;
180 <  my $query = "select dataset,user,creationTime,location,nFiles,status,crossSectionInPicobarn from ntuple where dataset like '$queryDataset' order by creationTime";
180 >  my $query = "select dataset,user,creationTime,location,nFiles,status,crossSectionInPicobarn,higherOrderCrossSectionInPicobarn from ntuple where dataset like '$queryDataset' order by creationTime";
181    $db->selectdb ("ntuple");
182    $results = $db->query ($query);
183    if ($results->numrows () == 1)
184      {
185        my @row = $results->fetchrow ();
186 <      return ($row[3], $row[4], $row[5], $row[6]);
186 >      return ($row[3], $row[4], $row[5], $row[7]) if $row[7];
187 >      return ($row[3], $row[4], $row[5], $row[6]) if !$row[7];
188      }
189    if ($results->numrows () == 0)
190      {
# Line 196 | Line 197 | getLocation
197    for (my $i = 1; $i <= $results->numrows (); $i++)
198      {
199        my @row = $results->fetchrow ();
200 <      $map{"$i"} = [$row[3], $row[4], $row[5], $row[6]];
200 >      $map{"$i"} = [$row[3], $row[4], $row[5], $row[7]] if $row[7];
201 >      $map{"$i"} = [$row[3], $row[4], $row[5], $row[6]] if !$row[7];
202        printf "(%2d) $row[0]\n", $i;
203        print "     created by $row[1] on $row[2]\n";
204      }
# Line 215 | Line 217 | getLocation
217   sub
218   outputCondor
219   {
220 +  my $condorFileName = shift;
221    my $workingDir = shift;
222    my $nJobs = shift;
223    my $dataset = shift;
224 +  my $label = shift;
225  
226    my $cmsRun = `which cmsRun`;
227 <  open (SUB, ">$workingDir/condor.sub");
227 >  my $condorFile = "";
228  
229 <  print SUB "Executable              = $cmsRun\n";
230 <  print SUB "Universe                = vanilla\n";
231 <  print SUB "Getenv                  = True\n";
232 <  print SUB "Arguments               = config_cfg.py True $nJobs \$(Process) $dataset\n" if $dataset;
233 <  print SUB "Arguments               = config_cfg.py True $nJobs \$(Process) NULL\n" if !$dataset;
234 <  print SUB "\n";
235 <  print SUB "Output                  = condor_\$(Process).out\n";
236 <  print SUB "Error                   = condor_\$(Process).err\n";
237 <  print SUB "Log                     = condor_\$(Process).log\n";
238 <  print SUB "\n";
239 <  print SUB "+IsLocalJob             = true\n";
240 <  print SUB "Rank                    = TARGET.IsLocalSlot\n";
241 <  print SUB "\n";
242 <  print SUB "Queue $nJobs\n";
229 >  if (!(-e $condorFileName))
230 >    {
231 >      my $arguments = "Arguments               = config_cfg.py True $nJobs \$(Process)";
232 >      $arguments += " $dataset" if $dataset;
233 >      $arguments += " NULL" if !$dataset;
234 >      $arguments += " $label" if $label;
235 >      $arguments += " NULL" if !$label;
236 >      $arguments += "\n";
237 >
238 >      $condorFile .= "Executable              = $cmsRun\n";
239 >      $condorFile .= "Universe                = vanilla\n";
240 >      $condorFile .= "Getenv                  = True\n";
241 >      $condorFile .= $arguments;
242 >      $condorFile .= "\n";
243 >      $condorFile .= "Output                  = condor_\$(Process).out\n";
244 >      $condorFile .= "Error                   = condor_\$(Process).err\n";
245 >      $condorFile .= "Log                     = condor_\$(Process).log\n";
246 >      $condorFile .= "\n";
247 >      $condorFile .= "+IsLocalJob             = true\n";
248 >      $condorFile .= "Rank                    = TARGET.IsLocalSlot\n";
249 >      $condorFile .= "\n";
250 >      $condorFile .= "Queue $nJobs\n";
251 >    }
252 >  else
253 >    {
254 >      open (SUB, "<$condorFileName");
255 >      my @condorFile = <SUB>;
256 >      close (SUB);
257 >      $condorFile = join ("", @condorFile);
258 >      $condorFile =~ s/\$cmsRun/$cmsRun/g;
259 >      $condorFile =~ s/\$nJobs/$nJobs/g;
260 >      $condorFile =~ s/\$dataset/$dataset/g if $dataset;
261 >      $condorFile =~ s/\$dataset/NULL/g if !$dataset;
262 >      $condorFile =~ s/\$label/$label/g if $label;
263 >      $condorFile =~ s/\$label/NULL/g if !$label;
264 >    }
265  
266 +  open (SUB, ">$workingDir/condor.sub");
267 +  print SUB $condorFile;
268    close (SUB);
269   }
270  
# Line 250 | Line 278 | printHelp
278    print "Submits CMSSW jobs to the OSU Tier 3 compute nodes using Condor.\n";
279    print "\n";
280    printf "%-29s%s\n", "  -h, --help", "print this help message";
281 +  printf "%-29s%s\n", "  -l, --label LABEL", "give the dataset a short label";
282    printf "%-29s%s\n", "  -m, --maxEvents N", "only run over N events in the dataset; default is";
283    printf "%-29s%s\n", " ", "to run over all events";
284    print "\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines