All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CBAlgoArray.h
Go to the documentation of this file.
1 /**
2  * \file CBAlgoArray.h
3  *
4  * \ingroup CMTool
5  *
6  * \brief Class def header for a class CBAlgoArray
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup CMTool
12 
13  @{*/
14 #ifndef RECOTOOL_CBALGOARRAY_H
15 #define RECOTOOL_CBALGOARRAY_H
16 
19 
20 namespace cmtool {
21  /**
22  \class CBAlgoArray
23  User implementation for CBAlgoArray class
24  doxygen documentation!
25  */
26  class CBAlgoArray : public CBoolAlgoBase {
27 
28  public:
29 
30  /// Default constructor
31  CBAlgoArray();
32 
33  /// Default destructor
34  virtual ~CBAlgoArray(){};
35 
36  /// A simple method to add a one merging step
37  void AddAlgo(CBoolAlgoBase* algo,
38  bool ask_and = true)
39  {
40  if(ask_and) _last_and_algo_index = _algo_array.size();
41  _algo_array.push_back(algo);
42  _ask_and.push_back(ask_and);
43  }
44 
45  /**
46  Optional function: called at the beginning of 1st iteration. This is called per event.
47  */
48  virtual void EventBegin(const std::vector<cluster::ClusterParamsAlg> &clusters);
49 
50  /**
51  Optional function: called at the end of event ... after the last merging iteration is over.
52  */
53  virtual void EventEnd();
54 
55  /**
56  Optional function: Called at the beginning of each iteration over possible pairs of clusters
57  */
58  virtual void IterationBegin(const std::vector<cluster::ClusterParamsAlg> &clusters);
59 
60  /**
61  Optional function: Called at the end of each iteration over possible pairs of clusters
62  */
63  virtual void IterationEnd();
64 
65  /**
66  Core function: given the CPAN input, return whether a cluster should be
67  merged or not.
68  */
69  virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1,
70  const ::cluster::ClusterParamsAlg &cluster2);
71 
72  /**
73  Optional function: called after each Merge() function call by CMergeManager IFF
74  CMergeManager is run with verbosity level kPerMerging. Maybe useful for debugging.
75  */
76  virtual void Report();
77 
78  /// Function to set verbosity
79  virtual void SetVerbose(bool doit=true)
80  { for(auto &algo : _algo_array) algo->SetVerbose(doit); }
81 
82  /// Function to reset the algorithm instance ... maybe implemented via child class
83  virtual void Reset();
84 
85  protected:
86 
87  /**
88  A list of algorithms to be run over. Algorithms are executed in consecutive order
89  in this vector, which is the order of calling AddMergeAlgo function. For each
90  algorithm, the Merge() function return bool is taken as either AND or OR condition
91  with the result of previous algorithm (or simply with "true" for the 1st algo).
92  Whether using AND or OR is a user configuration stored in _ask_and attribute
93  */
94  std::vector<CBoolAlgoBase*> _algo_array;
95 
96  /**
97  A boolean vector that holds user configuration of whether asking AND or OR condition
98  for algorithms in _algo_array.
99  */
100  std::vector<bool> _ask_and;
101 
102  /// Index of last AND condition algorithm to speed execution
104 
105  };
106 }
107 #endif
108 /** @} */ // end of doxygen group
Class def header for algorithm classes for CMergeManager.
std::vector< bool > _ask_and
Definition: CBAlgoArray.h:100
virtual void Report()
Definition: CBAlgoArray.cxx:92
virtual void SetVerbose(bool doit=true)
Function to set verbosity.
Definition: CBAlgoArray.h:79
virtual ~CBAlgoArray()
Default destructor.
Definition: CBAlgoArray.h:34
virtual void IterationBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CBAlgoArray.cxx:35
size_t _last_and_algo_index
Index of last AND condition algorithm to speed execution.
Definition: CBAlgoArray.h:103
CBAlgoArray()
Default constructor.
Definition: CBAlgoArray.cxx:6
virtual bool Bool(const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
Definition: CBAlgoArray.cxx:49
virtual void Reset()
Function to reset the algorithm instance ... maybe implemented via child class.
Definition: CBAlgoArray.cxx:14
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
virtual void IterationEnd()
Definition: CBAlgoArray.cxx:42
virtual void EventEnd()
Definition: CBAlgoArray.cxx:28
virtual void EventBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CBAlgoArray.cxx:21
void AddAlgo(CBoolAlgoBase *algo, bool ask_and=true)
A simple method to add a one merging step.
Definition: CBAlgoArray.h:37