Public Member Functions | Protected Attributes | List of all members
cmtool::CFAlgo3DAngle Class Reference

#include <CFAlgo3DAngle.h>

Inheritance diagram for cmtool::CFAlgo3DAngle:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgo3DAngle ()
 Default constructor. More...
 
virtual ~CFAlgo3DAngle ()
 Default destructor. More...
 
virtual float Float (const std::vector< const cluster::ClusterParamsAlg * > &clusters)
 
virtual void FixPhiTheta (double &phi, double &theta)
 
virtual void SetMaxMiddleMin (const double first, const double second, const double third, double &most, double &middle, double &least)
 
void SetDebug (bool debug)
 
void SetThetaCut (float theta_cut)
 
void SetPhiCut (float phi_cut)
 
void SetRatio (float ratio)
 
virtual void Report ()
 
virtual void Reset ()
 Function to reset the algorithm instance called within CMergeManager/CMatchManager's Reset() ... maybe implemented via child class. More...
 
- Public Member Functions inherited from cmtool::CFloatAlgoBase
 CFloatAlgoBase ()
 Default constructor. More...
 
virtual ~CFloatAlgoBase ()
 Default destructor. More...
 
- Public Member Functions inherited from cmtool::CMAlgoBase
 CMAlgoBase ()
 Default constructor. More...
 
virtual ~CMAlgoBase ()
 Default destructor. More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void IterationEnd ()
 
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

float _theta_cut
 
float _phi_cut
 
float _ratio_cut
 
float _debug
 
- Protected Attributes inherited from cmtool::CMAlgoBase
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 implementation for CFloatAlgoBase class doxygen documentation!

Definition at line 25 of file CFAlgo3DAngle.h.

Constructor & Destructor Documentation

cmtool::CFAlgo3DAngle::CFAlgo3DAngle ( )

Default constructor.

Definition at line 8 of file CFAlgo3DAngle.cxx.

9  //-------------------------------------------------------
10  {
11 
12  SetDebug(false) ;
13  SetThetaCut(30) ;
14  SetPhiCut(40) ;
15  SetRatio(0.0005) ;
16 
17  }
void SetRatio(float ratio)
Definition: CFAlgo3DAngle.h:56
CFloatAlgoBase()
Default constructor.
void SetDebug(bool debug)
Definition: CFAlgo3DAngle.h:50
void SetThetaCut(float theta_cut)
Definition: CFAlgo3DAngle.h:52
void SetPhiCut(float phi_cut)
Definition: CFAlgo3DAngle.h:54
virtual cmtool::CFAlgo3DAngle::~CFAlgo3DAngle ( )
inlinevirtual

Default destructor.

Definition at line 33 of file CFAlgo3DAngle.h.

33 {};

Member Function Documentation

void cmtool::CFAlgo3DAngle::FixPhiTheta ( double &  phi,
double &  theta 
)
virtual

If phi or theta are <360 (or greater than), adjust them to be in a more easily comparable range.

Definition at line 170 of file CFAlgo3DAngle.cxx.

172  {
173  // while(phi <= 0)
174  // phi += 360 ;
175  // while(phi > 720)
176  // phi -= 360 ;
177 // if(phi <=0)
178 
179  phi+=360;
180 
181  if(theta != -999)
182  theta += 180 ;
183 
184  }
float cmtool::CFAlgo3DAngle::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  clusters)
virtual

Calculate 3d angles from all permutations of the 3 planes. Weight them according to charge profile. Choose the 2 best weights and compare those 2 theta and phi

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 27 of file CFAlgo3DAngle.cxx.

