21 |
|
my $nBadJobs = 0; |
22 |
|
my $counting = 0; |
23 |
|
my %exitCodes; |
24 |
+ |
my %signals; |
25 |
|
my %crossSections; |
26 |
|
my $integratedLuminosity = 10000; |
27 |
|
$integratedLuminosity = $opt{"luminosity"} if $opt{"luminosity"}; |
42 |
|
close (FILE); |
43 |
|
my $fileContents = join ("", @fileContents); |
44 |
|
$fileContents =~ s/\n/ /g; |
45 |
< |
$fileContents =~ s/.*\(return value ([^)]*)\).*/$1/g; |
45 |
< |
$nGoodJobs++; |
46 |
< |
if ($fileContents != 0) |
45 |
> |
if ($fileContents =~ m/return value/) |
46 |
|
{ |
47 |
+ |
$fileContents =~ s/.*\(return value ([^)]*)\).*/$1/g; |
48 |
+ |
$nGoodJobs++; |
49 |
+ |
print "WARNING: Nonzero exit code for job $jobNumber. (return value $fileContents)\n" if $fileContents != 0; |
50 |
+ |
$exitCodes{$dir}{$jobNumber} = $fileContents; |
51 |
+ |
$counting = 1; |
52 |
+ |
} |
53 |
+ |
if ($fileContents =~ m/signal/) |
54 |
+ |
{ |
55 |
+ |
$fileContents =~ s/.*\(signal ([^)]*)\).*/$1/g; |
56 |
|
$nBadJobs++; |
57 |
< |
print "Skipping job $jobNumber. (return value $fileContents)\n"; |
57 |
> |
print "WARNING: Skipping job $jobNumber. (signal $fileContents)\n"; |
58 |
> |
$signals{$dir}{$jobNumber} = $fileContents; |
59 |
> |
$counting = 1; |
60 |
|
} |
51 |
– |
$exitCodes{$dir}{$jobNumber} = $fileContents; |
52 |
– |
$counting = 1; |
61 |
|
} |
62 |
|
if ($file =~ m/^.*\/crossSectionInPicobarn\.txt$/) |
63 |
|
{ |
78 |
|
{ |
79 |
|
my $jobNumber = $file; |
80 |
|
$jobNumber =~ s/^.*_([^_]*)\.root$/$1/; |
81 |
< |
$badJob = defined $exitCodes{$dir} && defined $exitCodes{$dir}{$jobNumber} && $exitCodes{$dir}{$jobNumber}; |
81 |
> |
$badJob = defined $signals{$dir} && defined $signals{$dir}{$jobNumber}; |
82 |
|
} |
83 |
|
next if $badJob; |
84 |
|
if ($file =~ m/^.*\.root$/) |
109 |
|
{ |
110 |
|
my $jobNumber = $file; |
111 |
|
$jobNumber =~ s/^.*_([^_]*)\.root$/$1/; |
112 |
< |
$badJob = defined $exitCodes{$dir} && defined $exitCodes{$dir}{$jobNumber} && $exitCodes{$dir}{$jobNumber}; |
112 |
> |
$badJob = defined $signals{$dir} && defined $signals{$dir}{$jobNumber}; |
113 |
|
} |
114 |
|
next if $badJob; |
115 |
|
if ($file =~ m/^.*\.root$/) |
122 |
|
} |
123 |
|
my $weights = join (",", @weights); |
124 |
|
system ("mergeTFileServiceHistograms -i $rootFiles -o $opt{'prefix'}.root -w $weights"); |
117 |
– |
system ("cutFlowTable $opt{'prefix'}.root $cutFlow >& $opt{'prefix'}.tex"); |
125 |
|
my $goodEvents = countEvents ("$opt{'prefix'}.root", $cutFlow); |
126 |
|
print "$nGoodJobs jobs ran successfully over $nTotalEvents ($goodEvents weighted) events.\n" if $counting; |
127 |
|
print "$nBadJobs jobs failed to run.\n" if $counting; |
169 |
|
$exeName =~ s/^.*\/([^\/]*)$/$1/; |
170 |
|
|
171 |
|
print "Usage: $exeName [OPTION]... -p PREFIX DIRECTORIES_AND_FILES\n"; |
172 |
< |
print "Merges ROOT files containing histograms and produces a cutflow table in the\n"; |
173 |
< |
print "form of a LaTeX document. If there are Condor logs in the specified\n"; |
174 |
< |
print "directories, checks for nonzero return values. If the directories where created\n"; |
175 |
< |
print "by \"osusub\", uses the cross section from the database to weight all histograms.\n"; |
172 |
> |
print "Merges ROOT files containing histograms. If there are Condor logs in the\n"; |
173 |
> |
print "specified directories, checks for nonzero return values. If the directories\n"; |
174 |
> |
print "where created by \"osusub\", uses the cross section from the database to weight\n"; |
175 |
> |
print "all histograms.\n"; |
176 |
|
print "\n"; |
177 |
|
print "Mandatory arguments to long options are mandatory for short options too.\n"; |
178 |
|
printf "%-29s%s\n", " -c, --cutflow HISTOGRAM", "name of histogram to use for the cutflow (default:"; |
180 |
|
printf "%-29s%s\n", " -h, --help", "print this help message"; |
181 |
|
printf "%-29s%s\n", " -l, --luminosity", "integrated luminosity to which the histograms are"; |
182 |
|
printf "%-29s%s\n", " ", "weighted (default: 10000/pb)"; |
183 |
< |
printf "%-29s%s\n", " -p, --prefix PREFIX", "output files are named PREFIX.root and PREFIX.tex"; |
183 |
> |
printf "%-29s%s\n", " -p, --prefix PREFIX", "output is named PREFIX.root"; |
184 |
|
printf "%-29s%s\n", " -w, --weight WEIGHT", "scale the output by WEIGHT, overriding the"; |
185 |
|
printf "%-29s%s\n", " ", "automatic weighting using the cross section from"; |
186 |
|
printf "%-29s%s\n", " ", "the database"; |