LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CBAlgoAngleAlign.cxx
Go to the documentation of this file.
1 #ifndef RECOTOOL_CBALGOANGLEALIGN_CXX
2 #define RECOTOOL_CBALGOANGLEALIGN_CXX
3 
4 #include "CBAlgoAngleAlign.h"
5 
6 namespace cmtool {
7 
9 
10  //this just sets default values
11  SetDebug(true);
12  SetAngleCut(10.); // in degrees
13  SetAllow180Ambig(false);
14  SetMinNHits(30);
15 
16 
17  } //end constructor
18 
19  bool CBAlgoAngleAlign::Bool(const ::cluster::ClusterParamsAlg &cluster1,
20  const ::cluster::ClusterParamsAlg &cluster2)
21  {
22 
23  double angle1 = cluster1.GetParams().angle_2d;
24  double angle2 = cluster2.GetParams().angle_2d;
25  size_t hits1 = cluster1.GetHitVector().size();
26  size_t hits2 = cluster2.GetHitVector().size();
27 
28  //if don't make hit cut return aflse
29  if ( (hits1 < _MinNHits) or (hits2 < _MinNHits) )
30  return false;
31 
32  if (_debug){
33  std::cout << "Cluster1:" << std::endl;
34  std::cout << "\tAngle: " << angle1 << std::endl;
35  std::cout << "\t Start: (" << cluster1.GetParams().start_point.w << ", " << cluster1.GetParams().start_point.t << ")" << std::endl;
36  std::cout << "Cluster2:" << std::endl;
37  std::cout << "\tAngle: " << angle2 << std::endl;
38  std::cout << "\t Start: (" << cluster2.GetParams().start_point.w << ", " << cluster2.GetParams().start_point.t << ")" << std::endl;
39  std::cout << std::endl;
40 
41  }
42 
43  //for some reason angles are frequently -999.99.
44  //if either angle is this, clearly the cluster 2d angle is not well defined
45  //and this algorithm does not apply
46  if(angle1 < -998 || angle2 < -998)
47  return false;
48 
49  bool compatible = false;
50 
51  //if you don't care if clusters have been reconstructed backwards
53  compatible = ( abs(angle1-angle2) < _MaxAngleSep ||
54  abs(angle1-angle2-180) < _MaxAngleSep ||
55  abs(angle1-angle2+180) < _MaxAngleSep );
56  else
57  compatible = ( abs(angle1-angle2) < _MaxAngleSep );
58 
59 
60  if(_verbose) {
61  if(compatible) std::cout<<"These two clusters are compatible in angle."<<std::endl;
62  }
63 
64  return compatible;
65 
66  } // end Merge function
67 
68 
69 }//end namespace cmtool
70 #endif
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
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:88
Class def header for a class CBAlgoAngleAlign.