ATLAS Offline Software
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 }
ConstDataVector::at
ElementProxy at(size_type n)
Access an element, as an lvalue.
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
asg
Definition: DataHandleTestTool.h:28
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JetParticleAssociation.h
JetParticleAssociation::match
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const =0
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
JetParticleAssociation::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition: JetParticleAssociation.cxx:36
JetParticleAssociation::m_particleKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_particleKey
Definition: JetParticleAssociation.h:42
JetParticleAssociation::m_decKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decKey
Definition: JetParticleAssociation.h:43
JetParticleAssociation::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition: JetParticleAssociation.h:40
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
WriteDecorHandle.h
Handle class for adding a decoration to an object.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
JetParticleAssociation::m_passPtKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_passPtKey
Definition: JetParticleAssociation.h:44
JetParticleAssociation::JetParticleAssociation
JetParticleAssociation(const std::string &name)
Definition: JetParticleAssociation.cxx:11
JetParticleAssociation::m_ptMinimum
Gaudi::Property< float > m_ptMinimum
Definition: JetParticleAssociation.h:41
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
doL1CaloHVCorrections.parts
parts
Definition: doL1CaloHVCorrections.py:334
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
JetParticleAssociation::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetParticleAssociation.cxx:15