ATLAS Offline Software
Loading...
Searching...
No Matches
PixelOverlay.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
11
13
14namespace Overlay
15{
16
19 return digit1->identify() < digit2->identify();
20 }
22
23// Specialize mergeChannelData() for the Pixel
24template <>
25void mergeChannelData(PixelRDORawData & /* baseDatum */,
26 const PixelRDORawData & /* additionalDatum */,
28 algorithm->msg(MSG::DEBUG) << "Overlay::mergeChannelData<PixelRDORawData>(): "
29 << "Merging of data on the same channel is not "
30 "explicitly implemented for PixelRDORawData"
31 << endmsg;
32}
33
34// Specialize copyCollection() for the Pixel
35template <>
36std::unique_ptr<PixelRDO_Collection> copyCollection(
37 const IdentifierHash &hashId, const PixelRDO_Collection *collection,
38 DataPool<Pixel1RawData> &dataItems) {
39 auto outputCollection = std::make_unique<PixelRDO_Collection>(hashId);
40 outputCollection->setIdentifier(collection->identify());
41 outputCollection->clear(SG::VIEW_ELEMENTS);
42 outputCollection->reserve(collection->size());
43 for (const PixelRDORawData *existingDatum : *collection) {
44 Pixel1RawData *datumCopy = dataItems.nextElementPtr();
45 (*datumCopy) =
46 Pixel1RawData(existingDatum->identify(), existingDatum->getWord());
47 outputCollection->push_back(datumCopy);
48 }
49 return outputCollection;
50}
51
52// Specizlize sortCollection() for the Pixel
53template <>
55 if (!std::is_sorted(collection->begin(), collection->end(), PixelRDOSorterObject)) {
56 std::stable_sort(collection->begin(), collection->end(), PixelRDOSorterObject);
57 }
58}
59
60} // namespace Overlay
61
62
63PixelOverlay::PixelOverlay(const std::string &name, ISvcLocator *pSvcLocator)
64 : IDC_OverlayBase(name, pSvcLocator)
65{
66}
67
69{
70 ATH_MSG_DEBUG("Initializing...");
71
72 // Check and initialize keys
73 ATH_CHECK( m_bkgInputKey.initialize(!m_bkgInputKey.key().empty()) );
74 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey);
75 ATH_CHECK( m_signalInputKey.initialize() );
76 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey);
77 ATH_CHECK( m_outputKey.initialize() );
78 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey);
79
80 return StatusCode::SUCCESS;
81}
82
83StatusCode PixelOverlay::execute(const EventContext& ctx) const
84{
85 ATH_MSG_DEBUG("execute() begin");
86
87 // Reading the input RDOs
88 ATH_MSG_VERBOSE("Retrieving input RDO containers");
89
90 const PixelRDO_Container *bkgContainerPtr = nullptr;
91 if (!m_bkgInputKey.empty()) {
93 if (!bkgContainer.isValid()) {
94 ATH_MSG_ERROR("Could not get background Pixel RDO container " << bkgContainer.name() << " from store " << bkgContainer.store());
95 return StatusCode::FAILURE;
96 }
97 bkgContainerPtr = bkgContainer.cptr();
98
99 ATH_MSG_DEBUG("Found background Pixel RDO container " << bkgContainer.name() << " in store " << bkgContainer.store());
100 ATH_MSG_DEBUG("Pixel Background = " << Overlay::debugPrint(bkgContainer.cptr()));
101 }
102
104 if (!signalContainer.isValid()) {
105 ATH_MSG_ERROR("Could not get signal Pixel RDO container " << signalContainer.name() << " from store " << signalContainer.store());
106 return StatusCode::FAILURE;
107 }
108 ATH_MSG_DEBUG("Found signal Pixel RDO container " << signalContainer.name() << " in store " << signalContainer.store());
109 ATH_MSG_DEBUG("Pixel Signal = " << Overlay::debugPrint(signalContainer.cptr()));
110
111 // Creating output RDO container
113 ATH_CHECK(outputContainer.record(std::make_unique<PixelRDO_Container>(signalContainer->size())));
114 if (!outputContainer.isValid()) {
115 ATH_MSG_ERROR("Could not record output Pixel RDO container " << outputContainer.name() << " to store " << outputContainer.store());
116 return StatusCode::FAILURE;
117 }
118 ATH_MSG_DEBUG("Recorded output Pixel RDO container " << outputContainer.name() << " in store " << outputContainer.store());
119 // The DataPool, this is what will actually own the elements
120 // we create during this algorithm. The containers are views.
121 DataPool<Pixel1RawData> dataItemsPool(ctx);
122 // It resizes but lets reserve already quite a few
123 dataItemsPool.prepareToAdd(100000);
124 ATH_CHECK(overlayContainerWithSorting(bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr(), dataItemsPool));
125 ATH_MSG_DEBUG("Pixel Result = " << Overlay::debugPrint(outputContainer.ptr()));
126
127 ATH_MSG_DEBUG("execute() end");
128 return StatusCode::SUCCESS;
129}
#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)
InDetRawDataCollection< PixelRDORawData > PixelRDO_Collection
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
void prepareToAdd(unsigned int size)
Prepare to add cached elements.
const_iterator end() const noexcept
const_iterator begin() const noexcept
size_type size() const noexcept
StatusCode overlayContainerWithSorting(const IDC_Container *bkgContainer, const IDC_Container *signalContainer, IDC_Container *outputContainer, DataPool< Type > &dataItems) const
IDC_OverlayBase(const std::string &name, ISvcLocator *pSvcLocator)
This is a "hash" representation of an Identifier.
virtual Identifier identify() const override final
virtual Identifier identify() const override final
virtual StatusCode initialize() override final
SG::ReadHandleKey< PixelRDO_Container > m_bkgInputKey
SG::ReadHandleKey< PixelRDO_Container > m_signalInputKey
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< PixelRDO_Container > m_outputKey
PixelOverlay(const std::string &name, ISvcLocator *pSvcLocator)
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)
void sortCollection(PixelRDO_Collection *collection)
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.
struct Overlay::PixelRDOSorter PixelRDOSorterObject
std::unique_ptr< HGTD_RDO_Collection > copyCollection(const IdentifierHash &hashId, const HGTD_RDO_Collection *collection)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
bool operator()(PixelRDORawData *digit1, PixelRDORawData *digit2)