29  {
30  // Code-block by Kazu starts
31  // This ensures the algorithm works only if # clusters is > 2 (and not =2)
32  // You may take out this block if you want to allow matching using clusters from only 2 planes.
33  if(clusters.size()==2 || clusters.size()==1) return -1;
34  // Code-block by Kazu ends
35 
36 
37  int plane_0 = clusters.at(0)->Plane();
38  int plane_1 = clusters.at(1)->Plane();
39  int plane_2 = clusters.at(2)->Plane();
40  double angle_2d_0 = clusters.at(0)->GetParams().angle_2d;
41  double angle_2d_1 = clusters.at(1)->GetParams().angle_2d;
42  double angle_2d_2 = clusters.at(2)->GetParams().angle_2d;
43  auto hits_0 = clusters.at(0)->GetParams().N_Hits ;
44  auto hits_1 = clusters.at(1)->GetParams().N_Hits ;
45  auto hits_2 = clusters.at(2)->GetParams().N_Hits ;
46 
47  auto sumCharge0 = clusters.at(0)->GetParams().sum_charge;
48  auto sumCharge1 = clusters.at(1)->GetParams().sum_charge;
49  auto sumCharge2 = clusters.at(2)->GetParams().sum_charge;
50 
51  //Calculate angles theta and phi for cluster pairs across 2 planes
52  //Theta goes from -90 to 90, phi from -180 to 180
53  double phi_01 = 0;
54  double theta_01 = 0;
55  double phi_12 = 0;
56  double theta_12 = 0;
57  double phi_02 = 0;
58  double theta_02 = 0;
59 
60  double max_phi(0), middle_phi(0), min_phi(0);
61  double max_theta(0), middle_theta(0), min_theta(0);
62  //When theta1, theta2, phi ratios are calcualted, find best 2
63  double max_ratio(0), middle_ratio(0), min_ratio(0);
64 
65  //For ordering hits and rejecting pairs which have a large difference in hit number
66  double max_hits(0), middle_hits(0), min_hits(0) ;
67 // double max_hits1(0), middle_hits1(0), min_hits1(0) ;
68 
69  //Calculate phi and theta from first 2 planes; check if third plane is consistent
71  geou.Get3DaxisN(plane_0,plane_1,angle_2d_0,angle_2d_1,phi_01,theta_01);
72  geou.Get3DaxisN(plane_1,plane_2,angle_2d_1,angle_2d_2,phi_12,theta_12);
73  geou.Get3DaxisN(plane_2,plane_0,angle_2d_2,angle_2d_0,phi_02,theta_02);
74 
75  //Adjust the range of phis/thetas that are bigger than 360 or less than 0.
76  FixPhiTheta(phi_01,theta_01);
77  FixPhiTheta(phi_12,theta_12);
78  FixPhiTheta(phi_02,theta_02);
79 
80  //Order phi and theta for ratio calculation later
81  SetMaxMiddleMin(phi_01,phi_12,phi_02,max_phi,middle_phi,min_phi);
82  SetMaxMiddleMin(theta_01,theta_12,theta_02,max_theta,middle_theta,min_theta);
83 
84  //Order hits from most to least
85  SetMaxMiddleMin(hits_0,hits_1,hits_2,max_hits,middle_hits,min_hits);
86 
87  //Ratio for hits
88  double ratio_max_min = 1;
89  double ratio_max_middle = 1;
90 
91  //Ratio for theta angles
92  double ratio_theta1 = 1;
93  double ratio_theta2 = 1;
94 
95  //Ratio for phi--only 1 ratio because 2 of the angles come from collection plane 2
96  //and are thus the same.
97  double ratio_phi = 1;
98 
99  //Total ratio
100  double ratio = 1;
101 
102  //This takes into account the fact that 0 and 360 having the same relative value (for phi; 0 and 180 for theta)
103  for(int i=0; i<2 ; i++){
104  while(min_phi + 360 < max_phi +_phi_cut && min_phi +360 > max_phi - _phi_cut)
105  {
106  min_phi +=360 ;
107  SetMaxMiddleMin(max_phi, middle_phi, min_phi,max_phi,middle_phi,min_phi);
108  }
109  }
110 
111  ratio_theta2 = min_theta / max_theta;
112  ratio_theta1 = middle_theta / max_theta;
113  ratio_phi = min_phi / max_phi ;
114 
115  //Get the biggest ratios for the thetas and phi
116  SetMaxMiddleMin(ratio_phi, ratio_theta1, ratio_theta2, max_ratio, middle_ratio, min_ratio);
117 
118  ratio_max_min = min_hits / max_hits ;
119  ratio_max_middle = middle_hits / max_hits ;
120 
121  ratio = max_ratio * sumCharge1* sumCharge2 * sumCharge0; //* ; //* ratio_phi ; //* ratio_max_middle ;
122 
123  //Test to make sure that max hits is not too much bigger than min
124  if( ratio_max_min <0.3)
125  ratio *= ratio_max_min ;
126 
127  //GeometryUtilities returns theta=-999 when 2d Angle=0--Don't know
128  //how else to deal with that. This seems to work.
129  if( theta_01 == -999 || theta_12 == -999 || theta_02 == -999)
130  return -1 ;
131 
132 
133  if(_debug && ratio > _ratio_cut ){
134  std::cout<<"\nNhits planes 0, 1, 2: " <<clusters.at(0)->GetParams().N_Hits<<", "<<clusters.at(1)->GetParams().N_Hits
135  <<", "<<clusters.at(2)->GetParams().N_Hits ;
136  std::cout<<"\nTheta1 , Theta2 : "<<ratio_theta1<<", "<<ratio_theta2;
137  std::cout<<"\nPhi Ratio: "<<ratio_phi;
138  std::cout<<"\nHits ratio mid : "<<ratio_max_middle ;
139  // std::cout<<"\nHits ratio min : "<<ratio_max_min ;
140  std::cout<<"\nTotal is: " <<ratio<<" ***************";
141 
142 
143  std::cout<<"\n\n0: 2dAngle: "<<clusters.at(0)->GetParams().cluster_angle_2d<<std::endl;
144  std::cout<<"1: 2dAngle: "<<clusters.at(1)->GetParams().cluster_angle_2d<<std::endl;
145  std::cout<<"2: 2dAngle: "<<clusters.at(2)->GetParams().cluster_angle_2d<<std::endl;
146  std::cout<<"\nTheta,Phi MaxMM : "<<max_theta<<", "<<middle_theta<<", "<<min_theta<<"\n\t\t"
147  <<max_phi<<", "<<middle_phi<<", "<<min_phi;
148 
149  std::cout<<"\nStart End Points: "<<clusters.at(0)->GetParams().start_point.t<<", "<<clusters.at(0)->GetParams().end_point.t<<"\n\t\t"
150  <<clusters.at(1)->GetParams().start_point.t<<", "<<clusters.at(1)->GetParams().end_point.t<<"\n\t\t "
151  <<clusters.at(2)->GetParams().start_point.t<<", "<<clusters.at(2)->GetParams().end_point.t;
152 
153 /* std::cout<<"\nFor planes 0 and 1: "<<std::endl ;
154  std::cout<<"\tPhi : "<<phi_01<<std::endl;
155  std::cout<<"\tTheta : "<<theta_01<<std::endl ;
156  std::cout<<"For planes 1 and 2: "<<std::endl ;
157  std::cout<<"\tPhi : "<<phi_12<<std::endl;
158  std::cout<<"\tTheta : "<<theta_12<<std::endl ;
159  std::cout<<"For plane 0 and 2: "<<std::endl ;
160  std::cout<<"\tPhi : "<<phi_02<<std::endl ;
161  std::cout<<"\tTheta : "<<theta_02<<std::endl; */
162  // std::cout<<"\nNEW CLUSTERS PAIRS NOW\n\n\n"<<std::endl<<std::endl;
163  std::cout<<"\n\n\n";
164  }
165 
166  return(ratio > _ratio_cut ? ratio : -1) ;
167  }
virtual void SetMaxMiddleMin(const double first, const double second, const double third, double &most, double &middle, double &least)
virtual void FixPhiTheta(double &phi, double &theta)
Int_t Get3DaxisN(Int_t iplane0, Int_t iplane1, Double_t omega0, Double_t omega1, Double_t &phi, Double_t &theta) const
QTextStream & endl(QTextStream &s)
void cmtool::CFAlgo3DAngle::Report ( )
virtual

