ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
Overlay
OverlayCopyAlgs
src
CopyPileupParticleTruthInfo.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
#include "
CopyPileupParticleTruthInfo.h
"
6
7
#include "
xAODTruth/TruthParticleAuxContainer.h
"
8
9
10
CopyPileupParticleTruthInfo::CopyPileupParticleTruthInfo
(
const
std::string &name, ISvcLocator *pSvcLocator)
11
:
AthReentrantAlgorithm
(name, pSvcLocator) {}
12
13
StatusCode
CopyPileupParticleTruthInfo::initialize
()
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
CopyPileupParticleTruthInfo::execute
(
const
EventContext& ctx)
const
27
{
28
ATH_MSG_DEBUG
(
"execute() begin"
);
29
30
// Reading the input timings
31
ATH_MSG_VERBOSE
(
"Retrieving input Truth particle containers"
);
32
33
SG::ReadHandle<xAOD::TruthParticleContainer>
bkgContainer(
m_bkgInputKey
, ctx);
34
if
(!bkgContainer.
isValid
()) {
35
ATH_MSG_ERROR
(
"Could not get background Truth particle container "
<< bkgContainer.
name
() <<
" from store "
<< bkgContainer.
store
());
36
return
StatusCode::FAILURE;
37
}
38
ATH_MSG_DEBUG
(
"Found background Truth particle container "
<< bkgContainer.
name
() <<
" in store "
<< bkgContainer.
store
());
39
40
// Creating output Truth particle container
41
SG::WriteHandle<xAOD::TruthParticleContainer>
outputContainer(
m_outputKey
, ctx);
42
ATH_CHECK
(outputContainer.
record
(std::make_unique<xAOD::TruthParticleContainer>(), std::make_unique<xAOD::TruthParticleAuxContainer>()));
43
if
(!outputContainer.
isValid
()) {
44
ATH_MSG_ERROR
(
"Could not record output Truth particle container "
<< outputContainer.
name
() <<
" to store "
<< outputContainer.
store
());
45
return
StatusCode::FAILURE;
46
}
47
ATH_MSG_DEBUG
(
"Recorded output Truth particle container "
<< outputContainer.
name
() <<
" in store "
<< outputContainer.
store
());
48
49
outputContainer->reserve(bkgContainer->size());
50
51
for
(
const
xAOD::TruthParticle
*bkgTruthParticle : *bkgContainer.
cptr
()) {
52
xAOD::TruthParticle
*xTruthParticle =
new
xAOD::TruthParticle
();
53
outputContainer->push_back(xTruthParticle);
54
*xTruthParticle = *bkgTruthParticle;
55
}
56
57
ATH_MSG_DEBUG
(
"execute() end"
);
58
return
StatusCode::SUCCESS;
59
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CopyPileupParticleTruthInfo.h
TruthParticleAuxContainer.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CopyPileupParticleTruthInfo::CopyPileupParticleTruthInfo
CopyPileupParticleTruthInfo(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CopyPileupParticleTruthInfo.cxx:10
CopyPileupParticleTruthInfo::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CopyPileupParticleTruthInfo.cxx:26
CopyPileupParticleTruthInfo::m_bkgInputKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_bkgInputKey
Definition
CopyPileupParticleTruthInfo.h:21
CopyPileupParticleTruthInfo::m_outputKey
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_outputKey
Definition
CopyPileupParticleTruthInfo.h:22
CopyPileupParticleTruthInfo::initialize
virtual StatusCode initialize() override
Definition
CopyPileupParticleTruthInfo.cxx:13
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition
StoreGate/src/VarHandleBase.cxx:382
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
Generated on
for ATLAS Offline Software by
1.17.0