CFAlgoArray.h
Go to the documentation of this file.
1 /**
2  * \file CFAlgoArray.h
3  *
4  * \ingroup CMTool
5  *
6  * \brief Class def header for a class CFAlgoArray
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup CMTool
12 
13  @{*/
14 #ifndef RECOTOOL_CFALGOARRAY_H
15 #define RECOTOOL_CFALGOARRAY_H
16 
18 
19 namespace cmtool {
20  /**
21  \class CFAlgoArray
22  User implementation for CFloatAlgoBase class
23  This is an array of priority algorithms. It has multiple
24  modes to compute combined Float() return value.
25  */
26  class CFAlgoArray : public CFloatAlgoBase {
27 
28  public:
29 
31  /**
32  DEFAULT: simply add Float() 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 Float() return values from all algorithms.
39  Note some algorithms are allowed to return negative values.
40  */
42  /**
43  Multiply Float() 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  Float() 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  CFAlgoArray();
58 
59  /// Default destructor
60  virtual ~CFAlgoArray(){};
61 
62  /// Setter to add a new algorithm
63  void AddAlgo(CFloatAlgoBase* 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 Float(const std::vector<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<CFloatAlgoBase*> _algo_array;
113 
114  /// evaluation mode
116 
117  };
118 }
119 #endif
120 /** @} */ // end of doxygen group
121 
CFAlgoArray()
Default constructor.
Definition: CFAlgoArray.cxx:6
virtual float Float(const std::vector< const cluster::ClusterParamsAlg * > &cluster)
Definition: CFAlgoArray.cxx:14
EvaluationMode_t _mode
evaluation mode
Definition: CFAlgoArray.h:115
Class def header for a class CFloatAlgoBase.
Cluster finding and building.
virtual ~CFAlgoArray()
Default destructor.
Definition: CFAlgoArray.h:60
virtual void IterationBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CFAlgoArray.h:100
void SetMode(EvaluationMode_t mode)
Setter for an evaluation.
Definition: CFAlgoArray.h:66
virtual void EventBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CFAlgoArray.h:86
virtual void Report()
Definition: CFAlgoArray.h:78
virtual void Reset()
Function to reset the algorithm instance, called together with manager&#39;s Reset()
Definition: CFAlgoArray.h:81
std::vector< CFloatAlgoBase * > _algo_array
vector of algorithms
Definition: CFAlgoArray.h:112
virtual void EventEnd()
Definition: CFAlgoArray.h:92
void AddAlgo(CFloatAlgoBase *algo)
Setter to add a new algorithm.
Definition: CFAlgoArray.h:63
Definition: cfalgo.cc:3
virtual void IterationEnd()
Definition: CFAlgoArray.h:106