ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMomentTools
Root
JetConstituentFrac.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetMomentTools/JetConstituentFrac.h
"
6
7
#include "
xAODJet/JetAccessorMap.h
"
8
#include "
AsgDataHandles/WriteDecorHandle.h
"
9
10
#include "
xAODPFlow/FlowElement.h
"
11
12
//**********************************************************************
13
14
JetConstituentFrac::JetConstituentFrac
(
const
std::string& name)
15
:
AsgTool
(name) { }
16
17
//**********************************************************************
18
19
StatusCode
JetConstituentFrac::initialize
() {
20
ATH_MSG_DEBUG
(
"Initializing JetConstituentFrac "
<< name());
21
22
if
(
m_jetContainerName
.empty()){
23
ATH_MSG_ERROR
(
"JetConstituentFrac needs to have its input jet container configured!"
);
24
return
StatusCode::FAILURE;
25
}
26
27
m_neutralEFracKey
=
m_jetContainerName
+
"."
+
m_neutralEFracKey
.key();
28
m_chargePTFracKey
=
m_jetContainerName
+
"."
+
m_chargePTFracKey
.key();
29
m_chargeMFracKey
=
m_jetContainerName
+
"."
+
m_chargeMFracKey
.key();
30
31
ATH_CHECK
(
m_neutralEFracKey
.initialize());
32
ATH_CHECK
(
m_chargePTFracKey
.initialize());
33
ATH_CHECK
(
m_chargeMFracKey
.initialize());
34
35
return
StatusCode::SUCCESS;
36
}
37
38
//**********************************************************************
39
40
StatusCode
JetConstituentFrac::decorate
(
const
xAOD::JetContainer
& jets)
const
{
41
ATH_MSG_VERBOSE
(
"Begin decorating jets."
);
42
for
(
const
xAOD::Jet
*
jet
: jets) {
43
44
fillConstituentFrac
(*
jet
);
45
46
}
47
return
StatusCode::SUCCESS;
48
}
49
50
void
JetConstituentFrac::fillConstituentFrac
(
const
xAOD::Jet
&
jet
)
const
{
51
52
float
neutE=0;
53
float
chargPt=0;
54
TLorentzVector chargM = {0., 0., 0., 0.};
55
56
size_t
numConstit =
jet
.numConstituents();
57
for
(
size_t
i=0; i<numConstit; i++ ) {
58
if
(
jet
.rawConstituent(i)->type()!=
xAOD::Type::FlowElement
) {
59
ATH_MSG_WARNING
(
"Tried to call fillConstituentFrac with a jet constituent that is not a FlowElement!"
);
60
continue
;
61
}
62
const
xAOD::FlowElement
* constit =
static_cast<
const
xAOD::FlowElement
*
>
(
jet
.rawConstituent(i));
63
64
if
(constit->
signalType
() ==
xAOD::FlowElement::Neutral
) neutE+= constit->
e
();
65
if
(constit->
signalType
() ==
xAOD::FlowElement::Charged
){
66
chargPt += constit->
pt
();
67
chargM += constit->
p4
();
68
}
69
}
70
71
SG::WriteDecorHandle<xAOD::JetContainer, float>
neutralEFracHandle(
m_neutralEFracKey
);
72
SG::WriteDecorHandle<xAOD::JetContainer, float>
chargePTFracHandle(
m_chargePTFracKey
);
73
SG::WriteDecorHandle<xAOD::JetContainer, float>
chargeMFracHandle(
m_chargeMFracKey
);
74
75
// Get jet p4 at constituent scale to compute ratios
76
xAOD::JetFourMom_t
uncalP4;
77
jet
.getAttribute<
xAOD::JetFourMom_t
>(
"JetConstitScaleMomentum"
,uncalP4);
78
79
neutralEFracHandle(
jet
) = neutE/uncalP4.e();
80
chargePTFracHandle(
jet
) = chargPt/uncalP4.pt();
81
chargeMFracHandle(
jet
) = uncalP4.M() != 0. ? chargM.M()/uncalP4.M() : 0.;
82
83
}
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
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
WriteDecorHandle.h
Handle class for adding a decoration to an object.
FlowElement.h
JetAccessorMap.h
JetConstituentFrac.h
JetConstituentFrac::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetConstituentFrac.cxx:19
JetConstituentFrac::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition
JetConstituentFrac.cxx:40
JetConstituentFrac::m_chargeMFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_chargeMFracKey
Definition
JetConstituentFrac.h:38
JetConstituentFrac::m_neutralEFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_neutralEFracKey
Definition
JetConstituentFrac.h:36
JetConstituentFrac::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetConstituentFrac.h:34
JetConstituentFrac::JetConstituentFrac
JetConstituentFrac(const std::string &t)
Definition
JetConstituentFrac.cxx:14
JetConstituentFrac::m_chargePTFracKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_chargePTFracKey
Definition
JetConstituentFrac.h:37
JetConstituentFrac::fillConstituentFrac
void fillConstituentFrac(const xAOD::Jet &jet) const
Definition
JetConstituentFrac.cxx:50
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::FlowElement_v1::pt
virtual double pt() const override
xAOD::FlowElement_v1::signalType
signal_t signalType() const
xAOD::FlowElement_v1::Neutral
@ Neutral
Definition
FlowElement_v1.h:37
xAOD::FlowElement_v1::Charged
@ Charged
Definition
FlowElement_v1.h:38
xAOD::FlowElement_v1::e
virtual double e() const override
The total energy of the particle.
Definition
FlowElement_v1.cxx:25
xAOD::FlowElement_v1::p4
virtual FourMom_t p4() const override
The full 4-momentum of the particle.
Definition
FlowElement_v1.cxx:33
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAODType::FlowElement
@ FlowElement
The object is a track-calo-cluster.
Definition
ObjectType.h:52
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition
FlowElement.h:16
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition
JetTypes.h:17
Generated on
for ATLAS Offline Software by
1.17.0