1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#ifndef __PHISTOGRAM_H__ |
8 |
|
|
#define __PHISTOGRAM_H__ |
9 |
|
|
|
10 |
|
|
#include <iostream> |
11 |
|
|
#include <fstream> |
12 |
|
|
|
13 |
|
|
///@brief Abstract Histogram |
14 |
|
|
template<typename T> |
15 |
|
|
class PHistogram{ |
16 |
|
|
public: |
17 |
|
|
PHistogram(size_t nbValue = 0); |
18 |
|
|
PHistogram(T min, T max, size_t nbValue = 0); |
19 |
|
|
PHistogram(const PHistogram<T> & other); |
20 |
|
|
virtual ~PHistogram(); |
21 |
|
|
|
22 |
|
|
bool save(const std::string & fileName) const; |
23 |
|
|
void resize(size_t nbValue); |
24 |
|
|
void setRange(T min, T max); |
25 |
|
|
void reset(); |
26 |
|
|
|
27 |
|
|
void checkLogValue(T lowValue); |
28 |
|
|
|
29 |
|
|
void addValue(T value); |
30 |
|
|
void addValue(const T * tabValue, size_t nbValues); |
31 |
|
|
void setValueRange(const T * tabValue, size_t nbValues); |
32 |
|
|
void addAmplitude(T value, T amplitude); |
33 |
|
|
void loadBins(const T* tabValues, size_t nbValues); |
34 |
|
|
|
35 |
|
|
void normalize(); |
36 |
|
|
|
37 |
|
|
size_t getUnderXMin() const; |
38 |
|
|
size_t getOverXMax() const; |
39 |
|
|
|
40 |
|
|
T getMin() const; |
41 |
|
|
T getMax() const; |
42 |
|
|
T getRange() const; |
43 |
|
|
|
44 |
|
|
PHistogram operator = (const PHistogram<T> & other); |
45 |
|
|
|
46 |
|
|
///Print the Histogram |
47 |
|
|
/** @param out : output stream |
48 |
|
|
* @param other : PHistogram |
49 |
|
|
* @return output stream |
50 |
|
|
*/ |
51 |
|
9 |
friend std::ostream & operator << (std::ostream & out, const PHistogram<T> & other){ |
52 |
|
9 |
out << "PHistogram[" << other.p_nbValue; |
53 |
|
9 |
out <<"]("; |
54 |
✓✓ |
9 |
if(other.p_nbValue != 0lu){ |
55 |
|
7 |
out << other.p_value[0]; |
56 |
✓✓ |
7 |
if(other.p_nbValue > 1){ |
57 |
✓✓ |
80 |
for(size_t i(1); i < other.p_nbValue; ++i){ |
58 |
|
74 |
out << ", " << other.p_value[i]; |
59 |
|
|
} |
60 |
|
|
} |
61 |
|
|
} |
62 |
|
9 |
out << ")"; |
63 |
|
9 |
return out; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
protected: |
67 |
|
|
void initialisationPHistogram(); |
68 |
|
|
void allocateHist(size_t nbValue); |
69 |
|
|
void copyPHistogram(const PHistogram<T> & other); |
70 |
|
|
|
71 |
|
|
///Number of values of the PHistogram |
72 |
|
|
size_t p_nbValue; |
73 |
|
|
///Table of values of the histogram |
74 |
|
|
T * p_value; |
75 |
|
|
///Intervalle des valeurs des bins de l'histogramme |
76 |
|
|
T p_xRange; |
77 |
|
|
///borne minimale de l'hitogramme |
78 |
|
|
T p_xMin; |
79 |
|
|
///borne maximale de l'hitogramme |
80 |
|
|
T p_xMax; |
81 |
|
|
///Nombre de tir dans l'histogramme |
82 |
|
|
size_t p_nbTirIn; |
83 |
|
|
///number of hit under p_xMin |
84 |
|
|
size_t p_underXMin; |
85 |
|
|
///number of hit over p_xMax |
86 |
|
|
size_t p_overXMax; |
87 |
|
|
}; |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
#include "PHistogram_impl.h" |
91 |
|
|
|
92 |
|
|
#endif |
93 |
|
|
|