LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CBAlgoStartTrack.cxx
Go to the documentation of this file.
2 
3 namespace cmtool {
4 
5  //-------------------------------------------------------
7  //-------------------------------------------------------
8  {
9 
10  SetMinHits(10);
11  SetMinWidth(1.00000);
12  SetMinOpeningAngle(0.15000);
13  SetMinEP(0.99000);
14  SetDebug(false);
15  }
16 
17  //-----------------------------
19  //-----------------------------
20  {}
21 
22  //------------------------------------------------------------------------------------------
23  //void CBAlgoStartTrack::EventBegin(const std::vector<cluster::ClusterParamsAlg> &clusters)
24  //------------------------------------------------------------------------------------------
25  //{
26  //
27  //}
28 
29  //-------------------------------
30  //void CBAlgoStartTrack::EventEnd()
31  //-------------------------------
32  //{
33  //
34  //}
35 
36  //-----------------------------------------------------------------------------------------------
37  //void CBAlgoStartTrack::IterationBegin(const std::vector<cluster::ClusterParamsAlg> &clusters)
38  //-----------------------------------------------------------------------------------------------
39  //{
40  //
41  //}
42 
43  //------------------------------------
44  //void CBAlgoStartTrack::IterationEnd()
45  //------------------------------------
46  //{
47  //
48  //}
49 
50  //----------------------------------------------------------------
51  bool CBAlgoStartTrack::Bool(const ::cluster::ClusterParamsAlg& cluster1,
52  const ::cluster::ClusterParamsAlg& cluster2)
53  //----------------------------------------------------------------
54  {
55 
56  if (cluster1.GetHitVector().size() < _min_hits || cluster2.GetHitVector().size() < _min_hits)
57  return false;
58 
59  bool FirstTrackSecondBlob = false;
60  bool SecondTrackFirstBlob = false;
61 
62  if (IsStartTrack(cluster1) && IsOverlappingBlob(cluster2)) FirstTrackSecondBlob = true;
63  if (IsStartTrack(cluster2) && IsOverlappingBlob(cluster1)) SecondTrackFirstBlob = true;
64 
65  if (_debug) {
66  if (FirstTrackSecondBlob) {
67  std::cout << "*********************************************" << std::endl;
68  std::cout << "First track second blob! First has params:" << std::endl;
69  std::cout << "Angle 2D = " << cluster1.GetParams().angle_2d << std::endl;
70  std::cout << "Opening Angle = " << cluster1.GetParams().opening_angle << std::endl;
71  std::cout << "Sum charge = " << cluster1.GetParams().sum_charge << std::endl;
72  std::cout << "Length = " << cluster1.GetParams().length << std::endl;
73  std::cout << "Width = " << cluster1.GetParams().width << std::endl;
74  std::cout << "N_Hits = " << cluster1.GetHitVector().size() << std::endl;
75  std::cout << "eigenvalue_principal = " << cluster1.GetParams().eigenvalue_principal
76  << std::endl;
77  std::cout << "Second has params:" << std::endl;
78  std::cout << "Angle 2D = " << cluster2.GetParams().angle_2d << std::endl;
79  std::cout << "Opening Angle = " << cluster2.GetParams().opening_angle << std::endl;
80  std::cout << "Sum charge = " << cluster2.GetParams().sum_charge << std::endl;
81  std::cout << "Length = " << cluster2.GetParams().length << std::endl;
82  std::cout << "Width = " << cluster2.GetParams().width << std::endl;
83  std::cout << "N_Hits = " << cluster2.GetHitVector().size() << std::endl;
84  std::cout << "eigenvalue_principal = " << cluster2.GetParams().eigenvalue_principal
85  << std::endl;
86  }
87  }
88 
89  //if cluster1 looks like a track and cluster2 looks like a blob
90  if (FirstTrackSecondBlob) {
91  std::pair<float, float> trackEndPoint =
92  std::pair<float, float>(cluster1.GetParams().end_point.w, cluster1.GetParams().end_point.t);
93 
94  //if the tracklike cluster's endpoint is inside polygon of blob
95  if (cluster2.GetParams().PolyObject.PointInside(trackEndPoint))
96  return true;
97  else
98  return false;
99  }
100 
101  //if cluster2 looks like a track and cluster1 looks like a blob
102  else if (SecondTrackFirstBlob) {
103  std::pair<float, float> trackEndPoint =
104  std::pair<float, float>(cluster2.GetParams().end_point.w, cluster2.GetParams().end_point.t);
105 
106  //if the tracklike cluster's endpoint is inside polygon of blob
107  if (cluster1.GetParams().PolyObject.PointInside(trackEndPoint))
108  return true;
109  else
110  return false;
111  }
112 
113  else
114  return false;
115 
116  //the reason for not just using (one track one blob) and
117  //polyoverlap for this is that
118  //this was merging BNB events where the track is clearly in a different
119  //direction than the blob
120 
121  //this will fail when the tracklike cluster is reconstructed backwards
122  //(looks like it's a track going into a blob, rather than exiting)
123  }
124 
125  //------------------------------
127  //------------------------------
128  {}
129 
130  bool CBAlgoStartTrack::IsStartTrack(const ::cluster::ClusterParamsAlg& cluster)
131  {
132  if (cluster.GetParams().eigenvalue_principal > _min_EP)
133  return true;
134  else
135  return false;
136  }
137 
138  bool CBAlgoStartTrack::IsOverlappingBlob(const ::cluster::ClusterParamsAlg& cluster)
139  {
140  if (cluster.GetParams().width > _min_width &&
141  cluster.GetParams().opening_angle > _min_opening_angle &&
142  cluster.GetParams().eigenvalue_principal < _min_EP)
143  return true;
144  else
145  return false;
146  }
147 }
void SetMinWidth(double value)
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Cluster finding and building.
void SetMinOpeningAngle(double value)
void SetMinEP(double value)
void SetMinHits(size_t value)
bool IsStartTrack(const ::cluster::ClusterParamsAlg &cluster)
This merge algo is looking for short tracks from the start of a shower that are overlapping a blob th...
CBAlgoStartTrack()
Default constructor.
virtual void Reset()
Function to reset the algorithm instance ... maybe implemented via child class.
bool IsOverlappingBlob(const ::cluster::ClusterParamsAlg &cluster)