LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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)
18  algo->Reset();
19  }
20 
21  //-------------------------------------------------------------------------------------
22  void CBAlgoArray::EventBegin(const std::vector<cluster::ClusterParamsAlg>& clusters)
23  //-------------------------------------------------------------------------------------
24  {
25  for (auto& algo : _algo_array)
26  algo->EventBegin(clusters);
27  }
28 
29  //--------------------------
31  //--------------------------
32  {
33  for (auto& algo : _algo_array)
34  algo->EventEnd();
35  }
36 
37  //-------------------------------------------------------------------------------------
38  void CBAlgoArray::IterationBegin(const std::vector<cluster::ClusterParamsAlg>& clusters)
39  //-------------------------------------------------------------------------------------
40  {
41  for (auto& algo : _algo_array)
42  algo->IterationBegin(clusters);
43  }
44 
45  //--------------------------
47  //--------------------------
48  {
49  for (auto& algo : _algo_array)
50  algo->IterationEnd();
51  }
52 
53  //--------------------------------------------------------------------
54  bool CBAlgoArray::Bool(const ::cluster::ClusterParamsAlg& cluster1,
55  const ::cluster::ClusterParamsAlg& cluster2)
56  //--------------------------------------------------------------------
57  {
58  bool status = true;
59 
60  for (size_t i = 0; i < _algo_array.size(); ++i) {
61 
62  if (!i)
63  status = _algo_array.at(i)->Bool(cluster1, cluster2);
64 
65  else {
66 
67  //
68  // Break before executing algo if possible
69  //
70 
71  // Case 1: if AND and status==false, then break
72  if (_ask_and.at(i) && !status) break;
73 
74  // Case 2: if OR and status==true, then break
75  if (!_ask_and.at(i) && status) break;
76 
77  // Case 3: the remaining algorithms are all OR condition and stauts==true
78  if (i > _last_and_algo_index && status) break;
79 
80  //
81  // Execute algorithm
82  //
83  if (_ask_and.at(i))
84 
85  status = status && _algo_array.at(i)->Bool(cluster1, cluster2);
86 
87  else
88 
89  status = status || _algo_array.at(i)->Bool(cluster1, cluster2);
90  }
91  }
92 
93  return status;
94  }
95 
96  //------------------------
98  //------------------------
99  {
100  for (auto& algo : _algo_array)
101  algo->Report();
102  }
103 
104 }
Class def header for a class CBAlgoArray.
std::vector< bool > _ask_and
Definition: CBAlgoArray.h:100
virtual void Report()
Definition: CBAlgoArray.cxx:97
virtual void IterationBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CBAlgoArray.cxx:38
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:54
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:46
virtual void EventEnd()
Definition: CBAlgoArray.cxx:30
virtual void EventBegin(const std::vector< cluster::ClusterParamsAlg > &clusters)
Definition: CBAlgoArray.cxx:22