ATLAS Offline Software
Loading...
Searching...
No Matches
MdtOverlay.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Andrei Gaponenko <agaponenko@lbl.gov>, 2006, 2007
6// Ketevi A. Assamagan <ketevi@bnl.gov>, March 2008
7// Piyali Banerjee <Piyali.Banerjee@cern.ch>, March 2011
8
10
13
15
16
17//================================================================
18namespace Overlay
19{
25 template<>
26 void mergeChannelData(MdtDigit& signalDigit,
27 const MdtDigit& bkgDigit,
29 {
30 // We want to use the integration window provided by MdtOverlay, thus the constraint
31 const MdtOverlay *parent = dynamic_cast<const MdtOverlay *>(algorithm);
32 if (!parent) {
33 throw std::runtime_error("mergeChannelData<MdtDigit>() called by a wrong parent algorithm? Must be MdtOverlay.");
34 }
35
36 int sig_tdc = signalDigit.tdc();
37 int bkg_tdc = bkgDigit.tdc();
38
41 if (std::abs(sig_tdc - bkg_tdc) > parent->adcIntegrationWindow() && sig_tdc < bkg_tdc ) {
42 // do nothing - keep baseDigit.
43 }
46 else if (std::abs(sig_tdc - bkg_tdc) > parent->adcIntegrationWindow() && sig_tdc > bkg_tdc ) {
47 // Use the background digit as the final answer
48 signalDigit = bkgDigit;
49 }
54 else if (std::abs(sig_tdc - bkg_tdc) < parent->adcIntegrationWindow() ) {
55 int tdc = std::min( signalDigit.tdc(), bkgDigit.tdc() );
56 int adc = signalDigit.adc() + bkgDigit.adc();
57 signalDigit = MdtDigit(signalDigit.identify(), tdc, adc, false);
58 }
59 }
60} // namespace Overlay
61
62
63//================================================================
64MdtOverlay::MdtOverlay(const std::string &name, ISvcLocator *pSvcLocator)
65 : IDC_MuonOverlayBase(name, pSvcLocator)
66{
67}
68
69//================================================================
71{
72 ATH_MSG_DEBUG("Initializing...");
73
74 // Check and initialize keys
75 ATH_CHECK( m_bkgInputKey.initialize(!m_bkgInputKey.key().empty()) );
76 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey );
77 ATH_CHECK(m_signalInputKey.initialize());
78 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey );
79 ATH_CHECK(m_outputKey.initialize());
80 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey );
81
82 return StatusCode::SUCCESS;
83}
84
85//================================================================
86StatusCode MdtOverlay::execute(const EventContext& ctx) const {
87 ATH_MSG_DEBUG("execute() begin");
88
89
90 const MdtDigitContainer *bkgContainerPtr = nullptr;
91 if (!m_bkgInputKey.empty()) {
93 if (!bkgContainer.isValid()) {
94 ATH_MSG_ERROR("Could not get background MDT container " << bkgContainer.name() << " from store " << bkgContainer.store());
95 return StatusCode::FAILURE;
96 }
97 bkgContainerPtr = bkgContainer.cptr();
98
99 ATH_MSG_DEBUG("Found background MdtDigitContainer called " << bkgContainer.name() << " in store " << bkgContainer.store());
100 ATH_MSG_DEBUG("MDT Background = " << Overlay::debugPrint(bkgContainer.cptr()));
101 ATH_MSG_VERBOSE("MDT background has digit_size " << bkgContainer->digit_size());
102 }
103
105 if(!signalContainer.isValid() ) {
106 ATH_MSG_ERROR("Could not get signal MDT container " << signalContainer.name() << " from store " << signalContainer.store());
107 return StatusCode::FAILURE;
108 }
109 ATH_MSG_DEBUG("Found signal MdtDigitContainer called " << signalContainer.name() << " in store " << signalContainer.store());
110 ATH_MSG_DEBUG("MDT Signal = " << Overlay::debugPrint(signalContainer.cptr()));
111 ATH_MSG_VERBOSE("MDT signal has digit_size " << signalContainer->digit_size());
112
114 ATH_CHECK(outputContainer.record(std::make_unique<MdtDigitContainer>(signalContainer->size())));
115 if (!outputContainer.isValid()) {
116 ATH_MSG_ERROR("Could not record output MdtDigitContainer called " << outputContainer.name() << " to store " << outputContainer.store());
117 return StatusCode::FAILURE;
118 }
119 ATH_MSG_DEBUG("Recorded output MdtDigitContainer called " << outputContainer.name() << " in store " << outputContainer.store());
120
121 // Do the actual overlay
122 ATH_CHECK(overlayContainer(bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr()));
123 ATH_MSG_DEBUG("MDT Result = " << Overlay::debugPrint(outputContainer.cptr()));
124
125
126 ATH_MSG_DEBUG("execute() end");
127
128 return StatusCode::SUCCESS;
129}
#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)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
StatusCode overlayContainer(const IDC_Container *bkgContainer, const IDC_Container *signalContainer, IDC_Container *outputContainer) const
IDC_MuonOverlayBase(const std::string &name, ISvcLocator *pSvcLocator)
Use IdentifiableContainer with MdtDigitCollection.
int16_t adc() const
Definition MdtDigit.h:28
int16_t tdc() const
Definition MdtDigit.h:26
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadHandleKey< MdtDigitContainer > m_bkgInputKey
Definition MdtOverlay.h:32
virtual StatusCode initialize() override final
SG::ReadHandleKey< MdtDigitContainer > m_signalInputKey
Definition MdtOverlay.h:33
MdtOverlay(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< MdtDigitContainer > m_outputKey
Definition MdtOverlay.h:34
Identifier identify() const
Definition MuonDigit.h:30
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.
const_pointer_type cptr() const
Dereference the pointer.
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.