ATLAS Offline Software
Trigger
TrigAnalysis
TriggerMatchingTool
Root
TypedScoringTool.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TriggerMatchingTool/TypedScoringTool.h
"
6
#include "
xAODBase/IParticle.h
"
7
8
#include <sstream>
9
10
namespace
Trig
{
11
TypedScoringTool::TypedScoringTool
(
const
std::string &
name
) :
12
asg
::AsgTool(
name
)
13
{}
14
15
StatusCode
TypedScoringTool::initialize
()
16
{
17
if
(!
m_defaultTool
.empty())
18
ATH_CHECK
(
m_defaultTool
.retrieve());
19
else
20
ATH_MSG_WARNING
(
"No default scoring tool given, may result in crash if type isn't covered."
);
21
22
if
(
m_typedTools
.size() !=
m_toolTypes
.size())
23
{
24
ATH_MSG_ERROR
(
"Number of tools "
<<
m_typedTools
.size() <<
" doesn't match the number types"
<<
m_toolTypes
.size() <<
"!"
);
25
return
StatusCode::FAILURE;
26
}
27
ATH_CHECK
(
m_typedTools
.retrieve());
28
for
(std::size_t
idx
= 0;
idx
<
m_typedTools
.size(); ++
idx
)
29
m_tools
[
static_cast<
xAOD::Type::ObjectType
>
(
m_toolTypes
[
idx
])] =
m_typedTools
[
idx
].operator->();
30
return
StatusCode::SUCCESS;
31
}
32
33
float
TypedScoringTool::score
(
34
const
xAOD::IParticle
&
online
,
35
const
xAOD::IParticle
&
offline
)
const
36
{
37
const
Trig::IMatchScoringTool
*
tool
=
getTool
(
online
.type());
38
if
(!
tool
)
39
{
40
// Convert the enum to a string
41
std::ostringstream oss;
42
oss <<
online
.type();
43
throw
std::out_of_range(oss.str());
44
}
45
return
tool
->score(
online
,
offline
);
46
}
47
48
const
Trig::IMatchScoringTool
*
TypedScoringTool::getTool
(
xAOD::Type::ObjectType
type
)
const
49
{
50
auto
itr =
m_tools
.find(
type
);
51
if
(itr !=
m_tools
.end())
52
return
itr->second;
53
if
(
m_defaultTool
.empty())
54
return
nullptr
;
55
return
m_defaultTool
.operator->();
56
}
57
}
Trig::TypedScoringTool::m_toolTypes
Gaudi::Property< std::vector< int > > m_toolTypes
Definition:
TypedScoringTool.h:36
IParticle.h
TypedScoringTool.h
Trig
The common trigger namespace for trigger analysis tools.
Definition:
CaloTowerVecMon.h:44
ObjectType
ObjectType
Definition:
BaseObject.h:11
Trig::TypedScoringTool::m_typedTools
ToolHandleArray< Trig::IMatchScoringTool > m_typedTools
Definition:
TypedScoringTool.h:34
Trig::TypedScoringTool::score
virtual float score(const xAOD::IParticle &online, const xAOD::IParticle &offline) const override
Calculate the matching score for a pair of particles.
Definition:
TypedScoringTool.cxx:33
asg
Definition:
DataHandleTestTool.h:28
offline
Trig::TypedScoringTool::getTool
const Trig::IMatchScoringTool * getTool(xAOD::Type::ObjectType type) const
Definition:
TypedScoringTool.cxx:48
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition:
Event/xAOD/xAODBase/xAODBase/IParticle.h:40
Trig::TypedScoringTool::m_tools
std::map< xAOD::Type::ObjectType, const Trig::IMatchScoringTool * > m_tools
Definition:
TypedScoringTool.h:38
TileSynchronizeBch.online
online
Definition:
TileSynchronizeBch.py:88
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
Trig::IMatchScoringTool
Interface class for scoring pairs of particles for matching.
Definition:
IMatchScoringTool.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trig::TypedScoringTool::m_defaultTool
ToolHandle< Trig::IMatchScoringTool > m_defaultTool
Definition:
TypedScoringTool.h:32
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:192
AtlCoolConsole.tool
tool
Definition:
AtlCoolConsole.py:453
Trig::TypedScoringTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition:
TypedScoringTool.cxx:15
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition:
CaloScaleNoiseConfig.py:78
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition:
LArNewCalib_DelayDump_OFC_Cali.py:69
Trig::TypedScoringTool::TypedScoringTool
TypedScoringTool(const std::string &name)
Definition:
TypedScoringTool.cxx:11
Generated on Sun Jun 30 2024 21:32:05 for ATLAS Offline Software by
1.8.18