ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_Overlay.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "HGTD_Overlay.h"
6
8
9
10namespace Overlay
11{
12 // Specialize mergeChannelData() for the HGTD
13 template <>
14 void mergeChannelData(HGTD_RDO &/* baseDatum */,
15 const HGTD_RDO &/* additionalDatum */,
17 {
18 algorithm->msg(MSG::DEBUG) << "Overlay::mergeChannelData<HGTD_RDORawData>(): "
19 << "Merging of data on the same channel is not explicitly implemented for HGTD_RDORawData" << endmsg;
20 }
21
22 // Specialize copyCollection() for the HGTD
23 template<>
24 std::unique_ptr<HGTD_RDO_Collection> copyCollection(const IdentifierHash &hashId,
25 const HGTD_RDO_Collection *collection)
26 {
27 auto outputCollection = std::make_unique<HGTD_RDO_Collection>(hashId);
28 outputCollection->setIdentifier(collection->identify());
29
30 for (const HGTD_RDO *existingDatum : *collection) {
31 // Owned by the collection
32 auto *datumCopy = new HGTD_RDO(existingDatum->identify(), existingDatum->getTOA(), existingDatum->getTOT(),
33 existingDatum->getBCID(), existingDatum->getL1ID(), existingDatum->getL1A());
34 outputCollection->push_back(datumCopy);
35 }
36
37 return outputCollection;
38 }
39} // namespace Overlay
40
41
42HGTD_Overlay::HGTD_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
43 : IDC_OverlayBase(name, pSvcLocator)
44{
45}
46
48{
49 ATH_MSG_DEBUG("Initializing...");
50
51 // Check and initialize keys
52 ATH_CHECK( m_bkgInputKey.initialize(!m_bkgInputKey.key().empty()) );
53 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey);
54 ATH_CHECK( m_signalInputKey.initialize() );
55 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey);
56 ATH_CHECK( m_outputKey.initialize() );
57 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
58
59 return StatusCode::SUCCESS;
60}
61
62StatusCode HGTD_Overlay::execute(const EventContext& ctx) const
63{
64 ATH_MSG_DEBUG("execute() begin");
65
66 // Reading the input RDOs
67 ATH_MSG_VERBOSE("Retrieving input RDO containers");
68
69 const HGTD_RDO_Container *bkgContainerPtr = nullptr;
70 if (!m_bkgInputKey.empty()) {
72 if (!bkgContainer.isValid()) {
73 ATH_MSG_ERROR("Could not get background HGTD RDO container " << bkgContainer.name() << " from store " << bkgContainer.store());
74 return StatusCode::FAILURE;
75 }
76 bkgContainerPtr = bkgContainer.cptr();
77
78 ATH_MSG_DEBUG("Found background HGTD RDO container " << bkgContainer.name() << " in store " << bkgContainer.store());
79 ATH_MSG_DEBUG("HGTD Background = " << Overlay::debugPrint(bkgContainer.cptr()));
80 }
81
83 if (!signalContainer.isValid()) {
84 ATH_MSG_ERROR("Could not get signal HGTD RDO container " << signalContainer.name() << " from store " << signalContainer.store());
85 return StatusCode::FAILURE;
86 }
87 ATH_MSG_DEBUG("Found signal HGTD RDO container " << signalContainer.name() << " in store " << signalContainer.store());
88 ATH_MSG_DEBUG("HGTD Signal = " << Overlay::debugPrint(signalContainer.cptr()));
89
90 // Creating output RDO container
92 ATH_CHECK(outputContainer.record(std::make_unique<HGTD_RDO_Container>(signalContainer->size())));
93 if (!outputContainer.isValid()) {
94 ATH_MSG_ERROR("Could not record output HGTD RDO container " << outputContainer.name() << " to store " << outputContainer.store());
95 return StatusCode::FAILURE;
96 }
97 ATH_MSG_DEBUG("Recorded output HGTD RDO container " << outputContainer.name() << " in store " << outputContainer.store());
98
99 ATH_CHECK(overlayContainer(bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr()));
100 ATH_MSG_DEBUG("HGTD Result = " << Overlay::debugPrint(outputContainer.ptr()));
101
102 ATH_MSG_DEBUG("execute() end");
103 return StatusCode::SUCCESS;
104}
#define endmsg
#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)
HGTD_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< HGTD_RDO_Container > m_bkgInputKey
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadHandleKey< HGTD_RDO_Container > m_signalInputKey
virtual StatusCode initialize() override final
SG::WriteHandleKey< HGTD_RDO_Container > m_outputKey
const Identifier & identify() const
IDC_OverlayBase(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode overlayContainer(const IDC_Container *bkgContainer, const IDC_Container *signalContainer, IDC_Container *outputContainer) const
This is a "hash" representation of an Identifier.
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?
pointer_type ptr()
Dereference the pointer.
std::string algorithm
Definition hcg.cxx:85
Helpers for overlaying Identifiable Containers.
void mergeChannelData(HGTD_RDO &, const HGTD_RDO &, const IDC_OverlayBase *algorithm)
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.
std::unique_ptr< HGTD_RDO_Collection > copyCollection(const IdentifierHash &hashId, const HGTD_RDO_Collection *collection)