ATLAS Offline Software
MinimalSumAssociation.cxx
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
8 #include "munkres.h"
9 
10 
11 MinimalSumAssociation::MinimalSumAssociation() : asg::AsgMessaging("MinimalSumAssociation"){
12  msg().setLevel(MSG::DEBUG);
13 }
14 
17  int nrows = matrix.size();
18  int ncols = matrix.at(0).size();
19 
20  auto workmatrix = matrix;
21  //if we have more columns than rows we pad the matrix to make it square
22  if(nrows < ncols){
23  for(int i = (ncols - nrows); i > 0;i--){
24  workmatrix.push_back(std::vector<double>(ncols,0));
25  }
26  }
27 
28  munkres::vec_type costs;
29  costs.reserve(ncols);
30  munkres munk(workmatrix);
31 
32  bool debug = false;
33  auto result = munk.run(costs,debug);
34 
35  //result is indexed by row
36  //i.e. when matrix is matrxi[reco][trig]
37  //it maps reco particle at index i to trig particle at index
38  //result[i]
39  for(int i = 0;i < nrows;++i){
40  resultmap[i] = result[i];
41  }
42 
43  return resultmap;
44 }
get_generator_info.result
result
Definition: get_generator_info.py:21
munkres
Definition: munkres.h:17
asg
Definition: DataHandleTestTool.h:28
munkres.h
IAssociationStrategy::index_assignment_t
std::map< unsigned int, unsigned int > index_assignment_t
Definition: IAssociationStrategy.h:16
munkres::run
result_type run(vec_type &costvector, bool debug=false)
Definition: munkres.cxx:20
lumiFormat.i
int i
Definition: lumiFormat.py:92
MinimalSumAssociation::MinimalSumAssociation
MinimalSumAssociation()
Definition: MinimalSumAssociation.cxx:11
asg::AsgMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessaging.cxx:49
MinimalSumAssociation::associate
index_assignment_t associate(const std::vector< std::vector< double > > &matrix)
Definition: MinimalSumAssociation.cxx:15
munkres::vec_type
std::vector< double > vec_type
Definition: munkres.h:19
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
DEBUG
#define DEBUG
Definition: page_access.h:11
MinimalSumAssociation.h