ATLAS Offline Software
Public Member Functions | List of all members
top::OSLeptonSelector Class Reference

Keep only events that have at least one opposite sign lepton pair. More...

#include <OSLeptonSelector.h>

Inheritance diagram for top::OSLeptonSelector:
Collaboration diagram for top::OSLeptonSelector:

Public Member Functions

bool apply (const top::Event &event) const override
 This does stuff based on the information in an event. More...
 
bool applyParticleLevel (const top::ParticleLevelEvent &event) const override
 This does stuff based on the information in a particle level event. More...
 
std::string name () const override
 A human readable name. More...
 

Detailed Description

Keep only events that have at least one opposite sign lepton pair.

Try to find at least one lepton (el, mu) with positive charge, and at least one with negative charge.

Definition at line 17 of file OSLeptonSelector.h.

Member Function Documentation

◆ apply()

bool top::OSLeptonSelector::apply ( const top::Event ) const
overridevirtual

This does stuff based on the information in an event.

The idea is that you implement this to return either true or false based on the information held within top::Event. If this returns true then the event is kept. If it returns false then the event is removed.

Parameters
top::EventThe current event.
Returns
true if the event should be kept, false otherwise.

Implements top::EventSelectorBase.

Definition at line 9 of file OSLeptonSelector.cxx.

9  {
10  unsigned int negative_counter = 0;
11  unsigned int positive_counter = 0;
12 
13  for (const auto* const elPtr : event.m_electrons)
14  if (elPtr->charge() > 0) ++positive_counter;
15  else ++negative_counter;
16 
17  for (const auto* const muPtr : event.m_muons)
18  if (muPtr->charge() > 0) ++positive_counter;
19  else ++negative_counter;
20 
21  return positive_counter > 0 && negative_counter > 0;
22  }

◆ applyParticleLevel()

bool top::OSLeptonSelector::applyParticleLevel ( const top::ParticleLevelEvent ) const
overridevirtual

This does stuff based on the information in a particle level event.

The idea is that you implement this to return either true or false, based on the information held within the top::ParticleLevelEvent. If this function returns true, then the event is kept, otherwise it is removed. The function has a default implementation (which returns true) because it is expected that many EventSelector objects do not operate on ParticleLevelEvent objects.

Parameters
top::ParticleLevelEventthe current particle level event.
trueif the event should be kept (i.e. it passed the selector criteria), false otherwise.

Reimplemented from top::EventSelectorBase.

Definition at line 24 of file OSLeptonSelector.cxx.

24  {
25  // If any of the required collections is a nullptr (i.e. has not been
26  // loaded) return false.
27  if (not event.m_electrons
28  or not event.m_muons) {
29  return false;
30  }
31 
32  unsigned int negative_counter = 0;
33  unsigned int positive_counter = 0;
34 
35  for (const auto elPtr : *event.m_electrons)
36  if (elPtr->charge() > 0) ++positive_counter;
37  else ++negative_counter;
38 
39  for (const auto muPtr : *event.m_muons)
40  if (muPtr->charge() > 0) ++positive_counter;
41  else ++negative_counter;
42 
43  return positive_counter > 0 && negative_counter > 0;
44  }

◆ name()

std::string top::OSLeptonSelector::name ( ) const
overridevirtual

A human readable name.

Mostly used for printing the cut and value to the screen. Must be implemented for each tool.

Implements top::EventSelectorBase.

Definition at line 46 of file OSLeptonSelector.cxx.

46  {
47  return "OS";
48  }

The documentation for this class was generated from the following files:
event
POOL::TEvent event(POOL::TEvent::kClassAccess)