ATLAS Offline Software
Loading...
Searching...
No Matches
RecoverZeroPixelHitMuons.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <TVector3.h>
8
9RecoverZeroPixelHitMuons::RecoverZeroPixelHitMuons(const std::string& name, ISvcLocator* pSvcLocator) :
10 AthReentrantAlgorithm(name, pSvcLocator)
11{
12}
13
15{
19
20 return StatusCode::SUCCESS;
21}
22
23
24StatusCode RecoverZeroPixelHitMuons::execute(const EventContext& context) const
25{
26
28 if( ! inputMuons.isValid() ) {
29 ATH_MSG_ERROR ("Couldn't retrieve xAOD::MuonContainer with key: " << m_inputMuonContainerKey.key() );
30 return StatusCode::FAILURE;
31 }
32
34 if( ! inputTracks.isValid() ) {
35 ATH_MSG_ERROR ("Couldn't retrieve xAOD::TrackParticleContainer with key: " << m_inputTrackContainerKey.key() );
36 return StatusCode::FAILURE;
37 }
38
39 auto outputMuons = std::make_unique<xAOD::MuonContainer>();
40 auto outputMuonsAux = std::make_unique<xAOD::MuonAuxContainer>();
41
42 outputMuons->setStore (outputMuonsAux.get());
43
44 std::vector<const xAOD::Muon*> matchedMuons;
45 for (const xAOD::TrackParticle *t : *inputTracks){
46 // if we have a pixel hit, should reconstruct these guys as combined muons
47 uint8_t nPixHits = 0;
48 t->summaryValue(nPixHits,xAOD::numberOfPixelHits);
49 if (nPixHits > 0) continue;
50
51 // loop over muons
52 float min_dR=999.;
53 const xAOD::Muon* muMatch = nullptr;
54
55 for (const xAOD::Muon* m : *inputMuons){
56 if (m->muonType() != xAOD::Muon::MuonType::MuonStandAlone) continue;
57 if (std::find(matchedMuons.begin(), matchedMuons.end(), m) != matchedMuons.end()) continue;
58
59 // Define SA muon vector
60 float mu_dR= xAOD::P4Helpers::deltaR(t->eta(), t->phi(), m->eta(), m->phi());
61
62 // Update matching between ID track and SA muon
63 if (mu_dR < min_dR){
64 min_dR=mu_dR;
65 muMatch=m;
66 }
67 }
68 if ((min_dR < m_matchingDeltaR) && (muMatch->charge() == t->charge())){
69 matchedMuons.push_back(muMatch);
70 const xAOD::Muon &muon_match = *muMatch;
71 xAOD::Muon *zeroPixelHitMuon = outputMuons->push_back(std::make_unique<xAOD::Muon>(muon_match));
72 zeroPixelHitMuon->setP4(muon_match.pt(), t->eta(), t->phi());
73 zeroPixelHitMuon->setCharge(muon_match.charge());
74 zeroPixelHitMuon->setMuonType(xAOD::Muon::MuonType::ZeroPixelHit);
75 ElementLink<xAOD::TrackParticleContainer> link( *inputTracks, t->index() );
76 zeroPixelHitMuon->setTrackParticleLink(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle, link);
77 }
78
79 }
80
82
83 CHECK( outputMuonsHandle.record (std::move(outputMuons), std::move (outputMuonsAux)) );
84
85
86
87 return StatusCode::SUCCESS;
88}
89
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
An algorithm that can be simultaneously executed in multiple threads.
RecoverZeroPixelHitMuons(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackContainerKey
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &context) const override
Gaudi::Property< float > m_matchingDeltaR
SG::WriteHandleKey< xAOD::MuonContainer > m_outputMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_inputMuonContainerKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setTrackParticleLink(TrackParticleType type, const ElementLink< TrackParticleContainer > &link)
Set method for TrackParticle links.
Definition Muon_v1.cxx:461
virtual double pt() const override
The transverse momentum ( ) of the particle.
void setMuonType(MuonType type)
float charge() const
void setP4(double pt, double eta, double phi)
Set method for IParticle values.
Definition Muon_v1.cxx:71
void setCharge(float charge)
Set the charge (must be the same as primaryTrackParticle() ).
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].