LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cmtool::CBAlgoOutOfConeSeparate Class Reference

#include "CBAlgoOutOfConeSeparate.h"

Inheritance diagram for cmtool::CBAlgoOutOfConeSeparate:
cmtool::CBoolAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CBAlgoOutOfConeSeparate ()
 Default constructor. More...
 
virtual ~CBAlgoOutOfConeSeparate ()
 Default destructor. More...
 
virtual bool Bool (const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
 
void SetDebug (bool on)
 Set Debug Mode on or off. More...
 
void SetMaxAngleSep (float angle)
 Set Max Angle Separation for separation. More...
 
void SetMaxAngleFar (float angle)
 Set Max Angle Separation for separation for far away clusters. More...
 
void SetStartAngleFalloff (float d)
 Set Distance at which cone-acceptance angle starts falling off as 1/distance. Value should be distance^2 in cm^2. More...
 
void SetMinLength (float len)
 Set Minimum length for "big" cluster. More...
 
void SetMinHits (size_t n)
 SetMinimum number of hits for small cluster. More...
 
virtual void Reset ()
 Function to reset the algorithm instance ... maybe implemented via child class. More...
 
virtual void Report ()
 Function to report what's going on per merging. More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
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

bool _debug
 
float _MaxAngle
 
float _MaxAngleFar
 
float _MinLen
 
float _FallOff
 
size_t _minHits
 
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...
 

Detailed Description

Definition at line 26 of file CBAlgoOutOfConeSeparate.h.

Constructor & Destructor Documentation

cmtool::CBAlgoOutOfConeSeparate::CBAlgoOutOfConeSeparate ( )

Default constructor.

Definition at line 8 of file CBAlgoOutOfConeSeparate.cxx.

References SetDebug(), SetMaxAngleSep(), SetMinHits(), SetMinLength(), and SetStartAngleFalloff().

8  : CBoolAlgoBase()
9  //----------------------------------------
10  {
11 
12  SetDebug(false);
13  SetMaxAngleSep(20.);
14  SetMinLength(15.);
15  SetMinHits(20);
16  SetStartAngleFalloff(2800); // in cm^2
17  }
void SetMinLength(float len)
Set Minimum length for "big" cluster.
void SetStartAngleFalloff(float d)
Set Distance at which cone-acceptance angle starts falling off as 1/distance. Value should be distanc...
void SetDebug(bool on)
Set Debug Mode on or off.
void SetMaxAngleSep(float angle)
Set Max Angle Separation for separation.
CBoolAlgoBase()
Default constructor.
Definition: CBoolAlgoBase.h:31
void SetMinHits(size_t n)
SetMinimum number of hits for small cluster.
virtual cmtool::CBAlgoOutOfConeSeparate::~CBAlgoOutOfConeSeparate ( )
inlinevirtual

Default destructor.

Definition at line 33 of file CBAlgoOutOfConeSeparate.h.

References Bool().

33 {};

Member Function Documentation

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

Core function: given the ClusterParamsAlg input, return whether a cluster should be merged or not.

Reimplemented from cmtool::CBoolAlgoBase.

Definition at line 20 of file CBAlgoOutOfConeSeparate.cxx.

References _debug, _FallOff, _MaxAngle, _MaxAngleFar, _minHits, _MinLen, cmtool::CMAlgoBase::_verbose, util::abs(), and SetMaxAngleFar().

Referenced by ~CBAlgoOutOfConeSeparate().

23  {
24 
25  double angle1 = cluster1.GetParams().angle_2d;
26  double angle2 = cluster2.GetParams().angle_2d;
27 
28  double w_start1 = cluster1.GetParams().start_point.w;
29  double t_start1 = cluster1.GetParams().start_point.t;
30  double w_start2 = cluster2.GetParams().start_point.w;
31  double t_start2 = cluster2.GetParams().start_point.t;
32 
33  double len1 = cluster1.GetParams().length;
34  double len2 = cluster2.GetParams().length;
35 
36  size_t hits1 = cluster1.GetHitVector().size();
37  size_t hits2 = cluster2.GetHitVector().size();
38 
39  double startseparation =
40  (w_start2 - w_start1) * (w_start2 - w_start1) + (t_start2 - t_start1) * (t_start2 - t_start1);
41  //convert sepration to be instead of just angle -> angle/distance^n (n=1 for now)
43  (_FallOff / startseparation)); //distance^2 of 400 cm^2 taken as "standard"
44  if (_MaxAngleFar > 90.) _MaxAngleFar = 90.;
45 
46  //if either cluster has less than _minHits don't even try...
47  if ((hits1 < _minHits) or (hits2 < _minHits) or (angle1 < -360) or (angle2 < -360))
48  return false;
49 
50  if (_debug) {
51  std::cout << "Cluster 1:" << std::endl;
52  std::cout << "\tStart: ( " << w_start1 << ", " << t_start1 << " )" << std::endl;
53  std::cout << "\tAngle: " << angle1 << std::endl;
54  std::cout << "\tLength: " << len1 << std::endl;
55  std::cout << "\tN Hits: " << hits1 << std::endl;
56 
57  std::cout << "Cluster 2:" << std::endl;
58  std::cout << "\tStart: ( " << w_start2 << ", " << t_start2 << " )" << std::endl;
59  std::cout << "\tAngle: " << angle2 << std::endl;
60  std::cout << "\tLength: " << len2 << std::endl;
61  std::cout << "\tN Hits: " << hits2 << std::endl;
62 
63  std::cout << "Start Point Separation: " << startseparation << std::endl;
64  }
65 
66  //cluster 1 needs to be long enough (i.e. good) and cluster 2 must have minimum number of hits
67  double angle;
68  double separation;
69 
70  if (startseparation == 0) //do not prohibit merging if start point identical
71  return false;
72 
73  //first calculate angle of line in 2D plane connectng the two start points
74  if ((t_start2 - t_start1) == 0)
75  angle = 0.;
76  else {
77  double slope = (t_start2 - t_start1) / (w_start2 - w_start1);
78  angle = atan(slope) * 180. / 3.14;
79  }
80 
81  separation = abs(angle - angle1);
82 
83  if (_debug) {
84  std::cout << "Angle S1--S2: " << angle << std::endl;
85  std::cout << "Angle1--S2: " << separation << std::endl;
86  }
87  if (((((separation > _MaxAngle) and (separation < 180 - _MaxAngle)) or
88  ((separation > 180 + _MaxAngle) and (separation < 360 - _MaxAngle))) or
89  (((separation > _MaxAngleFar) and (separation < 180 - _MaxAngleFar)) or
90  ((separation > 180 + _MaxAngleFar) and (separation < 360 - _MaxAngleFar)))) and
91  (hits2 > _minHits) and (len1 > _MinLen)) {
92  if (_verbose) { std::cout << "Separate! cluster 1 BIG" << std::endl << std::endl; }
93  return true;
94  }
95 
96  //now change direction of angle so that it points from cluster 2 (big) to cluster 1 (small)
97  angle += 180.;
98  angle = (int)(angle) % 360;
99 
100  separation = abs(angle - angle2);
101  //separation *= (400./startseparation); //distance^2 of 400 cm^2 taken as "standard"
102  if (_debug) {
103  std::cout << "Angle S2--S1: " << angle << std::endl;
104  std::cout << "Angle2--S1: " << separation << std::endl;
105  }
106  if (((((separation > _MaxAngle) and (separation < 180 - _MaxAngle)) or
107  ((separation > 180 + _MaxAngle) and (separation < 360 - _MaxAngle))) or
108  (((separation > _MaxAngleFar) and (separation < 180 - _MaxAngleFar)) or
109  ((separation > 180 + _MaxAngleFar) and (separation < 360 - _MaxAngleFar)))) and
110  (hits1 > _minHits) and (len2 > _MinLen)) {
111  if (_verbose) { std::cout << "Separate! cluster 2 BIG" << std::endl << std::endl; }
112  return true;
113  }
114 
115  return false;
116  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
const cluster_params & GetParams() const
double t
Definition: PxUtils.h:10
const std::vector< util::PxHit > & GetHitVector() const
util::PxPoint start_point
start point
Definition: ClusterParams.h:23
double angle_2d
Angle of axis in wire/hit view.
Definition: ClusterParams.h:39
double w
Definition: PxUtils.h:9
void SetMaxAngleFar(float angle)
Set Max Angle Separation for separation for far away clusters.
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:82
virtual void cmtool::CMAlgoBase::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  )
inlinevirtualinherited

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

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

Definition at line 45 of file CMAlgoBase.h.

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

45 {}
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

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

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

Definition at line 50 of file CMAlgoBase.h.

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

50 {}
virtual void cmtool::CMAlgoBase::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  )
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::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 57 of file CMAlgoBase.h.

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

57 {}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

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

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

Definition at line 62 of file CMAlgoBase.h.

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

62 {}
virtual void cmtool::CBAlgoOutOfConeSeparate::Report ( )
inlinevirtual

Function to report what's going on per merging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 64 of file CBAlgoOutOfConeSeparate.h.

64 {}
virtual void cmtool::CBAlgoOutOfConeSeparate::Reset ( )
inlinevirtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 61 of file CBAlgoOutOfConeSeparate.h.

61 {}
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 72 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

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

72 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:79
void cmtool::CBAlgoOutOfConeSeparate::SetDebug ( bool  on)
inline

Set Debug Mode on or off.

Definition at line 43 of file CBAlgoOutOfConeSeparate.h.

References _debug.

Referenced by CBAlgoOutOfConeSeparate().

void cmtool::CBAlgoOutOfConeSeparate::SetMaxAngleFar ( float  angle)
inline

Set Max Angle Separation for separation for far away clusters.

Definition at line 49 of file CBAlgoOutOfConeSeparate.h.

