ATLAS Offline Software
LeptonFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // GeneratorFilters/LeptonFilter
6 //
7 // Allows the user to search for electrons or positrons. Event passes filters if
8 // there is a stable e or mu with p_t and eta in the specified range default is
9 // p_t >= 10 GeV and unlimited eta.
10 //
11 // Authors:
12 // Ian Hinchliffe Dec 2001
13 // Andy Buckley Apr 2009
14 
16 #include <cmath>
18 
19 LeptonFilter::LeptonFilter(const std::string& name, ISvcLocator* pSvcLocator)
20  : GenFilter(name,pSvcLocator)
21 {
22  declareProperty("Ptcut", m_Ptmin = 10000.0);
23  declareProperty("Etacut", m_EtaRange = 10.0);
24  declareProperty("PtcutMax", m_Ptmax = 1e99);
25 }
26 
27 
29  // Loop over all events in McEventCollection and extract the leading lepton pt
30  double leading_lepton_pt = 0;
31 
33  for (itr = events()->begin(); itr != events()->end(); ++itr) {
34  const HepMC::GenEvent* genEvt = *itr;
35 
36  // Loop over all particles in event
37  for (const auto& part: *genEvt) {
38 
39  // We're only interested in stable particles
40  if ( !MC::isStable(part)) continue;
41 
42  // We are specifically looking for electrons (+-11) and muons (+-13)
43  const long pid = part->pdg_id();
44  const long apid = std::abs(pid);
45  if (apid == 11 || apid == 13) {
46  const double pT = part->momentum().perp();
47  const double eta = part->momentum().pseudoRapidity();
48  const std::string pname = ((apid == 11) ? "electron" : "muon");
49  ATH_MSG_DEBUG( "Found " << pname
50  << ": pT, eta = " << pT << ", " << eta );
51 
52  // If we've found a stable electron or muon, check eta and pt
53  if (pT > leading_lepton_pt && std::abs(eta) <= m_EtaRange) {
54  leading_lepton_pt = pT;
55  }
56  }
57  }
58  }
59 
60  ATH_MSG_DEBUG ( "Leading lepton pt = " << leading_lepton_pt << "within |eta| <= " << m_EtaRange);
61 
62  if (leading_lepton_pt < m_Ptmin) {
63  setFilterPassed(false);
64  ATH_MSG_DEBUG( "Fail: no e or mu found "
65  << " with pT >= " << m_Ptmin);
66  } else if (leading_lepton_pt >= m_Ptmax) {
67  setFilterPassed(false);
68  ATH_MSG_DEBUG ( "Fail: high pt lepton veto "
69  << " pT < " << m_Ptmax );
70  } else {
71  setFilterPassed(true);
72  ATH_MSG_DEBUG ( "Within min and max pt cuts " << m_Ptmin << ", "
73  << m_Ptmax );
74  }
75  return StatusCode::SUCCESS;
76 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
LeptonFilter::filterEvent
virtual StatusCode filterEvent()
Do the filtering.
Definition: LeptonFilter.cxx:28
LeptonFilter::m_Ptmax
double m_Ptmax
Definition: LeptonFilter.h:51
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LeptonFilter::LeptonFilter
LeptonFilter(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: LeptonFilter.cxx:19
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LeptonFilter::m_EtaRange
double m_EtaRange
Definition: LeptonFilter.h:54
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
LeptonFilter.h
HepMCHelpers.h
LeptonFilter::m_Ptmin
double m_Ptmin
Definition: LeptonFilter.h:48