LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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
 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 (util::GeometryUtilities const &gser, 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 (util::GeometryUtilities const &gser)
 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 (util::GeometryUtilities const &gser)=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 41 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 44 of file CMManagerBase.h.

44  {
50  kPerEvent,
52  kNone
53  };
Somewhat verbose (cout per merging iteration)
Definition: CMManagerBase.h:48
Bit verbose (cout per event)
Definition: CMManagerBase.h:50
Extremely verbose (cout per individual algorithm execution)
Definition: CMManagerBase.h:46

Constructor & Destructor Documentation

cmtool::CMManagerBase::CMManagerBase ( )

Default constructor.

Definition at line 16 of file CMManagerBase.cxx.

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

17  {
18  _fout = 0;
20  _priority_algo = nullptr;
21  _min_nhits = 0;
22  _merge_till_converge = false;
23  Reset();
24  _time_report = false;
25  }
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 ( )
virtualdefault

Default destructor.

Member Function Documentation

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

Setter to add an algorithm for priority determination.

Definition at line 71 of file CMManagerBase.h.

Referenced by ShowerReco3D::ShowerReco3D().

71 { _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 155 of file CMManagerBase.cxx.

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

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

156  {
157 
158  TStopwatch localWatch;
159  localWatch.Start();
160 
161  _priority.clear();
162  _planes.clear();
163 
164  if (!clusters.size()) return;
165 
166  // Priority is computed cluster-by-cluster. In case of two clusters having the same priority
167  // value the one with lower cluster index gets the priority. Also, clusters with priority < 0
168  // are not logged (assumed not to be used)
169 
170  for (size_t i = 0; i < clusters.size(); ++i) {
171 
172  size_t c_index = clusters.size() - i - 1;
173 
174  float priority = clusters.at(c_index).GetNHits();
175 
176  if (_priority_algo) { priority = _priority_algo->Priority(clusters.at(c_index)); }
177 
178  if (priority > 0) {
179 
180  _priority.insert(std::make_pair(priority, c_index));
181 
182  if (_planes.find(clusters.at(c_index).Plane()) == _planes.end())
183 
184  _planes.insert(clusters.at(c_index).Plane());
185  }
186  }
187 
188  if (_time_report)
189  std::cout << Form(" CMManagerBase Time Report: ComputePriority = %g [s]",
190  localWatch.RealTime())
191  << std::endl;
192  }
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 62 of file CMManagerBase.h.

62 { _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 100 of file CMManagerBase.h.

Referenced by Process().

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

FMWK function called @ end of Process()

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

Definition at line 112 of file CMManagerBase.h.

Referenced by Process().

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

A getter for input clusters.

Definition at line 84 of file CMManagerBase.h.

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

84 { 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 103 of file CMManagerBase.h.

Referenced by Process().

103 {}
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 109 of file CMManagerBase.h.

Referenced by Process().

109 {}
virtual bool cmtool::CMManagerBase::IterationProcess ( util::GeometryUtilities const &  gser)
protectedpure virtual

FMWK function called @ iterative loop inside Process()

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

Referenced by Process().

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

Switch to continue merging till converges.

Definition at line 74 of file CMManagerBase.h.

References lar::dump::vector().

74 { _merge_till_converge = doit; }
bool _merge_till_converge
Iteration loop switch.
void cmtool::CMManagerBase::Process ( util::GeometryUtilities const &  gser)

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

Definition at line 89 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(), and showerreco::ShowerRecoManager::Reconstruct().

90  {
91 
92  if (!(_in_clusters.size())) return;
93 
94  TStopwatch localWatch;
95 
96  localWatch.Start();
97 
98  EventBegin();
99 
100  if (_time_report)
101  std::cout << Form(" CMManagerBase Time Report: EventBegin = %g [s]", localWatch.RealTime())
102  << std::endl;
103 
104  bool keep_going = true;
105 
106  while (keep_going) {
107 
108  localWatch.Start();
109 
110  IterationBegin();
111 
112  if (_time_report)
113  std::cout << Form(" CMManagerBase Time Report: IterationBegin = %g [s]",
114  localWatch.RealTime())
115  << std::endl;
116 
117  localWatch.Start();
118 
119  keep_going = IterationProcess(gser);
120 
121  if (_time_report)
122  std::cout << Form(" CMManagerBase Time Report: IterationProcess = %g [s]",
123  localWatch.RealTime())
124  << std::endl;
125  localWatch.Start();
126 
127  IterationEnd();
128 
129  if (_time_report)
130  std::cout << Form(" CMManagerBase Time Report: IterationEnd = %g [s]",
131  localWatch.RealTime())
132  << std::endl;
133 
134  if (!_merge_till_converge) {
135 
136  if (_debug_mode <= kPerIteration)
137 
138  std::cout
139  << "\033[93m Iterative approach = OFF ... exiting from iteration loop. \033[00m"
140  << std::endl;
141 
142  break;
143  }
144  }
145 
146  localWatch.Start();
147 
148  EventEnd();
149 
150  if (_time_report)
151  std::cout << Form(" CMManagerBase Time Report: EventEnd = %g [s]", localWatch.RealTime())
152  << std::endl;
153  }
Somewhat verbose (cout per merging iteration)
Definition: CMManagerBase.h:48
bool _time_report
Timing verbosity flag.
bool _merge_till_converge
Iteration loop switch.
virtual void EventBegin()
FMWK function called @ beginning of Process()
virtual bool IterationProcess(util::GeometryUtilities const &gser)=0
FMWK function called @ iterative loop inside Process()
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()
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 65 of file CMManagerBase.h.

References Reset().

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

Method to reset itself.

Definition at line 27 of file CMManagerBase.cxx.

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

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

28  {
29  _planes.clear();
30  _in_clusters.clear();
32  }
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 93 of file CMManagerBase.h.

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

A simple method to add a cluster.

Definition at line 34 of file CMManagerBase.cxx.

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

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

36  {
37 
38  TStopwatch localWatch;
39 
40  // Reset
41  this->Reset();
42 
43  // Clear & fill cluster info
44 
45  _in_clusters.clear();
46 
47  _in_clusters.reserve(clusters.size());
48 
50  tmp_alg.SetMinNHits(_min_nhits);
51  tmp_alg.SetVerbose(false);
52 
53  for (auto const& c : clusters) {
54 
55  _in_clusters.push_back(tmp_alg);
56  (*_in_clusters.rbegin()).Initialize();
57 
58  if ((*_in_clusters.rbegin()).SetHits(c) < 3) continue;
59  (*_in_clusters.rbegin()).DisableFANN();
60  (*_in_clusters.rbegin()).FillParams(gser, false, false, false, false, false, false);
61  (*_in_clusters.rbegin()).FillPolygon(gser);
62  }
63 
64  if (_time_report) {
65  std::cout << Form(" CMManagerBase Time Report: SetClusters (CPAN computation) = %g [s]",
66  localWatch.RealTime())
67  << " ... details below." << std::endl;
68 
69  for (auto const& c : _in_clusters)
70 
71  c.TimeReport(std::cout);
72  }
73  }
bool _time_report
Timing verbosity flag.
void Initialize()
Definition: errprop.cc:100
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 75 of file CMManagerBase.cxx.

References _in_clusters, and _time_report.

76  {
77  TStopwatch localWatch;
78 
79  localWatch.Start();
80 
81  _in_clusters = clusters;
82 
83  if (_time_report)
84  std::cout << Form(" CMManagerBase Time Report: SetClusters (copy) = %g [s]",
85  localWatch.RealTime())
86  << std::endl;
87  }
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 87 of file CMManagerBase.h.

References n.

87 { _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 131 of file CMManagerBase.h.

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

bool cmtool::CMManagerBase::_merge_till_converge
protected

Iteration loop switch.

Definition at line 137 of file CMManagerBase.h.

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

unsigned int cmtool::CMManagerBase::_min_nhits
protected

Minimum number of hits: the limit set for ClusterParamsAlg.

Definition at line 119 of file CMManagerBase.h.

Referenced by CMManagerBase(), and SetClusters().

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

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

Definition at line 140 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 116 of file CMManagerBase.h.

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


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