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.18 by ahart, Thu Jan 31 17:32:03 2013 UTC vs.
Revision 1.19 by ahart, Mon Feb 4 09:11:37 2013 UTC

# Line 46 | Line 46 | foreach my $file (@$files)
46          close (FILE);
47          my $fileContents = join ("", @fileContents);
48          $fileContents =~ s/\n/ /g;
49 +        $counting = 1;
50          if ($fileContents =~ m/return value/)
51            {
52              $fileContents =~ s/.*\(return value ([^)]*)\).*/$1/g;
53              $nGoodJobs++;
54              print "WARNING: Nonzero exit code for job $jobNumber. (return value $fileContents)\n" if $fileContents != 0;
55              $exitCodes{$dir}{$jobNumber} = $fileContents;
55            $counting = 1;
56            }
57          elsif ($fileContents =~ m/signal/)
58            {
# Line 60 | Line 60 | foreach my $file (@$files)
60              $nBadJobs++;
61              print "WARNING: Skipping job $jobNumber. (signal $fileContents)\n";
62              $signals{$dir}{$jobNumber} = $fileContents;
63            $counting = 1;
63            }
64          else
65            {
# Line 94 | Line 93 | foreach my $file (@$files)
93        {
94          foreach my $arg (@ARGV)
95            {
96 <            $dirs{$arg} = $dir;
98 <            if (substr ($file, 0, length ($arg)) eq $arg && countEvents ($file) >= 0)
96 >            if (substr ($file, 0, length ($arg)) eq $arg)
97                {
98 +                $dirs{$arg} = $dir;
99                  push (@{$rootFiles{$arg}}, $file);
100                  push (@weights, $opt{"weight"}) if $opt{"weight"};
101                  push (@weights, $opt{"xsection"} * $integratedLuminosity) if !$opt{"weight"} && $opt{"xsection"};
# Line 128 | Line 127 | foreach my $arg (@ARGV)
127      $nTotalEvents += $count;
128      $weights{$arg} /= $count if !$opt{"weight"} && $opt{"xsection"};
129      $weights{$arg} /= $count if !$opt{"weight"} && !$opt{"xsection"} && defined $crossSections{$dirs{$arg}};
130 <    push (@mergedFiles, "$tmpName");
130 >    push (@mergedFiles, $tmpName);
131      push (@mergedWeights, $weights{$arg});
132    }
133   my $mergedFiles = join (" ", @mergedFiles);
134   my $mergedWeights = join (",", @mergedWeights);
136 system ("mergeTFileServiceHistograms -i $mergedFiles -o $opt{'prefix'}_Unweighted.root");
135   system ("mergeTFileServiceHistograms -i $mergedFiles -o $opt{'prefix'}.root -w $mergedWeights");
136   foreach my $mergedFile (@mergedFiles)
137    {
138      unlink ("$mergedFile");
139    }
140 < my $output = sprintf "Weights:\n";
141 < my $printOutput = 0;
140 > print "=============================================\n";
141 > my $output = sprintf "Effective luminosities of samples:\n";
142 > my $printOutput = 1;
143   foreach my $arg (keys %weights)
144    {
145      my $shortArg = $arg;
146      $shortArg =~ s/^.*\/([^\/]*)$/$1/;
147 <    $output = sprintf "%s  $shortArg: %.5g (%.5g pb)\n", $output, $weights{$arg}, $weights{$arg} / $integratedLuminosity;
147 >    $output = sprintf "%s  $shortArg: %.5g/fb\n", $output, ($integratedLuminosity / (1000.0 * $weights{$arg}));
148 >  }
149 > print $output if $printOutput;
150 > $output = sprintf "Weights for target luminosity of %g/fb:\n", ($integratedLuminosity / 1000.0);
151 > $printOutput = 0;
152 > foreach my $arg (keys %weights)
153 >  {
154 >    my $shortArg = $arg;
155 >    $shortArg =~ s/^.*\/([^\/]*)$/$1/;
156 >    $output = sprintf "%s  $shortArg: %.5g\n", $output, $weights{$arg};
157      $printOutput = 1 if $weights{$arg} != 1;
158    }
159   print $output if $printOutput;
# Line 153 | Line 161 | my $goodEvents = countEvents ("$opt{'pre
161   print "$nGoodJobs jobs ran successfully over $nTotalEvents ($goodEvents weighted) events.\n" if $counting;
162   print "$nBadJobs jobs failed to run.\n" if $counting;
163   print "$nIncompleteJobs jobs have not finished.\n" if $counting;
164 + print "=============================================\n";
165  
166   sub
167   processArgs

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines