LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cmtool::CBAlgoPolyShortestDist Class Reference

#include "CBAlgoPolyShortestDist.h"

Inheritance diagram for cmtool::CBAlgoPolyShortestDist:
cmtool::CBoolAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CBAlgoPolyShortestDist ()
 Default constructor. More...
 
virtual ~CBAlgoPolyShortestDist ()
 Default destructor. More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual bool Bool (const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
 
virtual void Report ()
 
virtual void Reset ()
 Function to reset the algorithm instance ... maybe implemented via child class. More...
 
void SetMinNumHits (size_t nhits)
 
void SetMaxNumHits (int nhits)
 
void SetMinDistSquared (double dist)
 
void SetDebug (bool flag)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void IterationEnd ()
 
void SetAnaFile (TFile *fout)
 Setter function for an output plot TFile pointer. More...
 
virtual void SetVerbose (bool doit=true)
 Setter function for verbosity. More...
 

Protected Attributes

TFile * _fout
 TFile pointer to an output file. More...
 
bool _verbose
 Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager's verbosity level is >= kPerMerging. More...
 

Private Attributes

size_t _min_hits
 
size_t _max_hits
 
double _dist_sqrd_cut
 
bool _debug
 
double tmp_min_dist
 

Detailed Description

User implementation for CBoolAlgoBase class doxygen documentation!

Definition at line 26 of file CBAlgoPolyShortestDist.h.

Constructor & Destructor Documentation

cmtool::CBAlgoPolyShortestDist::CBAlgoPolyShortestDist ( )

Default constructor.

Definition at line 9 of file CBAlgoPolyShortestDist.cxx.

References SetDebug(), SetMaxNumHits(), SetMinDistSquared(), and SetMinNumHits().

9  : CBoolAlgoBase()
10  //-------------------------------------------------------
11  {
13  SetMinNumHits(0);
14  SetMaxNumHits(99999);
15  SetDebug(false);
16  }
CBoolAlgoBase()
Default constructor.
Definition: CBoolAlgoBase.h:32
virtual cmtool::CBAlgoPolyShortestDist::~CBAlgoPolyShortestDist ( )
inlinevirtual

Default destructor.

Definition at line 34 of file CBAlgoPolyShortestDist.h.

References Bool(), EventBegin(), Report(), and Reset().

34 {};

Member Function Documentation

bool cmtool::CBAlgoPolyShortestDist::Bool ( const ::cluster::ClusterParamsAlg cluster1,
const ::cluster::ClusterParamsAlg cluster2 
)
virtual

Optional function: called at the end of event ... after the last merging iteration is over. Optional function: called at the beggining of each iteration over all pairs of clusters. This provides all clusters' information in case the algorithm need them. Note this is called per iteration which may be more than once per event. Optional function: called at the end of each iteration over all pairs of clusters. Core function: given the CPAN input, return whether a cluster should be merged or not.

Reimplemented from cmtool::CBoolAlgoBase.

Definition at line 55 of file CBAlgoPolyShortestDist.cxx.

References _debug, _dist_sqrd_cut, _max_hits, _min_hits, and tmp_min_dist.

Referenced by ~CBAlgoPolyShortestDist().

58  {
59  if( (cluster1.GetHitVector().size() < _min_hits) ||
60  (cluster2.GetHitVector().size() < _min_hits) )
61  return false;
62 
63  if( (cluster1.GetHitVector().size() > _max_hits) ||
64  (cluster2.GetHitVector().size() > _max_hits) )
65  return false;
66 
67  //if either has < 3 sides do not merge!
68  if ( (cluster1.GetParams().PolyObject.Size() < 2) or
69  (cluster2.GetParams().PolyObject.Size() < 2) ){
70  return false;
71  }
72 
73  //loop over the points on the first polygon and calculate
74  //distance to each point on the second polygon
75  //if any two points are close enough to each other,
76  //merge the two clusters
77 
78  unsigned int npoints1 = cluster1.GetParams().PolyObject.Size();
79  unsigned int npoints2 = cluster2.GetParams().PolyObject.Size();
80  //loop over points on first polygon
81  for(unsigned int i = 0; i < npoints1; ++i){
82  float pt1w = cluster1.GetParams().PolyObject.Point(i).first;
83  float pt1t = cluster1.GetParams().PolyObject.Point(i).second;
84  //loop over points on second polygon
85  for(unsigned int j = 0; j < npoints2; ++j){
86  float pt2w = cluster2.GetParams().PolyObject.Point(j).first;
87  float pt2t = cluster2.GetParams().PolyObject.Point(j).second;
88  double distsqrd = pow(pt2w-pt1w,2)+pow(pt2t-pt1t,2);
89 
90  if(distsqrd < tmp_min_dist) tmp_min_dist = distsqrd;
91 
92  if(_debug){
93  std::cout<<"two polygon points dist2 is "<<distsqrd<<std::endl;
94  std::cout<<"minimum dist was "<<tmp_min_dist<<std::endl;
95  }
96  if(distsqrd<_dist_sqrd_cut)
97  return true;
98  }
99 
100  }
101 
102  return false;
103  }
Polygon2D PolyObject
Polygon Object...see Polygon2D.hh.
Definition: ClusterParams.h:22
const std::pair< float, float > & Point(unsigned int p) const
Definition: Polygon2D.cxx:135
unsigned int Size() const
Create Intersection Polygon.
Definition: Polygon2D.h:47
const cluster_params & GetParams() const
const std::vector< util::PxHit > & GetHitVector() const
void cmtool::CBAlgoPolyShortestDist::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
virtual

Optional function: called at the beginning of 1st iteration. This is called per event.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 26 of file CBAlgoPolyShortestDist.cxx.

References tmp_min_dist.

Referenced by ~CBAlgoPolyShortestDist().

28  {
29  if(clusters.size())
30  tmp_min_dist = 99999;
31  }
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

Optional function: called at the end of event ... after the last merging iteration is over.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 51 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventEnd(), and cmtool::CMergeManager::EventEnd().

52  {return;}
virtual void cmtool::CMAlgoBase::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtualinherited

Optional function: called at the beggining of each iteration over all pairs of clusters. This provides all clusters' information in case the algorithm need them. Note this is called per iteration which may be more than once per event.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 59 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventBegin(), cmtool::CMatchManager::IterationBegin(), and cmtool::CMergeManager::IterationBegin().

60  { if(clusters.size()) return;}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

Optional function: called at the end of each iteration over all pairs of clusters.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 65 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::IterationEnd(), and cmtool::CMergeManager::IterationEnd().

66  {return; }
void cmtool::CBAlgoPolyShortestDist::Report ( )
virtual

Optional function: called after each Merge() function call by CMergeManager IFF CMergeManager is run with verbosity level kPerMerging. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 106 of file CBAlgoPolyShortestDist.cxx.

Referenced by ~CBAlgoPolyShortestDist().

108  {
109 
110  }
void cmtool::CBAlgoPolyShortestDist::Reset ( )
virtual

Function to reset the algorithm instance ... maybe implemented via child class.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 19 of file CBAlgoPolyShortestDist.cxx.

Referenced by ~CBAlgoPolyShortestDist().

21  {
22 
23  }
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 77 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

Referenced by cmtool::CMergeManager::EventBegin().

77 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:85
void cmtool::CBAlgoPolyShortestDist::SetDebug ( bool  flag)
inline

Definition at line 81 of file CBAlgoPolyShortestDist.h.

References _debug.

Referenced by CBAlgoPolyShortestDist().

void cmtool::CBAlgoPolyShortestDist::SetMaxNumHits ( int  nhits)
inline

Definition at line 77 of file CBAlgoPolyShortestDist.h.

References _max_hits.

Referenced by CBAlgoPolyShortestDist().

void cmtool::CBAlgoPolyShortestDist::SetMinDistSquared ( double  dist)
inline

Definition at line 79 of file CBAlgoPolyShortestDist.h.

References _dist_sqrd_cut.

Referenced by CBAlgoPolyShortestDist().

void cmtool::CBAlgoPolyShortestDist::SetMinNumHits ( size_t  nhits)
inline

Definition at line 75 of file CBAlgoPolyShortestDist.h.

References _min_hits.

Referenced by CBAlgoPolyShortestDist().

virtual void cmtool::CMAlgoBase::SetVerbose ( bool  doit = true)
inlinevirtualinherited

Member Data Documentation

bool cmtool::CBAlgoPolyShortestDist::_debug
private

Definition at line 90 of file CBAlgoPolyShortestDist.h.

Referenced by Bool(), and SetDebug().

double cmtool::CBAlgoPolyShortestDist::_dist_sqrd_cut
private

Definition at line 88 of file CBAlgoPolyShortestDist.h.

Referenced by Bool(), and SetMinDistSquared().

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 85 of file CMAlgoBase.h.

Referenced by cmtool::CMAlgoBase::CMAlgoBase(), and cmtool::CMAlgoBase::SetAnaFile().

size_t cmtool::CBAlgoPolyShortestDist::_max_hits
private

Definition at line 86 of file CBAlgoPolyShortestDist.h.

Referenced by Bool(), and SetMaxNumHits().

size_t cmtool::CBAlgoPolyShortestDist::_min_hits
private

Definition at line 86 of file CBAlgoPolyShortestDist.h.

Referenced by Bool(), and SetMinNumHits().

double cmtool::CBAlgoPolyShortestDist::tmp_min_dist
private

Definition at line 92 of file CBAlgoPolyShortestDist.h.

Referenced by Bool(), and EventBegin().


The documentation for this class was generated from the following files: