LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cmtool::CMManagerBase Class Referenceabstract

#include "CMManagerBase.h"

Inheritance diagram for cmtool::CMManagerBase:
cmtool::CMatchManager cmtool::CMergeManager

Public Types

enum  CMMSGLevel_t { kPerMerging, kPerIteration, kPerEvent, kNone }
 Enum to specify message output level. More...
 

Public Member Functions

 CMManagerBase ()
 Default constructor. More...
 
virtual ~CMManagerBase ()
 Default destructor. More...
 
void DebugMode (CMMSGLevel_t level)
 Method to enable debug mode (lots of couts) More...
 
void ReportTimings (bool time_report=true)
 Method to enable timing profile cout. More...
 
void Reset ()
 Method to reset itself. More...
 
void AddPriorityAlgo (CPriorityAlgoBase *algo)
 Setter to add an algorithm for priority determination. More...
 
void MergeTillConverge (bool doit=true)
 Switch to continue merging till converges. More...
 
void SetClusters (const std::vector< std::vector< util::PxHit > > &clusters)
 A simple method to add a cluster. More...
 
void SetClusters (const std::vector< cluster::ClusterParamsAlg > &clusters)
 A simple method to add a cluster. More...
 
const std::vector< cluster::ClusterParamsAlg > & GetInputClusters () const
 A getter for input clusters. More...
 
void SetMinNHits (unsigned int n)
 A setter for minimum # of hits ... passed onto ClusterParamsAlg. More...
 
void Process ()
 A method to execute the main action, to be called per event. More...
 
void SetAnaFile (TFile *fout)
 A setter for an analysis output file. More...
 

Protected Member Functions

void ComputePriority (const std::vector< cluster::ClusterParamsAlg > &clusters)
 Function to compute priority. More...
 
virtual void EventBegin ()
 FMWK function called @ beginning of Process() More...
 
virtual void IterationBegin ()
 FMWK function called @ beginning of iterative loop inside Process() More...
 
virtual bool IterationProcess ()=0
 FMWK function called @ iterative loop inside Process() More...
 
virtual void IterationEnd ()
 FMWK function called @ end of iterative loop inside Process() More...
 
virtual void EventEnd ()
 FMWK function called @ end of Process() More...
 

Protected Attributes

bool _time_report
 Timing verbosity flag. More...
 
unsigned int _min_nhits
 Minimum number of hits: the limit set for ClusterParamsAlg. More...
 
CMMSGLevel_t _debug_mode
 Debug mode switch. More...
 
std::vector< cluster::ClusterParamsAlg_in_clusters
 Input clusters. More...
 
::cmtool::CPriorityAlgoBase_priority_algo
 Priority algorithm. More...
 
TFile * _fout
 Output analysis plot TFile. More...
 
std::multimap< float, size_t > _priority
 Priority record. More...
 
bool _merge_till_converge
 Iteration loop switch. More...
 
std::set< UChar_t > _planes
 A holder for # of unique planes in the clusters, computed in ComputePriority() function. More...
 

Detailed Description

A class that instantiates merging algorithm(s) and run. The book-keeping of merged cluster sets are done by CMergeBookKeeper.

Definition at line 29 of file CMManagerBase.h.

Member Enumeration Documentation

Enum to specify message output level.

Enumerator
kPerMerging 

Extremely verbose (cout per individual algorithm execution)

kPerIteration 

Somewhat verbose (cout per merging iteration)

kPerEvent 

Bit verbose (cout per event)

kNone 

Normal.

Definition at line 34 of file CMManagerBase.h.

34  {
40  kPerEvent,
42  kNone
43  };
Somewhat verbose (cout per merging iteration)
Definition: CMManagerBase.h:38
Bit verbose (cout per event)
Definition: CMManagerBase.h:40
Extremely verbose (cout per individual algorithm execution)
Definition: CMManagerBase.h:36

Constructor & Destructor Documentation

