All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CBAlgoArray.cxx
Go to the documentation of this file.
2 
3 namespace cmtool {
4 
5  //------------------------------------------
7  //------------------------------------------
8  {
9  _algo_array.clear();
10  _ask_and.clear();
11  }
12 
13  //-----------------------
15  //-----------------------
16  {
17  for(auto &algo : _algo_array) algo->Reset();
18  }
19 
20  //-------------------------------------------------------------------------------------
21  void CBAlgoArray::EventBegin(const std::vector<cluster::ClusterParamsAlg> &clusters)
22  //-------------------------------------------------------------------------------------
23  {
24  for(auto &algo : _algo_array) algo->EventBegin(clusters);
25  }
26 
27  //--------------------------
29  //--------------------------
30  {
31  for(auto &algo : _algo_array) algo->EventEnd();
32  }
33 
34  //-------------------------------------------------------------------------------------
35  void CBAlgoArray::IterationBegin(const std::vector<cluster::ClusterParamsAlg> &clusters)
36  //-------------------------------------------------------------------------------------
37  {
38  for(auto &algo : _algo_array) algo->IterationBegin(clusters);
39  }
40 
41  //--------------------------
43  //--------------------------
44  {
45  for(auto &algo : _algo_array) algo->IterationEnd();
46  }
47 
48  //--------------------------------------------------------------------
49  bool CBAlgoArray::Bool(const ::cluster::ClusterParamsAlg &cluster1,
50  const ::cluster::ClusterParamsAlg &cluster2)
51  //--------------------------------------------------------------------
52  {
53  bool status = true;
54 
55  for(size_t i=0; i<_algo_array.size(); ++i) {
56 
57  if(!i) status = _algo_array.at(i)->Bool(cluster1,cluster2);
58 
59  else {
60 
61  //
62  // Break before executing algo if possible
63  //
64 
65  // Case 1: if AND and status==false, then break
66  if( _ask_and.at(i) && !status ) break;
67 
68  // Case 2: if OR and status==true, then break
69  if( !_ask_and.at(i) && status ) break;
70 
71  // Case 3: the remaining algorithms are all OR condition and stauts==true
72  if( i > _last_and_algo_index && status) break;
73 
74  //
75  // Execute algorithm
76  //
77  if( _ask_and.at(i) )
78 
79  status = status && _algo_array.at(i)->Bool(cluster1,cluster2);
80 
81  else
82 
83  status = status || _algo_array.at(i)->Bool(cluster1,cluster2);
84 
85  }
86  }
87 
88  return status;
89  }
90 
91  //------------------------
93  //------------------------
94  {
95  for(auto &algo : _algo_array) algo->Report();
96  }
97 
98 }
Class def header for a class CBAlgoArray.
std::vector< bool > _ask_and
Definition: CBAlgoArray.h:100
virtual void Report()
Definition: CBAlgoArray.cxx:92
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