ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
8
9InDetSDOOverlay::InDetSDOOverlay(const std::string &name, ISvcLocator *pSvcLocator) :
10 AthReentrantAlgorithm(name, pSvcLocator) { }
11
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
37StatusCode 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()) {
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
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< InDetSimDataCollection > m_signalInputKey
virtual StatusCode initialize() override
SG::WriteHandleKey< InDetSimDataCollection > m_outputKey
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< InDetSimDataCollection > m_bkgInputKey
InDetSDOOverlay(const std::string &name, ISvcLocator *pSvcLocator)
const std::vector< Deposit > & getdeposits() const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?