ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::ClassifyAndCalculateHFAugmentation Class Reference

#include <ClassifyAndCalculateHFAugmentation.h>

Inheritance diagram for DerivationFramework::ClassifyAndCalculateHFAugmentation:
Collaboration diagram for DerivationFramework::ClassifyAndCalculateHFAugmentation:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthParticlesKey {this, "TruthParticleContainerName", "TruthParticles", "Name of the truth particles collection that is used to compute the HF Classification"}
SG::ReadHandleKey< xAOD::JetContainerm_jetCollectionKey {this, "jetCollectionName", "AntiKt4TruthDressedWZJets", "Name of the jet collection that is used to compute the HF Classification"}
SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey {this, "EventInfo", "EventInfo", ""}
SG::WriteDecorHandleKey< xAOD::EventInfom_hfDecorKey {this, "hfDecorationName", m_eventInfoKey , "HF_Classification", "Name that is used to store the HF Classification."}
SG::WriteDecorHandleKey< xAOD::EventInfom_SimplehfDecorKey {this, "SimplehfDecorationName", m_eventInfoKey ,"SimpleHFClassification", "Name that is used to store the simple HF Classification."}
SG::WriteDecorHandleKey< xAOD::JetContainerm_jetIDDecorationKey {this, "HadronOriginIDDecorationName", m_jetCollectionKey, "HFHadronOriginID", "jet origin ID decoration key"}
std::string m_hfDecorationName {""}
PublicToolHandle< DerivationFramework::JetMatchingToolm_JetMatchingTool_Tool {this, "JetMatchingTool", ""}
PublicToolHandle< DerivationFramework::ClassifyAndCalculateHFToolm_HFClassification_tool {this, "ClassifyAndComputeHFtool", ""}
PublicToolHandle< DerivationFramework::HadronOriginClassifierm_HadronOriginClassifier_Tool {this, "HadronOriginClassifierTool", ""}

Detailed Description

Definition at line 56 of file ClassifyAndCalculateHFAugmentation.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::ClassifyAndCalculateHFAugmentation::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 70 of file ClassifyAndCalculateHFAugmentation.cxx.

