ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRecTools
Root
ClusterAtMLScaleTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetRecTools/ClusterAtMLScaleTool.h
"
6
7
#include "
StoreGate/ReadDecorHandle.h
"
8
#include "GaudiKernel/ThreadLocalContext.h"
9
10
11
ClusterAtMLScaleTool::ClusterAtMLScaleTool
(
const
std::string& name) :
JetConstituentModifierBase
(name)
12
{
13
}
14
15
16
StatusCode
ClusterAtMLScaleTool::initialize
() {
17
18
if
(
m_inputType
!=
xAOD::Type::CaloCluster
) {
19
ATH_MSG_ERROR
(
"As the name suggests, ClusterAtMLScaleTool cannot operate on objects of type "
20
<<
m_inputType
);
21
return
StatusCode::FAILURE;
22
}
23
24
ATH_CHECK
(
m_clusterMLCorrectedEnergyKey
.initialize());
25
26
const
std::string&
type
=
m_clusterMLCorrectedEnergyDecorationType
.value();
27
if
(
type
!=
"float"
&&
type
!=
"double"
) {
28
ATH_MSG_ERROR
(
29
"Invalid value for ClusterMLCorrectedEnergyDecorationType: '"
30
<<
type
31
<<
"'. Allowed values are 'float' and 'double'."
);
32
return
StatusCode::FAILURE;
33
}
34
35
return
StatusCode::SUCCESS;
36
}
37
38
39
template
<
typename
T>
40
StatusCode
ClusterAtMLScaleTool::setClustersToMLScaleImpl
(
41
xAOD::CaloClusterContainer
& cont,
42
const
EventContext& ctx)
const
43
{
44
SG::ReadDecorHandle<xAOD::CaloClusterContainer, T>
dec(
45
m_clusterMLCorrectedEnergyKey
, ctx);
46
47
if
(!dec.isValid()) {
48
ATH_MSG_ERROR
(
"Decoration handle is not valid: "
49
<<
m_clusterMLCorrectedEnergyKey
.key());
50
return
StatusCode::FAILURE;
51
}
52
53
for
(
xAOD::CaloCluster
* cl : cont) {
54
if
(!cl)
continue
;
55
56
const
double
calE = dec(*cl);
57
58
cl->setCalE(calE);
59
cl->setCalM(cl->rawM());
60
cl->setCalPhi(cl->rawPhi());
61
cl->setCalEta(cl->rawEta());
62
}
63
64
return
StatusCode::SUCCESS;
65
}
66
template
StatusCode
67
ClusterAtMLScaleTool::setClustersToMLScaleImpl<float>
(
68
xAOD::CaloClusterContainer
&,
69
const
EventContext&)
const
;
70
71
template
StatusCode
72
ClusterAtMLScaleTool::setClustersToMLScaleImpl<double>
(
73
xAOD::CaloClusterContainer
&,
74
const
EventContext&)
const
;
75
76
77
StatusCode
ClusterAtMLScaleTool::setClustersToMLScale
(
xAOD::CaloClusterContainer
& cont)
const
{
78
79
const
EventContext& ctx = Gaudi::Hive::currentContext();
80
return
(
m_clusterMLCorrectedEnergyDecorationType
.value() ==
"double"
)
81
?
setClustersToMLScaleImpl<double>
(cont, ctx)
82
:
setClustersToMLScaleImpl<float>
(cont, ctx);
83
}
84
85
86
StatusCode
ClusterAtMLScaleTool::process_impl
(
xAOD::IParticleContainer
* cont)
const
{
87
xAOD::CaloClusterContainer
* clust =
dynamic_cast<
xAOD::CaloClusterContainer
*
>
(cont);
// Get CaloCluster container
88
if
(clust)
89
return
setClustersToMLScale
(*clust);
90
91
return
StatusCode::FAILURE;
92
}
93
94
95
ClusterAtMLScaleTool::~ClusterAtMLScaleTool
()=
default
;
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ClusterAtMLScaleTool.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ClusterAtMLScaleTool::setClustersToMLScale
StatusCode setClustersToMLScale(xAOD::CaloClusterContainer &cont) const
Definition
ClusterAtMLScaleTool.cxx:77
ClusterAtMLScaleTool::m_clusterMLCorrectedEnergyKey
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_clusterMLCorrectedEnergyKey
Definition
ClusterAtMLScaleTool.h:40
ClusterAtMLScaleTool::~ClusterAtMLScaleTool
~ClusterAtMLScaleTool()
ClusterAtMLScaleTool::m_clusterMLCorrectedEnergyDecorationType
Gaudi::Property< std::string > m_clusterMLCorrectedEnergyDecorationType
Definition
ClusterAtMLScaleTool.h:48
ClusterAtMLScaleTool::ClusterAtMLScaleTool
ClusterAtMLScaleTool(const std::string &name)
Definition
ClusterAtMLScaleTool.cxx:11
ClusterAtMLScaleTool::process_impl
virtual StatusCode process_impl(xAOD::IParticleContainer *cont) const override
Definition
ClusterAtMLScaleTool.cxx:86
ClusterAtMLScaleTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
ClusterAtMLScaleTool.cxx:16
ClusterAtMLScaleTool::setClustersToMLScaleImpl
StatusCode setClustersToMLScaleImpl(xAOD::CaloClusterContainer &cont, const EventContext &ctx) const
Definition
ClusterAtMLScaleTool.cxx:40
JetConstituentModifierBase::JetConstituentModifierBase
JetConstituentModifierBase(const std::string &name)
Definition
JetConstituentModifierBase.cxx:14
JetConstituentModifierBase::m_inputType
unsigned int m_inputType
Definition
JetConstituentModifierBase.h:60
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
xAODType::CaloCluster
@ CaloCluster
The object is a calorimeter cluster.
Definition
ObjectType.h:39
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
type
Generated on
for ATLAS Offline Software by
1.17.0