/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/CentroidCalculator.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/CentroidCalculator.hh Source File
Ratpac-two
CentroidCalculator.hh
1 
12 #ifndef __RAT_CentroidCalculator__
13 #define __RAT_CentroidCalculator__
14 #include <TVector3.h>
15 #include <math.h>
16 
17 namespace RAT {
18 
20  public:
23 
25  void Reset() {
26  fMoment0 = 0.0;
27  fMoment1.SetXYZ(0.0, 0.0, 0.0);
28  fMoment2.SetXYZ(0.0, 0.0, 0.0);
29  };
30 
32  void Fill(const TVector3 &point, double weight = 1.0) {
33  fMoment0 += weight;
34  fMoment1 += weight * point;
35  TVector3 square(point.X() * point.X(), point.Y() * point.Y(), point.Z() * point.Z());
36  fMoment2 += weight * square;
37  };
38 
40  void Add(const CentroidCalculator &other) {
41  fMoment0 += other.fMoment0;
42  fMoment1 += other.fMoment1;
43  fMoment2 += other.fMoment2;
44  };
45 
47  TVector3 GetMean() const { return fMoment1 * (1.0 / fMoment0); };
48 
50  TVector3 GetRMS() const {
51  TVector3 squareMoment1(fMoment1.X() * fMoment1.X(), fMoment1.Y() * fMoment1.Y(), fMoment1.Z() * fMoment1.Z());
52  TVector3 temp = fMoment0 * fMoment2 - squareMoment1;
53 
54  return TVector3(sqrt(temp.X()), sqrt(temp.Y()), sqrt(temp.Z())) * (1.0 / fMoment0);
55  };
56 
57  protected:
58  double fMoment0;
59  TVector3 fMoment1;
60  TVector3 fMoment2;
61 };
62 
63 } // namespace RAT
64 
65 #endif
Definition: CentroidCalculator.hh:19
void Fill(const TVector3 &point, double weight=1.0)
Definition: CentroidCalculator.hh:32
void Reset()
Definition: CentroidCalculator.hh:25
CentroidCalculator()
Definition: CentroidCalculator.hh:22
void Add(const CentroidCalculator &other)
Definition: CentroidCalculator.hh:40
TVector3 GetMean() const
Definition: CentroidCalculator.hh:47
TVector3 GetRMS() const
Definition: CentroidCalculator.hh:50
Definition: CCCrossSecMessenger.hh:29