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