ATLAS Offline Software
MLLWindowSelector.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 #include "TopEvent/EventTools.h"
7 
8 namespace top {
9  MLLWindow::MLLWindow(std::string params) :
10  m_cutvalue0(0.),
11  m_cutvalue1(0.) {
12  std::istringstream(params) >> m_cutvalue0 >> m_cutvalue1;
13  }
14 
15  bool MLLWindow::apply(const top::Event& event) const {
16  const xAOD::IParticle* lepton0 = 0;
17  const xAOD::IParticle* lepton1 = 0;
18 
19  if (event.m_electrons.size() == 2) {
20  lepton0 = event.m_electrons[0];
21  lepton1 = event.m_electrons[1];
22  } else if (event.m_muons.size() == 2) {
23  lepton0 = event.m_muons[0];
24  lepton1 = event.m_muons[1];
25  } else {
26  throw std::runtime_error("MLLWindowSelector::apply: Need two same-flavour electrons or muons");
27  }
28 
29  const double mll = top::invariantMass(*lepton0, *lepton1);
30  return mll < m_cutvalue0 || mll > m_cutvalue1;
31  }
32 
34  // If any of the required collections is a nullptr (i.e. has not been
35  // loaded) return false.
36  if (not event.m_electrons
37  or not event.m_muons) {
38  return false;
39  }
40 
41  const xAOD::IParticle* lepton0 = 0;
42  const xAOD::IParticle* lepton1 = 0;
43 
44  if (event.m_electrons->size() == 2) {
45  lepton0 = (*event.m_electrons)[0];
46  lepton1 = (*event.m_electrons)[1];
47  } else if (event.m_muons->size() == 2) {
48  lepton0 = (*event.m_muons)[0];
49  lepton1 = (*event.m_muons)[1];
50  } else {
51  throw std::runtime_error("MLLWindowSelector::applyParticleLevel: Need two same-flavour electrons or muons");
52  }
53 
54  const double mll = top::invariantMass(*lepton0, *lepton1);
55  return mll < m_cutvalue0 || mll > m_cutvalue1;
56  }
57 
58  std::string MLLWindow::name() const {
59  std::stringstream ss;
60  ss << "MLLWIN " << m_cutvalue0 << " " << m_cutvalue1;
61  return ss.str();
62  }
63 }
top::MLLWindow::MLLWindow
MLLWindow(std::string params)
Definition: MLLWindowSelector.cxx:9
top::MLLWindow::applyParticleLevel
bool applyParticleLevel(const top::ParticleLevelEvent &event) const override
This does stuff based on the information in a particle level event.
Definition: MLLWindowSelector.cxx:33
top::MLLWindow::m_cutvalue0
double m_cutvalue0
Definition: MLLWindowSelector.h:24
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::invariantMass
double invariantMass(const xAOD::IParticle &p1, const xAOD::IParticle &p2)
Calculate the invariant mass of two particles.
Definition: EventTools.cxx:48
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
MLLWindowSelector.h
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
top::MLLWindow::apply
bool apply(const top::Event &event) const override
This does stuff based on the information in an event.
Definition: MLLWindowSelector.cxx:15
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
top::MLLWindow::name
std::string name() const override
A human readable name.
Definition: MLLWindowSelector.cxx:58
top::ParticleLevelEvent
Definition: ParticleLevelEvent.h:24
top::MLLWindow::m_cutvalue1
double m_cutvalue1
Definition: MLLWindowSelector.h:25
top::Event
Very simple class to hold event data after reading from a file.
Definition: Event.h:49
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226