Skip to content

Commit 5fef641

Browse files
author
Daniel Abercrombie
authored
Merge pull request #132 from dabercro/stats
Dump Stats
2 parents 1649272 + 3e66a2c commit 5fef641

2 files changed

Lines changed: 59 additions & 6 deletions

File tree

RelVal/bin/testpanda.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#define PROG_SIZE 100
2-
#define DEFAULT_BINS 50
3-
4-
#define MINMAX 1e10
5-
61
#include <cstdlib>
72
#include <ctime>
83
#include <fstream>
@@ -27,6 +22,15 @@
2722
#include "PandaTree/RelVal/interface/EnumerateBranches.h"
2823
#include "PandaTree/RelVal/interface/TemplateMagic.h"
2924

25+
// Constants
26+
27+
namespace {
28+
constexpr int PROG_SIZE = 100;
29+
constexpr int DEFAULT_BINS = 50;
30+
31+
constexpr float MINMAX = 1e10;
32+
}
33+
3034
using namespace testpanda;
3135

3236
bool exists(const char* path) {
@@ -48,6 +52,7 @@ void draw_progress(int percent) {
4852
std::cout << ' ';
4953
}
5054
std::cout << "] " << percent * 100/PROG_SIZE << '%';
55+
std::flush(std::cout);
5156
}
5257

5358

@@ -373,11 +378,19 @@ int main(int argc, char** argv) {
373378

374379
// Check if only a single value was filled, and flag as potential bad filling.
375380
if (maximums[index].first == minimums[index].first) {
376-
std::ofstream flag_file((output_dir + "/" + branch_name + "_FLAG.txt"));
381+
std::ofstream flag_file(output_dir + "/" + branch_name + "_FLAG.txt");
377382
flag_file << maximums[index].first;
378383
flag_file.close();
379384
}
380385

386+
// Dump stats for some other diff tool to compare two directories
387+
std::ofstream stat_file(output_dir + "/" + branch_name + "_STATS.txt");
388+
stat_file << "Entries : " << histograms[index].GetEntries() << std::endl;
389+
stat_file << "Mean : " << histograms[index].GetMean() << std::endl;
390+
stat_file << "Std Dev : " << histograms[index].GetStdDev() << std::endl;
391+
stat_file << "Max : " << maximums[index].first << std::endl;
392+
stat_file << "Min : " << minimums[index].first << std::endl;
393+
stat_file.close();
381394
}
382395
};
383396

RelVal/scripts/comparepanda.pl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
use v5.10;
6+
use File::Compare;
7+
8+
my $fst_dir = shift || die "Need to specify two directories to compare to.";
9+
my $snd_dir = shift || die "Need to specify two directories to compare to.";
10+
11+
my $suff = "_STATS.txt";
12+
13+
my @fst_files = <$fst_dir/*/*$suff>;
14+
my @snd_files = <$snd_dir/*/*$suff>;
15+
16+
my $bad_matches = 0;
17+
18+
for (@fst_files) {
19+
my ($end) = $_ =~ m|(/[^/]+/[^/]+$suff)$|;
20+
my ($match) = grep { $_ =~ m/${end}$/ } @snd_files;
21+
22+
if ($match) {
23+
if (compare($_, $match)) {
24+
say "$end is different!";
25+
`diff $_ $match`;
26+
$bad_matches += 1;
27+
}
28+
}
29+
else {
30+
say "No file $snd_dir$end";
31+
$bad_matches += 1;
32+
}
33+
}
34+
35+
if ($bad_matches) {
36+
say "$bad_matches files don't match...";
37+
exit 1;
38+
}
39+
40+
say "All files match!";

0 commit comments

Comments
 (0)