Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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  {
45  /// Extremely verbose (cout per individual algorithm execution)
47  /// Somewhat verbose (cout per merging iteration)
49  /// Bit verbose (cout per event)
50  kPerEvent,
51  /// Normal
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.

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 80 of file CMManagerBase.h.

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

Function to compute priority.

Definition at line 160 of file CMManagerBase.cxx.

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

Method to enable debug mode (lots of couts)

Definition at line 63 of file CMManagerBase.h.

64  {
66  }
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 129 of file CMManagerBase.h.

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

FMWK function called @ end of Process()

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

Definition at line 147 of file CMManagerBase.h.

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

A getter for input clusters.

Definition at line 101 of file CMManagerBase.h.

102  {
103  return _in_clusters;
104  }
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 134 of file CMManagerBase.h.

135  {}
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 142 of file CMManagerBase.h.

143  {}
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.

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

Switch to continue merging till converges.

Definition at line 87 of file CMManagerBase.h.

88  {
89  _merge_till_converge = doit;
90  }
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 93 of file CMManagerBase.cxx.

94  {
95 
96  if (!(_in_clusters.size())) return;
97 
98  TStopwatch localWatch;
99 
100  localWatch.Start();
101 
102  EventBegin();
103 
104  if (_time_report)
105  std::cout << Form(" CMManagerBase Time Report: EventBegin = %g [s]", localWatch.RealTime())
106  << std::endl;
107 
108  bool keep_going = true;
109 
110  while (keep_going) {
111 
112  localWatch.Start();
113 
114  IterationBegin();
115 
116  if (_time_report)
117  std::cout << Form(" CMManagerBase Time Report: IterationBegin = %g [s]",
118  localWatch.RealTime())
119  << std::endl;
120 
121  localWatch.Start();
122 
123  keep_going = IterationProcess(gser);
124 
125  if (_time_report)
126  std::cout << Form(" CMManagerBase Time Report: IterationProcess = %g [s]",
127  localWatch.RealTime())
128  << std::endl;
129  localWatch.Start();
130 
131  IterationEnd();
132 
133  if (_time_report)
134  std::cout << Form(" CMManagerBase Time Report: IterationEnd = %g [s]",
135  localWatch.RealTime())
136  << std::endl;
137 
138  if (!_merge_till_converge) {
139 
140  if (_debug_mode <= kPerIteration)
141 
142  std::cout
143  << "\033[93m Iterative approach = OFF ... exiting from iteration loop. \033[00m"
144  << std::endl;
145 
146  break;
147  }
148  }
149 
150  localWatch.Start();
151 
152  EventEnd();
153 
154  if (_time_report)
155  std::cout << Form(" CMManagerBase Time Report: EventEnd = %g [s]", localWatch.RealTime())
156  << std::endl;
157  }
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()
QTextStream & endl(QTextStream &s)
void cmtool::CMManagerBase::ReportTimings ( bool  time_report = true)
inline

Method to enable timing profile cout.

Definition at line 70 of file CMManagerBase.h.

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

Method to reset itself.

Definition at line 28 of file CMManagerBase.cxx.

29  {
30  _planes.clear();
31  _in_clusters.clear();
33  }
virtual void Reset()
Function to reset the algorithm instance called within CMergeManager/CMatchManager&#39;s Reset() ...
Definition: CMAlgoBase.h:41
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 118 of file CMManagerBase.h.

119  {
120  _fout = fout;
121  }
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 36 of file CMManagerBase.cxx.

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

79  {
80  TStopwatch localWatch;
81 
82  localWatch.Start();
83 
84  _in_clusters = clusters;
85 
86  if (_time_report)
87  std::cout << Form(" CMManagerBase Time Report: SetClusters (copy) = %g [s]",
88  localWatch.RealTime())
89  << std::endl;
90  }
bool _time_report
Timing verbosity flag.
std::vector< cluster::ClusterParamsAlg > _in_clusters
Input clusters.
QTextStream & endl(QTextStream &s)
void cmtool::CMManagerBase::SetMinNHits ( unsigned int  n)
inline

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

Definition at line 108 of file CMManagerBase.h.

109  {
110  _min_nhits = n;
111  }
std::void_t< T > n
unsigned int _min_nhits
Minimum number of hits: the limit set for ClusterParamsAlg.

Member Data Documentation

CMMSGLevel_t cmtool::CMManagerBase::_debug_mode
protected

Debug mode switch.

Definition at line 158 of file CMManagerBase.h.

TFile* cmtool::CMManagerBase::_fout
protected

Output analysis plot TFile.

Definition at line 167 of file CMManagerBase.h.

std::vector<cluster::ClusterParamsAlg> cmtool::CMManagerBase::_in_clusters
protected

Input clusters.

Definition at line 161 of file CMManagerBase.h.

bool cmtool::CMManagerBase::_merge_till_converge
protected

Iteration loop switch.

Definition at line 173 of file CMManagerBase.h.

unsigned int cmtool::CMManagerBase::_min_nhits
protected

Minimum number of hits: the limit set for ClusterParamsAlg.

Definition at line 155 of file CMManagerBase.h.

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

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

Definition at line 176 of file CMManagerBase.h.

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

Priority record.

Definition at line 170 of file CMManagerBase.h.

::cmtool::CPriorityAlgoBase* cmtool::CMManagerBase::_priority_algo
protected

Priority algorithm.

Definition at line 164 of file CMManagerBase.h.

bool cmtool::CMManagerBase::_time_report
protected

Timing verbosity flag.

Definition at line 152 of file CMManagerBase.h.


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