ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkLLP
src
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
5
#include "
DerivationFrameworkLLP/RecoverZeroPixelHitMuons.h
"
6
#include "
FourMomUtils/xAODP4Helpers.h
"
7
#include <TVector3.h>
8
9
RecoverZeroPixelHitMuons::RecoverZeroPixelHitMuons
(
const
std::string& name, ISvcLocator* pSvcLocator) :
10
AthReentrantAlgorithm
(name, pSvcLocator)
11
{
12
}
13
14
StatusCode
RecoverZeroPixelHitMuons::initialize
()
15
{
16
ATH_CHECK
(
m_inputMuonContainerKey
.initialize());
17
ATH_CHECK
(
m_inputTrackContainerKey
.initialize());
18
ATH_CHECK
(
m_outputMuonContainerKey
.initialize());
19
20
return
StatusCode::SUCCESS;
21
}
22
23
24
StatusCode
RecoverZeroPixelHitMuons::execute
(
const
EventContext& context)
const
25
{
26
27
SG::ReadHandle<xAOD::MuonContainer>
inputMuons{
m_inputMuonContainerKey
, context};
28
if
( ! inputMuons.
isValid
() ) {
29
ATH_MSG_ERROR
(
"Couldn't retrieve xAOD::MuonContainer with key: "
<<
m_inputMuonContainerKey
.key() );
30
return
StatusCode::FAILURE;
31
}
32
33
SG::ReadHandle<xAOD::TrackParticleContainer>
inputTracks{
m_inputTrackContainerKey
, context};
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
81
SG::WriteHandle<xAOD::MuonContainer>
outputMuonsHandle{
m_outputMuonContainerKey
, context};
82
83
CHECK
( outputMuonsHandle.
record
(std::move(outputMuons), std::move (outputMuonsAux)) );
84
85
86
87
return
StatusCode::SUCCESS;
88
}
89
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
RecoverZeroPixelHitMuons.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
RecoverZeroPixelHitMuons::RecoverZeroPixelHitMuons
RecoverZeroPixelHitMuons(const std::string &name, ISvcLocator *pSvcLocator)
Definition
RecoverZeroPixelHitMuons.cxx:9
RecoverZeroPixelHitMuons::m_inputTrackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackContainerKey
Definition
RecoverZeroPixelHitMuons.h:35
RecoverZeroPixelHitMuons::initialize
virtual StatusCode initialize() override
Definition
RecoverZeroPixelHitMuons.cxx:14
RecoverZeroPixelHitMuons::execute
virtual StatusCode execute(const EventContext &context) const override
Definition
RecoverZeroPixelHitMuons.cxx:24
RecoverZeroPixelHitMuons::m_matchingDeltaR
Gaudi::Property< float > m_matchingDeltaR
Definition
RecoverZeroPixelHitMuons.h:39
RecoverZeroPixelHitMuons::m_outputMuonContainerKey
SG::WriteHandleKey< xAOD::MuonContainer > m_outputMuonContainerKey
Definition
RecoverZeroPixelHitMuons.h:36
RecoverZeroPixelHitMuons::m_inputMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_inputMuonContainerKey
Definition
RecoverZeroPixelHitMuons.h:34
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::Muon_v1::setTrackParticleLink
void setTrackParticleLink(TrackParticleType type, const ElementLink< TrackParticleContainer > &link)
Set method for TrackParticle links.
Definition
Muon_v1.cxx:460
xAOD::Muon_v1::pt
virtual double pt() const override
The transverse momentum ( ) of the particle.
xAOD::Muon_v1::setMuonType
void setMuonType(MuonType type)
xAOD::Muon_v1::charge
float charge() const
xAOD::Muon_v1::setP4
void setP4(double pt, double eta, double phi)
Set method for IParticle values.
Definition
Muon_v1.cxx:71
xAOD::Muon_v1::setCharge
void setCharge(float charge)
Set the charge (must be the same as primaryTrackParticle() ).
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition
xAODP4Helpers.h:150
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition
TrackingPrimitives.h:260
xAODP4Helpers.h
Generated on
for ATLAS Offline Software by
1.17.0