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