ATLAS Offline Software
BTaggingBuilderAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 
10 namespace FlavorTagDiscriminants {
12  const std::string& name, ISvcLocator* svcloc):
14  {
15  }
16 
17 
19  ATH_CHECK(m_jetKey.initialize());
20  ATH_CHECK(m_btaggingKey.initialize());
21  m_jetLinkKey = m_btaggingKey.key() + ".jetLink";
22  ATH_CHECK(m_jetLinkKey.initialize());
23  return StatusCode::SUCCESS;
24  }
25 
26 
27  StatusCode BTaggingBuilderAlg::execute(const EventContext& cxt) const {
28  // Note: BC = BTagging container, JC = JetContainer, see the
29  // typedefs in the header file
30 
32  SG::WriteHandle<BC> btagging(m_btaggingKey, cxt);
33  ATH_CHECK(jets.isValid());
34  ATH_CHECK(btagging.record(
35  std::make_unique<xAOD::BTaggingContainer>(),
36  std::make_unique<xAOD::BTaggingAuxContainer>())
37  );
39 
40  for (const xAOD::Jet* jet: *jets) {
41 
42  // the really odd looking charade below is, sadly, the cleanest
43  // way to put something in auxdata. The object _must_ be added
44  // to the vector before the auxdata is assigned!
45  auto btag = std::make_unique<xAOD::BTagging>();
46  auto b_ptr = btag.get();
47  btagging->push_back(std::move(btag));
48  // swap the lines above and below and this code will segfault.
49  jetLinks(*b_ptr) = ElementLink<JC>(m_jetKey.hashedKey(), jet->index());
50 
51  }
52 
53  return StatusCode::SUCCESS;
54 
55  }
56 
57 
59  return StatusCode::SUCCESS;
60  }
61 
62 }
FlavorTagDiscriminants::BTaggingBuilderAlg::m_jetKey
SG::ReadHandleKey< JC > m_jetKey
Definition: BTaggingBuilderAlg.h:30
FlavorTagDiscriminants::BTaggingBuilderAlg::finalize
virtual StatusCode finalize() override
Definition: BTaggingBuilderAlg.cxx:58
FlavorTagDiscriminants::BTaggingBuilderAlg::m_btaggingKey
SG::WriteHandleKey< BC > m_btaggingKey
Definition: BTaggingBuilderAlg.h:32
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
FlavorTagDiscriminants::BTaggingBuilderAlg::initialize
virtual StatusCode initialize() override
Definition: BTaggingBuilderAlg.cxx:18
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
FlavorTagDiscriminants::BTaggingBuilderAlg::execute
virtual StatusCode execute(const EventContext &cxt) const override
Definition: BTaggingBuilderAlg.cxx:27
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
BTaggingAuxContainer.h
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
FlavorTagDiscriminants::BTaggingBuilderAlg::m_jetLinkKey
SG::WriteDecorHandleKey< BC > m_jetLinkKey
Definition: BTaggingBuilderAlg.h:34
FlavorTagDiscriminants::BTaggingBuilderAlg::BTaggingBuilderAlg
BTaggingBuilderAlg(const std::string &name, ISvcLocator *svcloc)
Definition: BTaggingBuilderAlg.cxx:11
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
BTaggingBuilderAlg.h
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24