ATLAS Offline Software
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 
10 namespace 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 
42 HGTD_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
53  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey);
55  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey);
57  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
58 
59  return StatusCode::SUCCESS;
60 }
61 
62 StatusCode 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 }
IDC_OverlayHelpers.h
algorithm
std::string algorithm
Definition: hcg.cxx:82
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
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
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
HGTD_RDO
Definition: HGTD_RDO.h:53
HGTD_RDO_Container
Definition: HGTD_RDO_Container.h:18
HGTD_Overlay::m_signalInputKey
SG::ReadHandleKey< HGTD_RDO_Container > m_signalInputKey
Definition: HGTD_Overlay.h:23
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
HGTD_Overlay::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: HGTD_Overlay.cxx:62
HGTD_RDO_Collection
Definition: HGTD_RDO_Collection.h:19
Overlay::mergeChannelData
void mergeChannelData(HGTD_RDO &, const HGTD_RDO &, const IDC_OverlayBase *algorithm)
Definition: HGTD_Overlay.cxx:14
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Overlay::copyCollection
std::unique_ptr< HGTD_RDO_Collection > copyCollection(const IdentifierHash &hashId, const HGTD_RDO_Collection *collection)
Definition: HGTD_Overlay.cxx:24
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
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:379
IDC_OverlayBase::overlayContainer
StatusCode overlayContainer(const IDC_Container *bkgContainer, const IDC_Container *signalContainer, IDC_Container *outputContainer) const
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HGTD_Overlay::HGTD_Overlay
HGTD_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HGTD_Overlay.cxx:42
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
HGTD_Overlay::m_outputKey
SG::WriteHandleKey< HGTD_RDO_Container > m_outputKey
Definition: HGTD_Overlay.h:24
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
postInclude.outputCollection
outputCollection
Definition: postInclude.SortInput.py:27
HGTD_Overlay::initialize
virtual StatusCode initialize() override final
Definition: HGTD_Overlay.cxx:47
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HGTD_Overlay::m_bkgInputKey
SG::ReadHandleKey< HGTD_RDO_Container > m_bkgInputKey
Definition: HGTD_Overlay.h:22
SG::WriteHandle< HGTD_RDO_Container >
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DEBUG
#define DEBUG
Definition: page_access.h:11
Overlay
Helpers for overlaying Identifiable Containers.
Definition: HGTD_Overlay.cxx:11
HGTD_Overlay.h
IDC_OverlayBase
Definition: IDC_OverlayBase.h:25
HGTD_RDO_Collection::identify
const Identifier & identify() const
Definition: HGTD_RDO_Collection.h:32
IdentifierHash
Definition: IdentifierHash.h:38
Overlay::debugPrint
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.