ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
EventSelectionAlgorithms
Root
DileptonOSSFInvariantMassWindowSelectorAlg.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
8
#include "
EventSelectionAlgorithms/DileptonOSSFInvariantMassWindowSelectorAlg.h
"
9
10
using
ROOT::Math::PtEtaPhiEVector;
11
12
namespace
CP
{
13
14
StatusCode
DileptonOSSFInvariantMassWindowSelectorAlg::initialize
() {
15
ANA_CHECK
(
m_electronsHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
16
ANA_CHECK
(
m_electronSelection
.initialize(
m_systematicsList
,
m_electronsHandle
,
SG::AllowEmpty
));
17
ANA_CHECK
(
m_muonsHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
18
ANA_CHECK
(
m_muonSelection
.initialize(
m_systematicsList
,
m_muonsHandle
,
SG::AllowEmpty
));
19
ANA_CHECK
(
m_electronsTruthHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
20
ANA_CHECK
(
m_electronTruthSelection
.initialize(
m_systematicsList
,
m_electronsTruthHandle
,
SG::AllowEmpty
));
21
ANA_CHECK
(
m_muonsTruthHandle
.initialize(
m_systematicsList
,
SG::AllowEmpty
));
22
ANA_CHECK
(
m_muonTruthSelection
.initialize(
m_systematicsList
,
m_muonsTruthHandle
,
SG::AllowEmpty
));
23
ANA_CHECK
(
m_eventInfoHandle
.initialize(
m_systematicsList
));
24
ANA_CHECK
(
m_preselection
.initialize(
m_systematicsList
,
m_eventInfoHandle
,
SG::AllowEmpty
));
25
ANA_CHECK
(
m_decoration
.initialize(
m_systematicsList
,
m_eventInfoHandle
));
26
ANA_CHECK
(
m_systematicsList
.initialize());
27
return
StatusCode::SUCCESS;
28
}
29
30
// Compute invariant mass of two reco leptons
31
template
<
typename
T>
32
static
float
mll_reco
(
const
T* lep0,
const
T* lep1) {
33
return
(lep0->p4() + lep1->p4()).M();
34
}
35
36
// Compute invariant mass of two truth particles, optionally using dressed kinematics
37
static
float
mll_truth
(
const
xAOD::TruthParticle
* lep0,
38
const
xAOD::TruthParticle
* lep1,
39
bool
useDressed) {
40
if
(!useDressed)
41
return
(lep0->
p4
() + lep1->
p4
()).M();
42
43
static
const
SG::ConstAccessor<float>
acc_pt (
"pt_dressed"
);
44
static
const
SG::ConstAccessor<float>
acc_eta(
"eta_dressed"
);
45
static
const
SG::ConstAccessor<float>
acc_phi(
"phi_dressed"
);
46
static
const
SG::ConstAccessor<float>
acc_e (
"e_dressed"
);
47
48
PtEtaPhiEVector v0, v1;
49
v0.SetCoordinates(acc_pt(*lep0), acc_eta(*lep0), acc_phi(*lep0), acc_e(*lep0));
50
v1.SetCoordinates(acc_pt(*lep1), acc_eta(*lep1), acc_phi(*lep1), acc_e(*lep1));
51
return
(v0 + v1).M();
52
}
53
54
// Check whether mll falls inside the window
55
bool
DileptonOSSFInvariantMassWindowSelectorAlg::inWindow
(
float
mll)
const
{
56
return
mll >
m_mll_lower
&& mll <
m_mll_upper
;
57
}
58
59
StatusCode
DileptonOSSFInvariantMassWindowSelectorAlg::execute
(
const
EventContext& ctx) {
60
61
for
(
const
auto
&sys :
m_systematicsList
.systematicsVector()) {
62
63
const
xAOD::EventInfo
*evtInfo =
nullptr
;
64
ANA_CHECK
(
m_eventInfoHandle
.retrieve(evtInfo, sys, ctx));
65
66
m_decoration
.setBool(*evtInfo,
false
, sys);
67
68
if
(
m_preselection
&& !
m_preselection
.getBool(*evtInfo, sys))
69
continue
;
70
71
bool
decision =
false
;
72
73
if
(
m_electronsHandle
&& !decision) {
74
const
xAOD::ElectronContainer
*electrons =
nullptr
;
75
ANA_CHECK
(
m_electronsHandle
.retrieve(electrons, sys, ctx));
76
for
(
size_t
i = 0; i < electrons->size() && !decision; ++i) {
77
const
xAOD::Electron
* e0 = (*electrons)[i];
78
if
(
m_electronSelection
&& !
m_electronSelection
.getBool(*e0, sys))
continue
;
79
for
(
size_t
j = i + 1; j < electrons->size() && !decision; ++j) {
80
const
xAOD::Electron
* e1 = (*electrons)[j];
81
if
(
m_electronSelection
&& !
m_electronSelection
.getBool(*e1, sys))
continue
;
82
if
(e0->charge() == e1->charge())
continue
;
83
decision =
inWindow
(
mll_reco
(e0, e1));
84
}
85
}
86
}
87
88
if
(
m_muonsHandle
&& !decision) {
89
const
xAOD::MuonContainer
*muons =
nullptr
;
90
ANA_CHECK
(
m_muonsHandle
.retrieve(muons, sys, ctx));
91
for
(
size_t
i = 0; i < muons->
size
() && !decision; ++i) {
92
const
xAOD::Muon
* m0 = (*muons)[i];
93
if
(
m_muonSelection
&& !
m_muonSelection
.getBool(*m0, sys))
continue
;
94
for
(
size_t
j = i + 1; j < muons->
size
() && !decision; ++j) {
95
const
xAOD::Muon
* m1 = (*muons)[j];
96
if
(
m_muonSelection
&& !
m_muonSelection
.getBool(*m1, sys))
continue
;
97
if
(m0->
charge
() == m1->charge())
continue
;
98
decision =
inWindow
(
mll_reco
(m0, m1));
99
}
100
}
101
}
102
103
if
(
m_electronsTruthHandle
&& !decision) {
104
const
xAOD::TruthParticleContainer
*truthElectrons =
nullptr
;
105
ANA_CHECK
(
m_electronsTruthHandle
.retrieve(truthElectrons, sys, ctx));
106
for
(
size_t
i = 0; i < truthElectrons->
size
() && !decision; ++i) {
107
const
xAOD::TruthParticle
* e0 = (*truthElectrons)[i];
108
if
(
m_electronTruthSelection
&& !
m_electronTruthSelection
.getBool(*e0, sys))
continue
;
109
for
(
size_t
j = i + 1; j < truthElectrons->
size
() && !decision; ++j) {
110
const
xAOD::TruthParticle
* e1 = (*truthElectrons)[j];
111
if
(
m_electronTruthSelection
&& !
m_electronTruthSelection
.getBool(*e1, sys))
continue
;
112
if
(e0->charge() == e1->charge())
continue
;
113
decision =
inWindow
(
mll_truth
(e0, e1,
m_useDressedProperties
));
114
}
115
}
116
}
117
118
if
(
m_muonsTruthHandle
&& !decision) {
119
const
xAOD::TruthParticleContainer
*truthMuons =
nullptr
;
120
ANA_CHECK
(
m_muonsTruthHandle
.retrieve(truthMuons, sys, ctx));
121
for
(
size_t
i = 0; i < truthMuons->
size
() && !decision; ++i) {
122
const
xAOD::TruthParticle
* m0 = (*truthMuons)[i];
123
if
(
m_muonTruthSelection
&& !
m_muonTruthSelection
.getBool(*m0, sys))
continue
;
124
for
(
size_t
j = i + 1; j < truthMuons->
size
() && !decision; ++j) {
125
const
xAOD::TruthParticle
* m1 = (*truthMuons)[j];
126
if
(
m_muonTruthSelection
&& !
m_muonTruthSelection
.getBool(*m1, sys))
continue
;
127
if
(m0->
charge
() == m1->charge())
continue
;
128
decision =
inWindow
(
mll_truth
(m0, m1,
m_useDressedProperties
));
129
}
130
}
131
}
132
133
if
(
m_veto
) decision = !decision;
134
m_decoration
.setBool(*evtInfo, decision, sys);
135
}
136
137
return
StatusCode::SUCCESS;
138
}
139
140
}
// namespace CP
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
DileptonOSSFInvariantMassWindowSelectorAlg.h
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronsTruthHandle
CP::SysReadHandle< xAOD::TruthParticleContainer > m_electronsTruthHandle
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:60
CP::DileptonOSSFInvariantMassWindowSelectorAlg::inWindow
bool inWindow(float mll) const
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.cxx:55
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_mll_lower
Gaudi::Property< float > m_mll_lower
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:37
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:47
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:78
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:48
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonTruthSelection
CP::SysReadSelectionHandle m_muonTruthSelection
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:69
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:54
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:72
CP::DileptonOSSFInvariantMassWindowSelectorAlg::initialize
virtual StatusCode initialize() override
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.cxx:14
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:57
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_veto
Gaudi::Property< bool > m_veto
whether to veto events instead of selecting them
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:40
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:43
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:75
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonsTruthHandle
CP::SysReadHandle< xAOD::TruthParticleContainer > m_muonsTruthHandle
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:66
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:51
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronTruthSelection
CP::SysReadSelectionHandle m_electronTruthSelection
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:63
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_mll_upper
Gaudi::Property< float > m_mll_upper
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.h:38
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
EL::AnaAlgorithm::execute
virtual::StatusCode execute()
execute this algorithm
Definition
AnaAlgorithm.cxx:321
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
xAOD::Muon_v1::charge
float charge() const
xAOD::TruthParticle_v1::charge
double charge() const
Physical charge.
xAOD::TruthParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition
TruthParticle_v1.cxx:191
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::mll_reco
static float mll_reco(const T *lep0, const T *lep1)
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.cxx:32
CP::mll_truth
static float mll_truth(const xAOD::TruthParticle *lep0, const xAOD::TruthParticle *lep1, bool useDressed)
Definition
DileptonOSSFInvariantMassWindowSelectorAlg.cxx:37
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAOD::ElectronContainer
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/ElectronContainer.h:17
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
xAOD::TruthParticleContainer
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticleContainer.h:17
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
Generated on
for ATLAS Offline Software by
1.17.0