CPAlgoArray.h
Go to the documentation of this file.
1 /**
2  * \file CPAlgoArray.h
3  *
4  * \ingroup CMTool
5  *
6  * \brief Class def header for a class CPAlgoArray
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup CMTool
12 
13  @{*/
14 #ifndef RECOTOOL_CPALGOARRAY_H
15 #define RECOTOOL_CPALGOARRAY_H
16 
18 
19 namespace cmtool {
20  /**
21  \class CPAlgoArray
22  User implementation for CPriorityAlgoBase class
23  This is an array of priority algorithms. It has multiple
24  modes to compute combined Priority() return value.
25  */
26  class CPAlgoArray : public CPriorityAlgoBase {
27 
28  public:
29 
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  */
54  };
55 
56  /// Default constructor
57  CPAlgoArray();
58 
59  /// Default destructor
60  virtual ~CPAlgoArray(){};
61 
62  /// Setter to add a new algorithm
63  void AddAlgo(CPriorityAlgoBase* algo) { _algo_array.push_back(algo); }
64 
65  /// Setter for an evaluation
66  void SetMode(EvaluationMode_t mode) { _mode = mode; }
67 
68  /**
69  Core function: given a set of CPANs, return a float which indicates
70  the compatibility the cluster combination.
71  */
72  virtual float Priority(const ::cluster::ClusterParamsAlg &cluster);
73 
74  /**
75  Optional function: called after each iterative approach if a manager class is
76  run with verbosity level <= kPerIteration. Maybe useful for debugging.
77  */
78  virtual void Report() { for(auto const& algo : _algo_array) algo->Report(); }
79 
80  /// Function to reset the algorithm instance, called together with manager's Reset()
81  virtual void Reset() { for(auto const& algo : _algo_array) algo->Reset(); }
82 
83  /**
84  Optional function: called at the beginning of 1st iteration. This is called per event.
85  */
86  virtual void EventBegin(const std::vector<cluster::ClusterParamsAlg> &clusters)
87  { for(auto const& algo : _algo_array) algo->EventBegin(clusters); }
88 
89  /**
90  Optional function: called at the end of event ... after the last merging iteration is over.
91  */
92  virtual void EventEnd()
93  { for(auto const& algo : _algo_array) algo->EventEnd(); }
94 
95  /**
96  Optional function: called at the beggining of each iterative loop.
97  This provides all clusters' information in case the algorithm need them. Note this
98  is called per iteration which may be more than once per event.
99  */
100  virtual void IterationBegin(const std::vector<cluster::ClusterParamsAlg> &clusters)
101  { for(auto const& algo : _algo_array) algo->IterationBegin(clusters); }
102 
103  /**
104  Optional function: called at the end of each iterative loop.
105  */
106  virtual void IterationEnd()
107  { for(auto const& algo : _algo_array) algo->IterationEnd(); }
108 
109  protected:
110 
111  /// vector of algorithms
112  std::vector<CPriorityAlgoBase*> _algo_array;
113 
114  /// evaluation mode
116 
117  };
118 }
119 #endif
120 /** @} */ // end of doxygen group
121 
virtual void EventEnd()
Definition: CPAlgoArray.h:92
virtual void EventBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CPAlgoArray.h:86
virtual void IterationEnd()
Definition: CPAlgoArray.h:106
void AddAlgo(CPriorityAlgoBase *algo)
Setter to add a new algorithm.
Definition: CPAlgoArray.h:63
Cluster finding and building.
virtual void IterationBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CPAlgoArray.h:100
Class def header for a class CPriorityAlgoBase.
virtual ~CPAlgoArray()
Default destructor.
Definition: CPAlgoArray.h:60
CPAlgoArray()
Default constructor.
Definition: CPAlgoArray.cxx:6
std::vector< CPriorityAlgoBase * > _algo_array
vector of algorithms
Definition: CPAlgoArray.h:112
virtual float Priority(const ::cluster::ClusterParamsAlg &cluster)
Definition: CPAlgoArray.cxx:14
virtual void Report()
Definition: CPAlgoArray.h:78
EvaluationMode_t _mode
evaluation mode
Definition: CPAlgoArray.h:115
virtual void Reset()
Function to reset the algorithm instance, called together with manager&#39;s Reset()
Definition: CPAlgoArray.h:81
void SetMode(EvaluationMode_t mode)
Setter for an evaluation.
Definition: CPAlgoArray.h:66