Particle Identification and Tracking
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
common_src
include
histogram.h
Go to the documentation of this file.
1
//Copyright 2009 Thomas A Caswell
2
//tcaswell@uchicago.edu
3
//http://jfi.uchicago.edu/~tcaswell
4
//
5
//This program is free software; you can redistribute it and/or modify
6
//it under the terms of the GNU General Public License as published by
7
//the Free Software Foundation; either version 3 of the License, or (at
8
//your option) any later version.
9
//
10
//This program is distributed in the hope that it will be useful, but
11
//WITHOUT ANY WARRANTY; without even the implied warranty of
12
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
//General Public License for more details.
14
//
15
//You should have received a copy of the GNU General Public License
16
//along with this program; if not, see <http://www.gnu.org/licenses>.
17
//
18
//Additional permission under GNU GPL version 3 section 7
19
//
20
//If you modify this Program, or any covered work, by linking or
21
//combining it with MATLAB (or a modified version of that library),
22
//containing parts covered by the terms of MATLAB User License, the
23
//licensors of this Program grant you additional permission to convey
24
//the resulting work.
25
#ifndef HIST
26
#define HIST
27
28
#include <vector>
29
#include <exception>
30
#include <iostream>
31
32
namespace
gnuplot
33
{
34
class
Gnuplot;
35
}
36
37
namespace
utilities{
38
//forward declare
39
class
Generic_wrapper;
40
class
Md_store;
41
47
class
Histogram
{
48
public
:
53
template
<
class
T>
54
void
add_data_point
(T in);
55
59
std::vector<int>
get_bin_values
()
const
;
60
64
std::vector<float>
get_bin_edges
()
const
;
65
69
void
print
()
const
;
74
int
get_over_count
(){
75
return
over_count_
;
76
}
77
81
int
get_under_count
(){
82
return
under_count_
;
83
}
87
Histogram
(
int
num_bins,
float
bottom ,
float
top);
88
92
void
output_to_wrapper
(
Generic_wrapper
* wrapper_out,
93
const
std::string & g_name,
94
const
std::string & count_name,
95
const
std::string & edges_name,
96
const
Md_store
* g_md_store)
const
;
97
101
void
display
()
const
;
106
void
display
(gnuplot::Gnuplot & g)
const
;
107
108
109
110
~Histogram
(){};
111
112
protected
:
116
std::vector<int>
hist_array_
;
117
118
119
120
124
int
under_count_
;
125
129
int
over_count_
;
130
134
int
number_bins_
;
135
139
float
top_edge_
;
140
144
float
bottom_edge_
;
145
149
float
bin_width_
;
150
private
:
151
152
153
};
154
155
template
<
class
T>
156
void
Histogram::add_data_point
(T in){
157
using
std::cout;
158
using
std::endl;
159
float
tmp_in = (float) in;
160
if
(tmp_in <
bottom_edge_
){
161
++
under_count_
;
162
return
;
163
}
164
if
(tmp_in>=
top_edge_
){
165
++
over_count_
;
166
return
;
167
}
168
169
// ++(*(hist_array_ptr_ + ((int)((tmp_in - bottom_edge_)/bin_width_))));
170
// cout<<in<<"\t"<<((int)((tmp_in - bottom_edge_)/bin_width_))<<endl;
171
try
172
{
173
++
hist_array_
.at(((
unsigned
)((tmp_in -
bottom_edge_
)/
bin_width_
)));
174
}
175
catch
(std::exception & e)
176
{
177
cout<<e.what()<<endl;
178
cout<<tmp_in<<
"\t"
179
<<
bottom_edge_
<<
"\t"
180
<<
bin_width_
<<
"\t"
<<endl;
181
182
}
183
}
184
185
186
187
188
}
189
190
#endif
Generated on Tue Sep 10 2013 17:07:21 for Particle Identification and Tracking by
1.8.4