LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CBAlgoStartInCone.cxx
Go to the documentation of this file.
1 #ifndef RECOTOOL_CBALGOSTARTINCONE_CXX
2 #define RECOTOOL_CBALGOSTARTINCONE_CXX
3 
4 #include "CBAlgoStartInCone.h"
5 
6 namespace cmtool {
7 
9  {
10  // Nothing to be done in the base class
11  this->reconfigure();
12 
14  _wire_2_cm = geou.WireToCm();
15  _time_2_cm = geou.TimeToCm();
16 
17  SetMinHits(40);
18  SetMinLen(10);
19  SetDebug(false);
20  SetAngleCompat(90.);
21  SetLengthReach(1.0);
22 
23  }
24 
25 
27 
28  //not sure what needs to be reset/reconfigured for this algo
29 
30  }//end reconfigure function
31 
32 
33  bool CBAlgoStartInCone::Bool(const ::cluster::ClusterParamsAlg &cluster1,
34  const ::cluster::ClusterParamsAlg &cluster2)
35  {
36 
37  //apply filter on hit number and length immediately
38  if ( ( (cluster1.GetParams().length < _lenMin) and (cluster1.GetHitVector().size() < _NhitsMin) )
39  and ( (cluster2.GetParams().length < _lenMin) and (cluster2.GetHitVector().size() < _NhitsMin) ) )
40  return false;
41 
42  //A cluster has an associated cone defined as the cone originating
43  //at the start point of that cluster opening out in the direction
44  //of the end point with an angle equal to the opening angle
45  //If cluster A (B) has a start point within the volume defined
46  //by the cone of cluster B (A), and if cluster B (A) is good enough
47  // (enough hits, charge, length...) then the two are merged.
48 
49  double w_start1 = cluster1.GetParams().start_point.w;// * _wire_2_cm;
50  double t_start1 = cluster1.GetParams().start_point.t;// * _time_2_cm;
51  double angle1 = cluster1.GetParams().angle_2d;
52  double opening1 = cluster1.GetParams().opening_angle * (180./3.14);
53  double len1 = cluster1.GetParams().length;
54 
55  double w_start2 = cluster2.GetParams().start_point.w;// * _wire_2_cm;
56  double t_start2 = cluster2.GetParams().start_point.t;// * _time_2_cm;
57  double angle2 = cluster2.GetParams().angle_2d;
58  double opening2 = cluster2.GetParams().opening_angle * (180./3.14);
59  double len2 = cluster2.GetParams().length;
60 
61  //check for angle compatibility: the direction of the two clusters must be within
62  //this range of each other
63  if ( abs(angle2-angle1) > _angleCompat ){
64  if (_debug) { std::cout << "Directions too different....do not merge" << std::endl; }
65  return false;
66  }
67 
68  if (_debug){
69  std::cout << "Cluster 1:" << std::endl;
70  std::cout << "\tStart: ( " << w_start1 << ", " << t_start1 << " )" << std::endl;
71  std::cout << "\tAngle: " << angle1 << std::endl;
72  std::cout << "\tOpening Angle: " << opening1 << std::endl;
73  std::cout << "\tLength: " << len1 << std::endl;
74  std::cout << "Cluster 2:" << std::endl;
75  std::cout << "\tStart: ( " << w_start2 << ", " << t_start2 << " )" << std::endl;
76  std::cout << "\tAngle: " << angle2 << std::endl;
77  std::cout << "\tOpening Angle: " << opening2 << std::endl;
78  std::cout << "\tLength: " << len2 << std::endl;
79  std::cout << std::endl;
80  }
81 
82  //find if start point of A (B) in cone of B (A)
83  //do this by translating point A (B) such that
84  //start point of B (A) is at origin and + axis
85  //towards end point of B (A)
86  double w_start1_transl = w_start1 - w_start2;
87  double t_start1_transl = t_start1 - t_start2;
88  double w_start2_transl = w_start2 - w_start1;
89  double t_start2_transl = t_start2 - t_start1;
90 
91  double w_start1_rot = w_start1_transl*cos(angle2*3.14/180.) + t_start1_transl*sin(angle2*3.14/180.);
92  double t_start1_rot = - w_start1_transl*sin(angle2*3.14/180.) + t_start1_transl*cos(angle2*3.14/180.);
93  double w_start2_rot = w_start2_transl*cos(angle1*3.14/180.) + t_start2_transl*sin(angle1*3.14/180.);
94  double t_start2_rot = - w_start2_transl*sin(angle1*3.14/180.) + t_start2_transl*cos(angle1*3.14/180.);
95 
96  if (_debug){
97  std::cout << "\tStart Rot 1: ( " << w_start1_rot << ", " << t_start1_rot << " )" << std::endl;
98  std::cout << "\tStart Rot 2: ( " << w_start2_rot << ", " << t_start2_rot << " )" << std::endl;
99  }
100 
101  if ( (w_start1_rot < len2*_lengthReach ) and (w_start1_rot > 0) and
102  ( abs(t_start1_rot) < (abs(w_start1_rot*sin(opening2*3.14/180.))) ) and
103  (len2 > _lenMin) and
104  (cluster2.GetHitVector().size() > _NhitsMin) ){
105  if (_verbose) { std::cout << "Start point of Cluster 1 in cone of Cluster 2!" << std::endl; }
106  return true;
107  }
108  if ( (w_start2_rot < len1*_lengthReach ) and (w_start2_rot > 0) and
109  ( abs(t_start2_rot) < (abs(w_start2_rot*sin(opening1*3.14/180.))) ) and
110  (len1 > _lenMin) and
111  (cluster1.GetHitVector().size() > _NhitsMin) ){
112  if (_verbose) { std::cout << "Start point of Cluster 2 in cone of Cluster 1!" << std::endl; }
113  return true;
114  }
115 
116  return false;
117  }
118 
119 
120 }
121 
122 
123 #endif
void SetAngleCompat(double deg)
Set Angle Compatibility betweeen the clusters.
bool _verbose
Larger cluster which determines cone must be at least this long.
Double_t TimeToCm() const
Double_t WireToCm() const
size_t _NhitsMin
Conversion factors ogtten from GeometryUtilities.
void SetMinHits(size_t n)
Set Minimum number of hits for cone-cluster.
double _lenMin
Larger cluster which determines cone must have this many hits.
void SetLengthReach(double frac)
Set Length Reach: How for out the cone extends as percent of cluster length.
double _lengthReach
Two clusters must have direction within this value of each other.
void SetDebug(bool debug)
Set Debug for messages.
void SetMinLen(double l)
Set Minimum number of hits for cone-cluster.
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Merging Algorithm is Here.
Class def header for a class CBAlgoStartInCone.
CBAlgoStartInCone()
Default constructor.
void reconfigure()
Method to re-configure the instance.