ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleJetTools
Root
JetPileupLabelingTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ParticleJetTools/JetPileupLabelingTool.h
"
6
7
#include "
AsgDataHandles/ReadHandle.h
"
8
#include "
AsgDataHandles/ReadDecorHandle.h
"
9
#include "
AsgDataHandles/WriteDecorHandle.h
"
10
11
12
StatusCode
JetPileupLabelingTool::initialize
(){
13
14
ATH_MSG_INFO
(
"Initializing "
<< name());
15
print
();
16
17
m_decIsHSKey
=
m_jetContainerName
+
"."
+
m_decIsHSKey
.key();
18
m_decIsPUKey
=
m_jetContainerName
+
"."
+
m_decIsPUKey
.key();
19
20
ATH_CHECK
(
m_truthJetsKey
.initialize());
21
#ifndef XAOD_STANDALONE
22
if
(
m_suppressOutputDeps
) {
23
// For analysis applications, may not enforce scheduling via data deps
24
renounce
(
m_decIsHSKey
);
25
renounce
(
m_decIsPUKey
);
26
}
27
#endif
28
ATH_CHECK
(
m_decIsHSKey
.initialize());
29
ATH_CHECK
(
m_decIsPUKey
.initialize());
30
31
return
StatusCode::SUCCESS;
32
}
33
34
void
JetPileupLabelingTool::print
()
const
{
35
36
ATH_MSG_INFO
(
"Parameters for "
<< name() <<
" :"
);
37
ATH_MSG_INFO
(
"HS Truth Jet Container: "
<<
m_truthJetsKey
.key());
38
ATH_MSG_INFO
(
"Name of isHS Label Decoration: "
<<
m_decIsHSKey
.key());
39
ATH_MSG_INFO
(
"Name of isPU Label Decoration: "
<<
m_decIsPUKey
.key());
40
}
41
42
43
StatusCode
JetPileupLabelingTool::decorate
(
const
xAOD::JetContainer
& jets)
const
{
44
45
// Get collection of HS Truth Jets
46
SG::ReadHandle<xAOD::JetContainer>
truthHSJetsHandle =
SG::makeHandle
(
m_truthJetsKey
);
47
if
(!truthHSJetsHandle.
isValid
()){
48
ATH_MSG_ERROR
(
"Invalid JetContainer datahandle: "
<<
m_truthJetsKey
.key());
49
return
StatusCode::FAILURE;
50
}
51
const
xAOD::JetContainer
* truthHSJets = truthHSJetsHandle.
cptr
();
52
53
SG::WriteDecorHandle<xAOD::JetContainer, char>
isHSJetHandle (
m_decIsHSKey
);
54
SG::WriteDecorHandle<xAOD::JetContainer, char>
isPUJetHandle (
m_decIsPUKey
);
55
56
for
(
const
xAOD::Jet
*
jet
: jets){
57
bool
isHS =
false
;
58
bool
isPU =
true
;
59
for
(
const
xAOD::Jet
*truthJet : *truthHSJets) {
60
float
dr =
jet
->p4().DeltaR(truthJet->p4());
61
if
(dr < m_hsMaxDR && truthJet->pt() >
m_hsMinPt
)
62
isHS =
true
;
63
if
(dr < m_puMinDR && truthJet->pt() >
m_puMinPt
)
64
isPU =
false
;
65
if
(isHS && !isPU)
66
break
;
67
}
68
isHSJetHandle(*
jet
) = isHS;
69
isPUJetHandle(*
jet
) = isPU;
70
}
71
72
return
StatusCode::SUCCESS;
73
}
74
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
JetPileupLabelingTool.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition
AthCommonDataStore.h:380
JetPileupLabelingTool::m_hsMinPt
Gaudi::Property< float > m_hsMinPt
Definition
JetPileupLabelingTool.h:46
JetPileupLabelingTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetPileupLabelingTool.cxx:12
JetPileupLabelingTool::m_truthJetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_truthJetsKey
Definition
JetPileupLabelingTool.h:50
JetPileupLabelingTool::print
void print() const override
Print configured parameters.
Definition
JetPileupLabelingTool.cxx:34
JetPileupLabelingTool::m_puMinPt
Gaudi::Property< float > m_puMinPt
Definition
JetPileupLabelingTool.h:48
JetPileupLabelingTool::decorate
StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate hard-scatter and pileup labels to a jet collection.
Definition
JetPileupLabelingTool.cxx:43
JetPileupLabelingTool::m_decIsPUKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decIsPUKey
Definition
JetPileupLabelingTool.h:53
JetPileupLabelingTool::m_decIsHSKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decIsHSKey
Definition
JetPileupLabelingTool.h:52
JetPileupLabelingTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetPileupLabelingTool.h:41
JetPileupLabelingTool::m_suppressOutputDeps
Gaudi::Property< bool > m_suppressOutputDeps
Definition
JetPileupLabelingTool.h:43
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
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
Generated on
for ATLAS Offline Software by
1.17.0