ATLAS Offline Software
CopyJetTruthInfo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CopyJetTruthInfo.h"
6 
8 
9 
10 CopyJetTruthInfo::CopyJetTruthInfo(const std::string &name, ISvcLocator *pSvcLocator)
11  : AthReentrantAlgorithm(name, pSvcLocator) {}
12 
14 {
15  ATH_MSG_DEBUG("Initializing...");
16 
17  // Check and initialize keys
18  ATH_CHECK( m_bkgInputKey.initialize() );
19  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey);
20  ATH_CHECK( m_outputKey.initialize() );
21  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 StatusCode CopyJetTruthInfo::execute(const EventContext& ctx) const
27 {
28  ATH_MSG_DEBUG("execute() begin");
29 
30  // Reading the input timings
31  ATH_MSG_VERBOSE("Retrieving input jets containers");
32 
34  if (!bkgContainer.isValid()) {
35  ATH_MSG_ERROR("Could not get background jets container " << bkgContainer.name() << " from store " << bkgContainer.store());
36  return StatusCode::FAILURE;
37  }
38  ATH_MSG_DEBUG("Found background jets container " << bkgContainer.name() << " in store " << bkgContainer.store());
39 
40  // Creating output jets container
42  ATH_CHECK(outputContainer.record(std::make_unique<xAOD::JetContainer>(), std::make_unique<xAOD::JetAuxContainer>()));
43  if (!outputContainer.isValid()) {
44  ATH_MSG_ERROR("Could not record output jet container " << outputContainer.name() << " to store " << outputContainer.store());
45  return StatusCode::FAILURE;
46  }
47  ATH_MSG_DEBUG("Recorded output jet container " << outputContainer.name() << " in store " << outputContainer.store());
48 
49  outputContainer->reserve(bkgContainer->size());
50 
51  for (const xAOD::Jet *bkgJet : *bkgContainer.cptr()) {
52  xAOD::Jet *jet = new xAOD::Jet();
53  outputContainer->push_back(jet);
54  *jet = *bkgJet;
55  }
56 
57  ATH_MSG_DEBUG("execute() end");
58  return StatusCode::SUCCESS;
59 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
CopyJetTruthInfo::m_bkgInputKey
SG::ReadHandleKey< xAOD::JetContainer > m_bkgInputKey
Definition: CopyJetTruthInfo.h:21
CopyJetTruthInfo::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CopyJetTruthInfo.cxx:26
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
CopyJetTruthInfo::m_outputKey
SG::WriteHandleKey< xAOD::JetContainer > m_outputKey
Definition: CopyJetTruthInfo.h:22
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:376
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CopyJetTruthInfo.h
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.
CopyJetTruthInfo::CopyJetTruthInfo
CopyJetTruthInfo(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CopyJetTruthInfo.cxx:10
CopyJetTruthInfo::initialize
virtual StatusCode initialize() override
Definition: CopyJetTruthInfo.cxx:13
JetAuxContainer.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17