ATLAS Offline Software
Loading...
Searching...
No Matches
JetParticleAssociation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// author: cpollard@cern.ch
6
10
12 : asg::AsgTool(name) {
13}
14
16
17 ATH_MSG_DEBUG("Initializing JetParticleAssociator");
18 m_decKey = m_jetContainerName + "." + m_decKey.key();
19
20 ATH_CHECK(m_decKey.initialize());
21 ATH_CHECK(m_particleKey.initialize());
22
23 ATH_MSG_DEBUG("Minimum pt threshold: " << m_ptMinimum);
24 if (m_ptMinimum > 0.0) {
25 if (!m_passPtKey.key().empty()) {
27 ATH_MSG_DEBUG("Pass Key Decorator: " << m_passPtKey);
28 }
29 }
30
31 ATH_CHECK(m_passPtKey.initialize(!m_passPtKey.key().empty()));
32
33 return StatusCode::SUCCESS;
34}
35
38
39 const std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >* matches;
40
42 if( !parts.isValid() ) {
43 ATH_MSG_WARNING ("Couldn't retrieve particles with key: " << m_particleKey.key() );
44 return StatusCode::FAILURE;
45 }
46
48 std::vector<unsigned int> skipped;
49 for (unsigned int i = 0; i < jets.size(); i++) {
50 const xAOD::Jet* jet = jets.at(i);
51 if (jet->pt() > m_ptMinimum) {
52 ATH_MSG_VERBOSE("Adding jet, pt = " << jet->pt());
53 viewJets.push_back(jet);
54 } else {
55 ATH_MSG_VERBOSE("Skipping jet, pt = " << jet->pt());
56 skipped.push_back(i);
57 }
58 }
59
60 matches = match(*viewJets.asDataVector(), *parts);
61
62 ATH_MSG_DEBUG("About to decorate jets with" << m_decKey);
63
64 for (unsigned int iJet = 0; iJet < viewJets.size(); iJet++) {
65 decHandle(*(viewJets.at(iJet))) = (*matches)[iJet];
66 }
67 for (unsigned int iJet: skipped) {
68 decHandle(*jets.at(iJet)) = {};
69 }
70
71 if (!m_passPtKey.empty()) {
73 for (const xAOD::Jet* jet: viewJets) {
74 passHandle(*jet) = 1;
75 }
76 for (unsigned int iJet: skipped) {
77 passHandle(*jets.at(iJet)) = 0;
78 }
79 }
80
81 delete matches;
82
83 return StatusCode::SUCCESS;
84}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
DataVector adapter that acts like it holds const pointers.
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ElementProxy at(size_type n)
Access an element, as an lvalue.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decKey
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
SG::ReadHandleKey< xAOD::IParticleContainer > m_particleKey
Gaudi::Property< std::string > m_jetContainerName
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< float > m_ptMinimum
SG::WriteDecorHandleKey< xAOD::JetContainer > m_passPtKey
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const =0
JetParticleAssociation(const std::string &name)
Handle class for adding a decoration to an object.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".