LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PmaElement3D.h
Go to the documentation of this file.
1 
12 #ifndef PmaElement3D_h
13 #define PmaElement3D_h
14 
15 #include <cmath>
16 #include <vector>
17 
20 
21 class TVector2;
22 #include "TVector3.h"
23 
24 namespace pma {
25  class Element3D;
26  class Hit3D;
27  class Track3D;
28 }
29 
31 public:
32  virtual ~Element3D();
33 
35  int TPC(void) const { return fTPC; }
37  int Cryo(void) const { return fCryo; }
38 
40  virtual double GetDistance2To(const TVector3& p3d) const = 0;
41 
43  virtual double GetDistance2To(const TVector2& p2d, unsigned int view) const = 0;
44 
46  virtual pma::Vector3D GetDirection3D(void) const = 0;
47 
48  virtual TVector3 GetUnconstrainedProj3D(const TVector2& p2d, unsigned int view) const = 0;
49 
50  virtual void SetProjection(pma::Hit3D& h) const = 0;
51 
52  virtual double Length2(void) const = 0;
53  double Length(void) const { return sqrt(Length2()); }
54 
55  const std::vector<pma::Hit3D*>& Hits(void) const { return fAssignedHits; }
56 
57  bool HasHit(const pma::Hit3D* h) const
58  {
59  for (const auto a : fAssignedHits) {
60  if (h == a) return true;
61  }
62  return false;
63  }
64 
65  pma::Hit3D& Hit(size_t index) { return *(fAssignedHits[index]); }
66  void RemoveHitAt(size_t index)
67  {
68  if (index < fAssignedHits.size()) fAssignedHits.erase(fAssignedHits.begin() + index);
69  }
70  void AddHit(pma::Hit3D* h)
71  {
72  fAssignedHits.push_back(h);
73  SetProjection(*h);
74  }
75 
76  size_t NHits(void) const { return fAssignedHits.size(); }
77  size_t NEnabledHits(unsigned int view = geo::kUnknown) const;
78  size_t NPrecalcEnabledHits(void) const { return fNThisHitsEnabledAll; }
79 
80  TVector3 const& ReferencePoint(size_t index) const { return *(fAssignedPoints[index]); }
81  size_t NPoints(void) const { return fAssignedPoints.size(); }
82  void AddPoint(TVector3* p) { fAssignedPoints.push_back(p); }
83 
86  virtual void ClearAssigned(pma::Track3D* trk = 0);
87 
88  void UpdateHitParams(void);
89  void UpdateProjection(void)
90  {
91  for (auto h : fAssignedHits)
92  SetProjection(*h);
93  }
94  void SortHits(void);
95 
96  double SumDist2(void) const;
97  double SumDist2(unsigned int view) const;
98  double SumHitsQ(unsigned int view) const { return fSumHitsQ[view]; }
99  unsigned int NHits(unsigned int view) const { return fNHits[view]; }
100  unsigned int NThisHits(unsigned int view) const { return fNThisHits[view]; }
101 
102  double HitsRadius3D(unsigned int view) const;
103 
105  bool IsFrozen(void) const { return fFrozen; }
107  void SetFrozen(bool state) { fFrozen = state; }
108 
109  bool SelectRndHits(size_t nmax_per_view);
110  bool SelectAllHits(void);
111 
112  static float OptFactor(unsigned int view) { return fOptFactors[view]; }
113  static void SetOptFactor(unsigned int view, float value) { fOptFactors[view] = value; }
114 
115 protected:
116  Element3D(void); // Element3D is only a common base for nodes and segments
117  int fTPC, fCryo; // -1 if out of any TPC or cryostat
118 
119  virtual double SumDist2Hits(void) const = 0;
120 
121  bool fFrozen;
122  std::vector<pma::Hit3D*> fAssignedHits; // 2D hits
123  std::vector<TVector3*> fAssignedPoints; // 3D peculiar points reconstructed elsewhere
124  size_t fNThisHits[3];
126  size_t fNHits[3];
127  double fSumHitsQ[3];
128  double fHitsRadius;
129 
130  static float fOptFactors[3]; // impact factors of data from various 2D views
131 };
132 
133 #endif
size_t NPrecalcEnabledHits(void) const
Definition: PmaElement3D.h:78
unsigned int NHits(unsigned int view) const
Definition: PmaElement3D.h:99
double fSumHitsQ[3]
Definition: PmaElement3D.h:127
bool HasHit(const pma::Hit3D *h) const
Definition: PmaElement3D.h:57
void RemoveHitAt(size_t index)
Definition: PmaElement3D.h:66
std::vector< TVector3 * > fAssignedPoints
Definition: PmaElement3D.h:123
static void SetOptFactor(unsigned int view, float value)
Definition: PmaElement3D.h:113
Unknown view.
Definition: geo_types.h:142
virtual TVector3 GetUnconstrainedProj3D(const TVector2 &p2d, unsigned int view) const =0
void AddPoint(TVector3 *p)
Definition: PmaElement3D.h:82
size_t fNThisHits[3]
Definition: PmaElement3D.h:124
virtual void SetProjection(pma::Hit3D &h) const =0
double SumHitsQ(unsigned int view) const
Definition: PmaElement3D.h:98
recob::tracking::Vector_t Vector3D
Definition: Utilities.h:34
double HitsRadius3D(unsigned int view) const
virtual double Length2(void) const =0
virtual void ClearAssigned(pma::Track3D *trk=0)
virtual pma::Vector3D GetDirection3D(void) const =0
Get 3D direction cosines corresponding to this element.
int TPC(void) const
TPC index or -1 if out of any TPC.
Definition: PmaElement3D.h:35
size_t NPoints(void) const
Definition: PmaElement3D.h:81
const std::vector< pma::Hit3D * > & Hits(void) const
Definition: PmaElement3D.h:55
size_t fNHits[3]
Definition: PmaElement3D.h:126
void SetFrozen(bool state)
Fix / relese vertex 3D position.
Definition: PmaElement3D.h:107
pma::Hit3D & Hit(size_t index)
Definition: PmaElement3D.h:65
static float fOptFactors[3]
Definition: PmaElement3D.h:130
Definition of data types for geometry description.
double SumDist2(void) const
double value
Definition: spectrum.C:18
std::vector< pma::Hit3D * > fAssignedHits
Definition: PmaElement3D.h:122
unsigned int NThisHits(unsigned int view) const
Definition: PmaElement3D.h:100
int Cryo(void) const
Cryostat index or -1 if out of any cryostat.
Definition: PmaElement3D.h:37
Implementation of the Projection Matching Algorithm.
void UpdateProjection(void)
Definition: PmaElement3D.h:89
void SortHits(void)
bool SelectRndHits(size_t nmax_per_view)
bool IsFrozen(void) const
Check if the vertex 3D position is fixed.
Definition: PmaElement3D.h:105
size_t fNThisHitsEnabledAll
Definition: PmaElement3D.h:125
TVector3 const & ReferencePoint(size_t index) const
Definition: PmaElement3D.h:80
double fHitsRadius
Definition: PmaElement3D.h:128
virtual double GetDistance2To(const TVector3 &p3d) const =0
Distance [cm] from the 3D point to the object 3D.
void AddHit(pma::Hit3D *h)
Definition: PmaElement3D.h:70
void UpdateHitParams(void)
bool SelectAllHits(void)
virtual double SumDist2Hits(void) const =0
size_t NHits(void) const
Definition: PmaElement3D.h:76
double Length(void) const
Definition: PmaElement3D.h:53
size_t NEnabledHits(unsigned int view=geo::kUnknown) const
virtual ~Element3D()
static float OptFactor(unsigned int view)
Definition: PmaElement3D.h:112