ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11using namespace std;
12using namespace xAOD;
13
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
26
28 ATH_CHECK(m_trkOriginKey.initialize());
29 ATH_CHECK(m_z0SinThetaKey.initialize());
30
31 return StatusCode::SUCCESS;
32}
33
34
35const std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >*
37
38 //Get the vertex associated to each track by reading the decoration
40 trkOrigin(m_trkOriginKey);
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) {
104 EL.toContainedElement(parts, part);
105 (*matchedparts)[matchjetidx].push_back(EL);
106 }
107 }
108
109 }
110
111 return matchedparts;
112
113}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x,...)
Handle class for reading a decoration on an object.
static Double_t a
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
JetParticleAssociation(const std::string &name)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_trkOriginKey
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_z0SinThetaKey
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const override
Handle class for reading a decoration on an object.
Class providing the definition of the 4-vector interface.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.