ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
HeavyIonRec
HIJetRec
Root
HIJetDRAssociationTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
HIJetDRAssociationTool.h
"
6
#include <iomanip>
7
8
//**********************************************************************
9
10
HIJetDRAssociationTool::HIJetDRAssociationTool
(
const
std::string& n)
11
:
JetModifierBase
(n)
12
{
13
}
14
15
//**********************************************************************
16
17
StatusCode
HIJetDRAssociationTool::initialize
()
18
{
19
ATH_MSG_VERBOSE
(
"HIJetDRAssociationTool initialize"
);
20
ATH_CHECK
(
m_containerKey
.initialize( !
m_containerKey
.key().empty() ) );
21
return
StatusCode::SUCCESS;
22
}
23
24
25
26
StatusCode
HIJetDRAssociationTool::modify
(
xAOD::JetContainer
& jets)
const
27
{
28
29
const
xAOD::IParticleContainer
* ppars=0;
30
31
ATH_MSG_DEBUG
(
"Retrieving xAOD container "
<<
m_containerKey
.key() );
32
SG::ReadHandle<xAOD::IParticleContainer>
readHandlePcontainer (
m_containerKey
);
33
ppars = readHandlePcontainer.
get
();
34
35
using
Grid=std::vector<std::vector<std::vector<const xAOD::IParticle*>>>;
36
const
double
etaMin = -5;
37
const
double
etaMax = 5;
38
const
double
phiMin = -3.1416;
39
const
double
phiMax = 3.1416;
40
41
// build square grid
42
Grid grid;
43
grid.resize(1+ (etaMax-etaMin)/
m_DR
);
44
for
(
auto
& phiVec: grid) {
45
phiVec.resize(1+ (phiMax-phiMin)/
m_DR
);
46
}
47
48
auto
etaToIndex = [etaMin,
this
](
double
eta
) ->
size_t
{
return
(
eta
-etaMin)/
m_DR
; };
49
auto
phiToIndex = [phiMin,
this
](
double
phi
) ->
size_t
{
return
(
phi
-phiMin)/
m_DR
; };
50
51
auto
neighborsInEta = [&grid, etaToIndex](
double
eta
) -> std::vector<size_t> {
52
const
size_t
etaIndex = etaToIndex(
eta
);
53
if
( etaIndex == 0){
54
return
{etaIndex, etaIndex+1};
55
}
56
if
( etaIndex == grid.size()-1){
57
return
{etaIndex-1, etaIndex};
58
}
59
return
{etaIndex-1, etaIndex, etaIndex+1};
60
};
61
62
auto
neighborsInPhi = [&grid, phiToIndex](
double
phi
) -> std::vector<size_t> {
63
const
size_t
phiIndex = phiToIndex(
phi
);
64
if
( phiIndex == 0){
65
return
{grid[0].size()-1, phiIndex, phiIndex+1};
66
}
67
if
( phiIndex == grid[0].
size
()-1){
68
return
{phiIndex-1, phiIndex, 0ul};
// wrapping condition
69
}
70
return
{phiIndex-1, phiIndex, phiIndex+1};
71
};
72
73
for
(
const
auto
* ap : *ppars) {
74
grid[etaToIndex(ap->eta())][phiToIndex(ap->phi())].push_back(ap);
75
}
76
77
for
(
xAOD::JetContainer::iterator
ijet=jets.begin(); ijet!=jets.end(); ++ijet)
78
{
79
std::vector<const xAOD::IParticle*>
ParticleVector
;
80
xAOD::Jet
* theJet=(*ijet);
81
auto
etaN = neighborsInEta(theJet->
eta
());
82
auto
phiN = neighborsInPhi(theJet->
phi
());
83
84
for
(
size_t
etaI : etaN) {
85
for
(
size_t
phiI : phiN ) {
86
for
(
auto
ap: grid[etaI][phiI]) {
87
if
(theJet->
p4
().DeltaR( ap->p4()) <
m_DR
)
ParticleVector
.push_back(ap);
88
}
89
}
90
}
91
theJet->
setAssociatedObjects
(
m_assocName
,
ParticleVector
);
92
}
93
return
StatusCode::SUCCESS;
94
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:27
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:28
HIJetDRAssociationTool.h
ParticleVector
std::vector< const IParticle * > ParticleVector
Definition
JetConstituentFiller.cxx:21
size
size_t size() const
Number of registered mappings.
DataVector< xAOD::Jet_v1 >::iterator
DataModel_detail::iterator< DataVector > iterator
Definition
DataVector.h:842
HIJetDRAssociationTool::m_DR
Gaudi::Property< float > m_DR
DR cut defining association.
Definition
HIJetDRAssociationTool.h:58
HIJetDRAssociationTool::modify
virtual StatusCode modify(xAOD::JetContainer &jets) const override
Implementing abstract methods from base.
Definition
HIJetDRAssociationTool.cxx:26
HIJetDRAssociationTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
HIJetDRAssociationTool.cxx:17
HIJetDRAssociationTool::m_containerKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
name of IParticleContainer w/ particles to associate
Definition
HIJetDRAssociationTool.h:52
HIJetDRAssociationTool::m_assocName
Gaudi::Property< std::string > m_assocName
Name of jet attribute providing link between jets and IParticles.
Definition
HIJetDRAssociationTool.h:55
HIJetDRAssociationTool::HIJetDRAssociationTool
HIJetDRAssociationTool(const std::string &t)
Definition
HIJetDRAssociationTool.cxx:10
JetModifierBase::JetModifierBase
JetModifierBase(const std::string &myname)
Ctor.
Definition
JetModifierBase.cxx:9
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition
Jet_v1.cxx:54
xAOD::Jet_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition
Jet_v1.cxx:71
xAOD::Jet_v1::setAssociatedObjects
void setAssociatedObjects(const std::string &name, const std::vector< const T * > &vec)
set associated objects from a vector of arbitrary object.
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition
Jet_v1.cxx:49
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.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