cmtool::CMManagerBase::CMManagerBase ( )

Default constructor.

Definition at line 8 of file CMManagerBase.cxx.

References _debug_mode, _fout, _merge_till_converge, _min_nhits, _priority_algo, _time_report, kNone, and Reset().

9  {
10  _fout = 0;
12  _priority_algo = nullptr;
13  _min_nhits = 0;
14  _merge_till_converge = false;
15  Reset();
16  _time_report=false;
17  }
bool _time_report
Timing verbosity flag.
bool _merge_till_converge
Iteration loop switch.
TFile * _fout
Output analysis plot TFile.
CMMSGLevel_t _debug_mode
Debug mode switch.
unsigned int _min_nhits
Minimum number of hits: the limit set for ClusterParamsAlg.
::cmtool::CPriorityAlgoBase * _priority_algo
Priority algorithm.
void Reset()
Method to reset itself.
virtual cmtool::CMManagerBase::~CMManagerBase ( )
inlinevirtual

Default destructor.

Definition at line 51 of file CMManagerBase.h.

51 {}

Member Function Documentation

void cmtool::CMManagerBase::AddPriorityAlgo ( CPriorityAlgoBase algo)
inline

Setter to add an algorithm for priority determination.

Definition at line 63 of file CMManagerBase.h.

References _priority_algo.

Referenced by cluster::FuzzyClusterMerger::FuzzyClusterMerger(), and ShowerReco3D::ShowerReco3D().

63 { _priority_algo = algo; }
::cmtool::CPriorityAlgoBase * _priority_algo
Priority algorithm.
void cmtool::CMManagerBase::ComputePriority ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
protected

Function to compute priority.

Definition at line 147 of file CMManagerBase.cxx.

References _planes, _priority, _priority_algo, _time_report, and cmtool::CPriorityAlgoBase::Priority().

Referenced by cmtool::CMatchManager::IterationProcess(), cmtool::CMergeManager::IterationProcess(), and SetAnaFile().

147  {
148 
149  TStopwatch localWatch;
150  localWatch.Start();
151 
152  _priority.clear();
153  _planes.clear();
154 
155  if(!clusters.size()) return;
156 
157  // Priority is computed cluster-by-cluster. In case of two clusters having the same priority
158  // value the one with lower cluster index gets the priority. Also, clusters with priority < 0
159  // are not logged (assumed not to be used)
160 
161  for(size_t i=0; i<clusters.size(); ++i) {
162 
163  size_t c_index = clusters.size() - i - 1;
164 
165  float priority = clusters.at(c_index).GetNHits();
166 
167  if(_priority_algo) {
168 
169  priority = _priority_algo->Priority(clusters.at(c_index));
170 
171  }
172 
173  if(priority>0) {
174 
175  _priority.insert(std::make_pair(priority,c_index));
176 
177  if( _planes.find(clusters.at(c_index).Plane()) == _planes.end() )
178 
179  _planes.insert(clusters.at(c_index).Plane());
180 
181  }
182 
183  }
184 
185  if(_time_report) std::cout << Form(" CMManagerBase Time Report: ComputePriority = %g [s]",
186  localWatch.RealTime())
187  << std::endl;
188 
189  }
bool _time_report
Timing verbosity flag.
std::multimap< float, size_t > _priority
Priority record.
virtual float Priority(const cluster::ClusterParamsAlg &cluster)
::cmtool::CPriorityAlgoBase * _priority_algo
Priority algorithm.
std::set< UChar_t > _planes
A holder for # of unique planes in the clusters, computed in ComputePriority() function.
void cmtool::CMManagerBase::DebugMode ( CMMSGLevel_t  level)
inline

Method to enable debug mode (lots of couts)

Definition at line 54 of file CMManagerBase.h.

References _debug_mode.

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

54 {_debug_mode=level;}
CMMSGLevel_t _debug_mode
Debug mode switch.
virtual void cmtool::CMManagerBase::EventBegin ( )
inlineprotectedvirtual

