ATLAS Offline Software
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 
7 #include "StoreGate/ReadHandle.h"
10 
11 
12 namespace MuonR4{
15  ATH_CHECK(m_readMarkKey.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 }
MuonR4::SegmentMarkerAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SegmentMarkerAlg.cxx:21
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonR4::SegmentMarkerAlg::m_writeMarkKey
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_writeMarkKey
Key to the decoration.
Definition: SegmentMarkerAlg.h:34
Utils.h
SegmentMarkerAlg.h
ViewHelper::makeHandle
SG::ReadHandle< T > makeHandle(const SG::View *view, const SG::ReadHandleKey< T > &rhKey, const EventContext &context)
navigate from the TrigComposite to nearest view and fetch object from it
Definition: ViewHelper.h:265
MuonR4::SegmentMarkerAlg::m_segKey
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segKey
Key to the segment container to fetch the marked segments.
Definition: SegmentMarkerAlg.h:32
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
MuonR4::SegmentMarkerAlg::initialize
virtual StatusCode initialize() override final
Definition: SegmentMarkerAlg.cxx:13
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MuonR4::SegmentMarkerAlg::m_readMarkKey
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_readMarkKey
Key to the decoration to fetch the marked muons.
Definition: SegmentMarkerAlg.h:30
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::decorKeyFromKey
std::string decorKeyFromKey(const std::string &key, const std::string &deflt)
Extract the decoration part of key.
Definition: DecorKeyHelpers.cxx:42
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MuonR4::SegmentMarkerAlg::m_muonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
Key to the primary muon container to select the muon from
Definition: SegmentMarkerAlg.h:28
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
ReadDecorHandle.h
Handle class for reading a decoration on an object.
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
ReadHandle.h
Handle class for reading from StoreGate.