ATLAS Offline Software
MergeMuonInDetTracksAlg.cxx
Go to the documentation of this file.
1 /*
2  Merge muon ID track containers from inside-out and outside-in reconstruction
3 
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
9 
10 MergeMuonInDetTracksAlg::MergeMuonInDetTracksAlg(const std::string& name, ISvcLocator* pSvcLocator )
11 :AthReentrantAlgorithm(name, pSvcLocator)
12 {
13 }
14 
16 
19  ATH_CHECK(m_muonCBContainerKey.initialize());
23  ATH_CHECK(m_muonL2mtContainerKey.initialize());
25  return StatusCode::SUCCESS;
26 }
27 
28 StatusCode MergeMuonInDetTracksAlg::execute(const EventContext& ctx) const
29 {
30 
32  ATH_CHECK(wh_outidtracks.record(std::make_unique<xAOD::TrackParticleContainer>(), std::make_unique<xAOD::TrackParticleAuxContainer>()));
33  xAOD::TrackParticleContainer *idtracksout = wh_outidtracks.ptr();
34 
36  ATH_CHECK(cbMuons.isPresent());
37  ATH_MSG_DEBUG("adding combined muon container with size: "<<cbMuons->size());
38 
40  ATH_CHECK(ioMuons.isPresent());
41  ATH_MSG_DEBUG("adding inside-out muon container with size: "<<ioMuons->size());
42 
44  ATH_CHECK(l2mtMuons.isPresent());
45  ATH_MSG_DEBUG("adding L2 multi-track muon container with size: "<<l2mtMuons->size());
46 
48  ATH_CHECK(FullIDtracks.isPresent());
49  ATH_MSG_DEBUG("full container of ID tracks with size: "<<FullIDtracks->size());
50  for(auto track : *FullIDtracks) {
51  bool trackMatcher = false;
52  // check the cb muon id tracks
53  for(auto cbmuon : *cbMuons) {
54  if(!cbmuon->idTrack()) continue;
55  if(cbmuon->idTrack()==track) {
56  trackMatcher = true;
57  break;
58  }
59  }
60 
61  // check the l2io muon id tracks
62  for(auto iomuon : *ioMuons) {
63  if(!iomuon->idTrack()) continue;
64  if(iomuon->idTrack()==track) {
65  trackMatcher = true;
66  break;
67  }
68  }
69 
70  // check the l2mt muon id tracks
71  for(auto l2mtmuon : *l2mtMuons) {
72  if(!l2mtmuon->idTrack()) continue;
73  if(l2mtmuon->idTrack()==track) {
74  trackMatcher = true;
75  break;
76  }
77  }
78 
79  // add the track to the ID track container if it matches an ID track from the full collection
80  if(trackMatcher) {
81  idtracksout->push_back(new xAOD::TrackParticle(*track));
82  }
83  else {
84  ATH_MSG_DEBUG("no inner detector tracks could be matched to any cb, io or l2mt muon in the event");
85  }
86  }
87  ATH_MSG_DEBUG("output ID muon tracks with size: " << idtracksout->size());
88  return StatusCode::SUCCESS;
89 
90 }
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MergeMuonInDetTracksAlg::m_muonInsideOutContainerKey
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muonInsideOutContainerKey
Definition: MergeMuonInDetTracksAlg.h:33
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition: AthCommonDataStore.h:380
MergeMuonInDetTracksAlg::m_fullIDtrackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_fullIDtrackContainerKey
Definition: MergeMuonInDetTracksAlg.h:31
MergeMuonInDetTracksAlg::MergeMuonInDetTracksAlg
MergeMuonInDetTracksAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: MergeMuonInDetTracksAlg.cxx:10
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MergeMuonInDetTracksAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: MergeMuonInDetTracksAlg.cxx:15
MergeMuonInDetTracksAlg::m_muonL2mtContainerKey
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muonL2mtContainerKey
Definition: MergeMuonInDetTracksAlg.h:34
MergeMuonInDetTracksAlg::m_idTrackOutputKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_idTrackOutputKey
Definition: MergeMuonInDetTracksAlg.h:35
TrackParticleAuxContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MergeMuonInDetTracksAlg::m_muonCBContainerKey
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muonCBContainerKey
Definition: MergeMuonInDetTracksAlg.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MergeMuonInDetTracksAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
execute the filter alg
Definition: MergeMuonInDetTracksAlg.cxx:28
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MergeMuonInDetTracksAlg.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:394
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.