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