LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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...
 
virtual ~CFAlgoQRatio ()
 Default destructor. More...
 
virtual float Float (const std::vector< const cluster::ClusterParamsAlg * > &clusters)
 
virtual void Report ()
 
virtual void Reset ()
 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 > &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 _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 9 of file CFAlgoQRatio.cxx.

References _qratio_cut.

10  //-------------------------------------------------------
11  {
12  _qratio_cut = 0.1 ;// Preliminary cuts
13 
14  }
CFloatAlgoBase()
Default constructor.
virtual cmtool::CFAlgoQRatio::~CFAlgoQRatio ( )
inlinevirtual

Default destructor.

Definition at line 33 of file CFAlgoQRatio.h.

References Float(), Report(), and Reset().

33 {};

Member Function Documentation

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

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

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

Definition at line 45 of file CMAlgoBase.h.

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

46  { if(clusters.size()) return; }
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

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

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

Definition at line 51 of file CMAlgoBase.h.

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

52  {return;}
float cmtool::CFAlgoQRatio::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  clusters)
virtual

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

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 24 of file CFAlgoQRatio.cxx.

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

Referenced by ~CFAlgoQRatio().

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

Definition at line 59 of file CMAlgoBase.h.

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

60  { if(clusters.size()) return;}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

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

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

Definition at line 65 of file CMAlgoBase.h.

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

66  {return; }
void cmtool::CFAlgoQRatio::Report ( )
virtual

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 77 of file CFAlgoQRatio.cxx.

Referenced by ~CFAlgoQRatio().

79  {
80 
81  }
void cmtool::CFAlgoQRatio::Reset ( )
virtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 17 of file CFAlgoQRatio.cxx.

Referenced by ~CFAlgoQRatio().

19  {
20 
21  }
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 77 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

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

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

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

Definition at line 57 of file CFAlgoQRatio.h.

References _qratio_cut.

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

Member Data Documentation

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 85 of file CMAlgoBase.h.

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

float cmtool::CFAlgoQRatio::_qratio_cut
protected

Definition at line 61 of file CFAlgoQRatio.h.

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


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