LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CBAlgoPolyOverlap.cxx
Go to the documentation of this file.
1 #ifndef RECOTOOL_CBALGOPOLYOVERLAP_CXX
2 #define RECOTOOL_CBALGOPOLYOVERLAP_CXX
3 
4 #include "CBAlgoPolyOverlap.h"
5 
6 namespace cmtool {
7 
9  {
10  // Nothing to be done in the base class
11  SetDebug(false);
12  SetMinNumHits(0);
13 
14  this->reconfigure();
15  }
16 
17 
19 
20  //not sure what needs to be reset/reconfigured for this algo
21 
22  }//end reconfigure function
23 
24 
25  bool CBAlgoPolyOverlap::Bool(const ::cluster::ClusterParamsAlg &cluster1,
26  const ::cluster::ClusterParamsAlg &cluster2)
27  {
28 
29  if( (cluster1.GetParams().N_Hits < _min_hits) ||
30  (cluster2.GetParams().N_Hits < _min_hits) )
31  return false;
32 
33  //if either has < 3 sides do not merge!
34  if ( (cluster1.GetParams().PolyObject.Size() < 2) or
35  (cluster2.GetParams().PolyObject.Size() < 2) ){
36  return false;
37  }
38  if (_debug and cluster1.GetParams().N_Hits > 10 and cluster2.GetParams().N_Hits > 10) {
39  std::cout << "Cluster 1:" << std::endl;
40  std::cout << "\tN_Hits: " << cluster1.GetParams().N_Hits << std::endl;
41  std::cout << "\tN Sides:" << cluster1.GetParams().PolyObject.Size() << std::endl;
42  for (unsigned int n=0; n < cluster1.GetParams().PolyObject.Size(); n++)
43  std::cout << "\t\t\t(" << cluster1.GetParams().PolyObject.Point(n).first << ", "
44  << cluster1.GetParams().PolyObject.Point(n).second << ")" << std::endl;
45  std::cout << "Cluster 2:" << std::endl;
46  std::cout << "\tN_Hits: " << cluster2.GetParams().N_Hits << std::endl;
47  std::cout << "\tN Sides:" << cluster2.GetParams().PolyObject.Size() << std::endl;
48  for (unsigned int n=0; n < cluster2.GetParams().PolyObject.Size(); n++)
49  std::cout << "\t\t\t(" << cluster2.GetParams().PolyObject.Point(n).first << ", "
50  << cluster2.GetParams().PolyObject.Point(n).second << ")" << std::endl;
51  }
52 
53  //if the two polygons overlap even partially
54  //then return true! --> MERGE!
55  if ( cluster1.GetParams().PolyObject.PolyOverlapSegments(cluster2.GetParams().PolyObject) ){
56  if (_verbose) { std::cout << "Overlap...merging!" << std::endl; }
57  return true;
58  }
59  return false;
60 
61  }
62 
63 
64 }
65 
66 #endif
void SetMinNumHits(size_t nhits)
CBAlgoPolyOverlap()
Default constructor.
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Char_t n[5]
Class def header for a class CBAlgoPolyOverlap.
void reconfigure()
Method to re-configure the instance.
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:88