All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
cmtool::CBAlgoArray Class Reference

#include <CBAlgoArray.h>

Inheritance diagram for cmtool::CBAlgoArray:
cmtool::CBoolAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CBAlgoArray ()
 Default constructor. More...
 
virtual ~CBAlgoArray ()
 Default destructor. More...
 
void AddAlgo (CBoolAlgoBase *algo, bool ask_and=true)
 A simple method to add a one merging step. More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void IterationEnd ()
 
virtual bool Bool (const ::cluster::ClusterParamsAlg &cluster1, const ::cluster::ClusterParamsAlg &cluster2)
 
virtual void Report ()
 
virtual void SetVerbose (bool doit=true)
 Function to set verbosity. More...
 
virtual void Reset ()
 Function to reset the algorithm instance ... maybe implemented via child class. More...
 
- Public Member Functions inherited from cmtool::CBoolAlgoBase
 CBoolAlgoBase ()
 Default constructor. More...
 
virtual ~CBoolAlgoBase ()
 Default destructor. More...
 
- Public Member Functions inherited from cmtool::CMAlgoBase
 CMAlgoBase ()
 
virtual ~CMAlgoBase ()=default
 
void SetAnaFile (TFile *fout)
 Setter function for an output plot TFile pointer. More...
 

Protected Attributes

std::vector< CBoolAlgoBase * > _algo_array
 
std::vector< bool > _ask_and
 
size_t _last_and_algo_index
 Index of last AND condition algorithm to speed execution. More...
 
- Protected Attributes inherited from cmtool::CMAlgoBase
TFile * _fout
 TFile pointer to an output file. More...
 
bool _verbose
 Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager's verbosity level is >= kPerMerging. More...
 

Detailed Description

User implementation for CBAlgoArray class doxygen documentation!

Definition at line 26 of file CBAlgoArray.h.

Constructor & Destructor Documentation

cmtool::CBAlgoArray::CBAlgoArray ( )

Default constructor.

Definition at line 6 of file CBAlgoArray.cxx.

6  : CBoolAlgoBase()
7  //------------------------------------------
8  {
9  _algo_array.clear();
10  _ask_and.clear();
11  }
std::vector< bool > _ask_and
Definition: CBAlgoArray.h:100
CBoolAlgoBase()
Default constructor.
Definition: CBoolAlgoBase.h:32
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
virtual cmtool::CBAlgoArray::~CBAlgoArray ( )
inlinevirtual

Default destructor.

Definition at line 34 of file CBAlgoArray.h.

34 {};

Member Function Documentation

void cmtool::CBAlgoArray::AddAlgo ( CBoolAlgoBase algo,
bool  ask_and = true 
)
inline

A simple method to add a one merging step.

Definition at line 37 of file CBAlgoArray.h.

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  }
std::vector< bool > _ask_and
Definition: CBAlgoArray.h:100
size_t _last_and_algo_index
Index of last AND condition algorithm to speed execution.
Definition: CBAlgoArray.h:103
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
bool cmtool::CBAlgoArray::Bool ( const ::cluster::ClusterParamsAlg cluster1,
const ::cluster::ClusterParamsAlg cluster2 
)
virtual

Core function: given the CPAN input, return whether a cluster should be merged or not.

Reimplemented from cmtool::CBoolAlgoBase.

Definition at line 49 of file CBAlgoArray.cxx.

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  }
std::vector< bool > _ask_and
Definition: CBAlgoArray.h:100
size_t _last_and_algo_index
Index of last AND condition algorithm to speed execution.
Definition: CBAlgoArray.h:103
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CBAlgoArray::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
virtual

Optional function: called at the beginning of 1st iteration. This is called per event.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 21 of file CBAlgoArray.cxx.

23  {
24  for(auto &algo : _algo_array) algo->EventBegin(clusters);
25  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CBAlgoArray::EventEnd ( )
virtual

Optional function: called at the end of event ... after the last merging iteration is over.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 28 of file CBAlgoArray.cxx.

30  {
31  for(auto &algo : _algo_array) algo->EventEnd();
32  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CBAlgoArray::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
virtual

Optional function: Called at the beginning of each iteration over possible pairs of clusters

Reimplemented from cmtool::CMAlgoBase.

Definition at line 35 of file CBAlgoArray.cxx.

37  {
38  for(auto &algo : _algo_array) algo->IterationBegin(clusters);
39  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CBAlgoArray::IterationEnd ( )
virtual

Optional function: Called at the end of each iteration over possible pairs of clusters

Reimplemented from cmtool::CMAlgoBase.

Definition at line 42 of file CBAlgoArray.cxx.

44  {
45  for(auto &algo : _algo_array) algo->IterationEnd();
46  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CBAlgoArray::Report ( )
virtual

Optional function: called after each Merge() function call by CMergeManager IFF CMergeManager is run with verbosity level kPerMerging. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 92 of file CBAlgoArray.cxx.

94  {
95  for(auto &algo : _algo_array) algo->Report();
96  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CBAlgoArray::Reset ( )
virtual

Function to reset the algorithm instance ... maybe implemented via child class.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 14 of file CBAlgoArray.cxx.

16  {
17  for(auto &algo : _algo_array) algo->Reset();
18  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
virtual void cmtool::CBAlgoArray::SetVerbose ( bool  doit = true)
inlinevirtual

Function to set verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 79 of file CBAlgoArray.h.

80  { for(auto &algo : _algo_array) algo->SetVerbose(doit); }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94

Member Data Documentation

std::vector<CBoolAlgoBase*> cmtool::CBAlgoArray::_algo_array
protected

A list of algorithms to be run over. Algorithms are executed in consecutive order in this vector, which is the order of calling AddMergeAlgo function. For each algorithm, the Merge() function return bool is taken as either AND or OR condition with the result of previous algorithm (or simply with "true" for the 1st algo). Whether using AND or OR is a user configuration stored in _ask_and attribute

Definition at line 94 of file CBAlgoArray.h.

std::vector<bool> cmtool::CBAlgoArray::_ask_and
protected

A boolean vector that holds user configuration of whether asking AND or OR condition for algorithms in _algo_array.

Definition at line 100 of file CBAlgoArray.h.

size_t cmtool::CBAlgoArray::_last_and_algo_index
protected

Index of last AND condition algorithm to speed execution.

Definition at line 103 of file CBAlgoArray.h.


The documentation for this class was generated from the following files: