ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigAnalysis
TriggerMatchingTool
Root
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
5
#include "
TriggerMatchingTool/MatchingImplementation.h
"
6
#include "
TriggerMatchingTool/MatchingTool.h
"
7
#include "
MinimalSumAssociation.h
"
8
#include <utility>
9
10
namespace
Trig
{
11
12
MatchingImplementation::MatchingImplementation
(
MatchingTool
& mt,
double
threshold
) :
asg
::
AsgMessaging
(
"MatchingImplementation"
),
m_tool
(mt),
m_threshold
(
threshold
) {
13
m_strategies
[
Trig::MatchingStrategy::MinimalSum
] = std::unique_ptr<IAssociationStrategy>(
new
MinimalSumAssociation
());
14
}
15
16
const
Trig::TrigDecisionTool
*
MatchingImplementation::tdt
()
const
{
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MatchingImplementation.h
MatchingTool.h
MinimalSumAssociation.h
IAssociationStrategy::index_assignment_t
std::map< unsigned int, unsigned int > index_assignment_t
Definition
IAssociationStrategy.h:16
MinimalSumAssociation
Definition
MinimalSumAssociation.h:14
Trig::MatchingImplementation::MatchingImplementation
MatchingImplementation(MatchingTool &mt, double threshold=0.4)
Definition
MatchingImplementation.cxx:12
Trig::MatchingImplementation::m_strategies
std::map< Trig::MatchingStrategy::Strategy, std::unique_ptr< IAssociationStrategy > > m_strategies
Definition
MatchingImplementation.h:42
Trig::MatchingImplementation::assocIsMatched
bool assocIsMatched(const IAssociationStrategy::index_assignment_t &association, const std::vector< std::vector< double > > &matrix, double threshold) const
Definition
MatchingImplementation.cxx:20
Trig::MatchingImplementation::tdt
const Trig::TrigDecisionTool * tdt() const
Definition
MatchingImplementation.cxx:16
Trig::MatchingImplementation::m_threshold
double m_threshold
Definition
MatchingImplementation.h:43
Trig::MatchingImplementation::matchDistanceMatrix
bool matchDistanceMatrix(const std::vector< std::vector< double > > &matrix, const Trig::MatchingStrategy::Strategy strategy=Trig::MatchingStrategy::MinimalSum, double threshold=0.0) const
Definition
MatchingImplementation.cxx:35
Trig::MatchingImplementation::m_tool
MatchingTool & m_tool
Definition
MatchingImplementation.h:41
Trig::MatchingTool
Definition
MatchingTool.h:23
Trig::TrigDecisionTool
Definition
TrigDecisionTool.h:65
asg::AsgMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition
AsgMessaging.cxx:49
asg::AsgMessaging::AsgMessaging
AsgMessaging(const std::string &name)
Constructor with a name.
Definition
AsgMessaging.cxx:17
asg::AsgMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level of the object.
Definition
AsgMessaging.cxx:41
Trig::MatchingStrategy::Strategy
Strategy
Definition
MatchingImplementation.h:26
Trig::MatchingStrategy::MinimalSum
@ MinimalSum
Definition
MatchingImplementation.h:27
Trig
The common trigger namespace for trigger analysis tools.
Definition
LArCellMonAlg.h:33
Trig::distance
int distance(const BunchCrossing bc1, const BunchCrossing bc2)
I need this function only for technical reasons.
Definition
BunchCrossing.cxx:402
asg
Definition
DataHandleTestTool.h:28
threshold
Definition
chainparser.cxx:74
Generated on
for ATLAS Offline Software by
1.17.0