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
10
using namespace
std
;
11
using namespace
xAOD
;
12
13
JetParticleOriginVertexAssociation::JetParticleOriginVertexAssociation
(
const
string
&
name
)
14
:
JetParticleAssociation
(
name
) {
15
16
declareProperty
(
"coneSizeFitPar1"
,
m_coneSizeFitPar1
=0);
17
declareProperty
(
"coneSizeFitPar2"
,
m_coneSizeFitPar2
=0);
18
declareProperty
(
"coneSizeFitPar3"
,
m_coneSizeFitPar3
=0);
19
declareProperty
(
"dzCut"
,
m_dzCut
=10);
20
declareProperty
(
"useMinZ0Vertex"
,
m_useMinZ0Vertex
=
false
);
21
return
;
22
}
23
24
25
const
std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >*
26
JetParticleOriginVertexAssociation::match
(
const
xAOD::JetContainer
& jets,
const
xAOD::IParticleContainer
& parts)
const
{
27
28
//Get the vertex associated to each track by reading the decoration
29
const
SG::AuxElement::ConstAccessor<std::vector<ElementLink<xAOD::VertexContainer>>> trkOrigin(
"btagIp_ByVertex_TrkOriginVtx"
);
30
const
SG::AuxElement::ConstAccessor<std::vector<float>> z0SinTheta(
"btagIp_ByVertex_z0SinTheta"
);
31
//Create the 2d output vector
32
std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >* matchedparts =
33
new
vector<std::vector<ElementLink<xAOD::IParticleContainer> > >(jets.size());
34
35
//loop through the tracks
36
for
(
const
IParticle
* part: parts) {
37
38
// Retrieve the vector of vertex ElementLinks associated with the track and the corresponding z0 vector
39
const
std::vector<ElementLink<xAOD::VertexContainer>>& vertexLink_vec = trkOrigin(*part);
40
const
std::vector<float>& z0SinTheta_vec = z0SinTheta(*part);
41
// check if the vectors are not empty
42
if
(z0SinTheta_vec.empty())
continue
;
43
// index of vertex with min(z0)
44
unsigned
int
selectedVertexIndex = -1;
45
if
(
m_useMinZ0Vertex
) {
46
// Find the vertex with the minimum absolute value of z0SinTheta
47
auto
minAbsIt = std::min_element(z0SinTheta_vec.begin(), z0SinTheta_vec.end(),
48
[](
float
a
,
float
b) {
49
return std::abs(a) < std::abs(b);
50
});
51
// find index of the vertex with mindZ
52
if
(minAbsIt != z0SinTheta_vec.end()) {
53
selectedVertexIndex = std::distance(z0SinTheta_vec.begin(), minAbsIt);
54
}
55
}
56
// loop through vertices
57
for
(
unsigned
int
iVtx=0; iVtx < z0SinTheta_vec.size(); iVtx++){
58
// if we want to do exclusive, only use the vertex with the min(z0)
59
if
(
m_useMinZ0Vertex
&& selectedVertexIndex!=iVtx)
continue
;
60
// retrieve vertex link
61
const
ElementLink<xAOD::VertexContainer>
& vertexLink = vertexLink_vec.at(iVtx);
62
// check if link is valid
63
if
(!vertexLink.
isValid
()) {
64
ATH_MSG_WARNING
(
"Track decoration 'btagIp_TrkOriginVertex' is missing for this track"
);
65
continue
;
66
}
67
// if the dz(track, vertex) doesnt pass the cut then continue to next vertex
68
if
(z0SinTheta_vec.at(iVtx) >
m_dzCut
)
continue
;
69
70
// Continue processing
71
//Get vertex associated with the track
72
const
Vertex
* vtx_to_trk = *vertexLink;
73
int
matchjetidx = -1;
74
double
drmin = -1.0;
75
// Loop through jets
76
for
(
unsigned
int
iJet = 0; iJet < jets.size(); iJet++) {
77
//get jet
78
const
Jet
*
jet
= jets[iJet];
79
// if origin of jet is not the same as the vertex associated to the track then continue to next jet
80
if
(
jet
->getAssociatedObject<
xAOD::Vertex
>(
"OriginVertex"
) != vtx_to_trk)
continue
;
81
82
// do dR matching between jet and track
83
double
match_dr =
coneSize
(
jet
->pt());
84
double
dr =
jet
->p4().DeltaR(part->p4());
85
if
(dr > match_dr)
continue
;
86
if
(drmin < 0 || dr < drmin) {
87
drmin = dr;
88
matchjetidx = iJet;
89
}
90
}
91
if
(matchjetidx >= 0) {
92
ElementLink<xAOD::IParticleContainer>
EL
;
93
EL
.toContainedElement(parts, part);
94
(*matchedparts)[matchjetidx].push_back(
EL
);
95
}
96
}
97
98
}
99
100
return
matchedparts;
101
102
}
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
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::JetParticleAssociation
JetParticleAssociation(const std::string &name)
Definition
JetParticleAssociation.cxx:11
JetParticleOriginVertexAssociation::m_coneSizeFitPar3
double m_coneSizeFitPar3
Definition
JetParticleOriginVertexAssociation.h:34
JetParticleOriginVertexAssociation::coneSize
double coneSize(double pt) const
Definition
JetParticleOriginVertexAssociation.h:26
JetParticleOriginVertexAssociation::m_coneSizeFitPar2
double m_coneSizeFitPar2
Definition
JetParticleOriginVertexAssociation.h:33
JetParticleOriginVertexAssociation::JetParticleOriginVertexAssociation
JetParticleOriginVertexAssociation(const std::string &name)
Definition
JetParticleOriginVertexAssociation.cxx:13
JetParticleOriginVertexAssociation::m_coneSizeFitPar1
double m_coneSizeFitPar1
Definition
JetParticleOriginVertexAssociation.h:32
JetParticleOriginVertexAssociation::m_dzCut
float m_dzCut
Definition
JetParticleOriginVertexAssociation.h:35
JetParticleOriginVertexAssociation::match
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const override
Definition
JetParticleOriginVertexAssociation.cxx:26
JetParticleOriginVertexAssociation::m_useMinZ0Vertex
bool m_useMinZ0Vertex
Definition
JetParticleOriginVertexAssociation.h:36
Jet
Definition
Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
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::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