ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtHitClusterFull.cxx
Go to the documentation of this file.
1 #include "AtHitClusterFull.h"
2 
3 #include <Math/Point3D.h> // for PositionVector3D
4 #include <TError.h> // for Error
5 #include <TMatrixTSym.h> // for TMatrixTSym
6 #include <TMatrixTUtils.h> // for TMatrixTRow
7 
8 #include <algorithm> // for max
9 #include <array> // for array
10 
12 {
14  fHits.push_back(hit);
15 }
16 
18 {
19  XYZPoint pos{0, 0, 0};
20  for (auto &hit : fHits) {
21  auto hitPos = hit.GetPosition();
22  pos.SetCoordinates(pos.X() + hitPos.X(), pos.Y() + hitPos.Y(), pos.Z() + hitPos.Z());
23  }
24  return pos / fHits.size();
25 }
26 
28 {
29  TMatrixDSym cov{3};
30  cov.Zero();
31 
32  std::array<double, 3> pos{}, hitPos{};
33  GetPositionUnWeighted().GetCoordinates(pos.begin());
34  for (const auto &hit : fHits) {
35  hit.GetPosition().GetCoordinates(hitPos.begin());
36 
37  for (int i = 0; i < 3; ++i)
38  for (int j = 0; j < 3; ++j)
39  cov[i][j] += (hitPos[i] - pos[i]) * (hitPos[j] - pos[j]) / (fClusterSize - 1);
40  }
41 
42  return cov;
43 }
44 
46 {
47  TMatrixDSym cov{3};
48  cov.Zero();
49 
50  std::array<double, 3> pos{}, hitPos{};
51  fPositionCharge.GetCoordinates(pos.begin());
52  for (const auto &hit : fHits) {
53  hit.GetPosition().GetCoordinates(hitPos.begin());
54 
55  for (int i = 0; i < 3; ++i)
56  for (int j = 0; j < 3; ++j)
57  cov[i][j] += hit.GetCharge() * (hitPos[i] - pos[i]) * (hitPos[j] - pos[j]) / (fCharge - 1);
58  }
59 
60  return cov;
61 }
62 
64 {
65  TMatrixDSym cov{3};
66  cov.Zero();
67 
68  std::array<double, 3> pos{}, hitPos{};
69  fPosition.GetCoordinates(pos.begin());
70  for (const auto &hit : fHits) {
71  hit.GetPosition().GetCoordinates(hitPos.begin());
72 
73  for (int i = 0; i < 3; ++i)
74  for (int j = 0; j < 3; ++j)
75  cov[i][j] += hit.GetCharge() * (hitPos[i] - pos[i]) * (hitPos[j] - pos[j]) / (fCharge - 1);
76  }
77 
78  return cov;
79 }
AtHit::XYZPoint
ROOT::Math::XYZPoint XYZPoint
Definition: AtHit.h:29
AtHitClusterFull.h
AtHitClusterFull::GetCovMatrixCharge
TMatrixDSym GetCovMatrixCharge() const
Definition: AtHitClusterFull.cxx:45
AtHitCluster::fPositionCharge
XYZPoint fPositionCharge
Definition: AtHitCluster.h:52
AtHitClusterFull::GetCovMatrixFull
TMatrixDSym GetCovMatrixFull() const
Definition: AtHitClusterFull.cxx:63
AtHit::fPosition
XYZPoint fPosition
Definition: AtHit.h:36
AtHit::fCharge
Double_t fCharge
Definition: AtHit.h:31
AtHitClusterFull::GetPositionUnWeighted
XYZPoint GetPositionUnWeighted() const
Definition: AtHitClusterFull.cxx:17
AtHitClusterFull::GetCovMatrixNoWeight
TMatrixDSym GetCovMatrixNoWeight() const
Definition: AtHitClusterFull.cxx:27
AtHitCluster::AddHit
virtual void AddHit(const AtHit &hit)
Add hit to cluster.
Definition: AtHitCluster.cxx:52
AtHitClusterFull::AddHit
virtual void AddHit(const AtHit &hit) override
Add hit to cluster.
Definition: AtHitClusterFull.cxx:11
AtHitClusterFull::fHits
std::vector< AtHit > fHits
Definition: AtHitClusterFull.h:40
AtHitCluster::fClusterSize
Int_t fClusterSize
Definition: AtHitCluster.h:57
AtHit
Point in space with charge.
Definition: AtHit.h:27