ATLAS Offline Software
Loading...
Searching...
No Matches
MatchingImplementation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include <utility>
9
10namespace Trig {
11
15
17 return std::as_const(m_tool).m_trigDecTool.operator->();
18}
19
20 bool MatchingImplementation::assocIsMatched(const IAssociationStrategy::index_assignment_t& association, const std::vector<std::vector<double> >& matrix, double threshold) const {
21 int ndim = matrix.size();
22 if(!ndim) return false;
23
24 bool result = true;
25 for(auto trig_reco : association){
26 double distance = matrix[trig_reco.first][trig_reco.second];
27 bool single_assoc = distance < threshold;
28 result = result && single_assoc;
29 ATH_MSG_DEBUG("reco: " << trig_reco.first << " associated to trig: " << trig_reco.second <<
30 " with distance: " << distance << " ok: " << single_assoc << " overall: " << result);
31 }
32 return result;
33}
34
35 bool MatchingImplementation::matchDistanceMatrix(const std::vector<std::vector<double> >& matrix, const Trig::MatchingStrategy::Strategy strategy, double threshold) const {
36 int nrows = matrix.size();
37 int ncols = matrix.at(0).size();
38
39 ATH_MSG_DEBUG("matching a " << nrows << "x" << ncols << "matrix now");
40
41
42 auto MSG_MATRIX = MSG::DEBUG;
43 if(msgLvl(MSG_MATRIX)){
44 msg() << MSG_MATRIX << "===========" << endmsg;
45 for(auto& row : matrix){
46 msg() << MSG_MATRIX << "|";
47 for(auto distance : row){
48 msg() << MSG_MATRIX << distance << " , ";
49 }
50 msg() << MSG_MATRIX << "|" << endmsg;
51 }
52 msg() << MSG_MATRIX << "===========" << endmsg;
53 }
54
55
56 //require that every row contains an entry that is smaller than threshold, otherwise matching will obviously fail
57 for(auto& row : matrix) {
58 bool rowOk=false;
59 for(auto distance : row) {
60 if( distance < threshold ) { rowOk = true; break; }
61 }
62 if(!rowOk) {
63 ATH_MSG_DEBUG("row of matrix does not contain any distance below threshold. Return false"); return false;
64 }
65 }
66
67 auto association_map = m_strategies.at(strategy)->associate(matrix);
68 return assocIsMatched(association_map,matrix,threshold);
69}
70
71}
#define endmsg
#define ATH_MSG_DEBUG(x)
std::map< unsigned int, unsigned int > index_assignment_t
MatchingImplementation(MatchingTool &mt, double threshold=0.4)
std::map< Trig::MatchingStrategy::Strategy, std::unique_ptr< IAssociationStrategy > > m_strategies
bool assocIsMatched(const IAssociationStrategy::index_assignment_t &association, const std::vector< std::vector< double > > &matrix, double threshold) const
const Trig::TrigDecisionTool * tdt() const
bool matchDistanceMatrix(const std::vector< std::vector< double > > &matrix, const Trig::MatchingStrategy::Strategy strategy=Trig::MatchingStrategy::MinimalSum, double threshold=0.0) const
MsgStream & msg() const
The standard message stream.
AsgMessaging(const std::string &name)
Constructor with a name.
bool msgLvl(const MSG::Level lvl) const
Test the output level of the object.
The common trigger namespace for trigger analysis tools.
int distance(const BunchCrossing bc1, const BunchCrossing bc2)
I need this function only for technical reasons.