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

Comparing UserCode/OSUT3Analysis/AnaTools/scripts/mergeHists (file contents):
Revision 1.24 by ahart, Fri Apr 12 05:18:05 2013 UTC vs.
Revision 1.27 by ahart, Tue Jun 18 02:00:39 2013 UTC

# Line 8 | Line 8 | sub processArgs;
8   sub printHelp;
9   sub getRunList;
10   sub countEvents;
11 + sub isEDM;
12  
13   my %opt;
14   Getopt::Long::Configure ("bundling");
# Line 83 | Line 84 | foreach my $file (@$files)
84      $dir =~ s/^(.*)\/[^\/]*$/$1/;
85      my $badJob = 0;
86      my $jobNumber;
87 <    if ($file =~ m/^.*_[^_]*\.root$/)
87 >    my $fileIsEDM = 0;
88 >    $fileIsEDM = isEDM ($file) if $file =~ m/^.*\.root$/;
89 >    if ($file =~ m/^.*_[^_]*\.root$/ && !$fileIsEDM)
90        {
91          $jobNumber = $file;
92          $jobNumber =~ s/^.*_([^_]*)\.root$/$1/;
93          $badJob = (defined $signals{$dir} && defined $signals{$dir}{$jobNumber}) || (defined $partial{$dir} && defined $partial{$dir}{$jobNumber});
94        }
95      next if $badJob;
96 <    if ($file =~ m/^.*\.root$/)
96 >    if ($file =~ m/^.*\.root$/ && !$fileIsEDM)
97        {
98          foreach my $arg (@ARGV)
99            {
# Line 141 | Line 144 | foreach my $arg (@ARGV)
144      $weights{$arg} /= $count if !$opt{"weight"} && !$opt{"xsection"} && defined $crossSections{$dirs{$arg}};
145      push (@mergedFiles, $tmpName);
146      push (@mergedWeights, $weights{$arg});
147 +    foreach my $rootFile (@{$rootFiles{$arg}})
148 +      {
149 +        my $weight = $weights{$arg};
150 +        system ("weightTrees $rootFile $weight");
151 +      }
152 +    if (defined $crossSections{$dirs{$arg}})
153 +      {
154 +        open (EVENT_COUNT, ">$dirs{$arg}/numberOfEvents.txt");
155 +        print EVENT_COUNT sprintf ("%.0f", $count) . "\n";
156 +        close (EVENT_COUNT);
157 +      }
158    }
159   my $mergedFiles = join (" ", @mergedFiles);
160   my $mergedWeights = join (",", @mergedWeights);
# Line 185 | Line 199 | foreach my $arg (keys %weights)
199   print $output if $printOutput;
200  
201   my $goodEvents = countEvents ("$opt{'prefix'}.root", $cutFlow);
202 < print "$nGoodJobs jobs ran successfully over $nTotalEvents ($goodEvents weighted) events.\n" if $counting;
202 > printf "$nGoodJobs jobs ran successfully over $nTotalEvents (%.1f weighted) events.\n", $goodEvents if $counting;
203   print "$nBadJobs jobs failed to run.\n" if $counting;
204   print "$nIncompleteJobs jobs have not finished.\n" if $counting;
205   print "=============================================\n";
# Line 291 | Line 305 | countEvents
305  
306    return $output;
307   }
308 +
309 + sub
310 + isEDM
311 + {
312 +  my $file = shift;
313 +
314 +  my $output = `edmFileUtil $file 2>&1`;
315 +  return 0 if $output =~ m/appears to be missing/ || $output =~ m/not a ROOT file/;
316 +  return 1;
317 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines