LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CFAlgoQRatio.cxx
Go to the documentation of this file.
2 
3 namespace cmtool {
4 
5  //-------------------------------------------------------
7  //-------------------------------------------------------
8  {
9  _qratio_cut = 0.1; // Preliminary cuts
10  }
11 
12  //-----------------------------
14  //-----------------------------
15  {}
16 
17  //-----------------------------------------------------------------------------------------
19  const std::vector<const cluster::ClusterParamsAlg*>& clusters)
20  //-----------------------------------------------------------------------------------------
21  {
22 
23  // Code-block by Kazu starts
24  // This ensures the algorithm works only if # clusters is > 2 (and not =2)
25  // You may take out this block if you want to allow matching using clusters from only 2 planes.
26  if (clusters.size() == 2) return -1;
27  // Code-block by Kazu ends
28 
29  double q_max = -1;
30  float ratio = 1;
31 
32  // Search for max charge & return if any cluster has negative charge
33  for (auto const& c : clusters) {
34 
35  //Ignore all clusters with less than 40 hits
36 
37  if (c->GetParams().sum_charge < 0) {
38  if (_verbose)
39  std::cout << "\033[00m Found a cluster with negative charge!\033[00m ... aborting "
40  << __FUNCTION__ << std::endl;
41  return -1;
42  }
43 
44  if (q_max < c->GetParams().sum_charge) q_max = c->GetParams().sum_charge;
45  }
46 
47  // Compute ratio
48  for (auto const& c : clusters) {
49  ratio *= c->GetParams().sum_charge / q_max;
50 
51  if (_verbose) {
52  std::cout << "Sum Charge: " << c->GetParams().sum_charge;
53  std::cout << "Q max : " << q_max << std::endl;
54  std::cout << "Ratio is: " << ratio << std::endl;
55  }
56  }
57 
58  if (_verbose) {
59  if (ratio > _qratio_cut)
60  std::cout << " ... pass!" << std::endl;
61  else
62  std::cout << " ... below cut value: " << _qratio_cut << std::endl;
63  }
64 
65  return (ratio > _qratio_cut ? ratio : -1);
66  }
67 
68  //------------------------------
70  //------------------------------
71  {}
72 
73 }
void Report() override
CFAlgoQRatio()
Default constructor.
Definition: CFAlgoQRatio.cxx:6
Class def header for a class CFAlgoQRatio.
float Float(util::GeometryUtilities const &, const std::vector< const cluster::ClusterParamsAlg * > &clusters) override
void Reset() override
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:82