ATLAS Offline Software
Loading...
Searching...
No Matches
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
14#include <string>
15
16// 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
26StatusCode DerivationFramework::TruthQGDecorationTool::addBranches(const EventContext& ctx) const
27{
28 // Event context
29
30 // Retrieve the jet container
32 if (!inputJets.isValid()) {
33 ATH_MSG_ERROR("Couldn't retrieve container with name " << m_jetsKey);
34 return StatusCode::FAILURE;
35 }
36
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Helper class to provide constant type-safe access to aux data.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decOutput
output decoration
virtual StatusCode addBranches(const EventContext &ctx) const
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
input collection key
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.