71 {
72
73
74 // Retrieve the truth particle container
75 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticlesHandle(m_truthParticlesKey, ctx);
76 if (!truthParticlesHandle.isValid()) {
77 ATH_MSG_ERROR ("Could not retrieve TruthParticleContainer " << truthParticlesHandle.key());
78 return StatusCode::FAILURE;
79 }
80 const xAOD::TruthParticleContainer* xTruthParticleContainer = truthParticlesHandle.cptr();
81
82 // Retrieve the jets container
83 SG::ReadHandle<xAOD::JetContainer> jetInputHandle(m_jetCollectionKey, ctx);
84 if (!jetInputHandle.isValid()) {
85 ATH_MSG_ERROR ("Could not retrieve JetContainer " << jetInputHandle.key());
86 return StatusCode::FAILURE;
87 }
88 const xAOD::JetContainer* JetCollection = jetInputHandle.cptr();
89
90 // Compute a map that associates the HF hadrons with their origin using the tool m_HadronOriginClassifier_Tool.
91 std::map<const xAOD::TruthParticle*, DerivationFramework::HadronOriginClassifier::HF_id> hadronMap = m_HadronOriginClassifier_Tool->GetOriginMap();
92
93 // Create a map with a list of matched hadrons for each jet.
94 std::map<const xAOD::Jet*, std::vector<xAOD::TruthParticleContainer::const_iterator>> particleMatch = m_JetMatchingTool_Tool->matchHadronsToJets(xTruthParticleContainer, JetCollection);
95
96 // Calculate the necessary information from the jets to compute the HF classifier.
97 m_HFClassification_tool->flagJets(JetCollection, particleMatch, hadronMap, m_hfDecorationName);
98
99 // Compute the HF classifier and the simple HF classifier.
100 int hfclassif = m_HFClassification_tool->computeHFClassification(JetCollection, m_hfDecorationName);
101 int simpleclassif = m_HFClassification_tool->getSimpleClassification(hfclassif);
102
103 // Retrieve EventInfo
104 SG::ReadHandle<xAOD::EventInfo> eventInfoHandle(m_eventInfoKey, ctx);
105 if (!eventInfoHandle.isValid()) {
106 ATH_MSG_ERROR ("Could not retrieve EventInfo " << eventInfoHandle.key());
107 return StatusCode::FAILURE;
108 }
109 const xAOD::EventInfo* EventInfo = eventInfoHandle.cptr();
110
111 // Decorate EventInfo with the HF Classification and the simple version
112 SG::WriteDecorHandle<xAOD::EventInfo, int> decorator_HFClassification(m_hfDecorKey, ctx);
113 decorator_HFClassification(*EventInfo) = hfclassif;
114
115 SG::WriteDecorHandle<xAOD::EventInfo, int> decorator_SimpleHFClassification(m_SimplehfDecorKey, ctx);
116 decorator_SimpleHFClassification(*EventInfo) = simpleclassif;
117
118 // Decorate truth jets with origin ID
119 SG::WriteDecorHandle<xAOD::JetContainer, int> jetIdDecorator(m_jetIDDecorationKey, ctx);
120 for (const auto jet : *JetCollection) {
121 int id = -999;
122 SG::ConstAccessor<int> hfidAcc(m_hfDecorationName + "_id");
123 if(hfidAcc.isAvailable(*jet)){
124 id = hfidAcc(*jet);
125 }
126 jetIdDecorator(*jet) = id;
127 }
128
129 return StatusCode::SUCCESS;
130 }
#define ATH_MSG_ERROR(x)
JetCollection
PublicToolHandle< DerivationFramework::ClassifyAndCalculateHFTool > m_HFClassification_tool
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticlesKey
PublicToolHandle< DerivationFramework::HadronOriginClassifier > m_HadronOriginClassifier_Tool
PublicToolHandle< DerivationFramework::JetMatchingTool > m_JetMatchingTool_Tool
EventInfo_v1 EventInfo
Definition of the latest event info version.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.

◆ initialize()

StatusCode DerivationFramework::ClassifyAndCalculateHFAugmentation::initialize ( )
finaloverridevirtual

Definition at line 27 of file ClassifyAndCalculateHFAugmentation.cxx.

27 {
28
29 ATH_MSG_INFO("Initialize HF computation");
30
31 ATH_MSG_INFO("Jets Container Name " << m_jetCollectionKey.key());
32 ATH_MSG_INFO("Truth Particles Container Name " << m_truthParticlesKey.key());
33 ATH_MSG_INFO("HF Classifier Name " << m_hfDecorKey.key());
34 ATH_MSG_INFO("Simple HF Classifier Name " << m_SimplehfDecorKey.key());
35 ATH_MSG_INFO("Jet Origin ID Decoration Name " << m_jetIDDecorationKey.key());
36 std::size_t pos = m_hfDecorKey.key().find(".");
37 if (pos != std::string::npos) { m_hfDecorationName = m_hfDecorKey.key().substr (pos+1); }
38 ATH_CHECK( m_truthParticlesKey.initialize() );
39 ATH_CHECK( m_jetCollectionKey.initialize() );
40 ATH_CHECK( m_eventInfoKey.initialize() );
41 ATH_CHECK( m_hfDecorKey.initialize() );
42 ATH_CHECK( m_SimplehfDecorKey.initialize() );
43 ATH_CHECK( m_jetIDDecorationKey.initialize() );
44
45 // Retrieve the necessary tools
46 if(m_HFClassification_tool.retrieve().isFailure()){
47 ATH_MSG_ERROR("Unable to retrieve the tool " << m_HFClassification_tool);
48 return StatusCode::FAILURE;
49 }
50
51 if(m_HadronOriginClassifier_Tool.retrieve().isFailure()){
52 ATH_MSG_ERROR("Unable to retrieve the tool " << m_HadronOriginClassifier_Tool);
53 return StatusCode::FAILURE;
54 }
55
56 if(m_JetMatchingTool_Tool.retrieve().isFailure()){
57 ATH_MSG_ERROR("Unable to retrieve the tool " << m_JetMatchingTool_Tool);
58 return StatusCode::FAILURE;
59 }
60
61 return StatusCode::SUCCESS;
62 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)

