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 |
|
{ |
60 |
|
$nBadJobs++; |
61 |
|
print "WARNING: Skipping job $jobNumber. (signal $fileContents)\n"; |
62 |
|
$signals{$dir}{$jobNumber} = $fileContents; |
63 |
– |
$counting = 1; |
63 |
|
} |
64 |
|
else |
65 |
|
{ |
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"}; |
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; |
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 |