Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 using ROOT::Math::PtEtaPhiEVector;
10 
11 namespace CP {
12 
14  : EL::AnaAlgorithm(name, pSvcLocator)
15  {}
16 
27 
31 
32  return StatusCode::SUCCESS;
33  }
34 
36  // accessors
37  static const SG::AuxElement::ConstAccessor<float> acc_pt_dressed("pt_dressed");
38  static const SG::AuxElement::ConstAccessor<float> acc_eta_dressed("eta_dressed");
39  static const SG::AuxElement::ConstAccessor<float> acc_phi_dressed("phi_dressed");
40  static const SG::AuxElement::ConstAccessor<float> acc_e_dressed("e_dressed");
41 
42  for (const auto &sys : m_systematicsList.systematicsVector()) {
43  // retrieve the EventInfo
44  const xAOD::EventInfo *evtInfo = nullptr;
45  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
46 
47  // default-decorate EventInfo
48  m_decoration.setBool(*evtInfo, 0, sys);
49 
50  // check the preselection
51  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
52  continue;
53 
54  // retrieve the electron container
55  const xAOD::ElectronContainer *electrons = nullptr;
58  // retrieve the muon container
59  const xAOD::MuonContainer *muons = nullptr;
60  if (m_muonsHandle)
62  // retrieve the truth electron container
63  const xAOD::TruthParticleContainer *truthElectrons = nullptr;
65  ANA_CHECK(m_electronsTruthHandle.retrieve(truthElectrons, sys));
66  // retrieve the truth muon container
67  const xAOD::TruthParticleContainer *truthMuons = nullptr;
69  ANA_CHECK(m_muonsTruthHandle.retrieve(truthMuons, sys));
70 
71  bool decision = false;
72 
74  if (electrons->size() >= 2) {
75  for (size_t i = 0; i < electrons->size() - 1 && !decision; ++i) {
76  const xAOD::Electron* firstElectron = (*electrons)[i];
77  if (!m_electronSelection || m_electronSelection.getBool(*firstElectron, sys)) {
78  for (size_t j = i + 1; j < electrons->size() && !decision; ++j) {
79  const xAOD::Electron* secondElectron = (*electrons)[j];
80  if (!m_electronSelection || m_electronSelection.getBool(*secondElectron, sys)) {
81  if (firstElectron->charge() != secondElectron->charge()){
82  float mll = (firstElectron->p4() + secondElectron->p4()).M();
83  decision |= (mll < m_mll_upper && mll > m_mll_lower);
84  }
85  }
86  }
87  }
88  }
89  }
90 
91  // 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.
92  if (!decision && muons->size() >= 2) {
93  for (size_t i = 0; i < muons->size() - 1 && !decision; ++i) {
94  const xAOD::Muon* firstMuon = (*muons)[i];
95  if (!m_muonSelection || m_muonSelection.getBool(*firstMuon, sys)) {
96  for (size_t j = i + 1; j < muons->size() && !decision; ++j) {
97  const xAOD::Muon* secondMuon = (*muons)[j];
98  if (!m_muonSelection || m_muonSelection.getBool(*secondMuon, sys)) {
99  if (firstMuon->charge() != secondMuon->charge()){
100  float mll = (firstMuon->p4() + secondMuon->p4()).M();
101  decision |= (mll < m_mll_upper && mll > m_mll_lower);
102  }
103  }
104  }
105  }
106  }
107  }
108  }
109  else {
110  if (truthElectrons->size() >= 2) {
111  for (size_t i = 0; i < truthElectrons->size() - 1 && !decision; ++i) {
112  const xAOD::TruthParticle* firstElectron = (*truthElectrons)[i];
114  for (size_t j = i + 1; j < truthElectrons->size() && !decision; ++j) {
115  const xAOD::TruthParticle* secondElectron = (*truthElectrons)[j];
116  if (!m_electronTruthSelection || m_electronTruthSelection.getBool(*secondElectron, sys)) {
117  if (firstElectron->charge() != secondElectron->charge()){
118  float mll = -1.;
120  PtEtaPhiEVector el0, el1;
121  el0.SetCoordinates(acc_pt_dressed(*firstElectron),
122  acc_eta_dressed(*firstElectron),
123  acc_phi_dressed(*firstElectron),
124  acc_e_dressed(*firstElectron));
125  el1.SetCoordinates(acc_pt_dressed(*secondElectron),
126  acc_eta_dressed(*secondElectron),
127  acc_phi_dressed(*secondElectron),
128  acc_e_dressed(*secondElectron));
129  mll = (el0+el1).M();
130  } else {
131  mll = (firstElectron->p4() + secondElectron->p4()).M();
132  }
133  decision |= (mll < m_mll_upper && mll > m_mll_lower);
134  }
135  }
136  }
137  }
138  }
139  }
140 
141  // 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.
142  if (!decision && truthMuons->size() >= 2) {
143  for (size_t i = 0; i < truthMuons->size() - 1 && !decision; ++i) {
144  const xAOD::TruthParticle* firstMuon = (*truthMuons)[i];
145  if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*firstMuon, sys)) {
146  for (size_t j = i + 1; j < truthMuons->size() && !decision; ++j) {
147  const xAOD::TruthParticle* secondMuon = (*truthMuons)[j];
148  if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*secondMuon, sys)) {
149  if (firstMuon->charge() != secondMuon->charge()){
150  float mll = -1.;
152  PtEtaPhiEVector mu0, mu1;
153  mu0.SetCoordinates(acc_pt_dressed(*firstMuon),
154  acc_eta_dressed(*firstMuon),
155  acc_phi_dressed(*firstMuon),
156  acc_e_dressed(*firstMuon));
157  mu1.SetCoordinates(acc_pt_dressed(*secondMuon),
158  acc_eta_dressed(*secondMuon),
159  acc_phi_dressed(*secondMuon),
160  acc_e_dressed(*secondMuon));
161  mll = (mu0+mu1).M();
162  } else {
163  mll = (firstMuon->p4() + secondMuon->p4()).M();
164  }
165  decision |= (mll < m_mll_upper && mll > m_mll_lower);
166  }
167  }
168  }
169  }
170  }
171  }
172  }
173 
174  if (m_veto) decision = !decision;
175  m_decoration.setBool(*evtInfo, decision, sys);
176 
177  }
178  return StatusCode::SUCCESS;
179  }
180 }
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:55
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:13
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
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
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:67
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
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
python.PhysicalConstants.mu0
int mu0
Definition: PhysicalConstants.py:96
xAOD::Muon_v1::charge
float charge() const
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonsHandle
CP::SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:52
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_muonsTruthHandle
CP::SysReadHandle< xAOD::TruthParticleContainer > m_muonsTruthHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:64
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:45
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronsHandle
CP::SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:46
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:73
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:85
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronSelection
CP::SysReadSelectionHandle m_electronSelection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:49
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:37
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:794
CP::DileptonOSSFInvariantMassWindowSelectorAlg::execute
virtual StatusCode execute() override
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.cxx:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_electronTruthSelection
CP::SysReadSelectionHandle m_electronTruthSelection
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:61
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:70
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:17
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:76
xAOD::TruthParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TruthParticle_v1.cxx:196
CP::DileptonOSSFInvariantMassWindowSelectorAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
Definition: DileptonOSSFInvariantMassWindowSelectorAlg.h:41
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:58
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