ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkMCTruth
src
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
13
#include "
DerivationFrameworkMCTruth/JetMatchingTool.h
"
14
15
namespace
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
26
JetMatchingTool::~JetMatchingTool
(){
27
}
28
29
/*
30
---------------------------------------------------------------------------------------------------------------------------------------
31
--------------------------------------------------------- Initialize/Finalize ---------------------------------------------------------
32
---------------------------------------------------------------------------------------------------------------------------------------
33
*/
34
35
StatusCode
JetMatchingTool::initialize
() {
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
48
StatusCode
JetMatchingTool::finalize
(){
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
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
JetMatchingTool.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
DataVector< TruthParticle_v1 >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DerivationFramework::JetMatchingTool::~JetMatchingTool
virtual ~JetMatchingTool()
Definition
JetMatchingTool.cxx:26
DerivationFramework::JetMatchingTool::initialize
virtual StatusCode initialize() override
Definition
JetMatchingTool.cxx:35
DerivationFramework::JetMatchingTool::m_drCut
Gaudi::Property< float > m_drCut
Definition
JetMatchingTool.h:80
DerivationFramework::JetMatchingTool::finalize
virtual StatusCode finalize() override
Definition
JetMatchingTool.cxx:48
DerivationFramework::JetMatchingTool::JetMatchingTool
JetMatchingTool(const std::string &t, const std::string &n, const IInterface *p)
Definition
JetMatchingTool.cxx:23
DerivationFramework::JetMatchingTool::m_jetEtaCut
Gaudi::Property< float > m_jetEtaCut
Definition
JetMatchingTool.h:79
DerivationFramework::JetMatchingTool::matchHadronsToJets
std::map< const xAOD::Jet *, std::vector< xAOD::TruthParticleContainer::const_iterator > > matchHadronsToJets(const xAOD::TruthParticleContainer *hadrons, const xAOD::JetContainer *jets) const
Definition
JetMatchingTool.cxx:58
DerivationFramework::JetMatchingTool::m_jetPtCut
Gaudi::Property< float > m_jetPtCut
Definition
JetMatchingTool.h:78
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
MCTruthPartClassifier::hadron
@ hadron
Definition
TruthClassifiers.h:147
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
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::TruthParticleContainer
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticleContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0