ATLAS Offline Software
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 
7 #include "xAODJet/JetContainer.h"
8 #include "AsgMessaging/Check.h"
10 
11 using namespace std;
12 using namespace xAOD;
13 
15  : AsgTool(name) {
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 {
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 = jetlabelpartsb,
68  .c = jetlabelpartsc,
69  .tau = jetlabelpartstau,
70  .origin = origin
71  };
73  }
74 
75  return StatusCode::SUCCESS;
76 }
77 
78 
79 std::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 
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
Check.h
ParticleJetGhostLabelTool::decorate
StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition: ParticleJetGhostLabelTool.cxx:30
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ParticleJetTools::declareProperties
void declareProperties(T &tool, LabelNames *n)
Definition: ParticleJetLabelCommon.h:105
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
ParticleJetGhostLabelTool::m_ghostcname
std::string m_ghostcname
Definition: ParticleJetGhostLabelTool.h:40
ParticleJetTools::LabelNames::check
void check()
Definition: ParticleJetLabelCommon.cxx:97
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ParticleJetLabelCommon.h
ParticleJetGhostLabelTool::m_labelnames
ParticleJetTools::LabelNames m_labelnames
Name of jet label attributes.
Definition: ParticleJetGhostLabelTool.h:38
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleJetGhostLabelTool.h
ParticleJetTools::Particles
Definition: ParticleJetLabelCommon.h:69
ParticleJetTools::childrenRemoved
void childrenRemoved(const std::vector< const xAOD::TruthParticle * > &parents, std::vector< const xAOD::TruthParticle * > &children)
Definition: ParticleJetLabelCommon.cxx:69
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ParticleJetTools
Definition: ParticleJetLabelCommon.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ParticleJetGhostLabelTool::m_truthEventsKey
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventsKey
Definition: ParticleJetGhostLabelTool.h:28
ReadHandle.h
Handle class for reading from StoreGate.
ParticleJetGhostLabelTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: ParticleJetGhostLabelTool.cxx:23
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
ParticleJetTools::signalProcessP3
Amg::Vector3D signalProcessP3(const xAOD::TruthEventContainer &)
Definition: ParticleJetLabelCommon.cxx:62
ParticleJetTools::setJetLabels
void setJetLabels(const xAOD::Jet &jet, const Particles &particles, const LabelNames &names)
Definition: ParticleJetLabelCommon.cxx:285
ParticleJetGhostLabelTool::m_ghosttauname
std::string m_ghosttauname
Definition: ParticleJetGhostLabelTool.h:39
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetContainer.h
ParticleJetGhostLabelTool::match
std::vector< const xAOD::TruthParticle * > match(const xAOD::Jet &, const std::string &ghostname) const
Definition: ParticleJetGhostLabelTool.cxx:80
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ParticleJetGhostLabelTool::m_ghostbname
std::string m_ghostbname
Definition: ParticleJetGhostLabelTool.h:41
ParticleJetGhostLabelTool::ParticleJetGhostLabelTool
ParticleJetGhostLabelTool(const std::string &name)
Constructor.
Definition: ParticleJetGhostLabelTool.cxx:14
ParticleJetGhostLabelTool::m_partptmin
double m_partptmin
Minimum pT for particle selection (in MeV)
Definition: ParticleJetGhostLabelTool.h:44