ATLAS Offline Software
MuonInJetCorrectionTool.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // MuonInJetCorrectionTool.cxx
8 // Implementation file for class MuonInJetCorrectionTool
10 
12 
14  : asg::AsgTool( name ){ }
15 
17 (xAOD::Jet& jet, const std::vector< const xAOD::Muon* >& muons, int& nmuons) const {
18  const xAOD::Muon* muon_in_jet = getMuonInJet(jet, muons, nmuons);
19 
20  if(nmuons>0){
21  float eLoss = 0.0;
22  muon_in_jet->parameter(eLoss,xAOD::Muon::EnergyLoss);
23  TLorentzVector mu_tlv = muon_in_jet->p4();
24  // Loss with same direction as muon + mass = 0
25  TLorentzVector Loss;
26  Loss.SetVectM(eLoss * (mu_tlv.Vect().Unit()), 0.);
27  TLorentzVector j = jet.p4() - Loss + mu_tlv;
28  xAOD::JetFourMom_t new_jet(j.Pt(), jet.eta(), jet.phi(), j.M());
29  jet.setJetP4(new_jet);
30  }
31 
32  return StatusCode::SUCCESS;
33 }
34 
36 (const xAOD::Jet& jet, const std::vector< const xAOD::Muon* >& muons, int& nmuons) const
37 {
38  const xAOD::Muon* muon_in_jet = nullptr;
39 
40  for(const auto& muon : muons){
41  double dR = jet.p4().DeltaR(muon->p4());
42  double dR_max = m_Jet_Muon_dR;
43  if(m_doVR){
44  if(m_doLargeR) dR_max = std::min(1.0, 0.04 + 200000./muon->pt());
45  else dR_max = std::min(0.4, 0.04 + 10000./muon->pt());
46  }
47  if(dR > dR_max) continue;
48 
49  nmuons++;
50  if(!muon_in_jet || muon->pt() > muon_in_jet->pt()) muon_in_jet = muon;
51  }
52 
53  return muon_in_jet;
54 }
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
MuonInJetCorrectionTool::MuonInJetCorrectionTool
MuonInJetCorrectionTool(const std::string &name)
Constructor with parameters:
Definition: MuonInJetCorrectionTool.cxx:13
xAOD::Muon_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Muon_v1.cxx:79
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
asg
Definition: DataHandleTestTool.h:28
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MuonInJetCorrectionTool::m_Jet_Muon_dR
Gaudi::Property< double > m_Jet_Muon_dR
Definition: MuonInJetCorrectionTool.h:47
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::Muon_v1::parameter
bool parameter(float &value, const ParamDef parameter) const
Get a parameter for this Muon - momentumBalanceSignificance for example.
xAOD::Muon_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
MuonInJetCorrectionTool::getMuonInJet
const xAOD::Muon * getMuonInJet(const xAOD::Jet &jet, const std::vector< const xAOD::Muon * > &muons, int &nmuons) const
Definition: MuonInJetCorrectionTool.cxx:36
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonInJetCorrectionTool::applyMuonInJetCorrection
virtual StatusCode applyMuonInJetCorrection(xAOD::Jet &jet, const std::vector< const xAOD::Muon * > &muons, int &nmuons) const override
Destructor:
Definition: MuonInJetCorrectionTool.cxx:17
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
MuonInJetCorrectionTool::m_doVR
Gaudi::Property< bool > m_doVR
Definition: MuonInJetCorrectionTool.h:48
MuonInJetCorrectionTool::m_doLargeR
Gaudi::Property< bool > m_doLargeR
Definition: MuonInJetCorrectionTool.h:49
MuonInJetCorrectionTool.h