ATLAS Offline Software
PhotonFilter.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 // Will pass if there are the specified number of photons with pT and eta in the specified range
8 
9 PhotonFilter::PhotonFilter(const std::string& name, ISvcLocator* pSvcLocator)
10  : GenFilter(name, pSvcLocator)
11 {
12  declareProperty("PtMin", m_Ptmin = 10000.);
13  declareProperty("PtMax", m_Ptmax = 100000000.);
14  declareProperty("EtaCut", m_EtaRange = 2.50);
15  declareProperty("NPhotons", m_NPhotons = 2);
16 
17  // Backward compatibility aliases
18  declareProperty("Ptcut", m_Ptmin = 10000.);
19 }
20 
21 
23  int NPhotons = 0;
24  for (McEventCollection::const_iterator itr = events()->begin(); itr != events()->end(); ++itr) {
25  const HepMC::GenEvent* genEvt = (*itr);
26  for (const auto& pitr: *genEvt) {
27  if (MC::isPhoton(pitr) && MC::isStable(pitr) &&
28  pitr->momentum().perp() >= m_Ptmin &&
29  pitr->momentum().perp() < m_Ptmax &&
30  std::abs(pitr->momentum().pseudoRapidity()) <= m_EtaRange) NPhotons++;
31  }
32  }
33  setFilterPassed(NPhotons >= m_NPhotons);
34  return StatusCode::SUCCESS;
35 }
PhotonFilter::m_Ptmin
double m_Ptmin
Definition: PhotonFilter.h:21
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
PhotonFilter::filterEvent
virtual StatusCode filterEvent()
Definition: PhotonFilter.cxx:22
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PhotonFilter::m_EtaRange
double m_EtaRange
Definition: PhotonFilter.h:23
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
PhotonFilter::PhotonFilter
PhotonFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PhotonFilter.cxx:9
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PhotonFilter::m_Ptmax
double m_Ptmax
Definition: PhotonFilter.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PhotonFilter.h
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition: EgammaxAODHelpers.cxx:21
PhotonFilter::m_NPhotons
int m_NPhotons
Definition: PhotonFilter.h:24
HepMCHelpers.h