LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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...
 
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...
 
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.

References _algo_array, and _ask_and.

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:31
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
virtual cmtool::CBAlgoArray::~CBAlgoArray ( )
inlinevirtual

Default destructor.

Definition at line 33 of file CBAlgoArray.h.

33 {};

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 36 of file CBAlgoArray.h.

References _algo_array, _ask_and, _last_and_algo_index, Bool(), EventBegin(), EventEnd(), IterationBegin(), IterationEnd(), and Report().

37  {
38  if (ask_and) _last_and_algo_index = _algo_array.size();
39  _algo_array.push_back(algo);
40  _ask_and.push_back(ask_and);
41  }
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 54 of file CBAlgoArray.cxx.

References _algo_array, _ask_and, and _last_and_algo_index.

Referenced by AddAlgo().

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  }
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 22 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by AddAlgo().

24  {
25  for (auto& algo : _algo_array)
26  algo->EventBegin(clusters);
27  }
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 30 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by AddAlgo().

32  {
33  for (auto& algo : _algo_array)
34  algo->EventEnd();
35  }
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 38 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by AddAlgo().

40  {
41  for (auto& algo : _algo_array)
42  algo->IterationBegin(clusters);
43  }
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 46 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by AddAlgo().

48  {
49  for (auto& algo : _algo_array)
50  algo->IterationEnd();
51  }
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 97 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by AddAlgo().

99  {
100  for (auto& algo : _algo_array)
101  algo->Report();
102  }
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.

References _algo_array.

Referenced by SetVerbose().

16  {
17  for (auto& algo : _algo_array)
18  algo->Reset();
19  }
std::vector< CBoolAlgoBase * > _algo_array
Definition: CBAlgoArray.h:94
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 72 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

Referenced by cmtool::CMergeManager::EventBegin().

72 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:79
virtual void cmtool::CBAlgoArray::SetVerbose ( bool  doit = true)
inlinevirtual

Function to set verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 77 of file CBAlgoArray.h.

References _algo_array, and Reset().

78  {
79  for (auto& algo : _algo_array)
80  algo->SetVerbose(doit);
81  }
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.

Referenced by AddAlgo(), Bool(), CBAlgoArray(), EventBegin(), EventEnd(), IterationBegin(), IterationEnd(), Report(), Reset(), and SetVerbose().

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.

Referenced by AddAlgo(), Bool(), and CBAlgoArray().

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 79 of file CMAlgoBase.h.

Referenced by cmtool::CMAlgoBase::CMAlgoBase(), and cmtool::CMAlgoBase::SetAnaFile().

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.

Referenced by AddAlgo(), and Bool().


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