FMWK function called @ beginning of Process()

Reimplemented in cmtool::CMergeManager, and cmtool::CMatchManager.

Definition at line 94 of file CMManagerBase.h.

Referenced by Process().

94 {}
virtual void cmtool::CMManagerBase::EventEnd ( )
inlineprotectedvirtual

FMWK function called @ end of Process()

Reimplemented in cmtool::CMergeManager, and cmtool::CMatchManager.

Definition at line 106 of file CMManagerBase.h.

Referenced by Process().

106 {}
const std::vector<cluster::ClusterParamsAlg>& cmtool::CMManagerBase::GetInputClusters ( ) const
inline

A getter for input clusters.

Definition at line 76 of file CMManagerBase.h.

References _in_clusters.

Referenced by showerreco::ShowerRecoManager::Process().

77  { return _in_clusters; }
std::vector< cluster::ClusterParamsAlg > _in_clusters
Input clusters.
virtual void cmtool::CMManagerBase::IterationBegin ( )
inlineprotectedvirtual

FMWK function called @ beginning of iterative loop inside Process()

Reimplemented in cmtool::CMergeManager, and cmtool::CMatchManager.

Definition at line 97 of file CMManagerBase.h.

References IterationProcess().

Referenced by Process().

97 {}
virtual void cmtool::CMManagerBase::IterationEnd ( )
inlineprotectedvirtual

FMWK function called @ end of iterative loop inside Process()

Reimplemented in cmtool::CMergeManager, and cmtool::CMatchManager.

Definition at line 103 of file CMManagerBase.h.

Referenced by Process().

103 {}
virtual bool cmtool::CMManagerBase::IterationProcess ( )
protectedpure virtual

FMWK function called @ iterative loop inside Process()

Implemented in cmtool::CMergeManager, and cmtool::CMatchManager.

Referenced by IterationBegin(), and Process().

void cmtool::CMManagerBase::MergeTillConverge ( bool  doit = true)
inline

Switch to continue merging till converges.

Definition at line 66 of file CMManagerBase.h.

References _merge_till_converge, SetClusters(), and lar::dump::vector().

Referenced by cluster::FuzzyClusterMerger::FuzzyClusterMerger(), and cluster::SimpleClusterMerger::SimpleClusterMerger().

66 {_merge_till_converge = doit;}
bool _merge_till_converge
Iteration loop switch.
void cmtool::CMManagerBase::Process ( )

A method to execute the main action, to be called per event.

Definition at line 83 of file CMManagerBase.cxx.

References _debug_mode, _in_clusters, _merge_till_converge, _time_report, EventBegin(), EventEnd(), IterationBegin(), IterationEnd(), IterationProcess(), and kPerIteration.

Referenced by cluster::ClusterMergeHelper::Process(), showerreco::ShowerRecoManager::Reconstruct(), and SetMinNHits().

84  {
85 
86  if(!(_in_clusters.size()))
87 
88  return;
89 
90  TStopwatch localWatch;
91 
92  localWatch.Start();
93 
94  EventBegin();
95 
96  if(_time_report) std::cout << Form(" CMManagerBase Time Report: EventBegin = %g [s]",
97  localWatch.RealTime())
98  << std::endl;
99 
100  bool keep_going = true;
101 
102  while(keep_going) {
103 
104  localWatch.Start();
105 
106  IterationBegin();
107 
108  if(_time_report) std::cout << Form(" CMManagerBase Time Report: IterationBegin = %g [s]",
109  localWatch.RealTime())
110  << std::endl;
111 
112  localWatch.Start();
113 
114  keep_going = IterationProcess();
115 
116  if(_time_report) std::cout << Form(" CMManagerBase Time Report: IterationProcess = %g [s]",
117  localWatch.RealTime())
118  << std::endl;
119  localWatch.Start();
120 
121  IterationEnd();
122 
123  if(_time_report) std::cout << Form(" CMManagerBase Time Report: IterationEnd = %g [s]",
124  localWatch.RealTime())
125  << std::endl;
126 
127  if(!_merge_till_converge) {
128 
130 
131  std::cout << "\033[93m Iterative approach = OFF ... exiting from iteration loop. \033[00m" << std::endl;
132 
133  break;
134  }
135  }
136 
137  localWatch.Start();
138 
139  EventEnd();
140 
141  if(_time_report) std::cout << Form(" CMManagerBase Time Report: EventEnd = %g [s]",
142  localWatch.RealTime())
143  << std::endl;
144 
145  }
Somewhat verbose (cout per merging iteration)
Definition: CMManagerBase.h:38
bool _time_report
Timing verbosity flag.
bool _merge_till_converge
Iteration loop switch.
virtual void EventBegin()
FMWK function called @ beginning of Process()
Definition: CMManagerBase.h:94
virtual void IterationEnd()
FMWK function called @ end of iterative loop inside Process()
CMMSGLevel_t _debug_mode
Debug mode switch.
virtual void IterationBegin()
FMWK function called @ beginning of iterative loop inside Process()
Definition: CMManagerBase.h:97
virtual bool IterationProcess()=0
FMWK function called @ iterative loop inside Process()
std::vector< cluster::ClusterParamsAlg > _in_clusters
Input clusters.
virtual void EventEnd()
FMWK function called @ end of Process()
void cmtool::CMManagerBase::ReportTimings ( bool  time_report = true)
inline

Method to enable timing profile cout.

Definition at line 57 of file CMManagerBase.h.

References _time_report, and Reset().

57 { _time_report = time_report; }
bool _time_report
Timing verbosity flag.
void cmtool::CMManagerBase::Reset ( )

Method to reset itself.

Definition at line 19 of file CMManagerBase.cxx.

References _in_clusters, _planes, _priority_algo, and cmtool::CMAlgoBase::Reset().

Referenced by CMManagerBase(), ReportTimings(), cmtool::CMergeManager::Reset(), cmtool::CMatchManager::Reset(), and SetClusters().

20  {
21  _planes.clear();
22  _in_clusters.clear();
24  }
virtual void Reset()
Function to reset the algorithm instance called within CMergeManager/CMatchManager&#39;s Reset() ...
Definition: CMAlgoBase.h:40
std::vector< cluster::ClusterParamsAlg > _in_clusters
Input clusters.
::cmtool::CPriorityAlgoBase * _priority_algo
Priority algorithm.
std::set< UChar_t > _planes
A holder for # of unique planes in the clusters, computed in ComputePriority() function.
void cmtool::CMManagerBase::SetAnaFile ( TFile *  fout)
inline

A setter for an analysis output file.

Definition at line 86 of file CMManagerBase.h.

References _fout, and ComputePriority().

86 { _fout = fout; }
TFile * _fout
Output analysis plot TFile.
void cmtool::CMManagerBase::SetClusters ( const std::vector< std::vector< util::PxHit > > &  clusters)

A simple method to add a cluster.

Definition at line 26 of file CMManagerBase.cxx.

References _in_clusters, _min_nhits, _time_report, Initialize(), Reset(), cluster::ClusterParamsAlg::SetMinNHits(), and cluster::ClusterParamsAlg::SetVerbose().

Referenced by MergeTillConverge(), showerreco::ShowerRecoManager::Reconstruct(), and cluster::ClusterMergeHelper::SetClusters().

