ATLAS Offline Software
ParticleFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Allows the user to search for particles with specified kinematics.
6 // It will pass if there is an particle with pT and eta or E in the specified range
8 
9 ParticleFilter::ParticleFilter(const std::string& name, ISvcLocator* pSvcLocator)
10  : GenFilter(name, pSvcLocator)
11 {
12 }
13 
14 
16  ATH_MSG_INFO("Ptcut=" << m_Ptmin);
17  ATH_MSG_INFO("Etacut=" << m_EtaRange);
18  ATH_MSG_INFO("Energycut=" << m_EnergyRange);
19  ATH_MSG_INFO("PDG=" << m_PDGID);
20  ATH_MSG_INFO("MinParts=" << m_MinParts);
21  ATH_MSG_INFO("Exclusive=" << m_Exclusive);
22  return StatusCode::SUCCESS;
23 }
24 
25 
27  int nParts = 0;
28  for (McEventCollection::const_iterator itr = events()->begin(); itr != events()->end(); ++itr) {
29  const HepMC::GenEvent* genEvt = (*itr);
30  for (const auto& pitr: *genEvt) {
31  if (std::abs(pitr->pdg_id()) != m_PDGID ) continue;
32  if (pitr->momentum().perp() >= m_Ptmin && std::abs(pitr->momentum().pseudoRapidity()) <= m_EtaRange && pitr->momentum().e() <= m_EnergyRange) {
33  if ((!m_Exclusive)&&(m_MinParts == 1)) return StatusCode::SUCCESS; // Found at least one particle and we have an inclusive requirement
34 
35  // Count only particles not decaying to themselves
36  bool notSelfDecay = true;
37  if (pitr->end_vertex()) {
38  for (const auto& child: *(pitr->end_vertex())) {
39  if ( child->pdg_id() != pitr->pdg_id()) continue;
40  if ( child == pitr) continue;
41  if ( HepMC::is_simulation_particle(child)) continue;
42  notSelfDecay = false;
43  break;
44  }
45  }
46  if (notSelfDecay) nParts++;
47  }
48  }
49  }
50  if (m_Exclusive)
51  {setFilterPassed(nParts == m_MinParts);}
52  else
53  {setFilterPassed(nParts >= m_MinParts);}
54  return StatusCode::SUCCESS;
55 }
ParticleFilter::m_EnergyRange
Gaudi::Property< double > m_EnergyRange
Definition: ParticleFilter.h:25
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
ParticleFilter::ParticleFilter
ParticleFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ParticleFilter.cxx:9
ParticleFilter::m_Ptmin
Gaudi::Property< double > m_Ptmin
Definition: ParticleFilter.h:23
ParticleFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: ParticleFilter.cxx:15
ParticleFilter::m_EtaRange
Gaudi::Property< double > m_EtaRange
Definition: ParticleFilter.h:24
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:299
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ParticleFilter::m_Exclusive
Gaudi::Property< bool > m_Exclusive
Definition: ParticleFilter.h:28
ParticleFilter::m_MinParts
Gaudi::Property< int > m_MinParts
Definition: ParticleFilter.h:27
ParticleFilter::m_PDGID
Gaudi::Property< int > m_PDGID
Definition: ParticleFilter.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ParticleFilter.h
ParticleFilter::filterEvent
virtual StatusCode filterEvent()
Definition: ParticleFilter.cxx:26