ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMomentTools
Root
JetLArHVTool.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 "
AsgDataHandles/WriteDecorHandle.h
"
6
7
#include "
JetMomentTools/JetLArHVTool.h
"
8
#include "
xAODCaloEvent/CaloCluster.h
"
9
10
JetLArHVTool::JetLArHVTool
(
const
std::string& name)
11
:
asg
::
AsgTool
(name)
12
{
13
}
14
15
16
StatusCode
JetLArHVTool::initialize
()
17
{
18
if
(
m_fracKey
.key().at(0) ==
'.'
||
m_nCellKey
.key().at(0) ==
'.'
){
19
ATH_MSG_ERROR
(
"JetLArHVTool needs to have its input jet container name configured!"
);
20
return
StatusCode::FAILURE;
21
}
22
23
// Prepend jet container name
24
m_fracKey
=
m_jetContainerName
+
"."
+
m_fracKey
.key();
25
m_nCellKey
=
m_jetContainerName
+
"."
+
m_nCellKey
.key();
26
27
ATH_CHECK
(
m_fracKey
.initialize());
28
ATH_CHECK
(
m_nCellKey
.initialize());
29
return
StatusCode::SUCCESS;
30
}
31
32
33
StatusCode
JetLArHVTool::decorate
(
const
xAOD::JetContainer
& jets)
const
34
{
35
36
SG::WriteDecorHandle<xAOD::JetContainer, float>
fracHandle(
m_fracKey
);
37
SG::WriteDecorHandle<xAOD::JetContainer, int>
nCellHandle(
m_nCellKey
);
38
39
for
(
const
xAOD::Jet
*
jet
: jets){
40
41
double
energyHVaff=0;
42
int
numCellsHVaff=0;
43
44
// loop over raw constituents. Look for clusters
45
size_t
num =
jet
->numConstituents();
46
for
(
size_t
i=0;i<num;i++) {
47
const
xAOD::CaloCluster
* cl =
dynamic_cast<
const
xAOD::CaloCluster
*
>
(
jet
->rawConstituent(i));
48
if
( !cl)
continue
;
49
50
double
m;
51
if
(cl->retrieveMoment(
xAOD::CaloCluster::ENG_BAD_HV_CELLS
,m) ) energyHVaff += m;
52
if
(cl->retrieveMoment(
xAOD::CaloCluster::N_BAD_HV_CELLS
, m) ) numCellsHVaff += m;
53
}
54
55
double
emE =
jet
->jetP4(
xAOD::JetEMScaleMomentum
).E();
56
// set the attributes
57
fracHandle(*
jet
) = energyHVaff / emE;
58
nCellHandle(*
jet
) = numCellsHVaff;
59
}
60
return
StatusCode::SUCCESS;
61
}
62
63
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:33
WriteDecorHandle.h
Handle class for adding a decoration to an object.
CaloCluster.h
JetLArHVTool.h
JetLArHVTool::m_fracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_fracKey
Definition
JetLArHVTool.h:43
JetLArHVTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetLArHVTool.h:40
JetLArHVTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition
JetLArHVTool.cxx:33
JetLArHVTool::JetLArHVTool
JetLArHVTool(const std::string &name)
Definition
JetLArHVTool.cxx:10
JetLArHVTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetLArHVTool.cxx:16
JetLArHVTool::m_nCellKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_nCellKey
Definition
JetLArHVTool.h:45
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
xAOD::CaloCluster_v1::ENG_BAD_HV_CELLS
@ ENG_BAD_HV_CELLS
Total em-scale energy of cells with bad HV in this cluster.
Definition
CaloCluster_v1.h:170
xAOD::CaloCluster_v1::N_BAD_HV_CELLS
@ N_BAD_HV_CELLS
number of cells with bad HV
Definition
CaloCluster_v1.h:171
asg
Definition
DataHandleTestTool.h:28
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::JetEMScaleMomentum
@ JetEMScaleMomentum
Definition
JetTypes.h:28
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0