ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentMarkerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4#include "SegmentMarkerAlg.h"
5
10
11
12namespace MuonR4{
14 ATH_CHECK(m_muonKey.initialize());
15 ATH_CHECK(m_readMarkKey.initialize());
16 ATH_CHECK(m_segKey.initialize());
18 ATH_CHECK(m_writeMarkKey.initialize());
19 return StatusCode::SUCCESS;
20 }
21 StatusCode SegmentMarkerAlg::execute(const EventContext& ctx) const{
22 const xAOD::MuonContainer* muons{nullptr};
23 ATH_CHECK(SG::get(muons, m_muonKey, ctx));
24
26 using namespace DerivationFramework;
27 auto decorHandle{makeHandle(ctx, m_writeMarkKey, false)};
28 ATH_CHECK(decorHandle.isPresent());
29
30 for (const xAOD::Muon* muon : *muons) {
31 if (!selHandle(*muon)) {
32 continue;
33 }
34 for (unsigned int s =0; s < muon->nMuonSegments(); ++s){
35 const xAOD::MuonSegment* seg = muon->muonSegment(s);
36 if (seg->container() != decorHandle.cptr()) {
37 ATH_MSG_FATAL("The segment "<<seg<<" does not live in container "<<m_segKey.fullKey());
38 return StatusCode::FAILURE;
39 }
40 decorHandle(*seg)= selHandle(*muon);
41 }
42 }
43 return StatusCode::SUCCESS;
44 }
45
46}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_writeMarkKey
Key to the decoration.
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_readMarkKey
Key to the decoration to fetch the marked muons.
virtual StatusCode initialize() override final
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
Key to the primary muon container to select the muon from.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segKey
Key to the segment container to fetch the marked segments.
virtual StatusCode execute(const EventContext &ctx) const override final
const SG::AuxVectorData * container() const
Return the container holding this element.
Handle class for reading a decoration on an object.
THE reconstruction tool.
SG::WriteDecorHandle< ContType, dType > makeHandle(const EventContext &ctx, const SG::WriteDecorHandleKey< ContType > &key, const dType &defValue=dType{})
This header ties the generic definitions in this package.
std::string decorKeyFromKey(const std::string &key, const std::string &deflt)
Extract the decoration part of key.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
MuonSegment_v1 MuonSegment
Reference the current persistent version: