Created
July 17, 2011 14:33
-
-
Save tsee/1087648 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; use warnings; | |
use Math::SimpleHisto::XS; | |
use SOOT qw/:all/; | |
my $nbins = 10000; | |
my $starttime = -7200.; | |
my $endtime = 0.; | |
my $hs = Math::SimpleHisto::XS->new(nbins => $nbins, min => $starttime, max => $endtime); | |
my @data = ( | |
# end time, duration, number of records | |
[-5009, 523, 200], | |
[-4002, 1123, 500], | |
[-4533, 222, 100], | |
[-3111, 2511, 3000], | |
); | |
foreach my $d (@data) { | |
my ($end, $dur, $n)= @$d; | |
my $start = $end-$dur; | |
my $rate = $n/$dur; | |
my $lowbin = $hs->find_bin($start); | |
warn "$start $lowbin"; | |
my $highbin = $hs->find_bin($end); | |
my $nbins_inrange = $highbin-$lowbin+1; | |
$hs->fill([map $hs->bin_center($_), ($lowbin .. $highbin)], [($rate) x $nbins_inrange]); | |
} | |
my $h = TH1D->new("h","h", $nbins, $starttime, $endtime)->keep; | |
$h->SetTitle(";Time [seconds];rate [records/second]"); | |
$h->Fill($hs->bin_center($_), $hs->bin_content($_)) for 0..$hs->nbins-1; | |
my $c=TCanvas->new->keep; | |
$h->Draw; | |
$gApplication->Run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment