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

#include "CBAlgoAngleCompat.h"

Inheritance diagram for cmtool::CBAlgoAngleCompat:
cmtool::CBoolAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CBAlgoAngleCompat ()
 Default constructor. More...
 
virtual ~CBAlgoAngleCompat ()
 Default destructor. More...
 
virtual bool Bool (const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
 Overloaded (from CBoolAlgoBase) Bool function. More...
 
void SetDebug (bool on)
 Method to set debug mode. More...
 
void SetAllow180Ambig (bool on)
 Method to set whether you allow angles to match with +/- 180 deg difference. More...
 
void SetAngleCut (double angle)
 Method to set cut value in degrees for angle compatibility test. More...
 
void SetUseOpeningAngle (bool on)
 Method to set angle cut value to be based on opening angle. More...
 
void SetMinHits (size_t n)
 Set Minimum Number of Hits to consider Cluster. More...
 
virtual void Reset ()
 Function to reset the algorithm instance called within CMergeManager/CMatchManager's Reset() ... maybe implemented via child class. More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
virtual void IterationEnd ()
 
virtual void Report ()
 
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
 
bool _allow_180_ambig
 bool to suppress lots of output if you want More...
 
double _max_allowed_2D_angle_diff
 hard shower-axis angle cutoff (only valid for _use_opening_angle==false) More...
 
bool _use_opening_angle
 
size_t _minHits
 
TH1F * angle_dist_histo
 Min Number of hits for cluster to be considered. More...
 
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

User defined class CBAlgoAngleCompat ... these comments are used to generate doxygen documentation!

Definition at line 28 of file CBAlgoAngleCompat.h.

Constructor & Destructor Documentation

cmtool::CBAlgoAngleCompat::CBAlgoAngleCompat ( )

Default constructor.

Definition at line 7 of file CBAlgoAngleCompat.cxx.

References SetAllow180Ambig(), SetAngleCut(), SetDebug(), SetMinHits(), and SetUseOpeningAngle().

7  : CBoolAlgoBase()
8  {
9 
10  //this just sets default values
11 
12  SetDebug(true);
13 
14  SetAngleCut(30.); // in degrees
15 
16  SetMinHits(0);
17 
18  SetAllow180Ambig(false);
19 
20  SetUseOpeningAngle(false);
21 
22  // angle_dist_histo = 0;
23 
24  // angle_dist_histo = new TH1F("angle_dist_histo","Cluster Angle Differences",100,-360,360);
25 
26  } //end constructor
void SetDebug(bool on)
Method to set debug mode.
CBoolAlgoBase()
Default constructor.
Definition: CBoolAlgoBase.h:31
void SetUseOpeningAngle(bool on)
Method to set angle cut value to be based on opening angle.
void SetAllow180Ambig(bool on)
Method to set whether you allow angles to match with +/- 180 deg difference.
void SetAngleCut(double angle)
Method to set cut value in degrees for angle compatibility test.
void SetMinHits(size_t n)
Set Minimum Number of Hits to consider Cluster.
virtual cmtool::CBAlgoAngleCompat::~CBAlgoAngleCompat ( )
inlinevirtual

Default destructor.

Definition at line 35 of file CBAlgoAngleCompat.h.

References Bool().

35 {};

Member Function Documentation

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

Overloaded (from CBoolAlgoBase) Bool function.

Reimplemented from cmtool::CBoolAlgoBase.

Definition at line 28 of file CBAlgoAngleCompat.cxx.

References _allow_180_ambig, _debug, _max_allowed_2D_angle_diff, _minHits, _use_opening_angle, cmtool::CMAlgoBase::_verbose, and util::abs().

Referenced by ~CBAlgoAngleCompat().

30  {
31 
32  //if number of hits not large enough skip
33  if (_minHits and ((cluster1.GetHitVector().size() < _minHits) or
34  (cluster2.GetHitVector().size() < _minHits))) {
35  return false;
36  }
37 
38  //pretty sure we don't need conversion factors here.
39  //already in cm/cm units, degrees? need to check that
40  double angle1 = cluster1.GetParams().angle_2d; // * _time_2_cm / _wire_2_cm;
41  double angle2 = cluster2.GetParams().angle_2d; // * _time_2_cm / _wire_2_cm;
42 
43  double w_start1 = cluster1.GetParams().start_point.w; // * _wire_2_cm;
44  double t_start1 = cluster1.GetParams().start_point.t; // * _time_2_cm;
45  double w_start2 = cluster2.GetParams().start_point.w; // * _wire_2_cm;
46  double t_start2 = cluster2.GetParams().start_point.t; // * _time_2_cm;
47 
48  if (_debug) {
49 
50  std::cout << "Cluster 1:" << std::endl;
51  std::cout << "\tAngle: " << angle1 << std::endl;
52  std::cout << "\tStart: ( " << w_start1 << ", " << t_start1 << " )" << std::endl;
53  std::cout << "Cluster 2:" << std::endl;
54  std::cout << "\tAngle: " << angle2 << std::endl;
55  std::cout << "\tStart: ( " << w_start2 << ", " << t_start2 << " )" << std::endl;
56  }
57 
58  //for some reason angles are frequently -999.99.
59  //if either angle is this, clearly the cluster 2d angle is not well defined
60  //and this algorithm does not apply
61  if (angle1 < -998 || angle2 < -998) return false;
62 
63  // if(angle_dist_histo){
64  // angle_dist_histo->Fill(angle1-angle2);
65  // }
66  // else
67  // std::cout<<"\n\n\nSOMETHING WENT HORRIBLY WRONG IN CBALGOANGLECOMPAT\n\n\n\n\n\n\n"<<std::endl;
68 
69  bool compatible = false;
70 
71  double my_cut_value = _max_allowed_2D_angle_diff;
72  //if using opening angle, have angle cutoff be the smaller of the two opening angles
74  my_cut_value =
75  std::min(cluster1.GetParams().opening_angle, cluster2.GetParams().opening_angle);
76 
77  //if you don't care if clusters have been reconstructed backwards
78  if (_allow_180_ambig)
79  compatible =
80  (abs(angle1 - angle2) < my_cut_value || abs(angle1 - angle2 - 180) < my_cut_value ||
81  abs(angle1 - angle2 + 180) < my_cut_value);
82  else
83  compatible = (abs(angle1 - angle2) < my_cut_value);
84 
85  if (_verbose) {
86  if (compatible)
87  std::cout << "These two clusters are compatible in angle." << std::endl;
88  else
89  std::cout << "These two clusters are NOT compatible in angle." << std::endl;
90  }
91 
92  return compatible;
93 
94  } // end Merge function
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
bool _allow_180_ambig
bool to suppress lots of output if you want
double _max_allowed_2D_angle_diff
hard shower-axis angle cutoff (only valid for _use_opening_angle==false)
double opening_angle
Width of angular distubtion wrt vertx.
Definition: ClusterParams.h:40
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 {}
void cmtool::CBAlgoAngleCompat::SetAllow180Ambig ( bool  on)
inline

Method to set whether you allow angles to match with +/- 180 deg difference.

Definition at line 45 of file CBAlgoAngleCompat.h.

References _allow_180_ambig.

Referenced by CBAlgoAngleCompat().

45 { _allow_180_ambig = on; }
bool _allow_180_ambig
bool to suppress lots of output if you want
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::CBAlgoAngleCompat::SetAngleCut ( double  angle)
inline

Method to set cut value in degrees for angle compatibility test.

Definition at line 48 of file CBAlgoAngleCompat.h.

References _max_allowed_2D_angle_diff.

Referenced by CBAlgoAngleCompat().

48 { _max_allowed_2D_angle_diff = angle; }
double _max_allowed_2D_angle_diff
hard shower-axis angle cutoff (only valid for _use_opening_angle==false)
void cmtool::CBAlgoAngleCompat::SetDebug ( bool  on)
inline

Method to set debug mode.

Definition at line 42 of file CBAlgoAngleCompat.h.

References _debug.

Referenced by CBAlgoAngleCompat().

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

Set Minimum Number of Hits to consider Cluster.

Definition at line 54 of file CBAlgoAngleCompat.h.

References _minHits, and n.

Referenced by CBAlgoAngleCompat().

54 { _minHits = n; }
Char_t n[5]
void cmtool::CBAlgoAngleCompat::SetUseOpeningAngle ( bool  on)
inline

Method to set angle cut value to be based on opening angle.

Definition at line 51 of file CBAlgoAngleCompat.h.

References _use_opening_angle.

Referenced by CBAlgoAngleCompat().

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::CBAlgoAngleCompat::_allow_180_ambig
protected

bool to suppress lots of output if you want

bool to allow "backwards" clusters (swapped start/end points) to still match in angle, even though they are 180 degrees apart only valid for _use_opening_angle==false

Definition at line 64 of file CBAlgoAngleCompat.h.

Referenced by Bool(), and SetAllow180Ambig().

bool cmtool::CBAlgoAngleCompat::_debug
protected

Definition at line 59 of file CBAlgoAngleCompat.h.

Referenced by Bool(), and SetDebug().

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().

double cmtool::CBAlgoAngleCompat::_max_allowed_2D_angle_diff
protected

hard shower-axis angle cutoff (only valid for _use_opening_angle==false)

Definition at line 67 of file CBAlgoAngleCompat.h.

Referenced by Bool(), and SetAngleCut().

size_t cmtool::CBAlgoAngleCompat::_minHits
protected

Definition at line 73 of file CBAlgoAngleCompat.h.

Referenced by Bool(), and SetMinHits().

bool cmtool::CBAlgoAngleCompat::_use_opening_angle
protected

bool set to true if you want to use opening angle as the cutoff angle instead of whatever you set with SetAngleCut

Definition at line 71 of file CBAlgoAngleCompat.h.

Referenced by Bool(), and SetUseOpeningAngle().

TH1F* cmtool::CBAlgoAngleCompat::angle_dist_histo
protected

Min Number of hits for cluster to be considered.

Histogram used for debugging/cut value settings

Definition at line 76 of file CBAlgoAngleCompat.h.


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