All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
cmtool::CPAlgoArray Class Reference

#include <CPAlgoArray.h>

Inheritance diagram for cmtool::CPAlgoArray:
cmtool::CPriorityAlgoBase cmtool::CMAlgoBase

Public Types

enum  EvaluationMode_t { kPositiveAddition, kSimpleAddition, kMultiplication, kLastAlgo }
 

Public Member Functions

 CPAlgoArray ()
 Default constructor. More...
 
virtual ~CPAlgoArray ()
 Default destructor. More...
 
void AddAlgo (CPriorityAlgoBase *algo)
 Setter to add a new algorithm. More...
 
void SetMode (EvaluationMode_t mode)
 Setter for an evaluation. More...
 
virtual float Priority (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 ()
 
- Public Member Functions inherited from cmtool::CPriorityAlgoBase
 CPriorityAlgoBase ()
 Default constructor. More...
 
virtual ~CPriorityAlgoBase ()
 Default destructor. More...
 
virtual float Priority (const cluster::ClusterParamsAlg &cluster)
 
- Public Member Functions inherited from cmtool::CMAlgoBase
 CMAlgoBase ()
 
virtual ~CMAlgoBase ()=default
 
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< CPriorityAlgoBase * > _algo_array
 vector of algorithms More...
 
EvaluationMode_t _mode
 evaluation mode More...
 
- Protected Attributes inherited from cmtool::CMAlgoBase
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 CPriorityAlgoBase class This is an array of priority algorithms. It has multiple modes to compute combined Priority() return value.

Definition at line 26 of file CPAlgoArray.h.

Member Enumeration Documentation

Enumerator
kPositiveAddition 

DEFAULT: simply add Priority() 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 Priority() return values from all algorithms. Note some algorithms are allowed to return negative values.

kMultiplication 

Multiply Priority() 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 Priority() return value. If any algorithm returns negative, it returns that and stop processing the rest of algorithms

Definition at line 30 of file CPAlgoArray.h.

30  {
31  /**
32  DEFAULT: simply add Priority() return values except negative return.
33  If there is a negative return value, it returns that and stop processing
34  the rest of algorithms
35  */
37  /**
38  Simply add Priority() return values from all algorithms.
39  Note some algorithms are allowed to return negative values.
40  */
42  /**
43  Multiply Priority() return values from all algorithms except negative
44  return. If there is a negative return, it returns that and stop
45  processing the rest of algorithms
46  */
48  /**
49  If all algorithms return positive values, return the last algorithm's
50  Priority() return value. If any algorithm returns negative, it returns that
51  and stop processing the rest of algorithms
52  */
53  kLastAlgo,
54  };

Constructor & Destructor Documentation

cmtool::CPAlgoArray::CPAlgoArray ( )

Default constructor.

Definition at line 6 of file CPAlgoArray.cxx.

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

Default destructor.

Definition at line 60 of file CPAlgoArray.h.

60 {};

Member Function Documentation

void cmtool::CPAlgoArray::AddAlgo ( CPriorityAlgoBase algo)
inline

Setter to add a new algorithm.

Definition at line 63 of file CPAlgoArray.h.

63 { _algo_array.push_back(algo); }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
virtual void cmtool::CPAlgoArray::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 CPAlgoArray.h.

87  { for(auto const& algo : _algo_array) algo->EventBegin(clusters); }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
virtual void cmtool::CPAlgoArray::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 CPAlgoArray.h.

93  { for(auto const& algo : _algo_array) algo->EventEnd(); }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
virtual void cmtool::CPAlgoArray::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 CPAlgoArray.h.

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

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 106 of file CPAlgoArray.h.

107  { for(auto const& algo : _algo_array) algo->IterationEnd(); }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
float cmtool::CPAlgoArray::Priority ( const ::cluster::ClusterParamsAlg cluster)
virtual

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

Definition at line 14 of file CPAlgoArray.cxx.

16  {
17 
18  std::vector<float> score_array;
19  score_array.reserve(_algo_array.size());
20 
21  for(auto const& algo : _algo_array) {
22 
23  float score = algo->Priority(cluster);
24 
25  if(_mode != kSimpleAddition && score < 0)
26 
27  return score;
28 
29  score_array.push_back(score);
30 
31  }
32 
33  float score_result = 0;
34 
35  switch(_mode) {
36 
37  case kLastAlgo:
38 
39  score_result = (*score_array.rbegin());
40  break;
41 
42  case kSimpleAddition:
43  case kPositiveAddition:
44 
45  for(auto const& score : score_array) score_result += score;
46  break;
47 
48  case kMultiplication:
49 
50  for(auto const& score : score_array) score_result *= score;
51  break;
52 
53  }
54 
55  return score_result;
56  }
BEGIN_PROLOG or score(default)}sbnd_crttrackmatchingalg_crID
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
EvaluationMode_t _mode
evaluation mode
Definition: CPAlgoArray.h:115
virtual void cmtool::CPAlgoArray::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 CPAlgoArray.h.

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

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 81 of file CPAlgoArray.h.

81 { for(auto const& algo : _algo_array) algo->Reset(); }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
void cmtool::CPAlgoArray::SetMode ( EvaluationMode_t  mode)
inline

Setter for an evaluation.

Definition at line 66 of file CPAlgoArray.h.

66 { _mode = mode; }
const char mode
Definition: noise_ana.cxx:20
EvaluationMode_t _mode
evaluation mode
Definition: CPAlgoArray.h:115

Member Data Documentation

std::vector<CPriorityAlgoBase*> cmtool::CPAlgoArray::_algo_array
protected

vector of algorithms

Definition at line 112 of file CPAlgoArray.h.

EvaluationMode_t cmtool::CPAlgoArray::_mode
protected

evaluation mode

Definition at line 115 of file CPAlgoArray.h.


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