LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cmtool::CFAlgoQRatio Class Reference

#include "CFAlgoQRatio.h"

Inheritance diagram for cmtool::CFAlgoQRatio:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgoQRatio ()
 Default constructor. More...
 
float Float (util::GeometryUtilities const &, const std::vector< const cluster::ClusterParamsAlg * > &clusters) override
 
void Report () override
 
void Reset () override
 Function to reset the algorithm instance, called together with manager's Reset() More...
 
void SetQRatioCut (float cut)
 Setter for the minimum value for charge ratio (below this value Float() returns -1) More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
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 _qratio_cut
 
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 This algorithm compares charge ratio of clusters to find a match

Definition at line 25 of file CFAlgoQRatio.h.

Constructor & Destructor Documentation

cmtool::CFAlgoQRatio::CFAlgoQRatio ( )

Default constructor.

Definition at line 6 of file CFAlgoQRatio.cxx.

References _qratio_cut.

6  : CFloatAlgoBase()
7  //-------------------------------------------------------
8  {
9  _qratio_cut = 0.1; // Preliminary cuts
10  }

Member Function Documentation

virtual void cmtool::CMAlgoBase::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  )
inlinevirtualinherited

Optional function: called at the beginning of 1st iteration. This is called per event.

Reimplemented in cmtool::CPAlgoArray, cmtool::CBAlgoArray, and cmtool::CBAlgoPolyShortestDist.

Definition at line 45 of file CMAlgoBase.h.

Referenced by cmtool::CMergeManager::EventBegin().

45 {}
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

Optional function: called at the end of event ... after the last merging iteration is over.

Reimplemented in cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 50 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventEnd(), and cmtool::CMergeManager::EventEnd().

50 {}
float cmtool::CFAlgoQRatio::Float ( util::GeometryUtilities const &  ,
const std::vector< const cluster::ClusterParamsAlg * > &  clusters 
)
overridevirtual

Core function: given a set of CPANs, return a float which indicates the compatibility the cluster combination.

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 18 of file CFAlgoQRatio.cxx.

References _qratio_cut, and cmtool::CMAlgoBase::_verbose.

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  }
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:82
virtual void cmtool::CMAlgoBase::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  )
inlinevirtualinherited

Optional function: called at the beggining of each iteration over all pairs of clusters. This provides all clusters' information in case the algorithm need them. Note this is called per iteration which may be more than once per event.

Reimplemented in cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 57 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventBegin(), cmtool::CMatchManager::IterationBegin(), and cmtool::CMergeManager::IterationBegin().

57 {}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

Optional function: called at the end of each iteration over all pairs of clusters.

Reimplemented in cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 62 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::IterationEnd(), and cmtool::CMergeManager::IterationEnd().

62 {}
void cmtool::CFAlgoQRatio::Report ( )
overridevirtual

Optional function: called after each iterative approach if a manager class is run with verbosity level <= kPerIteration. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 69 of file CFAlgoQRatio.cxx.

71  {}
void cmtool::CFAlgoQRatio::Reset ( )
overridevirtual

Function to reset the algorithm instance, called together with manager's Reset()

Reimplemented from cmtool::CMAlgoBase.

Definition at line 13 of file CFAlgoQRatio.cxx.

15  {}
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 72 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

Referenced by cmtool::CMergeManager::EventBegin().

72 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:79
void cmtool::CFAlgoQRatio::SetQRatioCut ( float  cut)
inline

Setter for the minimum value for charge ratio (below this value Float() returns -1)

Definition at line 54 of file CFAlgoQRatio.h.

References _qratio_cut.

54 { _qratio_cut = cut; }
virtual void cmtool::CMAlgoBase::SetVerbose ( bool  doit = true)
inlinevirtualinherited

Setter function for verbosity.

Reimplemented in cmtool::CBAlgoArray, and cmtool::CFAlgoTimeOverlap.

Definition at line 75 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_verbose.

Referenced by cmtool::CMatchManager::EventBegin(), and cmtool::CMergeManager::EventBegin().

75 { _verbose = doit; }
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:82

Member Data Documentation

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 79 of file CMAlgoBase.h.

Referenced by cmtool::CMAlgoBase::CMAlgoBase(), and cmtool::CMAlgoBase::SetAnaFile().

float cmtool::CFAlgoQRatio::_qratio_cut
protected

Definition at line 57 of file CFAlgoQRatio.h.

Referenced by CFAlgoQRatio(), Float(), and SetQRatioCut().


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