Dumbbench
view release on metacpan or search on metacpan
simulator/lib/Dumbbench/Sim.pm view on Meta::CPAN
# This is just to create a pretty graph
sub show_plots {
my $self = shift;
my $cfg = $self->config;
$gStyle->SetFrameFillColor(kWhite);
$gStyle->SetPadColor(kWhite);
$gStyle->SetCanvasColor(kWhite);
$gStyle->SetFrameBorderMode(0);
$gStyle->SetCanvasBorderMode(0);
$gStyle->SetFillStyle(0);
# display distributions
my $hist = TH1D->new(
"base_dist", "timing distribution MC",
$cfg->hist_bins+0., $cfg->hist_min+0., $cfg->hist_max+0.
);
$hist->Fill($_) for @{$self->stats->data};
$hist->SetTitle("timing distribution MC;time [s];#");
$hist->SetStats(kFALSE);
my $good_hist = TH1D->new(
"good_dist", "accepted",
$cfg->hist_bins+0., $cfg->hist_min+0., $cfg->hist_max+0.
);
$good_hist->Fill($_) for @{$self->stats_good->data};
$good_hist->SetLineColor(kRed);
my $outlier_hist = TH1D->new(
"outlier_dist", "rejected",
$cfg->hist_bins+0., $cfg->hist_min+0., $cfg->hist_max+0.
);
$outlier_hist->Fill($_) for @{$self->stats_outliers->data};
$outlier_hist->SetLineColor(kBlue);
my $res_before = $self->ev_before->raw_number;
my $err_before = $self->ev_before->raw_error->[0];
my $res_after = $self->ev_after->raw_number;
my $err_after = $self->ev_after->raw_error->[0];
my $max_y = $hist->GetMaximum();
my $before = TGraphErrors->new(1, [$res_before*1.0], [$max_y*0.5], [$err_before*1.0], [0.]);
my $after = TGraphErrors->new(1, [$res_after*1.0], [$max_y*0.5], [$err_after*1.0], [0.]);
$before->SetTitle("Expect. Val (before)");
$after->SetTitle("Expect. Val (after)");
$before->SetMarkerColor(38);
$before->SetLineColor(38);
$after->SetMarkerColor(kCyan);
$after->SetLineColor(kCyan);
$_->SetMarkerStyle(21), $_->SetMarkerSize(0.8) for $before;
$_->SetMarkerStyle(20), $_->SetMarkerSize(0.7) for $after;
$_->SetFillColor(0), $_->SetFillStyle(0) for ($before, $after);
my $cv = TCanvas->new("cv");
$hist->Draw();
$good_hist->Draw("SAME");
$outlier_hist->Draw("SAME");
$_->Draw("P") for ($before, $after);
my $legend = $cv->BuildLegend();
$legend->SetShadowColor(0);
$legend->SetLineColor(0);
$cv->Update();
$gApplication->Run();
}
1;
( run in 1.719 second using v1.01-cache-2.11-cpan-39bf76dae61 )