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