ATLAS Offline Software
SameParticleHardScatteringFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 SameParticleHardScatteringFilter::SameParticleHardScatteringFilter(const std::string& name, ISvcLocator* pSvcLocator)
8  : GenFilter(name,pSvcLocator)
9 {
10  declareProperty("PDGParent",m_PDGParent);
11  declareProperty("PDGChild", m_PDGChild);
12 }
13 
15  if (m_PDGParent.size() == 0) ATH_MSG_ERROR("PDGParent[] not set ");
16  if (m_PDGChild.size() == 0) ATH_MSG_ERROR("PDGChild[] not set ");
17  for (int i=0; i < int(m_PDGParent.size()); i++) ATH_MSG_DEBUG("PDGParent["<<i<<"] = " << m_PDGParent[i]);
18  for (int i=0; i < int(m_PDGChild.size()); i++) ATH_MSG_DEBUG("PDGChild["<<i<<"] = " << m_PDGChild[i]);
19  return StatusCode::SUCCESS;
20 }
21 
23  ATH_MSG_DEBUG(" SameParticleHardScattering filtering for: Parent --> " << m_PDGParent[0]
24  << " and parent " << -m_PDGParent[0]
25  << ", Child --> " << m_PDGChild[0]);
26  int N_Parent[2];
27  N_Parent[0] = 0;
28  N_Parent[1] = 0;
29 
30  for (const HepMC::GenEvent* genEvt : *events_const()) {
31  for (const auto& pitr: *genEvt)
32  {
33  int id = pitr->pdg_id();
34  if (std::abs(id) != m_PDGChild[0]) continue; // searching for only b-quarks
35 
36  // a pointer to the production vertex
37  const HepMC::ConstGenVertexPtr& productionVtx = pitr->production_vertex();
38 
39  // Verify if we got a valid pointer and retrieve the number of parents
40  if (!productionVtx) continue;
41  // Incoming particle range check
42  if (productionVtx->particles_in_size() < 2) continue; // we are looking for excited tau-leptons produced in b-quark b-antiquark scattering
43 #ifdef HEPMC3
44  for (const auto& thisParent: productionVtx->particles_in()) {
45 #else
46  HepMC::GenVertex::particles_in_const_iterator firstParentIt = productionVtx->particles_in_const_begin();
47  HepMC::GenVertex::particles_in_const_iterator endParentIt = productionVtx->particles_in_const_end();
48  for (HepMC::GenVertex::particles_in_const_iterator thisParentIt = firstParentIt ; thisParentIt != endParentIt; ++thisParentIt) {
49  auto thisParent= *thisParentIt;
50 #endif
51  ATH_MSG_DEBUG(" SelectBQuarkScattering Filter: parent ==> " <<thisParent->pdg_id() << " child ===> " << pitr->pdg_id());
52  if ( thisParent->pdg_id() == m_PDGParent[0] )
53  {
54  N_Parent[0]++;
55  }
56  if ( thisParent->pdg_id() == -m_PDGParent[0] )
57  {
58  N_Parent[1]++;
59  }
60  }
61  }
62  }
63  setFilterPassed(N_Parent[0] >= 1 && N_Parent[1] >= 1);
64  return StatusCode::SUCCESS;
65 }
66 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SameParticleHardScatteringFilter::SameParticleHardScatteringFilter
SameParticleHardScatteringFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SameParticleHardScatteringFilter.cxx:7
GenBase::events_const
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition: GenBase.h:96
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SameParticleHardScatteringFilter.h
SameParticleHardScatteringFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: SameParticleHardScatteringFilter.cxx:14
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SameParticleHardScatteringFilter::m_PDGParent
std::vector< int > m_PDGParent
Definition: SameParticleHardScatteringFilter.h:21
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
SameParticleHardScatteringFilter::m_PDGChild
std::vector< int > m_PDGChild
Definition: SameParticleHardScatteringFilter.h:22
SameParticleHardScatteringFilter::filterEvent
virtual StatusCode filterEvent()
Definition: SameParticleHardScatteringFilter.cxx:22