ATLAS Offline Software
Loading...
Searching...
No Matches
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
10MergeMuonInDetTracksAlg::MergeMuonInDetTracksAlg(const std::string& name, ISvcLocator* pSvcLocator )
11:AthReentrantAlgorithm(name, pSvcLocator)
12{
13}
14
27
28StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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)
An algorithm that can be simultaneously executed in multiple threads.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual StatusCode execute(const EventContext &ctx) const override
execute the filter alg
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muonCBContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_fullIDtrackContainerKey
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muonInsideOutContainerKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_idTrackOutputKey
MergeMuonInDetTracksAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_muonL2mtContainerKey
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".