ATLAS Offline Software
Loading...
Searching...
No Matches
MM_Overlay.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
11
14
16
17
18//================================================================
19namespace Overlay
20{
26 template<>
27 void mergeChannelData(MmDigit& signalDigit,
28 const MmDigit& bkgDigit,
30 {
31 // We want to use the integration window provided by MmOverlay, thus the constraint
32 const MM_Overlay *parent = dynamic_cast<const MM_Overlay *>(algorithm);
33 if (!parent) {
34 throw std::runtime_error("mergeChannelData<MmDigit>() called by a wrong parent algorithm? Must be MM_Overlay.");
35 }
36 float sig_time = signalDigit.stripResponseTime();
37 float bkg_time = bkgDigit.stripResponseTime();
38
39
40 // As of now, we need to decide how to overlay MM digits
41 // NEEDS TO BE ADDRESSED
42 // For this preliminary version of July 2019, use only the data from the 1st digit in vector.
44 if ( std::abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time < bkg_time ) {
45 // do nothing - keep baseDigit.
46 }
48 else if ( std::abs(sig_time - bkg_time) > parent->timeIntegrationWindow() && sig_time > bkg_time ) {
49 // Use the background digit as the final answer
50 signalDigit = bkgDigit;
51 }
54 else if ( std::abs(sig_time - bkg_time) < parent->timeIntegrationWindow() ) {
55 // Use the earliest time
56 // And use all the other values of the signal digit.
57 float time = std::min( sig_time, bkg_time );
58 float charge = signalDigit.stripResponseCharge() + bkgDigit.stripResponseCharge();
59 signalDigit = MmDigit(signalDigit.identify(), time, charge);
60 }
61 }
62} // namespace Overlay
63
64
65//================================================================
66MM_Overlay::MM_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
67 : IDC_MuonOverlayBase(name, pSvcLocator)
68{
69}
70
71//================================================================
73{
74 ATH_MSG_DEBUG("Initializing...");
75
76 // Check and initialize keys
77 ATH_CHECK( m_bkgInputKey.initialize(!m_bkgInputKey.key().empty()) );
78 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgInputKey );
79 ATH_CHECK(m_signalInputKey.initialize());
80 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalInputKey );
81 ATH_CHECK(m_outputKey.initialize());
82 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey );
83
84 return StatusCode::SUCCESS;
85}
86
87//================================================================
88StatusCode MM_Overlay::execute(const EventContext& ctx) const {
89 ATH_MSG_DEBUG("execute() begin");
90
91
92 const MmDigitContainer *bkgContainerPtr = nullptr;
93 if (!m_bkgInputKey.empty()) {
95 if (!bkgContainer.isValid()) {
96 ATH_MSG_ERROR("Could not get background MM container " << bkgContainer.name() << " from store " << bkgContainer.store());
97 return StatusCode::FAILURE;
98 }
99 bkgContainerPtr = bkgContainer.cptr();
100
101 ATH_MSG_DEBUG("Found background MMDigitContainer called " << bkgContainer.name() << " in store " << bkgContainer.store());
102 ATH_MSG_DEBUG("MM Background = " << Overlay::debugPrint(bkgContainer.cptr()));
103 ATH_MSG_VERBOSE("MM background has digit_size " << bkgContainer->digit_size());
104 }
105
107 if(!signalContainer.isValid() ) {
108 ATH_MSG_ERROR("Could not get signal MM container " << signalContainer.name() << " from store " << signalContainer.store());
109 return StatusCode::FAILURE;
110 }
111 ATH_MSG_DEBUG("Found signal MmDigitContainer called " << signalContainer.name() << " in store " << signalContainer.store());
112 ATH_MSG_DEBUG("MM Signal = " << Overlay::debugPrint(signalContainer.cptr()));
113 ATH_MSG_VERBOSE("MM signal has digit_size " << signalContainer->digit_size());
114
116 ATH_CHECK(outputContainer.record(std::make_unique<MmDigitContainer>(signalContainer->size())));
117 if (!outputContainer.isValid()) {
118 ATH_MSG_ERROR("Could not record output MmDigitContainer called " << outputContainer.name() << " to store " << outputContainer.store());
119 return StatusCode::FAILURE;
120 }
121 ATH_MSG_DEBUG("Recorded output MmDigitContainer called " << outputContainer.name() << " in store " << outputContainer.store());
122
123 // Do the actual overlay
124 ATH_CHECK(overlayContainer(bkgContainerPtr, signalContainer.cptr(), outputContainer.ptr()));
125 ATH_MSG_DEBUG("MM Result = " << Overlay::debugPrint(outputContainer.cptr()));
126
127 ATH_MSG_DEBUG("execute() end");
128
129 return StatusCode::SUCCESS;
130}
#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)
double charge(const T &p)
Definition AtlasPID.h:997
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)
virtual StatusCode execute(const EventContext &ctx) const override final
MM_Overlay(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< MmDigitContainer > m_signalInputKey
Definition MM_Overlay.h:34
SG::WriteHandleKey< MmDigitContainer > m_outputKey
Definition MM_Overlay.h:35
virtual StatusCode initialize() override final
SG::ReadHandleKey< MmDigitContainer > m_bkgInputKey
Definition MM_Overlay.h:33
Use IdentifiableContainer with MmDigitCollection.
float stripResponseCharge() const
Return the charge.
Definition MmDigit.h:45
float stripResponseTime() const
strip response info
Definition MmDigit.h:43
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.