ATLAS Offline Software
Loading...
Searching...
No Matches
JetMatchingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// JetMatchingTool.cxx //
8// Implementation file for class JetMatchingTool //
9// Author: Adrian Berrocal Guardia <adrian.berrocal.guardia@cern.ch> //
10// //
12
14
15namespace DerivationFramework{
16
17 /*
18 ---------------------------------------------------------------------------------------------------------------------------------------
19 ------------------------------------------------------- Constructor/Destructor --------------------------------------------------------
20 ---------------------------------------------------------------------------------------------------------------------------------------
21 */
22
23 JetMatchingTool::JetMatchingTool(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t,n,p){
24 }
25
28
29 /*
30 ---------------------------------------------------------------------------------------------------------------------------------------
31 --------------------------------------------------------- Initialize/Finalize ---------------------------------------------------------
32 ---------------------------------------------------------------------------------------------------------------------------------------
33 */
34
36
37 ATH_MSG_INFO("Initialize");
38
39 // Print the cuts.
40
41 ATH_MSG_INFO("Cut on the pt of the jets: " << m_jetPtCut);
42 ATH_MSG_INFO("Cut on the eta of the jets: " << m_jetEtaCut);
43 ATH_MSG_INFO("Cut for deltaR to consider a match: " << m_drCut);
44
45 return StatusCode::SUCCESS;
46 }
47
49 return StatusCode::SUCCESS;
50 }
51
52 /*
53 --------------------------------------------------------------------------------------------------------------------------------------
54 ---------------------------------------------------------- Hadron Matching ----------------------------------------------------------
55 --------------------------------------------------------------------------------------------------------------------------------------
56 */
57
58 std::map<const xAOD::Jet*, std::vector<xAOD::TruthParticleContainer::const_iterator>> JetMatchingTool::matchHadronsToJets(const xAOD::TruthParticleContainer* hadrons, const xAOD::JetContainer* jets) const{
59
60 // NOTE (not from Adria): The matching is unique for hadrons but not for jets
61 // Need to cut on jets before matching, not for hadrons where we can do it later.
62 // However, the current HFClassification is matching hadrons to the closest jet before the cuts and then cut on jets later - was this studied
63
64 // Declare a map variable to store the list of truth particles that are matched to each jet.
65
66 std::map<const xAOD::Jet*, std::vector<xAOD::TruthParticleContainer::const_iterator>> particleMatch;
67
68 // Match each truth particle to a jet.
69 // Use a for to go through the truth particles.
70
71 for(xAOD::TruthParticleContainer::const_iterator hadron = hadrons->begin(); hadron!=hadrons->end(); ++hadron){
72
73 // Create a jet object to store the closest one to the truth particle that is being considered.
74
75 const xAOD::Jet* holder = nullptr;
76
77 // Define a variable to store the smallest deltaR between the jets and the hadron.
78
79 float drmin=999999;
80
81 // Use a for to go through the jets.
82
83 for(const xAOD::Jet* jet : *jets){
84
85 // Check if cuts are applied on jets.
86
87 if(m_jetPtCut>0 || m_jetEtaCut>=0){
88
89 // In this case, cuts should be applied.
90 // The jet is not considered if the cuts are not satisfied.
91
92 if(jet->p4().Pt()<m_jetPtCut) continue;
93 if(fabs(jet->p4().Eta())>m_jetEtaCut) continue;
94 }
95
96 // Compute deltaR between the jet and the hadron and check if it is smaller than drmin.
97 // If it is smaller, save the jet in holder and dr in drmin.
98
99 float dr = jet->p4().DeltaR((*hadron)->p4());
100
101 if(dr<drmin){
102 drmin=dr;
103 holder=jet;
104 }
105
106 }
107
108 // If the smallest drmin is smaller than drcut, then the truth particle is matched to the jet holder.
109 // Hence, save truth particle in particleMatch to the position that corresponds to jet holder.
110
111 if(drmin<m_drCut){
112 particleMatch[holder].push_back(hadron);
113 }
114
115 }
116
117 // Return the map particleMatch
118
119 return particleMatch;
120 }
121
122}
#define ATH_MSG_INFO(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual StatusCode initialize() override
virtual StatusCode finalize() override
JetMatchingTool(const std::string &t, const std::string &n, const IInterface *p)
Gaudi::Property< float > m_jetEtaCut
std::map< const xAOD::Jet *, std::vector< xAOD::TruthParticleContainer::const_iterator > > matchHadronsToJets(const xAOD::TruthParticleContainer *hadrons, const xAOD::JetContainer *jets) const
Gaudi::Property< float > m_jetPtCut
THE reconstruction tool.
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.