ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkMCTruth
src
TruthQGDecorationTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// TruthQGDecorationTool.cxx
7
// Create a single decoration for flavor tagging of truth jets
8
9
#include "
DerivationFrameworkMCTruth/TruthQGDecorationTool.h
"
10
#include "
StoreGate/ReadHandle.h
"
11
#include "
StoreGate/WriteDecorHandle.h
"
12
#include "
AthContainers/ConstAccessor.h
"
13
#include "
xAODJet/JetContainer.h
"
14
#include <string>
15
16
// Initialize
17
StatusCode
DerivationFramework::TruthQGDecorationTool::initialize
() {
18
19
ATH_CHECK
(
m_jetsKey
.initialize());
20
ATH_CHECK
(
m_decOutput
.initialize());
21
return
StatusCode::SUCCESS;
22
23
}
24
25
// Function to do dressing, implements interface in IAugmentationTool
26
StatusCode
DerivationFramework::TruthQGDecorationTool::addBranches
(
const
EventContext& ctx)
const
27
{
28
// Event context
29
30
// Retrieve the jet container
31
SG::ReadHandle<xAOD::JetContainer>
inputJets(
m_jetsKey
, ctx);
32
if
(!inputJets.
isValid
()) {
33
ATH_MSG_ERROR
(
"Couldn't retrieve container with name "
<<
m_jetsKey
);
34
return
StatusCode::FAILURE;
35
}
36
37
SG::WriteDecorHandle<xAOD::JetContainer,int>
output_decorator(
m_decOutput
, ctx);
38
static
const
SG::ConstAccessor<int>
PartonTruthLabelIDAcc(
"PartonTruthLabelID"
);
39
static
const
SG::ConstAccessor<int>
HadronConeExclTruthLabelIDAcc(
"HadronConeExclTruthLabelID"
);
40
41
for
(
const
auto
*ajet : *inputJets){
42
if
(!PartonTruthLabelIDAcc.
isAvailable
(*ajet) ){
43
ATH_MSG_ERROR
(
"Did not have input PartonTruthLabelID decorations available"
);
44
return
StatusCode::FAILURE;
45
}
46
else
if
(!HadronConeExclTruthLabelIDAcc.
isAvailable
(*ajet) ){
47
ATH_MSG_ERROR
(
"Did not have input HadronConeExclTruthLabelID decorations available"
);
48
return
StatusCode::FAILURE;
49
}
// Now we have the input decorations
50
/* Agreement from the HF-tagging and Jet/MET group:
51
- If it is non-zero, use the label from the HF-tagging group (b, c, tau)
52
- If it is zero, use the label from the Jet/MET group (q/g)
53
- In the case that the two disagree (e.g. Jet/MET says b and HF says light),
54
multiply the Jet/MET label by 100 to ensure this case is kept separate
55
*/
56
if
(HadronConeExclTruthLabelIDAcc(*ajet)!=0){
57
output_decorator(*ajet) = HadronConeExclTruthLabelIDAcc(*ajet);
58
}
else
{
59
int
labelid = PartonTruthLabelIDAcc(*ajet);
60
if
(std::abs(labelid)!=5 &&
61
std::abs(labelid)!=4 &&
62
std::abs(labelid)!=15){
63
output_decorator(*ajet) = labelid;
64
}
else
{
65
output_decorator(*ajet) = labelid*100;
66
}
67
}
68
}
// Loop over jets
69
70
return
StatusCode::SUCCESS;
71
}
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
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
JetContainer.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
TruthQGDecorationTool.h
DerivationFramework::TruthQGDecorationTool::initialize
StatusCode initialize()
Definition
TruthQGDecorationTool.cxx:17
DerivationFramework::TruthQGDecorationTool::m_decOutput
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decOutput
output decoration
Definition
TruthQGDecorationTool.h:38
DerivationFramework::TruthQGDecorationTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const
Definition
TruthQGDecorationTool.cxx:26
DerivationFramework::TruthQGDecorationTool::m_jetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
input collection key
Definition
TruthQGDecorationTool.h:35
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
Generated on
for ATLAS Offline Software by
1.17.0