ATLAS Offline Software
BTagTrackLinkCopyAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "xAODJet/JetContainer.h"
9 
12 
13 namespace FlavorTagDiscriminants {
15  const std::string& name, ISvcLocator* svcloc):
17  {
18  }
19 
20 
22  ATH_CHECK(m_jetTracks.initialize());
23  ATH_CHECK(m_btagTracks.initialize());
24  ATH_CHECK(m_jetLinks.initialize());
25  const auto& key_from_btag_tracks = m_btagTracks.contHandleKey().key();
26  const auto& key_from_jet_link = m_jetLinks.contHandleKey().key();
27  if (key_from_btag_tracks != key_from_jet_link) {
29  "Inconsistent keys for btag tracks '"
30  << key_from_btag_tracks << "' and btag -> jet links '"
31  << key_from_jet_link << "'");
32  return StatusCode::FAILURE;
33  }
34  return StatusCode::SUCCESS;
35  }
36 
37 
38  StatusCode BTagTrackLinkCopyAlg::execute(const EventContext& cxt) const {
39  // Note: BC = BTagging container, JC = JetContainer, see the
40  // typedefs in the header file
41 
43  using IPC = xAOD::IParticleContainer;
44 
45  // Note that the jet tracks might have to be changed back to IPC
46  // after Bill's megamerge.
48  m_jetTracks, cxt);
49  if (!jetTracks.isValid()) {
50  ATH_MSG_ERROR("no incoming tracks " << m_jetTracks.key());
51  return StatusCode::FAILURE;
52  }
54  m_btagTracks, cxt);
55 
57 
58  for (const SG::AuxElement* btag: *jetLinks) {
59 
60  const auto& jet_link = jetLinks(*btag);
61 
62  if (!jet_link.isValid()) {
63  ATH_MSG_ERROR("invalid jet link!");
64  return StatusCode::FAILURE;
65  }
66  SG::sgkey_t hash_from_jc = m_jetTracks.contHandleKey().hashedKey();
67  SG::sgkey_t hash_from_link = jet_link.key();
68  if (hash_from_link != hash_from_jc) {
70  "Your btag -> jet link points to '" << jet_link.dataID()
71  << "' but you're trying to copy tracks from '"
72  << m_jetTracks.contHandleKey().key() << "'");
73  return StatusCode::FAILURE;
74  }
75  const SG::AuxElement* jet = *jet_link;
76 
77  std::vector<ElementLink<TC> > tmpTracks;
78  for (const auto& elpart: jetTracks(*jet)) {
79  tmpTracks.push_back(ElementLink<TC>(elpart.key(), elpart.index()));
80  }
81  btagTracks(*btag) = tmpTracks;
82 
83  }
84  return StatusCode::SUCCESS;
85  }
86 
87 
89  return StatusCode::SUCCESS;
90  }
91 
92 }
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::BTagTrackLinkCopyAlg
BTagTrackLinkCopyAlg(const std::string &name, ISvcLocator *svcloc)
Definition: BTagTrackLinkCopyAlg.cxx:14
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::finalize
virtual StatusCode finalize() override
Definition: BTagTrackLinkCopyAlg.cxx:88
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:446
xAOD::TrackParticleContainer
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticleContainer.h:14
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition: xAOD/xAODBase/xAODBase/IParticleContainer.h:32
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::initialize
virtual StatusCode initialize() override
Definition: BTagTrackLinkCopyAlg.cxx:21
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::execute
virtual StatusCode execute(const EventContext &cxt) const override
Definition: BTagTrackLinkCopyAlg.cxx:38
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::m_jetTracks
SG::ReadDecorHandleKey< JC > m_jetTracks
Definition: BTagTrackLinkCopyAlg.h:29
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
BTagTrackLinkCopyAlg.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::m_btagTracks
SG::WriteDecorHandleKey< BC > m_btagTracks
Definition: BTagTrackLinkCopyAlg.h:31
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BTaggingContainer.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
JetContainer.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
FlavorTagDiscriminants::BTagTrackLinkCopyAlg::m_jetLinks
SG::ReadDecorHandleKey< BC > m_jetLinks
Definition: BTagTrackLinkCopyAlg.h:33
TrackParticleContainer.h