LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 ()
 
virtual float Priority (const cluster::ClusterParamsAlg &cluster)
 
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...
 
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 29 of file CPAlgoArray.h.

Constructor & Destructor Documentation

cmtool::CPAlgoArray::CPAlgoArray ( )

Default constructor.

Definition at line 6 of file CPAlgoArray.cxx.

References _algo_array, _mode, and kPositiveAddition.

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

Default destructor.

Definition at line 59 of file CPAlgoArray.h.

59 {};

Member Function Documentation

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

Setter to add a new algorithm.

Definition at line 62 of file CPAlgoArray.h.

References _algo_array.

Referenced by ShowerReco3D::ShowerReco3D().

62 { _algo_array.push_back(algo); }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:130
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 93 of file CPAlgoArray.h.

References _algo_array.

94  {
95  for (auto const& algo : _algo_array)
96  algo->EventBegin(clusters);
97  }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:130
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 102 of file CPAlgoArray.h.

References _algo_array.

103  {
104  for (auto const& algo : _algo_array)
105  algo->EventEnd();
106  }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:130
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 113 of file CPAlgoArray.h.

References _algo_array.

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

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 122 of file CPAlgoArray.h.

References _algo_array.

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

Core function: given the CPAN input, return whether a cluster should be merged or not.

Definition at line 40 of file CPriorityAlgoBase.h.

References cluster::ClusterParamsAlg::GetNHits().

Referenced by cmtool::CMManagerBase::ComputePriority().

41  {
42  if (cluster.GetNHits()) return 1.;
43  return 0.1;
44  }
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.

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

Referenced by SetMode().

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) return score;
26 
27  score_array.push_back(score);
28  }
29 
30  float score_result = 0;
31 
32  switch (_mode) {
33 
34  case kLastAlgo: score_result = (*score_array.rbegin()); break;
35 
36  case kSimpleAddition:
37  case kPositiveAddition:
38 
39  for (auto const& score : score_array)
40  score_result += score;
41  break;
42 
43  case kMultiplication:
44 
45  for (auto const& score : score_array)
46  score_result *= score;
47  break;
48  }
49 
50  return score_result;
51  }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:130
EvaluationMode_t _mode
evaluation mode
Definition: CPAlgoArray.h:133
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 77 of file CPAlgoArray.h.

References _algo_array.

78  {
79  for (auto const& algo : _algo_array)
80  algo->Report();
81  }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:130
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 84 of file CPAlgoArray.h.

References _algo_array.

85  {
86  for (auto const& algo : _algo_array)
87  algo->Reset();
88  }
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:130
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::CPAlgoArray::SetMode ( EvaluationMode_t  mode)
inline

Setter for an evaluation.

Definition at line 65 of file CPAlgoArray.h.

References _mode, and Priority().

65 { _mode = mode; }
EvaluationMode_t _mode
evaluation mode
Definition: CPAlgoArray.h:133
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

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

vector of algorithms

Definition at line 130 of file CPAlgoArray.h.

Referenced by AddAlgo(), CPAlgoArray(), EventBegin(), EventEnd(), IterationBegin(), IterationEnd(), Priority(), Report(), and Reset().

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

EvaluationMode_t cmtool::CPAlgoArray::_mode
protected

evaluation mode

Definition at line 133 of file CPAlgoArray.h.

Referenced by CPAlgoArray(), Priority(), and SetMode().


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