ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonOverlay
STGC_Overlay
src
STGC_Overlay.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
// Alexandre Laurier <alexandre.laurier@cern.ch>, May 2019
9
10
#include <
STGC_Overlay/STGC_Overlay.h
>
11
12
#include <
StoreGate/ReadHandle.h
>
13
#include <
StoreGate/WriteHandle.h
>
14
15
#include <
IDC_OverlayBase/IDC_OverlayHelpers.h
>
16
17
18
//================================================================
19
namespace
Overlay
20
{
26
template
<>
27
void
mergeChannelData
(
sTgcDigit
& signalDigit,
28
const
sTgcDigit
& bkgDigit,
29
const
IDC_MuonOverlayBase
*
algorithm
)
30
{
31
// We want to use the integration window provided by sTgcOverlay, thus the constraint
32
const
STGC_Overlay
*parent =
dynamic_cast<
const
STGC_Overlay
*
>
(
algorithm
);
33
if
(!parent) {
34
throw
std::runtime_error(
"mergeChannelData<sTgcDigit>() called by a wrong parent algorithm? Must be STGC_Overlay."
);
35
}
36
37
float
sig_time = signalDigit.
time
();
38
float
bkg_time = bkgDigit.
time
();
39
41
if
( abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time < bkg_time ) {
42
// do nothing - keep baseDigit.
43
}
45
else
if
( abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time > bkg_time ) {
46
// Use the background digit as the final answer
47
signalDigit = bkgDigit;
48
}
51
else
if
( abs(sig_time - bkg_time) < parent->timeIntegrationWindow() ) {
52
// Use the earliest time
53
float
time = std::min( signalDigit.
time
(), bkgDigit.
time
() );
54
float
charge
= signalDigit.
charge
() + bkgDigit.
charge
();
55
//signalDigit = sTgcDigit(signalDigit.identify(), time, charge);
56
signalDigit =
sTgcDigit
(signalDigit.
identify
(), signalDigit.
bcTag
(), time,
charge
, signalDigit.
isDead
(), signalDigit.
isPileup
());
57
}
58
}
59
}
// namespace Overlay
60
61
62
//================================================================
63
STGC_Overlay::STGC_Overlay
(
const
std::string &name, ISvcLocator *pSvcLocator)
64
:
IDC_MuonOverlayBase
(name, pSvcLocator)
65
{
66
}
67
68
//================================================================
69
StatusCode
STGC_Overlay::initialize
()
70
{
71
ATH_MSG_DEBUG
(
"Initializing..."
);
72
73
// Check and initialize keys
74
ATH_CHECK
(
m_bkgInputKey
.initialize(!
m_bkgInputKey
.key().empty()) );
75
ATH_MSG_VERBOSE
(
"Initialized ReadHandleKey: "
<<
m_bkgInputKey
);
76
ATH_CHECK
(
m_signalInputKey
.initialize());
77
ATH_MSG_VERBOSE
(
"Initialized ReadHandleKey: "
<<
m_signalInputKey
);
78
ATH_CHECK
(
m_outputKey
.initialize());
79
ATH_MSG_VERBOSE
(
"Initialized WriteHandleKey: "
<<
m_outputKey
);
80
81
return
StatusCode::SUCCESS;
82
}
83
84
//================================================================
85
StatusCode
STGC_Overlay::execute
(
const
EventContext& ctx)
const
{
86
ATH_MSG_DEBUG
(
"execute() begin"
);
87
88
89
const
sTgcDigitContainer
*bkgContainerPtr =
nullptr
;
90
if
(!
m_bkgInputKey
.empty()) {
91
SG::ReadHandle<sTgcDigitContainer>
bkgContainer (
m_bkgInputKey
, ctx);
92
if
(!bkgContainer.
isValid
()) {
93
ATH_MSG_ERROR
(
"Could not get background sTGC container "
<< bkgContainer.
name
() <<
" from store "
<< bkgContainer.
store
());
94
return
StatusCode::FAILURE;
95
}
96
bkgContainerPtr = bkgContainer.
cptr
();
97
98
ATH_MSG_DEBUG
(
"Found background sTGCDigitContainer called "
<< bkgContainer.
name
() <<
" in store "
<< bkgContainer.
store
());
99
ATH_MSG_DEBUG
(
"sTGC Background = "
<<
Overlay::debugPrint
(bkgContainer.
cptr
()));
100
ATH_MSG_VERBOSE
(
"sTGC background has digit_size "
<< bkgContainer->digit_size());
101
}
102
103
SG::ReadHandle<sTgcDigitContainer>
signalContainer(
m_signalInputKey
, ctx);
104
if
(!signalContainer.
isValid
() ) {
105
ATH_MSG_ERROR
(
"Could not get signal sTgc container "
<< signalContainer.
name
() <<
" from store "
<< signalContainer.
store
());
106
return
StatusCode::FAILURE;
107
}
108
ATH_MSG_DEBUG
(
"Found signal sTgcDigitContainer called "
<< signalContainer.
name
() <<
" in store "
<< signalContainer.
store
());
109
ATH_MSG_DEBUG
(
"sTGC Signal = "
<<
Overlay::debugPrint
(signalContainer.
cptr
()));
110
ATH_MSG_VERBOSE
(
"sTGC signal has digit_size "
<< signalContainer->digit_size());
111
112
SG::WriteHandle<sTgcDigitContainer>
outputContainer(
m_outputKey
, ctx);
113
ATH_CHECK
(outputContainer.
record
(std::make_unique<sTgcDigitContainer>(signalContainer->size())));
114
if
(!outputContainer.
isValid
()) {
115
ATH_MSG_ERROR
(
"Could not record output sTgcDigitContainer called "
<< outputContainer.
name
() <<
" to store "
<< outputContainer.
store
());
116
return
StatusCode::FAILURE;
117
}
118
ATH_MSG_DEBUG
(
"Recorded output sTgcDigitContainer called "
<< outputContainer.
name
() <<
" in store "
<< outputContainer.
store
());
119
120
// Do the actual overlay
121
ATH_CHECK
(
overlayContainer
(bkgContainerPtr, signalContainer.
cptr
(), outputContainer.
ptr
()));
122
ATH_MSG_DEBUG
(
"sTGC Result = "
<<
Overlay::debugPrint
(outputContainer.
cptr
()));
123
124
ATH_MSG_DEBUG
(
"execute() end"
);
125
126
return
StatusCode::SUCCESS;
127
}
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
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
IDC_OverlayHelpers.h
STGC_Overlay.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
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.
STGC_Overlay
Definition
STGC_Overlay.h:23
STGC_Overlay::m_signalInputKey
SG::ReadHandleKey< sTgcDigitContainer > m_signalInputKey
Definition
STGC_Overlay.h:34
STGC_Overlay::STGC_Overlay
STGC_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
Definition
STGC_Overlay.cxx:63
STGC_Overlay::initialize
virtual StatusCode initialize() override final
Definition
STGC_Overlay.cxx:69
STGC_Overlay::m_outputKey
SG::WriteHandleKey< sTgcDigitContainer > m_outputKey
Definition
STGC_Overlay.h:35
STGC_Overlay::m_bkgInputKey
SG::ReadHandleKey< sTgcDigitContainer > m_bkgInputKey
Definition
STGC_Overlay.h:33
STGC_Overlay::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
STGC_Overlay.cxx:85
sTgcDigitContainer
Use IdentifiableContainer with sTgcDigitCollection.
Definition
sTgcDigitContainer.h:50
sTgcDigit
Definition
sTgcDigit.h:20
sTgcDigit::time
float time() const
Definition
sTgcDigit.cxx:61
sTgcDigit::bcTag
uint16_t bcTag() const
Definition
sTgcDigit.cxx:34
sTgcDigit::charge
float charge() const
Definition
sTgcDigit.cxx:46
sTgcDigit::isDead
bool isDead() const
Definition
sTgcDigit.cxx:38
sTgcDigit::isPileup
bool isPileup() const
Definition
sTgcDigit.cxx:42
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