LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CFAlgoQRatio.cxx
Go to the documentation of this file.
1 #ifndef RECOTOOL_CFALGOQRATIO_CXX
2 #define RECOTOOL_CFALGOQRATIO_CXX
3 
4 #include "CFAlgoQRatio.h"
5 
6 namespace cmtool {
7 
8  //-------------------------------------------------------
10  //-------------------------------------------------------
11  {
12  _qratio_cut = 0.1 ;// Preliminary cuts
13 
14  }
15 
16  //-----------------------------
18  //-----------------------------
19  {
20 
21  }
22 
23  //-----------------------------------------------------------------------------------------
24  float CFAlgoQRatio::Float(const std::vector<const cluster::ClusterParamsAlg*> &clusters)
25  //-----------------------------------------------------------------------------------------
26  {
27 
28  // Code-block by Kazu starts
29  // This ensures the algorithm works only if # clusters is > 2 (and not =2)
30  // You may take out this block if you want to allow matching using clusters from only 2 planes.
31  if(clusters.size()==2) return -1;
32  // Code-block by Kazu ends
33 
34  double q_max = -1;
35  float ratio = 1;
36 
37  // Search for max charge & return if any cluster has negative charge
38  for(auto const& c : clusters) {
39 
40  //Ignore all clusters with less than 40 hits
41 
42  if(c->GetParams().sum_charge < 0) {
43  if(_verbose)
44  std::cout
45  << "\033[00m Found a cluster with negative charge!\033[00m ... aborting "
46  << __FUNCTION__ <<std::endl;
47  return -1;
48  }
49 
50 
51  if(q_max < c->GetParams().sum_charge)
52  q_max = c->GetParams().sum_charge;
53 
54  }
55 
56  // Compute ratio
57  for(auto const& c : clusters){
58  ratio *= c->GetParams().sum_charge / q_max;
59 
60  if(_verbose){
61  std::cout<<"Sum Charge: "<<c->GetParams().sum_charge ;
62  std::cout<<"Q max : "<<q_max<<std::endl ;
63  std::cout<<"Ratio is: "<<ratio<<std::endl;
64  }
65  }
66 
67  if(_verbose) {
68  if( ratio > _qratio_cut ) std::cout << " ... pass!" << std::endl;
69  else std::cout << " ... below cut value: " << _qratio_cut << std::endl;
70  }
71 
72  return ( ratio > _qratio_cut ? ratio : -1 );
73  }
74 
75 
76  //------------------------------
78  //------------------------------
79  {
80 
81  }
82 
83 }
84 #endif
virtual void Report()
CFAlgoQRatio()
Default constructor.
Definition: CFAlgoQRatio.cxx:9
virtual float Float(const std::vector< const cluster::ClusterParamsAlg * > &clusters)
Class def header for a class CFAlgoQRatio.
virtual void Reset()
Function to reset the algorithm instance, called together with manager&#39;s Reset()
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:88