ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonOverlay
MdtOverlay
src
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
9
#include <
MdtOverlay/MdtOverlay.h
>
10
11
#include <
StoreGate/ReadHandle.h
>
12
#include <
StoreGate/WriteHandle.h
>
13
14
#include <
IDC_OverlayBase/IDC_OverlayHelpers.h
>
15
16
17
//================================================================
18
namespace
Overlay
19
{
25
template
<>
26
void
mergeChannelData
(
MdtDigit
& signalDigit,
27
const
MdtDigit
& bkgDigit,
28
const
IDC_MuonOverlayBase
*
algorithm
)
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
//================================================================
64
MdtOverlay::MdtOverlay
(
const
std::string &name, ISvcLocator *pSvcLocator)
65
:
IDC_MuonOverlayBase
(name, pSvcLocator)
66
{
67
}
68
69
//================================================================
70
StatusCode
MdtOverlay::initialize
()
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
//================================================================
86
StatusCode
MdtOverlay::execute
(
const
EventContext& ctx)
const
{
87
ATH_MSG_DEBUG
(
"execute() begin"
);
88
89
90
const
MdtDigitContainer
*bkgContainerPtr =
nullptr
;
91
if
(!
m_bkgInputKey
.empty()) {
92
SG::ReadHandle<MdtDigitContainer>
bkgContainer (
m_bkgInputKey
, ctx);
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
104
SG::ReadHandle<MdtDigitContainer>
signalContainer(
m_signalInputKey
, ctx);
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
113
SG::WriteHandle<MdtDigitContainer>
outputContainer(
m_outputKey
, ctx);
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IDC_OverlayHelpers.h
MdtOverlay.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
IDC_MuonOverlayBase
Definition
IDC_MuonOverlayBase.h:27
IDC_MuonOverlayBase::overlayContainer
StatusCode overlayContainer(const IDC_Container *bkgContainer, const IDC_Container *signalContainer, IDC_Container *outputContainer) const
Definition
IDC_MuonOverlayBase.h:34
IDC_MuonOverlayBase::IDC_MuonOverlayBase
IDC_MuonOverlayBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
IDC_MuonOverlayBase.h:29
MdtDigitContainer
Use IdentifiableContainer with MdtDigitCollection.
Definition
MdtDigitContainer.h:50
MdtDigit
Definition
MdtDigit.h:19
MdtDigit::adc
int16_t adc() const
Definition
MdtDigit.h:28
MdtDigit::tdc
int16_t tdc() const
Definition
MdtDigit.h:26
MdtOverlay
Definition
MdtOverlay.h:22
MdtOverlay::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
MdtOverlay.cxx:86
MdtOverlay::m_bkgInputKey
SG::ReadHandleKey< MdtDigitContainer > m_bkgInputKey
Definition
MdtOverlay.h:32
MdtOverlay::initialize
virtual StatusCode initialize() override final
Definition
MdtOverlay.cxx:70
MdtOverlay::m_signalInputKey
SG::ReadHandleKey< MdtDigitContainer > m_signalInputKey
Definition
MdtOverlay.h:33
MdtOverlay::MdtOverlay
MdtOverlay(const std::string &name, ISvcLocator *pSvcLocator)
Definition
MdtOverlay.cxx:64
MdtOverlay::m_outputKey
SG::WriteHandleKey< MdtDigitContainer > m_outputKey
Definition
MdtOverlay.h:34
MuonDigit::identify
Identifier identify() const
Definition
MuonDigit.h:30
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition
StoreGate/src/VarHandleBase.cxx:382
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::cptr
const_pointer_type cptr() const
Dereference the pointer.
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
algorithm
std::string algorithm
Definition
hcg.cxx:87
Overlay
Helpers for overlaying Identifiable Containers.
Definition
HGTD_Overlay.cxx:11
Overlay::mergeChannelData
void mergeChannelData(HGTD_RDO &, const HGTD_RDO &, const IDC_OverlayBase *algorithm)
Definition
HGTD_Overlay.cxx:14
Overlay::debugPrint
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.
Generated on
for ATLAS Offline Software by
1.17.0