References _MaxAngleFar.

Referenced by Bool().

void cmtool::CBAlgoOutOfConeSeparate::SetMaxAngleSep ( float  angle)
inline

Set Max Angle Separation for separation.

Definition at line 46 of file CBAlgoOutOfConeSeparate.h.

References _MaxAngle.

Referenced by CBAlgoOutOfConeSeparate().

void cmtool::CBAlgoOutOfConeSeparate::SetMinHits ( size_t  n)
inline

SetMinimum number of hits for small cluster.

Definition at line 58 of file CBAlgoOutOfConeSeparate.h.

References _minHits, and n.

Referenced by CBAlgoOutOfConeSeparate().

void cmtool::CBAlgoOutOfConeSeparate::SetMinLength ( float  len)
inline

Set Minimum length for "big" cluster.

Definition at line 55 of file CBAlgoOutOfConeSeparate.h.

References _MinLen.

Referenced by CBAlgoOutOfConeSeparate().

void cmtool::CBAlgoOutOfConeSeparate::SetStartAngleFalloff ( float  d)
inline

Set Distance at which cone-acceptance angle starts falling off as 1/distance. Value should be distance^2 in cm^2.

Definition at line 52 of file CBAlgoOutOfConeSeparate.h.

References _FallOff, and d.

Referenced by CBAlgoOutOfConeSeparate().

52 { _FallOff = d; }
Float_t d
Definition: plot.C:235
virtual void cmtool::CMAlgoBase::SetVerbose ( bool  doit = true)
inlinevirtualinherited

Setter function for verbosity.

Reimplemented in cmtool::CBAlgoArray, and cmtool::CFAlgoTimeOverlap.

Definition at line 75 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_verbose.

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

75 { _verbose = doit; }
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:82

Member Data Documentation

bool cmtool::CBAlgoOutOfConeSeparate::_debug
protected

Definition at line 67 of file CBAlgoOutOfConeSeparate.h.

Referenced by Bool(), and SetDebug().

float cmtool::CBAlgoOutOfConeSeparate::_FallOff
protected

Definition at line 71 of file CBAlgoOutOfConeSeparate.h.

Referenced by Bool(), and SetStartAngleFalloff().

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 79 of file CMAlgoBase.h.

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

float cmtool::CBAlgoOutOfConeSeparate::_MaxAngle
protected

Definition at line 68 of file CBAlgoOutOfConeSeparate.h.

Referenced by Bool(), and SetMaxAngleSep().

float cmtool::CBAlgoOutOfConeSeparate::_MaxAngleFar
protected

Definition at line 69 of file CBAlgoOutOfConeSeparate.h.

Referenced by Bool(), and SetMaxAngleFar().

size_t cmtool::CBAlgoOutOfConeSeparate::_minHits
protected

Definition at line 72 of file CBAlgoOutOfConeSeparate.h.

Referenced by Bool(), and SetMinHits().

float cmtool::CBAlgoOutOfConeSeparate::_MinLen
protected

Definition at line 70 of file CBAlgoOutOfConeSeparate.h.

Referenced by Bool(), and SetMinLength().


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