Commit 4f9c24c9 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'fixes20.08.2020' into 'master'

SameParticleHardScatteringFilter

See merge request atlas/athena!45973
parents bd920bf1 3f51d4ff
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GENERATORFILTERS_SAMEPARTICLEHARDSCATTERINGFILTER_H
#define GENERATORFILTERS_SAMEPARTICLEHARDSCATTERINGFILTER_H
#include "GeneratorModules/GenFilter.h"
/// Allows the user to search for any given production Parent1 + Parent 2 -> Child1
/// @author Krystsina Petukhova, Oct 2020
class SameParticleHardScatteringFilter : public GenFilter {
public:
SameParticleHardScatteringFilter(const std::string& name, ISvcLocator* pSvcLocator);
virtual StatusCode filterInitialize();
virtual StatusCode filterEvent();
private:
std::vector<int> m_PDGParent;
std::vector<int> m_PDGChild;
};
#endif
......@@ -58,11 +58,6 @@ StatusCode ParentTwoChildrenFilter::filterEvent() {
if (n_daughters < 2) continue;
// Check whether decays are part of the requested set
HepMC::GenVertex::particle_iterator firstChild = pitr->end_vertex()->particles_begin(HepMC::children);
HepMC::GenVertex::particle_iterator endChild = pitr->end_vertex()->particles_end(HepMC::children);
HepMC::GenVertex::particle_iterator thisChild = firstChild;
int neutralPar = 0;
for(auto thisChild: *decayVtx) {
ATH_MSG_DEBUG(" ParentTwoChildrenFilter: parent ==> " <<pitr->pdg_id() << " child ===> " <<thisChild->pdg_id());
......
/*
Copyright (C) 2020 CERN for the benefit of the ATLAS collaboration
*/
#include "GeneratorFilters/SameParticleHardScatteringFilter.h"
SameParticleHardScatteringFilter::SameParticleHardScatteringFilter(const std::string& name, ISvcLocator* pSvcLocator)
: GenFilter(name,pSvcLocator)
{
declareProperty("PDGParent",m_PDGParent);
declareProperty("PDGChild", m_PDGChild);
}
StatusCode SameParticleHardScatteringFilter::filterInitialize() {
if (m_PDGParent.size() == 0) ATH_MSG_ERROR("PDGParent[] not set ");
if (m_PDGChild.size() == 0) ATH_MSG_ERROR("PDGChild[] not set ");
for (int i=0; i < int(m_PDGParent.size()); i++) ATH_MSG_DEBUG("PDGParent["<<i<<"] = " << m_PDGParent[i]);
for (int i=0; i < int(m_PDGChild.size()); i++) ATH_MSG_DEBUG("PDGChild["<<i<<"] = " << m_PDGChild[i]);
return StatusCode::SUCCESS;
}
StatusCode SameParticleHardScatteringFilter::filterEvent() {
ATH_MSG_DEBUG(" SameParticleHardScattering filtering for: Parent --> " << m_PDGParent[0]
<< " and parent " << -m_PDGParent[0]
<< ", Child --> " << m_PDGChild[0]);
int N_Parent[2];
N_Parent[0] = 0;
N_Parent[1] = 0;
for (McEventCollection::const_iterator itr = events_const()->begin(); itr!= events_const()->end(); ++itr)
{
const HepMC::GenEvent* genEvt = (*itr);
for (auto pitr: *genEvt)
{
int id = pitr->pdg_id();
if (std::abs(id) != m_PDGChild[0]) continue; // searching for only b-quarks
// a pointer to the production vertex
HepMC::ConstGenVertexPtr productionVtx = pitr->production_vertex();
// Verify if we got a valid pointer and retrieve the number of parents
if (!productionVtx) continue;
// Incoming particle range check
#ifdef HEPMC3
if (productionVtx->particles_in().size() < 2) continue; // we are looking for excited tau-leptons produced in b-quark b-antiquark scattering
for (auto thisParent: productionVtx->particles_in()) {
#else
if (productionVtx->particles_in_size() < 2) continue; // we are looking for excited tau-leptons produced in b-quark b-antiquark scattering
HepMC::GenVertex::particles_in_const_iterator firstParentIt = productionVtx->particles_in_const_begin();
HepMC::GenVertex::particles_in_const_iterator endParentIt = productionVtx->particles_in_const_end();
for (HepMC::GenVertex::particles_in_const_iterator thisParentIt = firstParentIt ; thisParentIt != endParentIt; ++thisParentIt) {
auto thisParent= *thisParentIt;
#endif
ATH_MSG_DEBUG(" SelectBQuarkScattering Filter: parent ==> " <<thisParent->pdg_id() << " child ===> " << pitr->pdg_id());
if ( thisParent->pdg_id() == m_PDGParent[0] )
{
N_Parent[0]++;
}
if ( thisParent->pdg_id() == -m_PDGParent[0] )
{
N_Parent[1]++;
}
}
}
}
setFilterPassed(N_Parent[0] >= 1 && N_Parent[1] >= 1);
return StatusCode::SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment