ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
tauRecTools
src
TauClusterFinder.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
#ifndef XAOD_ATHLYSIS
6
7
#include "
TauClusterFinder.h
"
8
#include "
tauRecTools/HelperFunctions.h
"
9
10
#include "
xAODBase/IParticleHelpers.h
"
11
12
13
TauClusterFinder::TauClusterFinder
(
const
std::string& name) :
14
TauRecToolBase
(name) {
15
}
16
17
18
StatusCode
TauClusterFinder::execute
(
xAOD::TauJet
& tau)
const
{
19
tau.
clearClusterLinks
();
20
21
if
(tau.
jet
() ==
nullptr
) {
22
ATH_MSG_ERROR
(
"Tau jet link is invalid."
);
23
return
StatusCode::FAILURE;
24
}
25
26
const
xAOD::Jet
* jetSeed = tau.
jet
();
27
28
// Find all the clusters in the JetConstituent
29
std::vector<const xAOD::CaloCluster*> clusterList =
getClusterList
(*jetSeed);
30
31
for
(
const
xAOD::CaloCluster
* cluster : clusterList) {
32
if
(cluster ==
nullptr
) {
33
ATH_MSG_WARNING
(
"Find cluster with nullptr, please check the configuration !"
);
34
continue
;
35
}
36
if
(
inEleRM
()){
37
static
const
SG::ConstAccessor<ElementLink<xAOD::CaloClusterContainer>
> acc_originalObject(
"ERMOriginalCaloCluster"
);
38
auto
original_cluster_link = acc_originalObject(*cluster);
39
if
(!original_cluster_link.isValid()){
40
ATH_MSG_ERROR
(
"Original ERM cluster link is not valid"
);
41
}
42
cluster = *original_cluster_link;
43
}
44
45
// Clusters with negative energy will be thinned, and the elementlinks to these
46
// clusters will not be valid.
47
if
(cluster->rawE() <= 0.)
continue
;
48
49
ElementLink<xAOD::IParticleContainer>
linkToCluster;
50
linkToCluster.
toContainedElement
(
51
*(
static_cast<
const
xAOD::IParticleContainer
*
>
(cluster->container())),
52
static_cast<
const
xAOD::IParticle
*
>
(cluster));
53
tau.
addClusterLink
(linkToCluster);
54
}
55
56
return
StatusCode::SUCCESS;
57
}
58
59
60
61
std::vector<const xAOD::CaloCluster*>
TauClusterFinder::getClusterList
(
const
xAOD::Jet
&
jet
)
const
{
62
std::vector<const xAOD::CaloCluster*> clusterList;
63
64
xAOD::JetConstituentVector
constituents =
jet
.getConstituents();
65
for
(
const
xAOD::JetConstituent
* constituent : constituents) {
66
ATH_MSG_DEBUG
(
"JetConstituent: "
);
67
ATH_MSG_DEBUG
(
"eta: "
<< constituent->eta() <<
" phi: "
<< constituent->phi() <<
" e: "
<< constituent->e());
68
69
if
( constituent->type() ==
xAOD::Type::CaloCluster
) {
70
const
xAOD::CaloCluster
* cluster =
static_cast<
const
xAOD::CaloCluster
*
>
(constituent->rawConstituent());
71
ATH_MSG_DEBUG
(
"CaloCluster: "
);
72
ATH_MSG_DEBUG
(
"eta: "
<< cluster->
eta
() <<
" phi: "
<< cluster->
phi
() <<
" e: "
<< cluster->
e
());
73
74
// If jet perfroms the vertex correction, then cluster in Topo jets is in a shallow copy of CaloCalTopoCluster.
75
// Since jets and the shallow copy may not be stored to AOD in R22, these clusters will be invalid with AOD as input.
76
// To fix this issue, we now retrieve the clusters in the original CaloCalTopoCluster.
77
const
xAOD::IParticle
* originalParticle =
xAOD::getOriginalObject
(*cluster);
78
if
(
m_useOrigCluster
and originalParticle !=
nullptr
) {
79
clusterList.push_back(
static_cast<
const
xAOD::CaloCluster
*
>
(originalParticle) );
80
}
81
else
{
82
clusterList.push_back(cluster);
83
}
84
}
85
else
if
( constituent->type() ==
xAOD::Type::FlowElement
) {
86
const
xAOD::FlowElement
* fe =
static_cast<
const
xAOD::FlowElement
*
>
( constituent->rawConstituent() );
87
88
if
(fe->
isCharged
())
continue
;
89
if
(fe->
nOtherObjects
()!=1){
90
ATH_MSG_WARNING
(
"Neutral PFO has "
<< std::to_string(fe->
nOtherObjects
()) <<
" clusters, expected exactly 1!\n"
);
91
continue
;
92
}
93
94
clusterList.push_back(
dynamic_cast<
const
xAOD::CaloCluster
*
>
(fe->
otherObject
(0)) );
95
}
96
else
{
97
ATH_MSG_WARNING
(
"Seed jet constituent type not supported ! Skip"
);
98
continue
;
99
}
100
}
101
102
for
(
const
xAOD::JetConstituent
* constituent : constituents) {
103
// There is only one type in the constituents
104
if
(constituent->type() !=
xAOD::Type::FlowElement
)
break
;
105
106
const
xAOD::FlowElement
* fe =
static_cast<
const
xAOD::FlowElement
*
>
( constituent->rawConstituent() );
107
if
(! fe->
isCharged
())
continue
;
108
109
for
(u_int
index
=0;
index
<fe->
nOtherObjects
();
index
++){
110
const
xAOD::CaloCluster
* cluster =
dynamic_cast<
const
xAOD::CaloCluster
*
>
(fe->
otherObject
(
index
));
111
// Check it is not duplicate of one in neutral list
112
if
( std::find(clusterList.begin(), clusterList.end(), cluster) == clusterList.end() ) {
113
clusterList.push_back(cluster);
114
}
115
}
116
}
117
118
return
clusterList;
119
}
120
121
#endif
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IParticleHelpers.h
HelperFunctions.h
TauClusterFinder.h
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::toContainedElement
bool toContainedElement(BaseConstReference container, ElementType element)
Set link to point to given element (slowest).
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
TauClusterFinder::execute
virtual StatusCode execute(xAOD::TauJet &tau) const override
Execution of this tool.
Definition
TauClusterFinder.cxx:18
TauClusterFinder::m_useOrigCluster
Gaudi::Property< bool > m_useOrigCluster
Definition
TauClusterFinder.h:40
TauClusterFinder::TauClusterFinder
TauClusterFinder(const std::string &name)
Constructor.
Definition
TauClusterFinder.cxx:13
TauClusterFinder::getClusterList
std::vector< const xAOD::CaloCluster * > getClusterList(const xAOD::Jet &jet) const
Definition
TauClusterFinder.cxx:61
TauRecToolBase::TauRecToolBase
TauRecToolBase(const std::string &name)
Definition
TauRecToolBase.cxx:125
TauRecToolBase::inEleRM
bool inEleRM() const
Definition
TauRecToolBase.h:89
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition
CaloCluster_v1.cxx:251
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition
CaloCluster_v1.cxx:265
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition
CaloCluster_v1.cxx:256
xAOD::FlowElement_v1::nOtherObjects
std::size_t nOtherObjects() const
Definition
FlowElement_v1.cxx:192
xAOD::FlowElement_v1::otherObject
const xAOD::IParticle * otherObject(std::size_t i) const
Definition
FlowElement_v1.cxx:196
xAOD::FlowElement_v1::isCharged
bool isCharged() const
Definition
FlowElement_v1.cxx:56
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::JetConstituentVector
A vector of jet constituents at the scale used during jet finding.
Definition
JetConstituentVector.h:117
xAOD::JetConstituent
4-vector of jet constituent at the scale used during jet finding.
Definition
JetConstituentVector.h:61
xAOD::TauJet_v3::clearClusterLinks
void clearClusterLinks()
Remove all clusters from the tau.
Definition
TauJet_v3.cxx:580
xAOD::TauJet_v3::jet
const Jet * jet() const
xAOD::TauJet_v3::addClusterLink
void addClusterLink(const ElementLink< IParticleContainer > &tr)
add a cluster link to the tau
Definition
TauJet_v3.cxx:575
index
Definition
index.py:1
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAODType::FlowElement
@ FlowElement
The object is a track-calo-cluster.
Definition
ObjectType.h:52
xAODType::CaloCluster
@ CaloCluster
The object is a calorimeter cluster.
Definition
ObjectType.h:39
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::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition
FlowElement.h:16
xAOD::getOriginalObject
const IParticle * getOriginalObject(const IParticle ©)
This function can be used to conveniently get a pointer back to the original object from which a copy...
Definition
IParticleHelpers.cxx:140
xAOD::TauJet
TauJet_v3 TauJet
Definition of the current "tau version".
Definition
TauJet.h:17
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
Generated on
for ATLAS Offline Software by
1.17.0