CBAlgoTrackSeparate.cxx
Go to the documentation of this file.
1 #include "CBAlgoTrackSeparate.h"
2 
4 
5 namespace cmtool {
6 
7  //----------------------------------------
9  //----------------------------------------
10  {
11 
12  //this just sets default values
13  SetVerbose(true);
14  SetDebug(true);
15 
16  //1e9 is huge; everything will be merged
17  SetMinNumHits(30);
18  SetMinAngleDiff(15.); //in degrees
19  SetMaxOpeningAngle(12.0); //in deg (parameter in rad!!)
20  SetMinLength(10.);
22  SetMaxWidth(10.);
23 
24 
25  //NOTE! Using this flag means all of the other crap
26  //(minNumHits, anglediff, openingangle, blah blah)
27  //is totally irrelevant. if we stick with this flag as the algo,
28  //we probably want to delete all of the old method
29  SetUseEP(true);
30  SetEPCutoff(0.99000);
32  _wire_2_cm = geou.WireToCm();
33  _time_2_cm = geou.TimeToCm();
34 
35  }
36 
37  //--------------------------------------------------------
38  bool CBAlgoTrackSeparate::Bool(const ::cluster::ClusterParamsAlg &cluster1,
39  const ::cluster::ClusterParamsAlg &cluster2)
40  //--------------------------------------------------------
41  {
42  //if you are using EP method for this algo:
43  if(_use_EP){
44  if(cluster1.GetParams().eigenvalue_principal > _ep_cut &&
45  cluster2.GetParams().eigenvalue_principal > _ep_cut)
46  return true;
47  }
48  //if you are using the original method for this algo:
49  else{
50 
51  //two clusters are considered un-mergable if:
52  //1) both have more than _MinNumHits
53  //2) opening angle for both < _MAxOpeningAngle
54  //3) diff. in direction of both < _MinAngleDiff
55 
56  size_t N_Hits1 = cluster1.GetHitVector().size();
57  size_t N_Hits2 = cluster2.GetHitVector().size();
58  auto start_point1 = cluster1.GetParams().start_point;
59  auto start_point2 = cluster2.GetParams().start_point;
60  double angle_2d1 = cluster1.GetParams().angle_2d;
61  double angle_2d2 = cluster2.GetParams().angle_2d;
62  double opening_angle1 = cluster1.GetParams().opening_angle;
63  double opening_angle2 = cluster2.GetParams().opening_angle;
64  Polygon2D PolyObject1 = cluster1.GetParams().PolyObject;
65  Polygon2D PolyObject2 = cluster2.GetParams().PolyObject;
66  double length1 = cluster1.GetParams().length;
67  double length2 = cluster2.GetParams().length;
68  double width1 = cluster1.GetParams().width;
69  double width2 = cluster2.GetParams().width;
70 
71  //first filter out low hits clusters
72  if ( (N_Hits1 > _MinNumHits) and
73  (N_Hits2 > _MinNumHits) ) {
74  if (_debug) {
75  std::cout << "Cluster1 Num Hits: " << N_Hits1 << std::endl;
76  std::cout << "\t Start: (" << start_point1.w << " " << start_point1.t << " )" << std::endl;
77  std::cout << "\t Opening ANgle " << opening_angle1*(360/(2*3.14)) << std::endl;
78  std::cout << "\t Angle2D: " << angle_2d1 << std::endl;
79  std::cout << "\t Length: " << length1 << std::endl;
80  std::cout << "\t Width: " << width1 << std::endl;
81  std::cout << "Cluster2 Num Hits: " << N_Hits2 << std::endl;
82  std::cout << "\t Start: (" << start_point2.w << " " << start_point2.t << " )" << std::endl;
83  std::cout << "\t Opening ANgle " << opening_angle2*(360/(2*3.14)) << std::endl;
84  std::cout << "\t Angle2D: " << angle_2d2 << std::endl;
85  std::cout << "\t Length: " << length2 << std::endl;
86  std::cout << "\t Width: " << width2 << std::endl;
87  }
88  if ( (N_Hits1 > _MinNumHits) and
89  (N_Hits2 > _MinNumHits) and
90  ( abs(angle_2d1 - angle_2d2) > _MinAngleDiff ) and
91  //( PolyObject1.Area()/N_Hits1 > _MinDensity ) and
92  //( PolyObject2.Area()/N_Hits2 > _MinDensity ) and
93  (opening_angle1 < _MaxOpeningAngle/(360/(2*3.14))) and
94  (opening_angle2 < _MaxOpeningAngle/(360/(2*3.14))) and
95  (width1 < _MaxWidth) and
96  (width2 < _MaxWidth) and
97  (length1 > _MinLength) and
98  (length2 > _MinLength) ){
99  if (_verbose) { std::cout << "*****************************************Separate with TrackSeparate!" << std::endl; }
100  return true;
101  }
102  }
103  }
104 
105  return false;
106 
107  }
108 
109  //-----------------------
111  //-----------------------
112  {
113  }
114 
115 }
Double_t TimeToCm() const
Double_t WireToCm() const
void SetMaxWidth(float maxwidth)
virtual void Report()
Function to report what&#39;s going on per merging.
CBAlgoTrackSeparate()
Default constructor.
Class def header for a class CBAlgoTrackSeparate.
T abs(T value)
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
void SetVerbose(bool on)
Setter function for verbosity.
void SetMinPolyHitDensity(float mindensity)
void SetMaxOpeningAngle(float maxangle)
void SetMinLength(float minlength)
Definition: cfalgo.cc:3
QTextStream & endl(QTextStream &s)
void SetMinAngleDiff(float anglesep)