LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 9 of file CBAlgoArray.cxx.

References _algo_array, and _ask_and.

9  : CBoolAlgoBase()
10  //------------------------------------------
11  {
12  _algo_array.clear();
13  _ask_and.clear();
14  }
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.

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

Referenced by cluster::SimpleClusterMerger::SimpleClusterMerger().

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

References _algo_array, _ask_and, and _last_and_algo_index.

Referenced by AddAlgo().

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

References _algo_array.

Referenced by AddAlgo().

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

References _algo_array.

Referenced by AddAlgo().

33  {
34  for(auto &algo : _algo_array) 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) algo->IterationBegin(clusters);
42  }
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 45 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by AddAlgo().

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

References _algo_array.

Referenced by AddAlgo().

97  {
98  for(auto &algo : _algo_array) algo->Report();
99  }
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 17 of file CBAlgoArray.cxx.

References _algo_array.

Referenced by SetVerbose().

19  {
20  for(auto &algo : _algo_array) algo->Reset();
21  }
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 77 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

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

77 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:85
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.

References _algo_array, and Reset().

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.

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 85 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: