CMManagerBase.h
Go to the documentation of this file.
1 /**
2  * \file CMManagerBase.h
3  *
4  * \ingroup CMTool
5  *
6  * \brief Class def header for a class CMManagerBase
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup CMTool
12 
13  @{*/
14 #ifndef RECOTOOL_CMMANAGERBASE_H
15 #define RECOTOOL_CMMANAGERBASE_H
16 
17 #include <map>
18 #include <set>
19 #include <stddef.h>
20 #include <vector>
21 
22 #include "RtypesCore.h"
23 class TFile;
24 
27 
28 namespace util {
29  class GeometryUtilities;
30 }
31 
32 namespace cmtool {
33 
34  class CPriorityAlgoBase;
35 
36  /**
37  \class CMManagerBase
38  A class that instantiates merging algorithm(s) and run.
39  The book-keeping of merged cluster sets are done by CMergeBookKeeper.
40  */
41  class CMManagerBase {
42  public:
43  /// Enum to specify message output level
44  enum CMMSGLevel_t {
45  /// Extremely verbose (cout per individual algorithm execution)
47  /// Somewhat verbose (cout per merging iteration)
49  /// Bit verbose (cout per event)
51  /// Normal
53  };
54 
55  /// Default constructor
56  CMManagerBase();
57 
58  /// Default destructor
59  virtual ~CMManagerBase() = default;
60 
61  /// Method to enable debug mode (lots of couts)
62  void
64  {
65  _debug_mode = level;
66  }
67 
68  /// Method to enable timing profile cout
69  void
70  ReportTimings(bool time_report = true)
71  {
72  _time_report = time_report;
73  }
74 
75  /// Method to reset itself
76  void Reset();
77 
78  /// Setter to add an algorithm for priority determination
79  void
81  {
82  _priority_algo = algo;
83  }
84 
85  /// Switch to continue merging till converges
86  void
87  MergeTillConverge(bool doit = true)
88  {
89  _merge_till_converge = doit;
90  }
91 
92  /// A simple method to add a cluster
93  void SetClusters(util::GeometryUtilities const& gser,
94  const std::vector<std::vector<util::PxHit>>& clusters);
95 
96  /// A simple method to add a cluster
97  void SetClusters(const std::vector<cluster::ClusterParamsAlg>& clusters);
98 
99  /// A getter for input clusters
100  const std::vector<cluster::ClusterParamsAlg>&
102  {
103  return _in_clusters;
104  }
105 
106  /// A setter for minimum # of hits ... passed onto ClusterParamsAlg
107  void
108  SetMinNHits(unsigned int n)
109  {
110  _min_nhits = n;
111  }
112 
113  /// A method to execute the main action, to be called per event
114  void Process(util::GeometryUtilities const& gser);
115 
116  /// A setter for an analysis output file
117  void
118  SetAnaFile(TFile* fout)
119  {
120  _fout = fout;
121  }
122 
123  protected:
124  /// Function to compute priority
125  void ComputePriority(const std::vector<cluster::ClusterParamsAlg>& clusters);
126 
127  /// FMWK function called @ beginning of Process()
128  virtual void
130  {}
131 
132  /// FMWK function called @ beginning of iterative loop inside Process()
133  virtual void
135  {}
136 
137  /// FMWK function called @ iterative loop inside Process()
138  virtual bool IterationProcess(util::GeometryUtilities const& gser) = 0;
139 
140  /// FMWK function called @ end of iterative loop inside Process()
141  virtual void
143  {}
144 
145  /// FMWK function called @ end of Process()
146  virtual void
148  {}
149 
150  protected:
151  /// Timing verbosity flag
153 
154  /// Minimum number of hits: the limit set for ClusterParamsAlg
155  unsigned int _min_nhits;
156 
157  /// Debug mode switch
159 
160  /// Input clusters
161  std::vector<cluster::ClusterParamsAlg> _in_clusters;
162 
163  /// Priority algorithm
165 
166  /// Output analysis plot TFile
167  TFile* _fout;
168 
169  /// Priority record
170  std::multimap<float, size_t> _priority;
171 
172  /// Iteration loop switch
174 
175  /// A holder for # of unique planes in the clusters, computed in ComputePriority() function
176  std::set<UChar_t> _planes;
177  };
178 }
179 
180 #endif
181 /** @} */ // end of doxygen group
Somewhat verbose (cout per merging iteration)
Definition: CMManagerBase.h:48
bool _time_report
Timing verbosity flag.
Namespace for general, non-LArSoft-specific utilities.
bool _merge_till_converge
Iteration loop switch.
TFile * _fout
Output analysis plot TFile.
void SetAnaFile(TFile *fout)
A setter for an analysis output file.
void SetMinNHits(unsigned int n)
A setter for minimum # of hits ... passed onto ClusterParamsAlg.
struct vector vector
const std::vector< cluster::ClusterParamsAlg > & GetInputClusters() const
A getter for input clusters.
virtual void EventBegin()
FMWK function called @ beginning of Process()
std::multimap< float, size_t > _priority
Priority record.
std::void_t< T > n
virtual void IterationEnd()
FMWK function called @ end of iterative loop inside Process()
CMMSGLevel_t
Enum to specify message output level.
Definition: CMManagerBase.h:44
CMMSGLevel_t _debug_mode
Debug mode switch.
virtual void IterationBegin()
FMWK function called @ beginning of iterative loop inside Process()
no compression
Definition: RawTypes.h:16
Bit verbose (cout per event)
Definition: CMManagerBase.h:50
unsigned int _min_nhits
Minimum number of hits: the limit set for ClusterParamsAlg.
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 DebugMode(CMMSGLevel_t level)
Method to enable debug mode (lots of couts)
Definition: CMManagerBase.h:63
Extremely verbose (cout per individual algorithm execution)
Definition: CMManagerBase.h:46
void MergeTillConverge(bool doit=true)
Switch to continue merging till converges.
Definition: CMManagerBase.h:87
void AddPriorityAlgo(CPriorityAlgoBase *algo)
Setter to add an algorithm for priority determination.
Definition: CMManagerBase.h:80
virtual void EventEnd()
FMWK function called @ end of Process()
void ReportTimings(bool time_report=true)
Method to enable timing profile cout.
Definition: CMManagerBase.h:70