LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CMatchBookKeeper.cxx
Go to the documentation of this file.
1 #ifndef RECOTOOL_MATCHBOOKKEEPER_CXX
2 #define RECOTOOL_MATCHBOOKKEEPER_CXX
3 
4 #include "CMatchBookKeeper.h"
5 
6 namespace cmtool {
7 
9  {
10  Reset();
11  }
12 
14  {
15  _register.clear();
16  }
17 
18  void CMatchBookKeeper::Match(const std::vector<unsigned int>& matched_indexes,
19  const float& score)
20  {
21  _register.insert(std::make_pair(score,matched_indexes));
22  }
23 
24 
25  std::vector<std::vector<unsigned int> > CMatchBookKeeper::GetResult() const
26  {
27  std::vector<std::vector<unsigned int> > res;
28 
29  PassResult(res);
30 
31  return res;
32 
33  }
34 
36  void CMatchBookKeeper::PassResult(std::vector<std::vector<unsigned int> >& result) const
37  {
38  result.clear();
39 
40  // Rough guess: assume half of registered pairs are good
41  result.reserve((unsigned int)(_register.size()/2));
42 
43  std::vector<bool> used_index;
44 
45  for( auto riter = _register.rbegin();
46  riter != _register.rend();
47  ++riter) {
48 
49  bool valid_set = true;
50 
51  for(auto const& index : (*riter).second) {
52 
53  if(index >= used_index.size())
54 
55  used_index.resize(index+1,false);
56 
57  else if(used_index.at(index)) valid_set = false;
58 
59  }
60 
61  if(valid_set) {
62 
63  result.push_back((*riter).second);
64 
65  for(auto& index : (*riter).second)
66 
67  used_index.at(index) = true;
68 
69  }
70 
71  }
72 
73  }
74 
75 }
76 
77 
78 #endif
Class def header for a class CMatchBookKeeper.
void PassResult(std::vector< std::vector< unsigned int > > &result) const
Method to pass result.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
CMatchBookKeeper()
Default constructor.
void Match(const std::vector< unsigned int > &matched_indexes, const float &score)
Method to register matched clusters.
std::multimap< float, std::vector< unsigned int > > _register
void Reset()
Reset method.
std::vector< std::vector< unsigned int > > GetResult() const
Method to get result.