Skip to content
Snippets Groups Projects
Commit e8855022 authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'etapttool' into 'main'

Remove the hardcoded filter limits  on the barcode of the vertex

See merge request atlas/athena!67826
parents 1f3b9939 e85bcde0
No related branches found
No related tags found
No related merge requests found
......@@ -26,10 +26,6 @@
#include "AtlasHepMC/Flow.h"
#include "TruthUtils/HepMCHelpers.h"
///////////////////////////////////////////////////////////////////
/// Public methods:
///////////////////////////////////////////////////////////////////
using CLHEP::GeV;
/// Constructors
......@@ -78,11 +74,6 @@ EtaPtFilterTool::EtaPtFilterTool( const std::string& type,
m_outerEtaRegionCuts.declareUpdateHandler( &EtaPtFilterTool::setupOuterEtaRegionCuts,
this );
declareProperty( "MaxHardScatteringVtxBarcode",
m_maxHardScatteringVtxBarcode = 20,
"Property to setup the maximum vertex barcode to look for "
"hard-scattering vertices" );
// switches
declareProperty( "OnlyGenerator",
m_onlyGenerator = false,
......@@ -316,9 +307,7 @@ StatusCode EtaPtFilterTool::addVertex( const HepMC::ConstGenVertexPtr& srcVtx, H
bool isSignalVertex) const
{
if ( 0 == srcVtx || 0 == evt ) {
ATH_MSG_ERROR("In addVertex(vtx,evt) : INVALID pointer given !!" << endmsg
<< " vtx: " << srcVtx << endmsg
<< " evt: " << evt);
ATH_MSG_ERROR("In addVertex(vtx,evt) : INVALID pointer given !!" << endmsg << " vtx: " << srcVtx << endmsg << " evt: " << evt);
return StatusCode::FAILURE;
}
#ifdef HEPMC3
......@@ -440,16 +429,33 @@ StatusCode EtaPtFilterTool::addVertex( const HepMC::ConstGenVertexPtr& srcVtx, H
return StatusCode::SUCCESS;
}
bool EtaPtFilterTool::isPartonVertex( const HepMC::ConstGenVertexPtr& vtx ) const
{
if (!vtx) return false;
#ifdef HEPMC3
for (auto& p: vtx->particles_in()) {
if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
auto pv = p->production_vertex();
if (pv && !isPartonVertex(pv)) return false;
}
for (auto& p: vtx->particles_out()) {
if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
}
#else
for ( auto p = vtx->particles_in_const_begin(), parentEnd = vtx->particles_in_const_end(); p != parentEnd; ++p ) {
if (MC::isHadron(*p)&&!MC::isBeam(*p)) return false;
auto pv = (*p)->production_vertex();
if (pv && !isPartonVertex(pv)) return false;
}
for ( auto p = vtx->particles_out_const_begin(), parentEnd = vtx->particles_out_const_end(); p != parentEnd; ++p ) {
if (MC::isHadron(*p)&&!MC::isBeam(*p)) return false;
}
#endif
return true;
}
bool EtaPtFilterTool::isFromHardScattering( const HepMC::ConstGenVertexPtr& vtx ) const
{
if ( std::abs(HepMC::barcode(vtx)) <= m_maxHardScatteringVtxBarcode.value() &&
m_ppFilter.isAccepted(vtx) &&
! m_showerFilter.isAccepted(vtx) ) {
return true;
} else {
return false;
}
return isPartonVertex(vtx)&&m_ppFilter.isAccepted(vtx) && ! m_showerFilter.isAccepted(vtx);
}
///////////////////////////////////////////////////////////////////
......@@ -503,12 +509,10 @@ StatusCode EtaPtFilterTool::initializeTool()
void EtaPtFilterTool::setupInnerEtaRegionCuts( Gaudi::Details::PropertyBase& /*innerRegion*/ )
{
// nothing to do (yet?)
return;
}
void EtaPtFilterTool::setupOuterEtaRegionCuts( Gaudi::Details::PropertyBase& /*outerRegion*/ )
{
// nothing to do (yet?)
return;
}
......@@ -105,8 +105,7 @@ class EtaPtFilterTool : public TruthParticleFilterBaseTool
bool isAccepted( const HepMC::ConstGenVertexPtr& vtx ) const;
/** Check if a given vertex is the signal process vertex. */
bool isSignalProcessVertex( const HepMC::ConstGenVertexPtr& vtx,
const HepMC::GenEvent* evt );
bool isSignalProcessVertex( const HepMC::ConstGenVertexPtr& vtx, const HepMC::GenEvent* evt );
/** Helper method to copy a given vertex and add it to a GenEvent
*/
......@@ -115,18 +114,8 @@ class EtaPtFilterTool : public TruthParticleFilterBaseTool
ParticleMap_t& pmap,
bool isSignalVertex = false ) const;
/** @brief Helper method to check if this @c HepMC::GenVertex looks
* like the hard-scattering vertex.
* As this information is not stored into the @c HepMC::GenEvent
* we have to rely on some ad-hoc procedure. Moreover, it is a very
* generator-dependent.
* Here is the adopted "solution":
* - check this vertex belongs to the ~20 first vertices. This can
* be configured through @c m_maxHardScatteringVtxBarcode via the
* property "MaxHardScatteringVtxBarcode". Default is 20.
* - check that there are 2 incoming partons. This is done using
* a @c McVtxFilter predicate.
*/
bool isPartonVertex( const HepMC::ConstGenVertexPtr& vtx ) const;
bool isFromHardScattering( const HepMC::ConstGenVertexPtr& vtx ) const;
///////////////////////////////////////////////////////////////////
......@@ -165,15 +154,6 @@ class EtaPtFilterTool : public TruthParticleFilterBaseTool
*/
DoubleArrayProperty m_outerEtaRegionCuts;
/** Property to setup the maximum vertex barcode to look for hard-scattering
* vertices.
* Default is 20.
* Note that you don't want to increase this number by a too big a number
* otherwise the downstream selection of the vertex could pick-up showering
* particles.
*/
IntegerProperty m_maxHardScatteringVtxBarcode;
/** Switch to only include particles from generation and reject particles
* from detector simulation (Geant4)
*/
......
......@@ -30,19 +30,7 @@
VtxBasedFilterTool::VtxBasedFilterTool( const std::string& type,
const std::string& name,
const IInterface* parent ) :
TruthParticleFilterBaseTool( type, name, parent )
{
//
// Property declaration
//
//declareProperty( "Property", m_nProperty );
declareProperty( "MaxHardScatteringVtxBarcode",
m_maxHardScatteringVtxBarcode = 30,
"Property to setup the maximum vertex barcode to look for "
"hard-scattering vertices" );
}
TruthParticleFilterBaseTool( type, name, parent ){}
/// Destructor
///////////////
......@@ -271,12 +259,34 @@ StatusCode VtxBasedFilterTool::addVertex( const HepMC::ConstGenVertexPtr& srcVtx
return StatusCode::SUCCESS;
}
bool
VtxBasedFilterTool::isFromHardScattering( const HepMC::ConstGenVertexPtr& vtx ) const
bool VtxBasedFilterTool::isPartonVertex( const HepMC::ConstGenVertexPtr& vtx ) const
{
if (!vtx) return false;
#ifdef HEPMC3
for (auto& p: vtx->particles_in()) {
if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
auto pv = p->production_vertex();
if (pv && !isPartonVertex(pv)) return false;
}
for (auto& p: vtx->particles_out()) {
if (MC::isHadron(p)&&!MC::isBeam(p)) return false;
}
#else
for ( auto p = vtx->particles_in_const_begin(), parentEnd = vtx->particles_in_const_end(); p != parentEnd; ++p ) {
if (MC::isHadron(*p)&&!MC::isBeam(*p)) return false;
auto pv = (*p)->production_vertex();
if (pv && !isPartonVertex(pv)) return false;
}
for ( auto p = vtx->particles_out_const_begin(), parentEnd = vtx->particles_out_const_end(); p != parentEnd; ++p ) {
if (MC::isHadron(*p)&&!MC::isBeam(*p)) return false;
}
#endif
return true;
}
bool VtxBasedFilterTool::isFromHardScattering( const HepMC::ConstGenVertexPtr& vtx ) const
{
return std::abs(HepMC::barcode(vtx)) <= m_maxHardScatteringVtxBarcode.value() &&
m_ppFilter.isAccepted(vtx) &&
! m_showerFilter.isAccepted(vtx);
return isPartonVertex(vtx) && m_ppFilter.isAccepted(vtx) && ! m_showerFilter.isAccepted(vtx);
}
///////////////////////////////////////////////////////////////////
......
......@@ -99,21 +99,10 @@ class VtxBasedFilterTool : public TruthParticleFilterBaseTool
/** Helper method to copy a given vertex and add it to a GenEvent
*/
StatusCode addVertex( const HepMC::ConstGenVertexPtr& srcVtx,
HepMC::GenEvent* evt ) const;
/** @brief Helper method to check if this @c HepMC::GenVertex looks
* like the hard-scattering vertex.
* As this information is not stored into the @c HepMC::GenEvent
* we have to rely on some ad-hoc procedure. Moreover, it is a very
* generator-dependent.
* Here is the adopted "solution":
* - check this vertex belongs to the ~20 first vertices. This can
* be configured through @c m_maxHardScatteringVtxBarcode via the
* property "MaxHardScatteringVtxBarcode". Default is 20.
* - check that there are 2 incoming partons. This is done using
* a @c McVtxFilter predicate.
*/
StatusCode addVertex( const HepMC::ConstGenVertexPtr& srcVtx, HepMC::GenEvent* evt ) const;
bool isPartonVertex( const HepMC::ConstGenVertexPtr& vtx ) const;
bool isFromHardScattering( const HepMC::ConstGenVertexPtr& vtx ) const;
///////////////////////////////////////////////////////////////////
......@@ -130,15 +119,6 @@ class VtxBasedFilterTool : public TruthParticleFilterBaseTool
///////////////////////////////////////////////////////////////////
protected:
/** Property to setup the maximum vertex barcode to look for hard-scattering
* vertices.
* Default is 20.
* Note that you don't want to increase this number by a too big a number
* otherwise the downstream selection of the vertex could pick-up showering
* particles.
*/
IntegerProperty m_maxHardScatteringVtxBarcode;
/** Predicate to select pp->X vertices where p is a parton (q,g)
* This will select vertices:
* q+q' -> X
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment