Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JWeight.hh
Go to the documentation of this file.
1#ifndef __JTOOLS__JWEIGHT__
2#define __JTOOLS__JWEIGHT__
3
4#include <cmath>
5
6#include "JLang/JTitle.hh"
7
8
9/**
10 * \author mdejong
11 */
12
13namespace JTOOLS {}
14namespace JPP { using namespace JTOOLS; }
15
16namespace JTOOLS {
17
18 using JLANG::JTitle;
19
20 /**
21 * Weight calculator.
22 */
23 class JWeight :
24 public JTitle
25 {
26 public:
27 /**
28 * Constructor.
29 *
30 * \param title title
31 */
32 JWeight(const JTitle& title = "") :
34 {
35 reset();
36 }
37
38
39 /**
40 * Reset.
41 */
42 void reset()
43 {
44 tot = 0.0;
45 err = 0.0;
46 num = 0;
47 }
48
49
50 /**
51 * Put weight.
52 *
53 * \param w weight
54 */
55 void put(const double w)
56 {
57 tot += w;
58 err += w*w;
59 num += 1;
60 }
61
62
63 /**
64 * Get total count.
65 *
66 * \return count
67 */
68 long long int getCount() const
69 {
70 return num;
71 }
72
73
74 /**
75 * Get total weight.
76 *
77 * \return weight
78 */
79 double getTotal() const
80 {
81 return tot;
82 }
83
84
85 /**
86 * Get total error.
87 *
88 * \return error
89 */
90 double getError() const
91 {
92 return sqrt(err);
93 }
94
95 protected:
96 double tot;
97 double err;
98 long long int num;
99 };
100}
101
102#endif
Auxiliary class for title.
Definition JTitle.hh:19
std::string title
Definition JTitle.hh:73
Weight calculator.
Definition JWeight.hh:25
double getError() const
Get total error.
Definition JWeight.hh:90
void put(const double w)
Put weight.
Definition JWeight.hh:55
long long int getCount() const
Get total count.
Definition JWeight.hh:68
long long int num
Definition JWeight.hh:98
void reset()
Reset.
Definition JWeight.hh:42
double getTotal() const
Get total weight.
Definition JWeight.hh:79
JWeight(const JTitle &title="")
Constructor.
Definition JWeight.hh:32
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.