LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cmtool::CMatchBookKeeper Class Reference

#include "CMatchBookKeeper.h"

Public Member Functions

 CMatchBookKeeper ()
 Default constructor. More...
 
void Reset ()
 Reset method. More...
 
void Match (const std::vector< unsigned int > &matched_indexes, const float &score)
 Method to register matched clusters. More...
 
std::vector< std::vector< unsigned int > > GetResult () const
 Method to get result. More...
 
void PassResult (std::vector< std::vector< unsigned int >> &result) const
 Method to pass result. More...
 

Protected Attributes

std::multimap< float, std::vector< unsigned int > > _register
 

Detailed Description

User defined class CMatchBookKeeper ... these comments are used to generate doxygen documentation!

Definition at line 26 of file CMatchBookKeeper.h.

Constructor & Destructor Documentation

cmtool::CMatchBookKeeper::CMatchBookKeeper ( )

Default constructor.

Definition at line 5 of file CMatchBookKeeper.cxx.

References Reset().

6  {
7  Reset();
8  }
void Reset()
Reset method.

Member Function Documentation

std::vector< std::vector< unsigned int > > cmtool::CMatchBookKeeper::GetResult ( ) const

Method to get result.

Definition at line 20 of file CMatchBookKeeper.cxx.

References PassResult().

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

21  {
22  std::vector<std::vector<unsigned int>> res;
23 
24  PassResult(res);
25 
26  return res;
27  }
void PassResult(std::vector< std::vector< unsigned int >> &result) const
Method to pass result.
void cmtool::CMatchBookKeeper::Match ( const std::vector< unsigned int > &  matched_indexes,
const float &  score 
)

Method to register matched clusters.

Definition at line 15 of file CMatchBookKeeper.cxx.

References _register.

Referenced by cmtool::CMatchManager::IterationProcess().

16  {
17  _register.insert(std::make_pair(score, matched_indexes));
18  }
std::multimap< float, std::vector< unsigned int > > _register
void cmtool::CMatchBookKeeper::PassResult ( std::vector< std::vector< unsigned int >> &  result) const

Method to pass result.

Definition at line 30 of file CMatchBookKeeper.cxx.

References _register.

Referenced by GetResult().

31  {
32  result.clear();
33 
34  // Rough guess: assume half of registered pairs are good
35  result.reserve((unsigned int)(_register.size() / 2));
36 
37  std::vector<bool> used_index;
38 
39  for (auto riter = _register.rbegin(); riter != _register.rend(); ++riter) {
40 
41  bool valid_set = true;
42 
43  for (auto const& index : (*riter).second) {
44 
45  if (index >= used_index.size())
46 
47  used_index.resize(index + 1, false);
48 
49  else if (used_index.at(index))
50  valid_set = false;
51  }
52 
53  if (valid_set) {
54 
55  result.push_back((*riter).second);
56 
57  for (auto& index : (*riter).second)
58 
59  used_index.at(index) = true;
60  }
61  }
62  }
std::multimap< float, std::vector< unsigned int > > _register
void cmtool::CMatchBookKeeper::Reset ( )

Reset method.

Definition at line 10 of file CMatchBookKeeper.cxx.

References _register.

Referenced by CMatchBookKeeper(), and cmtool::CMatchManager::Reset().

11  {
12  _register.clear();
13  }
std::multimap< float, std::vector< unsigned int > > _register

Member Data Documentation

std::multimap<float, std::vector<unsigned int> > cmtool::CMatchBookKeeper::_register
protected

Definition at line 45 of file CMatchBookKeeper.h.

Referenced by Match(), PassResult(), and Reset().


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