Particle Identification and Tracking
counted_vector.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 
26 #ifndef COUNTED_VECTOR
27 #define COUNTED_VECTOR
28 
29 #include <vector>
30 #include <string>
31 namespace utilities{
32 class Generic_wrapper;
33 class Md_store;
34 
42 public:
46  Counted_vector(int n_elements);
50  void add_to_element(int t, float val);
51 
55  void batch_add_to_element(int t, float val,int count);
56 
60  void output_to_wrapper(Generic_wrapper * out_wrapper,
61  std::string & g_name,
62  std::string & data_name,
63  std::string & count_name,
64  const Md_store* g_md_store
65  ) const;
66 
70  void print() const;
71 
75  void average_data();
76 
80  void unaverage_data();
81 
85  int get_length()const{return data_array_.size();}
86 
90  float get_val(int j)const
91  {
92  return data_array_.at(j);
93  }
97  int get_count(int j)const
98  {
99  return count_array_.at(j);
100  }
104  bool averaged() const
105  {
106  return averaged_;
107  }
108 
109 protected:
110 
114  std::vector<float> data_array_;
119  std::vector<int> count_array_;
124  bool averaged_;
125 
126 
127 };
128 
129 
130 }
131 
132 
133 
134 #endif