27  {
28 
29  TStopwatch localWatch;
30 
31  // Reset
32  this->Reset();
33 
34  // Clear & fill cluster info
35 
36  _in_clusters.clear();
37 
38  _in_clusters.reserve(clusters.size());
39 
41  tmp_alg.SetMinNHits(_min_nhits);
42  tmp_alg.SetVerbose(false);
43 
44  for(auto const &c : clusters) {
45 
46  _in_clusters.push_back(tmp_alg);
47  (*_in_clusters.rbegin()).Initialize();
48 
49  if((*_in_clusters.rbegin()).SetHits(c) < 3) continue;
50  (*_in_clusters.rbegin()).DisableFANN();
51  //(*_in_clusters.rbegin()).FillParams(true,true,true,true,true,false);
52  (*_in_clusters.rbegin()).FillParams(false,false,false,false,false,false);
53  (*_in_clusters.rbegin()).FillPolygon();
54 
55  }
56 
57  if(_time_report) {
58  std::cout << Form(" CMManagerBase Time Report: SetClusters (CPAN computation) = %g [s]",
59  localWatch.RealTime())
60  << " ... details below." << std::endl;
61 
62  for(auto const& c : _in_clusters)
63 
64  c.TimeReport(std::cout);
65 
66  }
67 
68  }
bool _time_report
Timing verbosity flag.
void Initialize()
Definition: errprop.cc:101
void SetMinNHits(size_t nhit)
unsigned int _min_nhits
Minimum number of hits: the limit set for ClusterParamsAlg.
std::vector< cluster::ClusterParamsAlg > _in_clusters
Input clusters.
void SetVerbose(bool yes=true)
void Reset()
Method to reset itself.
void cmtool::CMManagerBase::SetClusters ( const std::vector< cluster::ClusterParamsAlg > &  clusters)

A simple method to add a cluster.

Definition at line 70 of file CMManagerBase.cxx.

References _in_clusters, and _time_report.

71  {
72  TStopwatch localWatch;
73 
74  localWatch.Start();
75 
76  _in_clusters = clusters;
77 
78  if(_time_report) std::cout << Form(" CMManagerBase Time Report: SetClusters (copy) = %g [s]",
79  localWatch.RealTime())
80  << std::endl;
81  }
bool _time_report
Timing verbosity flag.
std::vector< cluster::ClusterParamsAlg > _in_clusters
Input clusters.
void cmtool::CMManagerBase::SetMinNHits ( unsigned int  n)
inline

A setter for minimum # of hits ... passed onto ClusterParamsAlg.

Definition at line 80 of file CMManagerBase.h.

References _min_nhits, n, and Process().

80 { _min_nhits = n; }
unsigned int _min_nhits
Minimum number of hits: the limit set for ClusterParamsAlg.
Char_t n[5]

Member Data Documentation

TFile* cmtool::CMManagerBase::_fout
protected

Output analysis plot TFile.

Definition at line 126 of file CMManagerBase.h.

Referenced by CMManagerBase(), cmtool::CMergeManager::EventBegin(), and SetAnaFile().

bool cmtool::CMManagerBase::_merge_till_converge
protected

Iteration loop switch.

Definition at line 132 of file CMManagerBase.h.

Referenced by CMManagerBase(), cmtool::CMergeManager::IterationEnd(), MergeTillConverge(), and Process().

unsigned int cmtool::CMManagerBase::_min_nhits
protected

Minimum number of hits: the limit set for ClusterParamsAlg.

Definition at line 114 of file CMManagerBase.h.

Referenced by CMManagerBase(), SetClusters(), and SetMinNHits().

std::set<UChar_t> cmtool::CMManagerBase::_planes
protected

A holder for # of unique planes in the clusters, computed in ComputePriority() function.

Definition at line 135 of file CMManagerBase.h.

Referenced by ComputePriority(), cmtool::CMatchManager::IterationProcess(), cmtool::CMergeManager::IterationProcess(), and Reset().

std::multimap<float,size_t> cmtool::CMManagerBase::_priority
protected
bool cmtool::CMManagerBase::_time_report
protected

Timing verbosity flag.

Definition at line 111 of file CMManagerBase.h.

Referenced by CMManagerBase(), ComputePriority(), Process(), ReportTimings(), and SetClusters().


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