LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CBAlgoAngleCompat.cxx
Go to the documentation of this file.
1 #ifndef RECOTOOL_CBALGOANGLECOMPAT_CXX
2 #define RECOTOOL_CBALGOANGLECOMPAT_CXX
3 
4 #include "CBAlgoAngleCompat.h"
5 
6 namespace cmtool {
7 
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
27 
28  bool CBAlgoAngleCompat::Bool(const ::cluster::ClusterParamsAlg &cluster1,
29  const ::cluster::ClusterParamsAlg &cluster2)
30  {
31 
32  //if number of hits not large enough skip
33  if ( _minHits and ((cluster1.GetHitVector().size() < _minHits) or (cluster2.GetHitVector().size() < _minHits)) ) {
34  return false;
35  }
36 
37  //pretty sure we don't need conversion factors here.
38  //already in cm/cm units, degrees? need to check that
39  double angle1 = cluster1.GetParams().angle_2d;// * _time_2_cm / _wire_2_cm;
40  double angle2 = cluster2.GetParams().angle_2d;// * _time_2_cm / _wire_2_cm;
41 
42  double w_start1 = cluster1.GetParams().start_point.w;// * _wire_2_cm;
43  double t_start1 = cluster1.GetParams().start_point.t;// * _time_2_cm;
44  double w_start2 = cluster2.GetParams().start_point.w;// * _wire_2_cm;
45  double t_start2 = cluster2.GetParams().start_point.t;// * _time_2_cm;
46 
47  if (_debug){
48 
49  std::cout << "Cluster 1:" << std::endl;
50  std::cout << "\tAngle: " << angle1 << std::endl;
51  std::cout << "\tStart: ( " << w_start1 << ", " << t_start1 << " )" << std::endl;
52  std::cout << "Cluster 2:" << std::endl;
53  std::cout << "\tAngle: " << angle2 << std::endl;
54  std::cout << "\tStart: ( " << w_start2 << ", " << t_start2 << " )" << std::endl;
55 
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)
62  return false;
63 
64  // if(angle_dist_histo){
65  // angle_dist_histo->Fill(angle1-angle2);
66  // }
67  // else
68  // std::cout<<"\n\n\nSOMETHING WENT HORRIBLY WRONG IN CBALGOANGLECOMPAT\n\n\n\n\n\n\n"<<std::endl;
69 
70  bool compatible = false;
71 
72  double my_cut_value = _max_allowed_2D_angle_diff;
73  //if using opening angle, have angle cutoff be the smaller of the two opening angles
75  my_cut_value = std::min(cluster1.GetParams().opening_angle, cluster2.GetParams().opening_angle);
76 
77  //if you don't care if clusters have been reconstructed backwards
79  compatible = ( abs(angle1-angle2) < my_cut_value ||
80  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 
86  if(_verbose) {
87  if(compatible) std::cout<<"These two clusters are compatible in angle."<<std::endl;
88  else std::cout<<"These two clusters are NOT compatible in angle."<<std::endl;
89  }
90 
91  return compatible;
92 
93  } // end Merge function
94 
95 
96 }//end namespace cmtool
97 #endif
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Overloaded (from CBoolAlgoBase) Bool function.
void SetDebug(bool on)
Method to set debug mode.
Class def header for a class CBAlgoAngleCompat.
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.
CBAlgoAngleCompat()
Default constructor.
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)
Int_t min
Definition: plot.C:26
void SetMinHits(size_t n)
Set Minimum Number of Hits to consider Cluster.
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:88