ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleJetTools
Root
JetParticleOriginVertexAssociation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// author: cpollard@cern.ch
6
7
#include "
ParticleJetTools/JetParticleOriginVertexAssociation.h
"
8
#include "
AsgMessaging/Check.h
"
9
#include "
AsgDataHandles/ReadDecorHandle.h
"
10
11
using namespace
std
;
12
using namespace
xAOD
;
13
14
JetParticleOriginVertexAssociation::JetParticleOriginVertexAssociation
(
const
string
&
name
)
15
:
JetParticleAssociation
(
name
) {
16
17
declareProperty
(
"coneSizeFitPar1"
,
m_coneSizeFitPar1
=0);
18
declareProperty
(
"coneSizeFitPar2"
,
m_coneSizeFitPar2
=0);
19
declareProperty
(
"coneSizeFitPar3"
,
m_coneSizeFitPar3
=0);
20
declareProperty
(
"dzCut"
,
m_dzCut
=10);
21
declareProperty
(
"useMinZ0Vertex"
,
m_useMinZ0Vertex
=
false
);
22
return
;
23
}
24
25
StatusCode
JetParticleOriginVertexAssociation::initialize
() {
26
27
ATH_CHECK
(
JetParticleAssociation::initialize
());
28
ATH_CHECK
(
m_trkOriginKey
.initialize());
29
ATH_CHECK
(
m_z0SinThetaKey
.initialize());
30
31
return
StatusCode::SUCCESS;
32
}
33
34
35
const
std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >*
36
JetParticleOriginVertexAssociation::match
(
const
xAOD::JetContainer
& jets,
const
xAOD::IParticleContainer
& parts)
const
{
37
38
//Get the vertex associated to each track by reading the decoration
39
SG::ReadDecorHandle<xAOD::TrackParticleContainer, std::vector<ElementLink<xAOD::VertexContainer>
>>
40
trkOrigin(
m_trkOriginKey
);
41
SG::ReadDecorHandle<xAOD::TrackParticleContainer, std::vector<float>
> z0SinTheta(
m_z0SinThetaKey
);
42
//Create the 2d output vector
43
std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >* matchedparts =
44
new
vector<std::vector<ElementLink<xAOD::IParticleContainer> > >(jets.size());
45
46
//loop through the tracks
47
for
(
const
IParticle
* part: parts) {
48
49
// Retrieve the vector of vertex ElementLinks associated with the track and the corresponding z0 vector
50
const
std::vector<ElementLink<xAOD::VertexContainer>>& vertexLink_vec = trkOrigin(*part);
51
const
std::vector<float>& z0SinTheta_vec = z0SinTheta(*part);
52
// check if the vectors are not empty
53
if
(z0SinTheta_vec.empty())
continue
;
54
// index of vertex with min(z0)
55
unsigned
int
selectedVertexIndex = -1;
56
if
(
m_useMinZ0Vertex
) {
57
// Find the vertex with the minimum absolute value of z0SinTheta
58
auto
minAbsIt = std::min_element(z0SinTheta_vec.begin(), z0SinTheta_vec.end(),
59
[](
float
a
,
float
b) {
60
return std::abs(a) < std::abs(b);
61
});
62
// find index of the vertex with mindZ
63
if
(minAbsIt != z0SinTheta_vec.end()) {
64
selectedVertexIndex = std::distance(z0SinTheta_vec.begin(), minAbsIt);
65
}
66
}
67
// loop through vertices
68
for
(
unsigned
int
iVtx=0; iVtx < z0SinTheta_vec.size(); iVtx++){
69
// if we want to do exclusive, only use the vertex with the min(z0)
70
if
(
m_useMinZ0Vertex
&& selectedVertexIndex!=iVtx)
continue
;
71
// retrieve vertex link
72
const
ElementLink<xAOD::VertexContainer>
& vertexLink = vertexLink_vec.at(iVtx);
73
// check if link is valid
74
if
(!vertexLink.
isValid
()) {
75
ATH_MSG_WARNING
(
"Track decoration 'btagIp_TrkOriginVertex' is missing for this track"
);
76
continue
;
77
}
78
// if the dz(track, vertex) doesnt pass the cut then continue to next vertex
79
if
(z0SinTheta_vec.at(iVtx) >
m_dzCut
)
continue
;
80
81
// Continue processing
82
//Get vertex associated with the track
83
const
Vertex
* vtx_to_trk = *vertexLink;
84
int
matchjetidx = -1;
85
double
drmin = -1.0;
86
// Loop through jets
87
for
(
unsigned
int
iJet = 0; iJet < jets.size(); iJet++) {
88
//get jet
89
const
Jet
*
jet
= jets[iJet];
90
// if origin of jet is not the same as the vertex associated to the track then continue to next jet
91
if
(
jet
->getAssociatedObject<
xAOD::Vertex
>(
"OriginVertex"
) != vtx_to_trk)
continue
;
92
93
// do dR matching between jet and track
94
double
match_dr =
coneSize
(
jet
->pt());
95
double
dr =
jet
->p4().DeltaR(part->p4());
96
if
(dr > match_dr)
continue
;
97
if
(drmin < 0 || dr < drmin) {
98
drmin = dr;
99
matchjetidx = iJet;
100
}
101
}
102
if
(matchjetidx >= 0) {
103
ElementLink<xAOD::IParticleContainer>
EL
;
104
EL
.toContainedElement(parts, part);
105
(*matchedparts)[matchjetidx].push_back(
EL
);
106
}
107
}
108
109
}
110
111
return
matchedparts;
112
113
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ReadDecorHandle.h
Handle class for reading a decoration on an object.
Check.h
JetParticleOriginVertexAssociation.h
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::isValid
bool isValid() const
Check if the element can be found.
JetParticleAssociation::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetParticleAssociation.cxx:15
JetParticleAssociation::JetParticleAssociation
JetParticleAssociation(const std::string &name)
Definition
JetParticleAssociation.cxx:11
JetParticleOriginVertexAssociation::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetParticleOriginVertexAssociation.cxx:25
JetParticleOriginVertexAssociation::m_trkOriginKey
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_trkOriginKey
Definition
JetParticleOriginVertexAssociation.h:40
JetParticleOriginVertexAssociation::m_coneSizeFitPar3
double m_coneSizeFitPar3
Definition
JetParticleOriginVertexAssociation.h:37
JetParticleOriginVertexAssociation::coneSize
double coneSize(double pt) const
Definition
JetParticleOriginVertexAssociation.h:29
JetParticleOriginVertexAssociation::m_z0SinThetaKey
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_z0SinThetaKey
Definition
JetParticleOriginVertexAssociation.h:42
JetParticleOriginVertexAssociation::m_coneSizeFitPar2
double m_coneSizeFitPar2
Definition
JetParticleOriginVertexAssociation.h:36
JetParticleOriginVertexAssociation::JetParticleOriginVertexAssociation
JetParticleOriginVertexAssociation(const std::string &name)
Definition
JetParticleOriginVertexAssociation.cxx:14
JetParticleOriginVertexAssociation::m_coneSizeFitPar1
double m_coneSizeFitPar1
Definition
JetParticleOriginVertexAssociation.h:35
JetParticleOriginVertexAssociation::m_dzCut
float m_dzCut
Definition
JetParticleOriginVertexAssociation.h:38
JetParticleOriginVertexAssociation::match
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const override
Definition
JetParticleOriginVertexAssociation.cxx:36
JetParticleOriginVertexAssociation::m_useMinZ0Vertex
bool m_useMinZ0Vertex
Definition
JetParticleOriginVertexAssociation.h:39
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std
STL namespace.
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
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