ATLAS Offline Software
Loading...
Searching...
No Matches
MinimalSumAssociation.cxx
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
8#include "munkres.h"
9
10
12 msg().setLevel(MSG::DEBUG);
13}
14
15IAssociationStrategy::index_assignment_t MinimalSumAssociation::associate(const std::vector<std::vector<double> >& matrix){
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
29 costs.reserve(ncols);
30 munkres munk(std::move(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}
const bool debug
std::map< unsigned int, unsigned int > index_assignment_t
index_assignment_t associate(const std::vector< std::vector< double > > &matrix)
MsgStream & msg() const
The standard message stream.
AsgMessaging(const std::string &name)
Constructor with a name.
result_type run(vec_type &costvector, bool debug=false)
Definition munkres.cxx:20
std::vector< double > vec_type
Definition munkres.h:19