ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleJetGhostLabelTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11using namespace std;
12using namespace xAOD;
13
15 : AsgTool(name) {
16 declareProperties(*this, &m_labelnames);
17 declareProperty("GhostBName", m_ghostbname="GhostBHadronsFinal", "Name of attribute for matched B hadrons.");
18 declareProperty("GhostCName", m_ghostcname="GhostCHadronsFinal", "Name of attribute for matched C hadrons.");
19 declareProperty("GhostTauName", m_ghosttauname="GhostTausFinal", "Name of attribute for matched Taus.");
20 declareProperty("PartPtMin", m_partptmin=5000, "Minimum pT of particles for labeling (MeV)");
21}
22
24{
25 m_labelnames.check();
26 ATH_CHECK(m_truthEventsKey.initialize());
27 return StatusCode::SUCCESS;
28}
29
31{
32
33 using namespace std;
34 using namespace xAOD;
35 namespace pjt = ParticleJetTools;
36
37 ATH_MSG_VERBOSE("In " << name() << "::modify()");
38
39
41 if (!truthEventsHandle.isValid()){
42 ATH_MSG_ERROR(" Invalid ReadHandle for TruthEvents with key: " << truthEventsHandle.key());
43 return StatusCode::FAILURE;
44 }
45
46 Amg::Vector3D origin = pjt::signalProcessP3(*truthEventsHandle);
47
48 for (const xAOD::Jet* jetptr: jets) {
49
50 const Jet& jet = *jetptr;
51 vector<const TruthParticle*> jetlabelpartsb = match(jet, m_ghostbname);
52 vector<const TruthParticle*> jetlabelpartsc = match(jet, m_ghostcname);
53 vector<const TruthParticle*> jetlabelpartstau = match(jet, m_ghosttauname);
54
55 // remove children whose parent hadrons are also in the jet.
56 // don't care about double tau jets
57 // so leave them for now.
58
60 childrenRemoved(jetlabelpartsb, jetlabelpartsb);
61 childrenRemoved(jetlabelpartsb, jetlabelpartsc);
62 childrenRemoved(jetlabelpartsc, jetlabelpartsc);
63
64 // set truth label for jets above pt threshold
65 // hierarchy: b > c > tau > light
67 .b = std::move(jetlabelpartsb),
68 .c = std::move(jetlabelpartsc),
69 .tau = std::move(jetlabelpartstau),
70 .origin = origin
71 };
73 }
74
75 return StatusCode::SUCCESS;
76}
77
78
79std::vector<const TruthParticle*>
81 const xAOD::Jet& jet, const std::string& ghostname) const {
82
83 ATH_MSG_VERBOSE("In " << name() << "::match()");
84
85 std::vector<const xAOD::TruthParticle*> parton_links
86 = jet.getAssociatedObjects<const xAOD::TruthParticle>(ghostname);
87
88 std::vector<const xAOD::TruthParticle*> selected_partons;
89 for (const xAOD::TruthParticle* part: parton_links) {
90 if (part->pt() > m_partptmin) {
91 selected_partons.push_back(part);
92 }
93 }
94 return selected_partons;
95}
96
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ParticleJetTools::LabelNames m_labelnames
Name of jet label attributes.
double m_partptmin
Minimum pT for particle selection (in MeV)
StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventsKey
ParticleJetGhostLabelTool(const std::string &name)
Constructor.
StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
std::vector< const xAOD::TruthParticle * > match(const xAOD::Jet &, const std::string &ghostname) const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Eigen::Matrix< double, 3, 1 > Vector3D
void setJetLabels(const xAOD::Jet &jet, const Particles &particles, const LabelNames &names)
void childrenRemoved(const std::vector< const xAOD::TruthParticle * > &parents, std::vector< const xAOD::TruthParticle * > &children)
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Jet_v1 Jet
Definition of the current "jet version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
JetContainer_v1 JetContainer
Definition of the current "jet container version".