LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
cmtool::CFAlgoArray Class Reference

#include "CFAlgoArray.h"

Inheritance diagram for cmtool::CFAlgoArray:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Types

enum  EvaluationMode_t { kPositiveAddition, kSimpleAddition, kMultiplication, kLastAlgo }
 

Public Member Functions

 CFAlgoArray ()
 Default constructor. More...
 
virtual ~CFAlgoArray ()
 Default destructor. More...
 
void AddAlgo (CFloatAlgoBase *algo)
 Setter to add a new algorithm. More...
 
void SetMode (EvaluationMode_t mode)
 Setter for an evaluation. More...
 
virtual float Float (const std::vector< const cluster::ClusterParamsAlg * > &cluster)
 
virtual void Report ()
 
virtual void Reset ()
 Function to reset the algorithm instance, called together with manager's Reset() 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

std::vector< CFloatAlgoBase * > _algo_array
 vector of algorithms More...
 
EvaluationMode_t _mode
 evaluation mode More...
 
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 is an array of priority algorithms. It has multiple modes to compute combined Float() return value.

Definition at line 26 of file CFAlgoArray.h.

Member Enumeration Documentation

Enumerator
kPositiveAddition 

DEFAULT: simply add Float() return values except negative return. If there is a negative return value, it returns that and stop processing the rest of algorithms

kSimpleAddition 

Simply add Float() return values from all algorithms. Note some algorithms are allowed to return negative values.

kMultiplication 

Multiply Float() return values from all algorithms except negative return. If there is a negative return, it returns that and stop processing the rest of algorithms

kLastAlgo 

If all algorithms return positive values, return the last algorithm's Float() return value. If any algorithm returns negative, it returns that and stop processing the rest of algorithms

Definition at line 30 of file CFAlgoArray.h.

Constructor & Destructor Documentation

cmtool::CFAlgoArray::CFAlgoArray ( )

Default constructor.

Definition at line 9 of file CFAlgoArray.cxx.

References _algo_array, _mode, and kPositiveAddition.

10  //-------------------------------------------------------
11  {
13  _algo_array.clear();
14  }
EvaluationMode_t _mode
evaluation mode
Definition: CFAlgoArray.h:115
CFloatAlgoBase()
Default constructor.
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual cmtool::CFAlgoArray::~CFAlgoArray ( )
inlinevirtual

Default destructor.

Definition at line 60 of file CFAlgoArray.h.

60 {};

Member Function Documentation

void cmtool::CFAlgoArray::AddAlgo ( CFloatAlgoBase algo)
inline

Setter to add a new algorithm.

Definition at line 63 of file CFAlgoArray.h.

References _algo_array.

63 { _algo_array.push_back(algo); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void cmtool::CFAlgoArray::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 86 of file CFAlgoArray.h.

References _algo_array.

87  { for(auto const& algo : _algo_array) algo->EventBegin(clusters); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void cmtool::CFAlgoArray::EventEnd ( )
inlinevirtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 92 of file CFAlgoArray.h.

References _algo_array.

93  { for(auto const& algo : _algo_array) algo->EventEnd(); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
float cmtool::CFAlgoArray::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  cluster)
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 17 of file CFAlgoArray.cxx.

References _algo_array, _mode, kLastAlgo, kMultiplication, kPositiveAddition, and kSimpleAddition.

Referenced by SetMode().

19  {
20 
21  std::vector<float> score_array;
22  score_array.reserve(_algo_array.size());
23 
24  for(auto const& algo : _algo_array) {
25 
26  float score = algo->Float(clusters);
27 
28  if(_mode != kSimpleAddition && score < 0)
29 
30  return score;
31 
32  score_array.push_back(score);
33 
34  }
35 
36  float score_result = 0;
37 
38  switch(_mode) {
39 
40  case kLastAlgo:
41 
42  score_result = (*score_array.rbegin());
43  break;
44 
45  case kSimpleAddition:
46  case kPositiveAddition:
47 
48  for(auto const& score : score_array) score_result += score;
49  break;
50 
51  case kMultiplication:
52 
53  for(auto const& score : score_array) score_result *= score;
54  break;
55 
56  }
57 
58  return score_result;
59  }
EvaluationMode_t _mode
evaluation mode
Definition: CFAlgoArray.h:115
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void cmtool::CFAlgoArray::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtual

Optional function: called at the beggining of each iterative loop. 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 from cmtool::CMAlgoBase.

Definition at line 100 of file CFAlgoArray.h.

References _algo_array.

101  { for(auto const& algo : _algo_array) algo->IterationBegin(clusters); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void cmtool::CFAlgoArray::IterationEnd ( )
inlinevirtual

Optional function: called at the end of each iterative loop.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 106 of file CFAlgoArray.h.

References _algo_array.

107  { for(auto const& algo : _algo_array) algo->IterationEnd(); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void cmtool::CFAlgoArray::Report ( )
inlinevirtual

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 78 of file CFAlgoArray.h.

References _algo_array.

78 { for(auto const& algo : _algo_array) algo->Report(); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void cmtool::CFAlgoArray::Reset ( )
inlinevirtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 81 of file CFAlgoArray.h.

References _algo_array.

81 { for(auto const& algo : _algo_array) algo->Reset(); }
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
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::CFAlgoArray::SetMode ( EvaluationMode_t  mode)
inline

Setter for an evaluation.

Definition at line 66 of file CFAlgoArray.h.

References _mode, and Float().

66 { _mode = mode; }
EvaluationMode_t _mode
evaluation mode
Definition: CFAlgoArray.h:115
virtual void cmtool::CMAlgoBase::SetVerbose ( bool  doit = true)
inlinevirtualinherited

Member Data Documentation

std::vector<CFloatAlgoBase*> cmtool::CFAlgoArray::_algo_array
protected

vector of algorithms

Definition at line 112 of file CFAlgoArray.h.

Referenced by AddAlgo(), CFAlgoArray(), EventBegin(), EventEnd(), Float(), IterationBegin(), IterationEnd(), Report(), and Reset().

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().

EvaluationMode_t cmtool::CFAlgoArray::_mode
protected

evaluation mode

Definition at line 115 of file CFAlgoArray.h.

Referenced by CFAlgoArray(), Float(), and SetMode().


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