All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PmaElement3D.h
Go to the documentation of this file.
1 /**
2  * @file PmaElement3D.h
3  *
4  * @author D.Stefan and R.Sulej
5  *
6  * @brief Implementation of the Projection Matching Algorithm
7  *
8  * Base for 3D segments and track nodes. See PmaTrack3D.h file for details.
9  * See PmaTrack3D.h file for details.
10  */
11 
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 {
26  class Element3D;
27  class Hit3D;
28  class Track3D;
29 }
30 
32 {
33 public:
34  /// TPC index or -1 if out of any TPC.
35  int TPC(void) const { return fTPC; }
36  /// Cryostat index or -1 if out of any cryostat.
37  int Cryo(void) const { return fCryo; }
38 
39  /// Distance [cm] from the 3D point to the object 3D.
40  virtual double GetDistance2To(const TVector3& p3d) const = 0;
41 
42  /// Distance [cm] from the 2D point to the object's 2D projection in one of wire views.
43  virtual double GetDistance2To(const TVector2& p2d, unsigned int view) const = 0;
44 
45  /// Get 3D direction cosines corresponding to this element.
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) { if (h == a) return true; }
60  return false;
61  }
62 
63  pma::Hit3D& Hit(size_t index) { return *(fAssignedHits[index]); }
64  void RemoveHitAt(size_t index)
65  {
66  if (index < fAssignedHits.size())
67  fAssignedHits.erase(fAssignedHits.begin() + index);
68  }
70  {
71  fAssignedHits.push_back(h);
72  SetProjection(*h);
73  }
74 
75  size_t NHits(void) const { return fAssignedHits.size(); }
76  size_t NEnabledHits(unsigned int view = geo::kUnknown) const;
77  size_t NPrecalcEnabledHits(void) const { return fNThisHitsEnabledAll; }
78 
79  TVector3 const & ReferencePoint(size_t index) const { return *(fAssignedPoints[index]); }
80  size_t NPoints(void) const { return fAssignedPoints.size(); }
81  void AddPoint(TVector3* p) { fAssignedPoints.push_back(p); }
82 
83  /// Clear hits/points vectors of this element, optionally only
84  /// those which are owned by given track.
85  virtual void ClearAssigned(pma::Track3D* trk = 0);
86 
87  void UpdateHitParams(void);
88  void UpdateProjection(void) { for (auto h : fAssignedHits) SetProjection(*h); }
89  void SortHits(void);
90 
91  double SumDist2(void) const;
92  double SumDist2(unsigned int view) const;
93  double SumHitsQ(unsigned int view) const { return fSumHitsQ[view]; }
94  unsigned int NHits(unsigned int view) const { return fNHits[view]; }
95  unsigned int NThisHits(unsigned int view) const { return fNThisHits[view]; }
96 
97  double HitsRadius3D(unsigned int view) const;
98 
99  /// Check if the vertex 3D position is fixed.
100  bool IsFrozen(void) const { return fFrozen; }
101  /// Fix / relese vertex 3D position.
102  void SetFrozen(bool state) { fFrozen = state; }
103 
104  bool SelectRndHits(size_t nmax_per_view);
105  bool SelectAllHits(void);
106 
107  static float OptFactor(unsigned int view) { return fOptFactors[view]; }
108  static void SetOptFactor(unsigned int view, float value) { fOptFactors[view] = value; }
109 
110 protected:
111  Element3D(void); // Element3D is only a common base for nodes and segments
112  int fTPC, fCryo; // -1 if out of any TPC or cryostat
113 
114  virtual double SumDist2Hits(void) const = 0;
115 
116  bool fFrozen;
117  std::vector< pma::Hit3D* > fAssignedHits; // 2D hits
118  std::vector< TVector3* > fAssignedPoints; // 3D peculiar points reconstructed elsewhere
119  size_t fNThisHits[3];
121  size_t fNHits[3];
122  double fSumHitsQ[3];
123  double fHitsRadius;
124 
125  static float fOptFactors[3]; // impact factors of data from various 2D views
126 };
127 
128 #endif
size_t NPrecalcEnabledHits(void) const
Definition: PmaElement3D.h:77
unsigned int NHits(unsigned int view) const
Definition: PmaElement3D.h:94
double fSumHitsQ[3]
Definition: PmaElement3D.h:122
bool HasHit(const pma::Hit3D *h) const
Definition: PmaElement3D.h:57
virtual void SetProjection(pma::Hit3D &h) const =0
void RemoveHitAt(size_t index)
Definition: PmaElement3D.h:64
static void SetOptFactor(unsigned int view, float value)
Definition: PmaElement3D.h:108
Unknown view.
Definition: geo_types.h:136
void AddPoint(TVector3 *p)
Definition: PmaElement3D.h:81
virtual double SumDist2Hits(void) const =0
pdgs p
Definition: selectors.fcl:22
virtual double Length2(void) const =0
size_t fNThisHits[3]
Definition: PmaElement3D.h:119
double SumHitsQ(unsigned int view) const
Definition: PmaElement3D.h:93
recob::tracking::Vector_t Vector3D
double HitsRadius3D(unsigned int view) const
virtual void ClearAssigned(pma::Track3D *trk=0)
process_name gaushit a
int TPC(void) const
TPC index or -1 if out of any TPC.
Definition: PmaElement3D.h:35
while getopts h
size_t NPoints(void) const
Definition: PmaElement3D.h:80
virtual double GetDistance2To(const TVector3 &p3d) const =0
Distance [cm] from the 3D point to the object 3D.
size_t fNHits[3]
Definition: PmaElement3D.h:121
const std::vector< pma::Hit3D * > & Hits(void) const
Definition: PmaElement3D.h:55
std::vector< TVector3 * > fAssignedPoints
Definition: PmaElement3D.h:118
void SetFrozen(bool state)
Fix / relese vertex 3D position.
Definition: PmaElement3D.h:102
std::vector< pma::Hit3D * > fAssignedHits
Definition: PmaElement3D.h:117
pma::Hit3D & Hit(size_t index)
Definition: PmaElement3D.h:63
virtual pma::Vector3D GetDirection3D(void) const =0
Get 3D direction cosines corresponding to this element.
static float fOptFactors[3]
Definition: PmaElement3D.h:125
Definition of data types for geometry description.
double SumDist2(void) const
virtual TVector3 GetUnconstrainedProj3D(const TVector2 &p2d, unsigned int view) const =0
unsigned int NThisHits(unsigned int view) const
Definition: PmaElement3D.h:95
int Cryo(void) const
Cryostat index or -1 if out of any cryostat.
Definition: PmaElement3D.h:37
void UpdateProjection(void)
Definition: PmaElement3D.h:88
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:100
size_t fNThisHitsEnabledAll
Definition: PmaElement3D.h:120
TVector3 const & ReferencePoint(size_t index) const
Definition: PmaElement3D.h:79
double fHitsRadius
Definition: PmaElement3D.h:123
void AddHit(pma::Hit3D *h)
Definition: PmaElement3D.h:69
void UpdateHitParams(void)
temporary value
bool SelectAllHits(void)
size_t NHits(void) const
Definition: PmaElement3D.h:75
double Length(void) const
Definition: PmaElement3D.h:53
size_t NEnabledHits(unsigned int view=geo::kUnknown) const
static float OptFactor(unsigned int view)
Definition: PmaElement3D.h:107