Optional function: called after Bool() function is called for all possible cluster pairs by CMergeManager/CMatchManager IFF run with verbosity level kPerIteration. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 269 of file CFAlgo3DAngle.cxx.

271  {
272 
273  }
void cmtool::CFAlgo3DAngle::Reset ( void  )
virtual

Function to reset the algorithm instance called within CMergeManager/CMatchManager's Reset() ... maybe implemented via child class.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 20 of file CFAlgo3DAngle.cxx.

22  {
23 
24  }
void cmtool::CFAlgo3DAngle::SetDebug ( bool  debug)
inline

Definition at line 50 of file CFAlgo3DAngle.h.

void cmtool::CFAlgo3DAngle::SetMaxMiddleMin ( const double  first,
const double  second,
const double  third,
double &  most,
double &  middle,
double &  least 
)
virtual

Definition at line 188 of file CFAlgo3DAngle.cxx.

190  {
191 
192  if(first > second && first > third){
193  max = first;
194  }
195  else if (first > second && first < third){
196  max = third ;
197  middle = first ;
198  min = second ;
199  }
200  else if (first > third && first < second){
201  max = second ;
202  middle = first ;
203  min = third ;
204  }
205  else if(first <second && first <third)
206  min = first ;
207 
208 
209  if (max == first && second > third){
210  middle = second ;
211  min = third ;
212  }
213  else if (max ==first && third > second){
214  middle = third ;
215  min = second ;
216  }
217 
218  if(min ==first && second > third){
219  middle = third ;
220  max = second;
221  }
222  else if(min ==first && third > second){
223  middle = second ;
224  max = third ;
225  }
226 
227 
228  //Very rarely, the angles(or hits) may be equal
229  if( first == second && first > third ){
230  max = first;
231  middle = second ;
232  min = third ;
233  }
234  else if( first == second && first < third){
235  max = third;
236  middle = first ;
237  min = second ;
238  }
239 
240  else if( first ==third && first > second){
241  max = first;
242  middle = third;
243  min = second;
244  }
245 
246  else if( first == third && first < second){
247  max = second ;
248  middle = first;
249  min = third ;
250  }
251 
252  else if( second ==third && second < first){
253  max = first;
254  middle = third;
255  min = second;
256  }
257 
258  else if( second == third && second > first){
259  max = second;
260  middle = third;
261  min = first ;
262  }
263 
264 
265 }
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
void cmtool::CFAlgo3DAngle::SetPhiCut ( float  phi_cut)
inline

Definition at line 54 of file CFAlgo3DAngle.h.

54 { _phi_cut = phi_cut ; }
void cmtool::CFAlgo3DAngle::SetRatio ( float  ratio)
inline

Definition at line 56 of file CFAlgo3DAngle.h.

void cmtool::CFAlgo3DAngle::SetThetaCut ( float  theta_cut)
inline

Definition at line 52 of file CFAlgo3DAngle.h.

52 { _theta_cut = theta_cut ; }

Member Data Documentation

float cmtool::CFAlgo3DAngle::_debug
protected

Definition at line 66 of file CFAlgo3DAngle.h.

float cmtool::CFAlgo3DAngle::_phi_cut
protected

Definition at line 64 of file CFAlgo3DAngle.h.

float cmtool::CFAlgo3DAngle::_ratio_cut
protected

Definition at line 65 of file CFAlgo3DAngle.h.

float cmtool::CFAlgo3DAngle::_theta_cut
protected

Definition at line 63 of file CFAlgo3DAngle.h.


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