ATLAS Offline Software
DileptonOSSFInvariantMassWindowSelectorAlg.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 
8 
9 namespace CP {
10 
12  : EL::AnaAlgorithm(name, pSvcLocator)
13  {}
14 
25 
29 
30  return StatusCode::SUCCESS;
31  }
32 
34  for (const auto &sys : m_systematicsList.systematicsVector()) {
35  // retrieve the EventInfo
36  const xAOD::EventInfo *evtInfo = nullptr;
37  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
38 
39  // default-decorate EventInfo
40  m_decoration.setBool(*evtInfo, 0, sys);
41 
42  // check the preselection
43  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
44  continue;
45 
46  // retrieve the electron container
47  const xAOD::ElectronContainer *electrons = nullptr;
50  // retrieve the muon container
51  const xAOD::MuonContainer *muons = nullptr;
52  if (m_muonsHandle)
54  // retrieve the truth electron container
55  const xAOD::TruthParticleContainer *truthElectrons = nullptr;
57  ANA_CHECK(m_electronsTruthHandle.retrieve(truthElectrons, sys));
58  // retrieve the truth muon container
59  const xAOD::TruthParticleContainer *truthMuons = nullptr;
61  ANA_CHECK(m_muonsTruthHandle.retrieve(truthMuons, sys));
62 
63  bool decision = false;
64 
66  if (electrons->size() >= 2) {
67  for (size_t i = 0; i < electrons->size() - 1 && !decision; ++i) {
68  const xAOD::Electron* firstElectron = (*electrons)[i];
69  if (!m_electronSelection || m_electronSelection.getBool(*firstElectron, sys)) {
70  for (size_t j = i + 1; j < electrons->size() && !decision; ++j) {
71  const xAOD::Electron* secondElectron = (*electrons)[j];
72  if (!m_electronSelection || m_electronSelection.getBool(*secondElectron, sys)) {
73  if (firstElectron->charge() != secondElectron->charge()){
74  float mll = (firstElectron->p4() + secondElectron->p4()).M();
75  decision |= (mll < m_mll_upper && mll > m_mll_lower);
76  }
77  }
78  }
79  }
80  }
81  }
82 
83  // If a pair of electrons satisfies the mass requirements, there is no need to loop over muon pairs. The event is either kept or vetoed hereafter.
84  if (!decision && muons->size() >= 2) {
85  for (size_t i = 0; i < muons->size() - 1 && !decision; ++i) {
86  const xAOD::Muon* firstMuon = (*muons)[i];
87  if (!m_muonSelection || m_muonSelection.getBool(*firstMuon, sys)) {
88  for (size_t j = i + 1; j < muons->size() && !decision; ++j) {
89  const xAOD::Muon* secondMuon = (*muons)[j];
90  if (!m_muonSelection || m_muonSelection.getBool(*secondMuon, sys)) {
91  if (firstMuon->charge() != secondMuon->charge()){
92  float mll = (firstMuon->p4() + secondMuon->p4()).M();
93  decision |= (mll < m_mll_upper && mll > m_mll_lower);
94  }
95  }
96  }
97  }
98  }
99  }
100  }
101  else {
102  if (truthElectrons->size() >= 2) {
103  for (size_t i = 0; i < truthElectrons->size() - 1 && !decision; ++i) {
104  const xAOD::TruthParticle* firstElectron = (*truthElectrons)[i];
106  for (size_t j = i + 1; j < truthElectrons->size() && !decision; ++j) {
107  const xAOD::TruthParticle* secondElectron = (*truthElectrons)[j];
108  if (!m_electronTruthSelection || m_electronTruthSelection.getBool(*secondElectron, sys)) {
109  if (firstElectron->charge() != secondElectron->charge()){
110  float mll = (firstElectron->p4() + secondElectron->p4()).M();
111  decision |= (mll < m_mll_upper && mll > m_mll_lower);
112  }
113  }
114  }
115  }
116  }
117  }
118 
119  // If a pair of electrons satisfies the mass requirements, there is no need to loop over muon pairs. The event is either kept or vetoed hereafter.
120  if (!decision && truthMuons->size() >= 2) {
121  for (size_t i = 0; i < truthMuons->size() - 1 && !decision; ++i) {
122  const xAOD::TruthParticle* firstMuon = (*truthMuons)[i];
123  if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*firstMuon, sys)) {
124  for (size_t j = i + 1; j < truthMuons->size() && !decision; ++j) {
125  const xAOD::TruthParticle* secondMuon = (*truthMuons)[j];
126  if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*secondMuon, sys)) {
127  if (firstMuon->charge() != secondMuon->charge()){
128  float mll = (firstMuon->p4() + secondMuon->p4()).M();
129  decision |= (mll < m_mll_upper && mll > m_mll_lower);
130  }
131  }
132  }
133  }
134  }
135  }
136  }
137 
138  if (m_veto) decision = !decision;
139  m_decoration.setBool(*evtInfo, decision, sys);
140 
141  }
142  return StatusCode::SUCCESS;
143  }
144 }
xAOD::Electron_v1::charge
float charge() const
Obtain the charge of the object.
xAOD::Muon_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Muon_v1.cxx:79
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonSelection
CP::SysReadSelectionHandle m_muonSelection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:50
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_veto
Gaudi::Property< bool > m_veto
whether to veto events instead of selecting them
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:38
xAOD::Egamma_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle as a TLoretzVector.
Definition: Egamma_v1.cxx:98
CP::DileptonOSSFInvariantMassWindowSelectorAlg::DileptonOSSFInvariantMassWindowSelectorAlg
DileptonOSSFInvariantMassWindowSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.cxx:11
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonTruthSelection
CP::SysReadSelectionHandle m_muonTruthSelection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:62
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::SysWriteSelectionHandle::setBool
void setBool(const SG::AuxElement &element, bool selection, const CP::SystematicSet &sys) const
set the selection decoration
xAOD::Muon_v1::charge
float charge() const
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:47
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonsTruthHandle
CP::SysReadHandle< xAOD::TruthParticleContainer > m_muonsTruthHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:59
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:40
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:41
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:68
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
lumiFormat.i
int i
Definition: lumiFormat.py:92
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:44
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::DileptonOSSFInvariantMassWindowSelectorAlg::execute
virtual StatusCode execute() override
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.cxx:33
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronTruthSelection
CP::SysReadSelectionHandle m_electronTruthSelection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:56
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_mll_lower
Gaudi::Property< float > m_mll_lower
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:35
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:65
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::DileptonOSSFInvariantMassWindowSelectorAlg::initialize
virtual StatusCode initialize() override
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.cxx:15
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:71
xAOD::TruthParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TruthParticle_v1.cxx:196
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronsTruthHandle
CP::SysReadHandle< xAOD::TruthParticleContainer > m_electronsTruthHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:53
xAOD::TruthParticle_v1::charge
double charge() const
Physical charge.
CP::SysWriteSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysWriteSelectionHandle.cxx:34
DileptonOSSFInvariantMassWindowSelectorAlg.h