Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RecoverZeroPixelHitMuons.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <TVector3.h>
7 
8 RecoverZeroPixelHitMuons::RecoverZeroPixelHitMuons(const std::string& name, ISvcLocator* pSvcLocator) :
9  AthReentrantAlgorithm(name, pSvcLocator)
10 {
11 }
12 
14 {
17  ATH_CHECK(m_outputMuonContainerKey.initialize());
18 
19  return StatusCode::SUCCESS;
20 }
21 
22 
23 StatusCode RecoverZeroPixelHitMuons::execute(const EventContext& context) const
24 {
25 
27  if( ! inputMuons.isValid() ) {
28  ATH_MSG_ERROR ("Couldn't retrieve xAOD::MuonContainer with key: " << m_inputMuonContainerKey.key() );
29  return StatusCode::FAILURE;
30  }
31 
33  if( ! inputTracks.isValid() ) {
34  ATH_MSG_ERROR ("Couldn't retrieve xAOD::TrackParticleContainer with key: " << m_inputTrackContainerKey.key() );
35  return StatusCode::FAILURE;
36  }
37 
38  auto outputMuons = std::make_unique<xAOD::MuonContainer>();
39  auto outputMuonsAux = std::make_unique<xAOD::MuonAuxContainer>();
40 
41  outputMuons->setStore (outputMuonsAux.get());
42 
44  double track_eta=0.0;
45  double track_phi=0.0;
46  double track_charge=0.0;
47  double mu_charge=0.0;
48  std::vector<const xAOD::Muon*> matchedMuons;
49  int n_tracks=0;
50  for (const xAOD::TrackParticle *t : *inputTracks){
51  n_tracks++;
52  // if we have a pixel hit, should reconstruct these guys as combined muons
53  uint8_t nPixHits = 0;
54  t->summaryValue(nPixHits,xAOD::numberOfPixelHits);
55  if (nPixHits > 0) continue;
56 
57  // Define ID track vector and charge
58  TVector3 track_vector;
59  track_vector.SetPtEtaPhi(t->pt(), t->eta(), t->phi());
60  track_eta=t->eta();
61  track_phi=t->phi();
62  track_charge=t->charge();
63  // loop over muons
65  float min_dR=999.;
66  float min_mu_charge=0.0;
68 
69  for (muItr = inputMuons->begin(); muItr != inputMuons->end(); ++muItr){
70  const xAOD::Muon &m = *(*muItr);
71  if (m.muonType() != xAOD::Muon::MuonStandAlone) continue;
72  if (std::find(matchedMuons.begin(), matchedMuons.end(), *muItr) != matchedMuons.end()) continue;
73 
74  // Define SA muon vector
75  TVector3 mu_vector;
76  mu_vector.SetPtEtaPhi(m.pt(), m.eta(), m.phi());
77  mu_charge=m.charge();
78  float mu_dR=mu_vector.DeltaR(track_vector);
79 
80  // Update matching between ID track and SA muon
81  if (mu_dR < min_dR){
82  min_dR=mu_dR;
83  min_mu_charge=mu_charge;
84  muMatchItr=muItr;
85  }
86  }
87  if ((min_dR < m_matchingDeltaR) && (min_mu_charge == track_charge)){
88  matchedMuons.push_back(*muMatchItr);
89  const xAOD::Muon &muon_match = *(*muMatchItr);
90  xAOD::Muon *zeroPixelHitMuon = new xAOD::Muon(muon_match);
91  outputMuons->push_back(zeroPixelHitMuon);
92  zeroPixelHitMuon->setP4(muon_match.pt(),track_eta,track_phi);
93  zeroPixelHitMuon->setCharge(min_mu_charge);
94  // Set to not assigned Muon Type to distinguish from other muons, will need to properly define in MuonType enum later
95  zeroPixelHitMuon->setMuonType((xAOD::Muon::MuonType)10);
97  zeroPixelHitMuon->setTrackParticleLink(xAOD::Muon::InnerDetectorTrackParticle, link);
98  }
99 
100  }
101 
103 
104  CHECK( outputMuonsHandle.record (std::move(outputMuons), std::move (outputMuonsAux)) );
105 
106 
107 
108  return StatusCode::SUCCESS;
109 }
110 
RecoverZeroPixelHitMuons::RecoverZeroPixelHitMuons
RecoverZeroPixelHitMuons(const std::string &name, ISvcLocator *pSvcLocator)
Definition: RecoverZeroPixelHitMuons.cxx:8
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::Muon_v1::setTrackParticleLink
void setTrackParticleLink(TrackParticleType type, const ElementLink< TrackParticleContainer > &link)
Set method for TrackParticle links.
Definition: Muon_v1.cxx:505
RecoverZeroPixelHitMuons.h
xAOD::Muon_v1::setP4
void setP4(double pt, double eta, double phi)
Set method for IParticle values.
Definition: Muon_v1.cxx:66
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:260
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
RecoverZeroPixelHitMuons::m_outputMuonContainerKey
SG::WriteHandleKey< xAOD::MuonContainer > m_outputMuonContainerKey
Definition: RecoverZeroPixelHitMuons.h:36
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
RecoverZeroPixelHitMuons::m_inputMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_inputMuonContainerKey
Definition: RecoverZeroPixelHitMuons.h:34
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.TrigInDetConfig.inputTracks
inputTracks
Definition: TrigInDetConfig.py:190
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RecoverZeroPixelHitMuons::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: RecoverZeroPixelHitMuons.cxx:23
xAOD::Muon_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
xAOD::Muon_v1::setCharge
void setCharge(float charge)
Set the charge (must be the same as primaryTrackParticle() )
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
RecoverZeroPixelHitMuons::m_inputTrackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackContainerKey
Definition: RecoverZeroPixelHitMuons.h:35
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
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
RecoverZeroPixelHitMuons::initialize
virtual StatusCode initialize() override
Definition: RecoverZeroPixelHitMuons.cxx:13
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::Muon_v1::setMuonType
void setMuonType(MuonType type)
RecoverZeroPixelHitMuons::m_matchingDeltaR
Gaudi::Property< float > m_matchingDeltaR
Definition: RecoverZeroPixelHitMuons.h:39