Skip to content
Snippets Groups Projects
Commit 3c3c1f72 authored by Zach Marshall's avatar Zach Marshall
Browse files

WIP: Adding keep children strategy

The idea of this strategy is as a replacement for !27797

After chatting with John Chapman, we realized that we could set up a
truth strategy that only modifies the keep children setting of the truth
incident. This does *not* modify the decision about the strategy (keep
or throw away the vertex); it only modifies the setting of keep
children. This can be used on top of existing truth strategies to change
their behavior, for example by keeping all the decay products of an LLP
or keeping all the decay products of a hadronic interaction, even in a
mode where they would normally be dropped. Two example configurations
are given.
parent c05b5d89
No related branches found
No related tags found
No related merge requests found
......@@ -205,3 +205,16 @@ def getLLPTruthStrategy(name="ISF_LLPTruthStrategy", **kwargs):
# http://www-geant4.kek.jp/lxr/source//processes/management/include/G4ProcessType.hh
kwargs.setdefault('PassProcessCategory', 9 ) # ==
return CfgMgr.ISF__LLPTruthStrategy(name, **kwargs);
def getKeepLLPDecayChildrenStrategy(name="ISF_KeepLLPDecayChildrenStrategy", **kwargs):
# ProcessCategory==9 corresponds to the 'fUserDefined' G4ProcessType:
# http://www-geant4.kek.jp/lxr/source//processes/management/include/G4ProcessType.hh
kwargs.setdefault('PassProcessCategory' , 9 ) # ==
kwargs.setdefault('VertexTypeRangeLow' , 200) # All kinds of decay processes
kwargs.setdefault('VertexTypeRangeHigh' , 299) # ...
kwargs.setdefault('BSMParent', True)
return CfgMgr.ISF__KeepChildrenTruthStrategy(name, **kwargs);
def getKeepHadronicInteractionChildrenStrategy(name="ISF_KeepHadronicInteractionChildrenStrategy", **kwargs):
kwargs.setdefault('VertexTypes' , [ 111, 121, 131, 141, 151, 161, 210 ])
return CfgMgr.ISF__KeepChildrenTruthStrategy(name, **kwargs);
......@@ -24,3 +24,6 @@ addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getTruthStrategyGroupCaloDecay",
addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getTruthStrategyGroupCaloDecay_MC15", "ISF_MCTruthStrategyGroupCaloDecay_MC15")
addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getValidationTruthStrategy", "ISF_ValidationTruthStrategy")
addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getLLPTruthStrategy", "ISF_LLPTruthStrategy")
# Truth Strategy Modifiers
addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getKeepLLPDecayChildrenStrategy", "ISF_KeepLLPDecayChildrenStrategy")
addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getKeepHadronicInteractionChildrenStrategy", "ISF_KeepHadronicInteractionChildrenStrategy")
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// KeepChildrenTruthStrategy.cxx, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
// class header include
#include "KeepChildrenTruthStrategy.h"
// ISF includes
#include "ISF_Event/ITruthIncident.h"
#include "ISF_Event/ISFParticle.h"
// For BSM helper
#include "TruthUtils/PIDHelpers.h"
/** Constructor **/
ISF::KeepChildrenTruthStrategy::KeepChildrenTruthStrategy(const std::string& t, const std::string& n, const IInterface* p)
: base_class(t,n,p)
, m_vertexTypesVector(0)
, m_vertexTypes()
, m_doVertexRangeCheck(false)
, m_vertexTypeRangeLow(0)
, m_vertexTypeRangeHigh(0)
, m_vertexTypeRangeLength(0)
, m_passProcessCategory(0)
, m_bsmParent(false)
, m_parentPdgCodesVector(0)
, m_parentPdgCodes()
{
// if set to true, kinetic cuts are passed even if only child particles pass them
// (used for special cases such as de-excitation)
declareProperty("VertexTypes" , m_vertexTypesVector );
declareProperty("VertexTypeRangeLow" , m_vertexTypeRangeLow );
declareProperty("VertexTypeRangeHigh" , m_vertexTypeRangeHigh );
declareProperty("PassProcessCategory", m_passProcessCategory=9);
declareProperty("ParentPDGCodes" , m_parentPdgCodesVector );
declareProperty("BSMParent" , m_bsmParent );
}
/** Destructor **/
ISF::KeepChildrenTruthStrategy::~KeepChildrenTruthStrategy()
{
}
// Athena algtool's Hooks
StatusCode ISF::KeepChildrenTruthStrategy::initialize()
{
ATH_MSG_VERBOSE("Initializing ...");
// VertexTypeRanges:
//
// check whether user input makes sense:
if ( m_vertexTypeRangeHigh < m_vertexTypeRangeLow) {
ATH_MSG_ERROR("The given parameter VertexTypeRangeLow is bigger than VertexTypeRangeHigh. ABORT");
return StatusCode::FAILURE;
}
// the length of the given vertex type range
m_vertexTypeRangeLength = unsigned(m_vertexTypeRangeHigh - m_vertexTypeRangeLow) + 1;
// if neither lower now upper range limit given, disable range check
m_doVertexRangeCheck = m_vertexTypeRangeLow && m_vertexTypeRangeHigh;
// fill PDG code std::set used for optimized search
m_parentPdgCodes.insert( m_parentPdgCodesVector.begin(), m_parentPdgCodesVector.end());
// fill vertex type std::set used for optimized search
m_vertexTypes.insert( m_vertexTypesVector.begin(), m_vertexTypesVector.end());
return StatusCode::SUCCESS;
}
bool ISF::KeepChildrenTruthStrategy::pass( ITruthIncident& ti) const {
// check whether parent PDG code matches with any of the given ones
// Could require BSM parents and hit BSM, or give a list and be on the list
// Or require neither and apply to everything
if ( !( (m_bsmParent && MC::PID::isBSM(abs(ti.parentPdgCode()))) || // BSM parent and parent is BSM
(m_parentPdgCodes.size() && m_parentPdgCodes.find(ti.parentPdgCode())==m_parentPdgCodes.end()) || // Explicit list and parent in the list
(!m_bsmParent && !m_parentPdgCodes.size()) ) ){ // Neither BSM parent nor explicit list -- allow all
return false;
}
// vertex type check
// ----
int vxtype = ti.physicsProcessCode();
int processCategory = ti.physicsProcessCategory(); // == G4ProcessType
if ((processCategory!=m_passProcessCategory && m_passProcessCategory!=0) && // Not in the category we were after
(m_doVertexRangeCheck || m_vertexTypes.size()) ){ // Should do the category check
// (part 1) vxtype in given range?: this is a small performance trick (only one comparison operator to check if within range)
// -> exactly equivalent to: m_doVertexRangeCheck && (m_vertexTypeLow<=vxtype) && (vxtype<=m_vertexTypeRangeHigh)
bool vtxTypeRangePassed = m_doVertexRangeCheck && ( unsigned(vxtype-m_vertexTypeRangeLow) < m_vertexTypeRangeLength );
// (part 2) if not in range or range check disabled, check whether vxtype
// std::set contains the given vertex type
if ( (!vtxTypeRangePassed) && (m_vertexTypes.find(vxtype)==m_vertexTypes.end()) ) {
// vxtype not registered -> not passed
return false;
}
}
// all cuts passed. Save all children.
for (unsigned short i=0;i<ti.numberOfChildren();++i){
ti.setChildPassedFilters(i);
}
// This strategy does not cause the *saving* of a vertex -- it only changes the strategy for the children
return false;
}
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// KeepChildrenTruthStrategy.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ISF_TOOLS_KEEPCHILDRENTRUTHSTRATEGY_H
#define ISF_TOOLS_KEEPCHILDRENTRUTHSTRATEGY_H 1
// stl includes
#include <set>
#include <vector>
// Athena includes
#include "AthenaBaseComps/AthAlgTool.h"
// ISF includes
#include "ISF_HepMC_Interfaces/ITruthStrategy.h"
namespace ISF {
typedef std::vector<int> VertexTypesVector;
typedef std::set<int> VertexTypesSet;
typedef std::vector<int> PDGCodesVector;
typedef std::set<int> PDGCodesSet;
/** @class KeepChildrenTruthStrategy
A modifier for the purposes of truth strategies defining cases
in which we should keep all the children of an interaction.
@author Zach.Marshall -at- cern.ch
*/
class KeepChildrenTruthStrategy : public extends<AthAlgTool, ITruthStrategy> {
public:
/** Constructor with parameters */
KeepChildrenTruthStrategy( const std::string& t, const std::string& n, const IInterface* p );
/** Destructor */
~KeepChildrenTruthStrategy();
// Athena algtool's Hooks
StatusCode initialize();
/** true if the ITruthStrategy implementation applies to the given ITruthIncident */
bool pass( ITruthIncident& incident) const;
private:
/** vertex type (physics code) checks */
VertexTypesVector m_vertexTypesVector; //!< Python property
VertexTypesSet m_vertexTypes; //!< optimized for search
bool m_doVertexRangeCheck;
int m_vertexTypeRangeLow;
int m_vertexTypeRangeHigh;
unsigned m_vertexTypeRangeLength;
int m_passProcessCategory;
bool m_bsmParent; //!< Apply to BSM parents
/** PDG code checks */
PDGCodesVector m_parentPdgCodesVector; //!< Python property
PDGCodesSet m_parentPdgCodes; //!< optimized for search
};
}
#endif //> !ISF_TOOLS_KEEPCHILDRENTRUTHSTRATEGY_H
......@@ -9,6 +9,7 @@
#include "../GenParticleSimWhiteList.h"
#include "../LLPTruthStrategy.h"
#include "../ValidationTruthStrategy.h"
#include "../KeepChildrenTruthStrategy.h"
DECLARE_NAMESPACE_TOOL_FACTORY( ISF , CylinderVolumeTruthStrategy )
DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenericTruthStrategy )
......@@ -20,3 +21,4 @@ DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenParticlePositionFilter )
DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenParticleSimWhiteList )
DECLARE_NAMESPACE_TOOL_FACTORY( ISF , LLPTruthStrategy )
DECLARE_NAMESPACE_TOOL_FACTORY( ISF , ValidationTruthStrategy )
DECLARE_NAMESPACE_TOOL_FACTORY( ISF , KeepChildrenTruthStrategy )
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