LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CBAlgoAngleIncompat.cxx
Go to the documentation of this file.
2 
3 #include <cmath>
4 
5 namespace cmtool {
6 
7  //-------------------------------------------------------
9  //-------------------------------------------------------
10  {
11  SetAngleCut(30.);
12 
13  SetMinHits(0);
14 
15  SetAllow180Ambig(false);
16 
17  SetUseOpeningAngle(false);
18 
19  SetMinLength(20);
20 
21  SetDebug(false);
22  }
23 
24  //----------------------------------------------------------------
25  bool CBAlgoAngleIncompat::Bool(const ::cluster::ClusterParamsAlg& cluster1,
26  const ::cluster::ClusterParamsAlg& cluster2)
27  //----------------------------------------------------------------
28  {
29  //if either cluster is too small, do not prohibit them
30  if (cluster1.GetNHits() < _minHits || cluster2.GetNHits() < _minHits) return false;
31 
32  //if either cluster is too short, do not prohibit them
33  if (cluster1.GetParams().length < _min_length || cluster2.GetParams().length < _min_length)
34  return false;
35 
36  double angle1 = cluster1.GetParams().angle_2d;
37  double angle2 = cluster2.GetParams().angle_2d;
38 
39  if (angle1 < -998 || angle2 < -998) return false;
40 
41  bool compatible = false;
42 
43  double my_cut_value = _max_allowed_2D_angle_diff;
44 
45  //if using opening angle, have angle cutoff be the smaller of the two opening angles
47  my_cut_value =
48  std::min(cluster1.GetParams().opening_angle, cluster2.GetParams().opening_angle);
49 
50  //if you don't care if clusters have been reconstructed backwards
51  if (_allow_180_ambig)
52  compatible =
53  (abs(angle1 - angle2) < my_cut_value || abs(angle1 - angle2 - 180) < my_cut_value ||
54  abs(angle1 - angle2 + 180) < my_cut_value);
55  else
56  compatible = (abs(angle1 - angle2) < my_cut_value);
57 
58  if (_debug) {
59  if (!compatible)
60 
61  std::cout << "CBAlgoAngleIncompat is PROHIBITING clusters with angles " << angle1 << " and "
62  << angle2 << std::endl;
63  }
64 
65  return !compatible;
66  }
67 
68 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
Class def header for a class CBAlgoAngleIncompat.
CBAlgoAngleIncompat()
Default constructor.
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)