ATLAS Offline Software
ZtoLeptonFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 ZtoLeptonFilter::ZtoLeptonFilter(const std::string& name, ISvcLocator* pSvcLocator)
9  : GenFilter(name, pSvcLocator)
10 {
11  declareProperty("Ptcut",m_Ptmin = .0);
12  declareProperty("Etacut",m_EtaRange = 10.0);
13 }
14 
15 
18  for (itr = events()->begin(); itr!=events()->end(); ++itr) {
19  const HepMC::GenEvent* genEvt = (*itr);
20 #ifdef HEPMC3
21  for ( const auto& pitr: genEvt->particles()) {
22  if (MC::isZ(pitr)) {
23  if ( !pitr->end_vertex() && pitr->status()==3) continue; // Allow status 3 Zs with no end vertex
24  else if (!pitr->end_vertex() ){
25  // Found a Z boson with no end vertex and status!=3 . Something is sick about this event
26  break;
27  }
28  // Z children
29  for (const auto& thisChild: pitr->end_vertex()->particles_out()) {
30  if (std::abs(thisChild->pdg_id()) == 11 || std::abs(thisChild->pdg_id()) == 13 || std::abs(thisChild->pdg_id()) == 15) {
31  return StatusCode::SUCCESS;
32  }
33  }
34  }
35  }
36 #else
37  for (HepMC::GenEvent::particle_const_iterator pitr = genEvt->particles_begin(); pitr != genEvt->particles_end(); ++pitr) {
38  if (MC::isZ(*pitr)) {
39  if ( !(*pitr)->end_vertex() && (*pitr)->status()==3) continue; // Allow status 3 Zs with no end vertex
40  else if ( !(*pitr)->end_vertex() ){
41  // Found a Z boson with no end vertex and status!=3 . Something is sick about this event
42  break;
43  }
44  // Z children
45  HepMC::GenVertex::particle_iterator firstChild = (*pitr)->end_vertex()->particles_begin(HepMC::children);
46  HepMC::GenVertex::particle_iterator endChild = (*pitr)->end_vertex()->particles_end(HepMC::children);
47  HepMC::GenVertex::particle_iterator thisChild = firstChild;
48  for (; thisChild != endChild; ++thisChild) {
49  if (std::abs((*thisChild)->pdg_id()) == 11 || std::abs((*thisChild)->pdg_id()) == 13 || std::abs((*thisChild)->pdg_id()) == 15) {
50  return StatusCode::SUCCESS;
51  }
52  }
53  }
54  }
55 #endif
56  }
57  setFilterPassed(false);
58  return StatusCode::SUCCESS;
59 }
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
ZtoLeptonFilter::m_EtaRange
double m_EtaRange
Definition: ZtoLeptonFilter.h:21
ZtoLeptonFilter::ZtoLeptonFilter
ZtoLeptonFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZtoLeptonFilter.cxx:8
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
isZ
bool isZ(const T &p)
Definition: AtlasPID.h:164
ZtoLeptonFilter::m_Ptmin
double m_Ptmin
Definition: ZtoLeptonFilter.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ZtoLeptonFilter::filterEvent
virtual StatusCode filterEvent()
Definition: ZtoLeptonFilter.cxx:16
python.DecayParser.children
children
Definition: DecayParser.py:32
ZtoLeptonFilter.h
HepMCHelpers.h