LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CBAlgoAngleAlign.cxx
Go to the documentation of this file.
2 
3 #include <cmath>
4 
5 namespace cmtool {
6 
8  {
9 
10  //this just sets default values
11  SetDebug(true);
12  SetAngleCut(10.); // in degrees
13  SetAllow180Ambig(false);
14  SetMinNHits(30);
15 
16  } //end constructor
17 
18  bool CBAlgoAngleAlign::Bool(const ::cluster::ClusterParamsAlg& cluster1,
19  const ::cluster::ClusterParamsAlg& cluster2)
20  {
21 
22  double angle1 = cluster1.GetParams().angle_2d;
23  double angle2 = cluster2.GetParams().angle_2d;
24  size_t hits1 = cluster1.GetHitVector().size();
25  size_t hits2 = cluster2.GetHitVector().size();
26 
27  //if don't make hit cut return aflse
28  if ((hits1 < _MinNHits) or (hits2 < _MinNHits)) return false;
29 
30  if (_debug) {
31  std::cout << "Cluster1:" << std::endl;
32  std::cout << "\tAngle: " << angle1 << std::endl;
33  std::cout << "\t Start: (" << cluster1.GetParams().start_point.w << ", "
34  << cluster1.GetParams().start_point.t << ")" << std::endl;
35  std::cout << "Cluster2:" << std::endl;
36  std::cout << "\tAngle: " << angle2 << std::endl;
37  std::cout << "\t Start: (" << cluster2.GetParams().start_point.w << ", "
38  << cluster2.GetParams().start_point.t << ")" << std::endl;
39  std::cout << std::endl;
40  }
41 
42  //for some reason angles are frequently -999.99.
43  //if either angle is this, clearly the cluster 2d angle is not well defined
44  //and this algorithm does not apply
45  if (angle1 < -998 || angle2 < -998) return false;
46 
47  bool compatible = false;
48 
49  //if you don't care if clusters have been reconstructed backwards
50  if (_allow_180_ambig)
51  compatible =
52  (abs(angle1 - angle2) < _MaxAngleSep || abs(angle1 - angle2 - 180) < _MaxAngleSep ||
53  abs(angle1 - angle2 + 180) < _MaxAngleSep);
54  else
55  compatible = (abs(angle1 - angle2) < _MaxAngleSep);
56 
57  if (_verbose) {
58  if (compatible) std::cout << "These two clusters are compatible in angle." << std::endl;
59  }
60 
61  return compatible;
62 
63  } // end Merge function
64 
65 } //end namespace cmtool
void SetAngleCut(double angle)
Method to set cut value in degrees for angle compatibility test.
bool _allow_180_ambig
minimum number of hits for cluster to be considered
constexpr auto abs(T v)
Returns the absolute value of the argument.
void SetDebug(bool on)
Method to set debug mode.
double _MaxAngleSep
hard shower-axis angle cutoff (only valid for _use_opening_angle==false)
void SetAllow180Ambig(bool on)
Method to set whether you allow angles to match with +/- 180 deg difference.
CBAlgoAngleAlign()
Default constructor.
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Overloaded (from CBoolAlgoBase) Bool function.
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:82
Class def header for a class CBAlgoAngleAlign.