ATLAS Offline Software
PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Muon.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 #include "TopEvent/EventTools.h"
8 
10 using namespace TopObjectSelectionTools;
11 
12 namespace top {
13  Muon::Muon(const double ptcut, IsolationBase* isolation,
14  const double d0SigCut, const double delta_z0_sintheta,
15  const bool applyTTVACut) :
16  m_ptcut(ptcut),
17  m_d0SigCut(d0SigCut),
18  m_delta_z0(delta_z0_sintheta),
19  m_muonSelectionTool("MuonSelectionTool"),
20  m_muonSelectionToolLoose("MuonSelectionToolLoose"),
21  m_isolation(isolation),
22  m_applyTTVACut(applyTTVACut) {
23  top::check(m_muonSelectionTool.retrieve(), "Failed to retrieve muonSelectionTool");
24  top::check(m_muonSelectionToolLoose.retrieve(), "Failed to retrieve muonSelectionToolLoose");
25  }
26 
27  Muon::Muon(const double ptcut, IsolationBase* isolation, const bool applyTTVACut)
28  : Muon::Muon(ptcut, isolation, 3.0, 0.5, applyTTVACut) {}
29 
30  Muon::Muon(const double ptcut, IsolationBase* isolation)
31  : Muon::Muon(ptcut, isolation, 3.0, 0.5, true) {}
32 
33  bool Muon::passSelection(const xAOD::Muon& mu) const {
34  if (mu.pt() < m_ptcut) return false;
35 
36  if (!m_muonSelectionTool->accept(mu)) return false;
37 
38  //isolation, if m_isolation != nullptr
39  if (m_isolation && !m_isolation->passSelection(mu)) return false;
40 
41  // Track-to-vertex association
42  if (m_applyTTVACut) {
43  if (!passTTVACuts(mu)) return false;
44  }
45 
46  return true;
47  }
48 
49  bool Muon::passSelectionLoose(const xAOD::Muon& mu) const {
50  if (mu.pt() < m_ptcut) return false;
51 
52  if (!m_muonSelectionToolLoose->accept(mu)) return false;
53 
54  //isolation, if m_isolation != nullptr
55  if (m_isolation && !m_isolation->passSelectionLoose(mu)) return false;
56 
57  // Track-to-vertex association
58  if (m_applyTTVACut) {
59  if (!passTTVACuts(mu)) return false;
60  }
61 
62  return true;
63  }
64 
65  bool Muon::passTTVACuts(const xAOD::Muon& mu) const {
66  // TTVA:
67  // see https://twiki.cern.ch/twiki/bin/view/AtlasProtected/TrackingCPEOYE2015#Track_to_Vertex_Association
68  if (!mu.isAvailable<float>("d0sig")) {
69  ATH_MSG_WARNING("d0 significance not found for muon. "
70  << "Maybe no primary vertex? Won't accept.");
71  return false;
72  }
73 
74  float d0sig = mu.auxdataConst<float>("d0sig");
75  if (std::abs(d0sig) >= 3) return false;
76 
77  if (!mu.isAvailable<float>("delta_z0_sintheta")) {
78  ATH_MSG_WARNING("delta z0*sin(theta) not found for muon. "
79  << "Maybe no primary vertex? Won't accept.");
80  return false;
81  }
82 
83  float delta_z0_sintheta = mu.auxdataConst<float>("delta_z0_sintheta");
84  if (std::abs(delta_z0_sintheta) >= 0.5) return false;
85 
86  return true;
87  }
88 
89  void Muon::print(std::ostream& os) const {
90  os << "Muon\n"
91  << " * pT > " << m_ptcut << "\n"
92  << " * Everything else from muon tool - fill this in?\n";
93 
94  if (!m_isolation) os << " * No isolation requirement\n";
95  else m_isolation->print(os);
96  }
97 }
Muon.h
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::Muon::passTTVACuts
virtual bool passTTVACuts(const xAOD::Muon &mu) const
The track-to-vertex association (TTVA) cuts.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Muon.cxx:65
top::Muon::passSelectionLoose
virtual bool passSelectionLoose(const xAOD::Muon &mu) const override
The loose selection needed by some background estimates.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Muon.cxx:49
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Pythia8_A14_NNPDF23LO_forMGHT_EvtGen.ptcut
float ptcut
Definition: Pythia8_A14_NNPDF23LO_forMGHT_EvtGen.py:9
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MsgCategory.h
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
top::Muon::m_isolation
std::unique_ptr< top::IsolationBase > m_isolation
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Muon.h:85
top::Muon::passSelection
virtual bool passSelection(const xAOD::Muon &mu) const override
Implements the logic to select good muons.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Muon.cxx:33
top::Muon::m_muonSelectionTool
ToolHandle< CP::IMuonSelectionTool > m_muonSelectionTool
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Muon.h:81
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
top::Muon::m_muonSelectionToolLoose
ToolHandle< CP::IMuonSelectionTool > m_muonSelectionToolLoose
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Muon.h:82
top::Muon::Muon
Muon(const double ptcut, IsolationBase *isolation)
Construct the tool to select good muons.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Muon.cxx:30
top::Muon::m_applyTTVACut
bool m_applyTTVACut
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Muon.h:88
Muon
struct TBPatternUnitContext Muon
top::IsolationBase
A common base for implementing isolation cuts.
Definition: IsolationTools.h:16
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
top::Muon::print
virtual void print(std::ostream &os) const override
Because everybody likes to know what object definitions they ran with.
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/Muon.cxx:89
top::Muon::m_ptcut
double m_ptcut
Definition: PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/TopObjectSelectionTools/Muon.h:74
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53