Member Data Documentation

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_eventInfoKey {this, "EventInfo", "EventInfo", ""}
private

Definition at line 86 of file ClassifyAndCalculateHFAugmentation.h.

86{this, "EventInfo", "EventInfo", ""};

◆ m_HadronOriginClassifier_Tool

PublicToolHandle<DerivationFramework::HadronOriginClassifier> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_HadronOriginClassifier_Tool {this, "HadronOriginClassifierTool", ""}
private

Definition at line 103 of file ClassifyAndCalculateHFAugmentation.h.

103{this, "HadronOriginClassifierTool", ""};

◆ m_HFClassification_tool

PublicToolHandle<DerivationFramework::ClassifyAndCalculateHFTool> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_HFClassification_tool {this, "ClassifyAndComputeHFtool", ""}
private

Definition at line 102 of file ClassifyAndCalculateHFAugmentation.h.

102{this, "ClassifyAndComputeHFtool", ""};

◆ m_hfDecorationName

std::string DerivationFramework::ClassifyAndCalculateHFAugmentation::m_hfDecorationName {""}
private

Definition at line 95 of file ClassifyAndCalculateHFAugmentation.h.

95{""};

◆ m_hfDecorKey

SG::WriteDecorHandleKey<xAOD::EventInfo> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_hfDecorKey {this, "hfDecorationName", m_eventInfoKey , "HF_Classification", "Name that is used to store the HF Classification."}
private

Definition at line 92 of file ClassifyAndCalculateHFAugmentation.h.

92{this, "hfDecorationName", m_eventInfoKey , "HF_Classification", "Name that is used to store the HF Classification."};

◆ m_jetCollectionKey

SG::ReadHandleKey<xAOD::JetContainer> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_jetCollectionKey {this, "jetCollectionName", "AntiKt4TruthDressedWZJets", "Name of the jet collection that is used to compute the HF Classification"}
private

Definition at line 85 of file ClassifyAndCalculateHFAugmentation.h.

85{this, "jetCollectionName", "AntiKt4TruthDressedWZJets", "Name of the jet collection that is used to compute the HF Classification"};

◆ m_jetIDDecorationKey

SG::WriteDecorHandleKey<xAOD::JetContainer> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_jetIDDecorationKey {this, "HadronOriginIDDecorationName", m_jetCollectionKey, "HFHadronOriginID", "jet origin ID decoration key"}
private

Definition at line 94 of file ClassifyAndCalculateHFAugmentation.h.

94{this, "HadronOriginIDDecorationName", m_jetCollectionKey, "HFHadronOriginID", "jet origin ID decoration key"};

◆ m_JetMatchingTool_Tool

PublicToolHandle<DerivationFramework::JetMatchingTool> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_JetMatchingTool_Tool {this, "JetMatchingTool", ""}
private

Definition at line 101 of file ClassifyAndCalculateHFAugmentation.h.

101{this, "JetMatchingTool", ""};

◆ m_SimplehfDecorKey

SG::WriteDecorHandleKey<xAOD::EventInfo> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_SimplehfDecorKey {this, "SimplehfDecorationName", m_eventInfoKey ,"SimpleHFClassification", "Name that is used to store the simple HF Classification."}
private

Definition at line 93 of file ClassifyAndCalculateHFAugmentation.h.

93{this, "SimplehfDecorationName", m_eventInfoKey ,"SimpleHFClassification", "Name that is used to store the simple HF Classification."};

◆ m_truthParticlesKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> DerivationFramework::ClassifyAndCalculateHFAugmentation::m_truthParticlesKey {this, "TruthParticleContainerName", "TruthParticles", "Name of the truth particles collection that is used to compute the HF Classification"}
private

Definition at line 84 of file ClassifyAndCalculateHFAugmentation.h.

84{this, "TruthParticleContainerName", "TruthParticles", "Name of the truth particles collection that is used to compute the HF Classification"};

The documentation for this class was generated from the following files: