ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRawAlgs
InDetOverlay
src
InDetSDOOverlay.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
InDetOverlay/InDetSDOOverlay.h
"
6
7
#include "
InDetSimData/InDetSimData.h
"
8
9
InDetSDOOverlay::InDetSDOOverlay
(
const
std::string &name, ISvcLocator *pSvcLocator) :
10
AthReentrantAlgorithm
(name, pSvcLocator) { }
11
12
StatusCode
InDetSDOOverlay::initialize
()
13
{
14
ATH_MSG_DEBUG
(
"Initializing..."
);
15
16
if
(
m_signalInputKey
.key().empty()) {
17
ATH_MSG_ERROR
(
"Missing signal input SDO key."
);
18
return
StatusCode::FAILURE;
19
}
20
21
if
(
m_outputKey
.key().empty()) {
22
ATH_MSG_ERROR
(
"Missing output SDO key."
);
23
return
StatusCode::FAILURE;
24
}
25
26
// Check and initialize keys
27
ATH_CHECK
(
m_bkgInputKey
.initialize(!
m_bkgInputKey
.key().empty()) );
28
ATH_MSG_VERBOSE
(
"Initialized ReadHandleKey: "
<<
m_bkgInputKey
);
29
ATH_CHECK
(
m_signalInputKey
.initialize() );
30
ATH_MSG_VERBOSE
(
"Initialized ReadHandleKey: "
<<
m_signalInputKey
);
31
ATH_CHECK
(
m_outputKey
.initialize() );
32
ATH_MSG_VERBOSE
(
"Initialized WriteHandleKey: "
<<
m_outputKey
);
33
34
return
StatusCode::SUCCESS;
35
}
36
37
StatusCode
InDetSDOOverlay::execute
(
const
EventContext& ctx)
const
38
{
39
ATH_MSG_DEBUG
(
"execute() begin"
);
40
41
// Reading the input containers
42
ATH_MSG_VERBOSE
(
"Retrieving input containers"
);
43
44
const
InDetSimDataCollection
*bkgContainerPtr =
nullptr
;
45
if
(!
m_bkgInputKey
.key().empty()) {
46
SG::ReadHandle<InDetSimDataCollection>
bkgContainer(
m_bkgInputKey
, ctx);
47
if
(!bkgContainer.
isValid
()) {
48
ATH_MSG_ERROR
(
"Could not get background InDetSimDataCollection container "
<< bkgContainer.
name
() <<
" from store "
<< bkgContainer.
store
());
49
return
StatusCode::FAILURE;
50
}
51
bkgContainerPtr = bkgContainer.
cptr
();
52
53
ATH_MSG_DEBUG
(
"Found background InDetSimDataCollection container "
<< bkgContainer.
name
() <<
" in store "
<< bkgContainer.
store
());
54
}
55
56
SG::ReadHandle<InDetSimDataCollection>
signalContainer(
m_signalInputKey
, ctx);
57
if
(!signalContainer.
isValid
()) {
58
ATH_MSG_ERROR
(
"Could not get signal InDetSimDataCollection container "
<< signalContainer.
name
() <<
" from store "
<< signalContainer.
store
());
59
return
StatusCode::FAILURE;
60
}
61
ATH_MSG_DEBUG
(
"Found signal InDetSimDataCollection container "
<< signalContainer.
name
() <<
" in store "
<< signalContainer.
store
());
62
63
// Creating output RDO container
64
SG::WriteHandle<InDetSimDataCollection>
outputContainer(
m_outputKey
, ctx);
65
ATH_CHECK
(outputContainer.
record
(std::make_unique<InDetSimDataCollection>()));
66
if
(!outputContainer.
isValid
()) {
67
ATH_MSG_ERROR
(
"Could not record output InDetSimDataCollection container "
<< outputContainer.
name
() <<
" to store "
<< outputContainer.
store
());
68
return
StatusCode::FAILURE;
69
}
70
ATH_MSG_DEBUG
(
"Recorded output InDetSimDataCollection container "
<< outputContainer.
name
() <<
" in store "
<< outputContainer.
store
());
71
72
// Copy over signal SDO
73
ATH_MSG_VERBOSE
(
"Inserting signal SDO, size = "
<< signalContainer->size());
74
outputContainer->insert(signalContainer->begin(), signalContainer->end());
75
76
// Merge with background
77
if
(!
m_bkgInputKey
.key().empty()) {
78
ATH_MSG_VERBOSE
(
"Inserting background SDO, size = "
<< bkgContainerPtr->size());
79
80
for
(
const
auto
&entry : *bkgContainerPtr) {
81
auto
it = outputContainer->find(entry.first);
82
if
(it != outputContainer->end()) {
83
// merge necessary
84
const
InDetSimData
&outSimData = it->second;
85
std::vector<InDetSimData::Deposit> depositsVector(outSimData.
getdeposits
());
86
depositsVector.insert(depositsVector.end(), entry.second.getdeposits().begin(), entry.second.getdeposits().end());
87
88
it->second =
InDetSimData
(depositsVector);
89
}
else
{
90
outputContainer->insert(entry);
91
}
92
}
93
}
94
95
ATH_MSG_VERBOSE
(
"Output SDO size "
<< outputContainer->size());
96
97
ATH_MSG_DEBUG
(
"execute() end"
);
98
return
StatusCode::SUCCESS;
99
}
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
InDetSDOOverlay.h
InDetSimData.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
InDetSDOOverlay::m_signalInputKey
SG::ReadHandleKey< InDetSimDataCollection > m_signalInputKey
Definition
InDetSDOOverlay.h:21
InDetSDOOverlay::initialize
virtual StatusCode initialize() override
Definition
InDetSDOOverlay.cxx:12
InDetSDOOverlay::m_outputKey
SG::WriteHandleKey< InDetSimDataCollection > m_outputKey
Definition
InDetSDOOverlay.h:22
InDetSDOOverlay::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
InDetSDOOverlay.cxx:37
InDetSDOOverlay::m_bkgInputKey
SG::ReadHandleKey< InDetSimDataCollection > m_bkgInputKey
Definition
InDetSDOOverlay.h:20
InDetSDOOverlay::InDetSDOOverlay
InDetSDOOverlay(const std::string &name, ISvcLocator *pSvcLocator)
Definition
InDetSDOOverlay.cxx:9
InDetSimDataCollection
Definition
InDetSimDataCollection.h:25
InDetSimData
Definition
InDetSimData.h:42
InDetSimData::getdeposits
const std::vector< Deposit > & getdeposits() const
Definition
InDetSimData.h:74
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?
Generated on
for ATLAS Offline Software by
1.17.0