diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/ConeSimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/ConeSimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..4442330bb880b8c0e5fd179bfac466cb1ec42ebf --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/ConeSimSelector.h @@ -0,0 +1,100 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// ConeSimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_CONESIMSELECTOR_H +#define ISF_TOOLS_CONESIMSELECTOR_H 1 + +// ISF includes +#include "ISF_Event/ConeParticleCuts.h" +#include "ISF_Interfaces/ISimulationSelector.h" +#include "ISF_Event/HepMCHelper.h" + +// Framework +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +namespace Trk { + class IExtrapolator; + class ITrackingGeometrySvc; + class TrackingGeometry; + class TrackingVolume; + class PdgToParticleHypothesis; +} + +namespace ISF { + + /** @class ConeSimSelector + + This SimulationSelector implementation registers cones around particles that + are given to the updateInsideSubDet(..) or the updateOutsideSubDet(..) method + and pass certain cuts (pT, pdg, HepMC ancestor). PassSelectorCuts(..) determines + whether the given particle is inside such a cone or not. + + @author Andreas.Salzburger -at- cern.ch , Elmar.Ritsch -at- cern.ch + */ + class ConeSimSelector : public ISimulationSelector, public ConeParticleCuts { + + public: + /** Constructor with parameters */ + ConeSimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~ConeSimSelector(); + + /** Athena AlgTool initialize */ + StatusCode initialize(); + + /** Athena AlgTool finalize */ + StatusCode finalize(); + + /** called at the beginning of each event (used for resetting dynamic selectors) */ + virtual void beginEvent(); + + /** called at the beginning of each event (used for resetting dynamic selectors) */ + virtual void endEvent(); + + /** update internal event representation (create cones in our case)*/ + virtual void update(const ISFParticle& p ); + + /** check whether given particle is within any of the registered cones + -> will be used for routing decision*/ + virtual bool passSelectorCuts(const ISFParticle& particle) const; + + private: + + bool retrieveTrackingGeometry() const; + + std::vector<int> m_absPDGVector; //!< abs(PDG) for particles to create cones around + /** ISFParticle has to have a relative which is in this list to create a cone*/ + bool m_checkRelatives;//!< on/off for checking relatives + std::vector<int> m_relativesVec; //!< Python property + std::set<int> m_relatives; //!< used during runtime (faster) + + /** ISFParticle relation to the given pdg codes */ + int m_relationProp; //!< Python property + HepMC::IteratorRange m_relation; //!< HepMC + + /** tracking geometry for geometry signature */ + mutable const Trk::TrackingGeometry* m_trackingGeometry; //!< the tracking geometry owned by the navigator + ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc; //!< ServiceHandle to the TrackingGeometrySvc + std::string m_trackingGeometryName; //!< default name of the TrackingGeometry + + /** extrapolation to calo entry */ + ToolHandle<Trk::IExtrapolator> m_extrapolator; //!< ToolHandle for track extrapolator + + bool m_extrapolateToCalo; //!< on/off for extrapolating track to CaloEntry prior before building cone + + mutable const Trk::TrackingVolume* m_caloEntrance; + + Trk::PdgToParticleHypothesis* m_pdgToParticleHypothesis; //!< converts PDG ID to hypothesis for TrackParameters + + }; + +} + +#endif //> !ISF_TOOLS_CONESIMSELECTOR_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/DefaultSimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/DefaultSimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..fab66f3bfbfc48e9d41580c44173a31d85846c2b --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/DefaultSimSelector.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// DefaultSimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_DEFAULTSIMFILTER_H +#define ISF_TOOLS_DEFAULTSIMFILTER_H 1 + +// ISF includes +#include "ISF_Interfaces/ISimulationSelector.h" + +namespace ISF { + + /** @class DefaultSimSelector + + This SimlationSelector implementation will select all particles that are handed to it. + ( passFilter() always returns true ) + + @author Elmar.Ritsch -at- cern.ch + */ + class DefaultSimSelector : public ISimulationSelector { + + public: + /** Constructor with parameters */ + DefaultSimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~DefaultSimSelector(); + + // Athena algtool's Hooks + StatusCode initialize(); + StatusCode finalize(); + + /** check whether given particle passes all cuts -> will be used for routing decision*/ + inline virtual bool passSelectorCuts(const ISFParticle& particle) const; + + private: + }; + +} + + +#endif //> !ISF_TOOLS_DEFAULTSIMFILTER_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/HistorySimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/HistorySimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..a5e322f5f575cddbb05862119ebf9c294cf69362 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/HistorySimSelector.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// HistorySimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_PASSPORTSIMSELECTOR_H +#define ISF_TOOLS_PASSPORTSIMSELECTOR_H 1 + +// Framework includes +#include "GaudiKernel/ServiceHandle.h" + +// ISF includes +#include "ISF_Interfaces/ISimulationSelector.h" +#include "ISF_Event/SimSvcID.h" + +namespace ISF { + + // forward declarations + class ISimulationSvc; + + + /** @class HistorySimSelector + + Simplistic simulation selector using the particle's history + + @author Elmar.Ritsch -at- cern.ch + */ + class HistorySimSelector : public ISimulationSelector { + + public: + /** Constructor with parameters */ + HistorySimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~HistorySimSelector(); + + // Athena algtool's Hooks + virtual StatusCode initialize(); + virtual StatusCode finalize(); + + /** called at the beginning of each athena event */ + virtual void beginEvent(); + + /** check whether given particle passes all cuts -> will be used for routing decision*/ + virtual bool passSelectorCuts(const ISFParticle& particle) const; + + private: + /** will check given particles if they were previously simulated by + the SimulationSvc/ID defined in here */ + ServiceHandle<ISF::ISimulationSvc> m_prevSimSvcHandle; //!< SimSvc handle + SimSvcID m_prevSimSvcID; //!< same SimSvc ID + + bool m_checkSameGeoID; //!< check that geoID did not change + }; + +} + +#endif //> !ISF_TOOLS_PASSPORTSIMSELECTOR_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/KinematicSimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/KinematicSimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..1628519251d11ca9df42cf251fafb25aef75b051 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/KinematicSimSelector.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// KinematicSimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_KINEMATICSIMSELECTOR_H +#define ISF_TOOLS_KINEMATICSIMSELECTOR_H 1 + +// ISF includes +#include "ISF_Event/KinematicParticleCuts.h" +#include "ISF_Interfaces/ISimulationSelector.h" + +namespace ISF { + + /** @class KinematicSimSelector + + Simplistic kinematic filter on energy and pseudorapidity. + + @author Elmar.Ritsch -at- cern.ch + */ + class KinematicSimSelector : public ISimulationSelector, public KinematicParticleCuts { + + public: + /** Constructor with parameters */ + KinematicSimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~KinematicSimSelector(); + + // Athena algtool's Hooks + virtual StatusCode initialize(); + virtual StatusCode finalize(); + + /** check whether given particle passes all cuts -> will be used for routing decision*/ + virtual bool passSelectorCuts(const ISFParticle& particle) const; + }; + +} + +#endif //> !ISF_TOOLS_KINEMATICSIMSELECTOR_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/PileupSimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/PileupSimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..810c6a888cc0ed24787224206130e9d68bf82b2c --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/PileupSimSelector.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PileupSimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_PILEUPMUSIMFILTER_H +#define ISF_TOOLS_PILEUPMUSIMFILTER_H 1 + +// ISF includes +#include "ISF_Interfaces/ISimulationSelector.h" + +// Barcode interpretation +#include "BarcodeServices/BitCalculator.h" + +namespace ISF { + + /** @class PileupSimSelector + + This SimlationSelector implementation will select all particles that are handed to it. + ( passFilter() always returns true ) + + @author Elmar.Ritsch -at- cern.ch + */ + class PileupSimSelector : public ISimulationSelector { + + public: + /** Constructor with parameters */ + PileupSimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~PileupSimSelector(); + + // Athena algtool's Hooks + StatusCode initialize(); + StatusCode finalize(); + + /** check whether given particle passes all cuts -> will be used for routing decision*/ + inline virtual bool passSelectorCuts(const ISFParticle& particle) const; + + private: + mutable Barcode::BitCalculator m_bitcalculator; + }; + +} + + +#endif //> !ISF_TOOLS_PILEUPMUSIMFILTER_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/RandomSimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/RandomSimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..33b9d3f6bf7e66da51a1f98778a3c40cb4715cc1 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/RandomSimSelector.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// RandomSimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_RANDOMSIMFILTER_H +#define ISF_TOOLS_RANDOMSIMFILTER_H 1 + +// ISF includes +#include "ISF_Interfaces/ISimulationSelector.h" + +class TRandom; + +namespace ISF { + + /** @class RandomSimSelector + + This SimlationSelector implementation will select all particles that are handed to it. + ( passFilter() always returns true ) + + @author Elmar.Ritsch -at- cern.ch + */ + class RandomSimSelector : public ISimulationSelector { + + public: + /** Constructor with parameters */ + RandomSimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~RandomSimSelector(); + + // Athena algtool's Hooks + StatusCode initialize(); + StatusCode finalize(); + + /** check whether given particle passes all cuts -> will be used for routing decision*/ + inline virtual bool passSelectorCuts(const ISFParticle& particle) const; + + private: + + mutable TRandom* m_random; + }; + +} + + +#endif //> !ISF_TOOLS_RANDOMSIMFILTER_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/TruthAssocSimSelector.h b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/TruthAssocSimSelector.h new file mode 100644 index 0000000000000000000000000000000000000000..570a02aba252ece649665b10767d6616c1a54823 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/ISF_SimulationSelectors/TruthAssocSimSelector.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TruthAssocSimSelector.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ISF_TOOLS_TRUTHASSOCSIMSELECTOR_H +#define ISF_TOOLS_TRUTHASSOCSIMSELECTOR_H 1 + +// STL includes +#include <vector> +#include <set> + +// ISF includes +#include "ISF_Interfaces/ISimulationSelector.h" + +// HepMC includes +#include "HepMC/IteratorRange.h" + +namespace ISF { + + /** @class TruthAssocSimSelector + + SimulationSelector using the TruthAssociation of ISFParticles, eg: + * check on parent particle + * check on production process + + @author Elmar.Ritsch -at- cern.ch + */ + class TruthAssocSimSelector : public ISimulationSelector { + + public: + /** Constructor with parameters */ + TruthAssocSimSelector( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~TruthAssocSimSelector(); + + // Athena algtool's Hooks + virtual StatusCode initialize(); + virtual StatusCode finalize(); + + /** check whether given particle passes all cuts -> will be used for routing decision*/ + virtual bool passSelectorCuts(const ISFParticle& particle) const; + + private: + /** ISFParticle has to have a relative which is in this list */ + std::vector<int> m_relativesVec; //!< Python property + std::set<int> m_relatives; //!< used during runtime (faster) + + + /** ISFParticle relation to the given pdg codes */ + int m_relationProp; //!< Python property + HepMC::IteratorRange m_relation; //!< HepMC + + }; + +} + +#endif //> !ISF_TOOLS_TRUTHASSOCSIMSELECTOR_H diff --git a/Simulation/ISF/ISF_SimulationSelectors/cmt/requirements b/Simulation/ISF/ISF_SimulationSelectors/cmt/requirements new file mode 100644 index 0000000000000000000000000000000000000000..45d46ccde40128bbc5d859d44de50d46e9de4f64 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/cmt/requirements @@ -0,0 +1,39 @@ +package ISF_SimulationSelectors +author <Elmar.Ritsch@cern.ch> + +manager Andreas Salzburger <Andreas.Salzburger@cern.ch> +manager Elmar Ritsch <Elmar.Ritsch@cern.ch> +manager Wolfgang Lukas <Wolfgang.Lukas@cern.ch> + +################################################################# +# public use statements +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use AtlasHepMC AtlasHepMC-* External + +use ISF_Event ISF_Event-* Simulation/ISF/ISF_Core +use ISF_Interfaces ISF_Interfaces-* Simulation/ISF/ISF_Core + +use AtlasROOT AtlasROOT-* External +use BarcodeServices BarcodeServices-* Simulation/Barcode + +################################################################# +# private use statements +private +use ISF_HepMC_Event ISF_HepMC_Event-* Simulation/ISF/ISF_HepMC + +use TrkDetDescrInterfaces TrkDetDescrInterfaces-* Tracking/TrkDetDescr +use TrkExInterfaces TrkExInterfaces-* Tracking/TrkExtrapolation +use TrkEventPrimitives TrkEventPrimitives-* Tracking/TrkEvent +use TrkParameters TrkParameters-* Tracking/TrkEvent +use TrkGeometry TrkGeometry-* Tracking/TrkDetDescr + +public +library ISF_SimulationSelectors *.cxx components/*.cxx +apply_pattern declare_python_modules files="*.py" +apply_pattern component_library + +private +# uncomment the following lines to enable debug symbols in this package: +#macro cppdebugflags '$(cppdebugflags_s)' +#macro_remove componentshr_linkopts "-Wl,-s" diff --git a/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfig.py b/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..a514a80afa942ebd53025511edd47d3fb90d5033 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/python/ISF_SimulationSelectorsConfig.py @@ -0,0 +1,263 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +""" +ISF_SimulationSelectors configurations for ISF +Elmar Ritsch, 04/02/2013 +""" + +from AthenaCommon.CfgGetter import getPrivateTool,getPrivateToolClone,getPublicTool,getPublicToolClone,\ + getService,getServiceClone,getAlgorithm,getAlgorithmClone + +from AthenaCommon.Constants import * # FATAL,ERROR etc. +from AthenaCommon.SystemOfUnits import * +from AthenaCommon.DetFlags import DetFlags + +from ISF_Config.ISF_jobProperties import ISF_Flags # IMPORTANT: Flags must be set before tools are retrieved + +# +# the default SimSelectors +# +def getDefaultSimSelector(name="ISF_DefaultSimSelector", **kwargs): + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__DefaultSimSelector + return ISF__DefaultSimSelector(name, **kwargs ) + +def getPileupSimSelector(name="ISF_PileupSimSelector", **kwargs): + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__PileupSimSelector + return ISF__PileupSimSelector(name, **kwargs ) + +def getRandomSimSelector(name="ISF_RandomSimSelector", **kwargs): + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__RandomSimSelector + return ISF__RandomSimSelector(name, **kwargs ) + +def getDefaultParticleKillerSelector(name="ISF_DefaultParticleKillerSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_ParticleKillerSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getDefaultGeant4Selector(name="ISF_DefaultGeant4Selector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_Geant4SimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getFullGeant4Selector(name="ISF_FullGeant4Selector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FullGeant4SimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getDefaultFastCaloSimSelector(name="ISF_DefaultFastCaloSimSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FastCaloSimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getFastCaloSimPileupSelector(name="ISF_FastCaloSimPileupSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FastCaloSimPileupSvc')) + return getPileupSimSelector(name, **kwargs ) + +def getDefaultLegacyAFIIFastCaloSimSelector(name="ISF_DefaultLegacyAFIIFastCaloSimSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_LegacyAFIIFastCaloSimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getFastHitConvAlgFastCaloSimSelector(name="ISF_FastHitConvAlgFastCaloSimSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FastHitConvAlgFastCaloSimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getFastHitConvAlgLegacyAFIIFastCaloSimSelector(name="ISF_FastHitConvAlgLegacyAFIIFastCaloSimSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FastHitConvAlgLegacyAFIIFastCaloSimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getDefaultFatrasSelector(name="ISF_DefaultFatrasSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FatrasSimSvc')) + return getDefaultSimSelector(name, **kwargs ) + +def getFatrasPileupSelector(name="ISF_FatrasPileupSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FatrasPileupSimSvc')) + return getPileupSimSelector(name, **kwargs ) + +def getFatrasRandomSelector(name="ISF_FatrasRandomSelector", **kwargs): + kwargs.setdefault("Simulator" , getService('ISF_FatrasSimSvc')) + return getRandomSimSelector(name, **kwargs ) + +def getElectronGeant4Selector(name="ISF_ElectronGeant4Selector", **kwargs): + kwargs.setdefault('ParticlePDG' , 11) + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__KinematicSimSelector + return ISF__KinematicSimSelector(name, **kwargs) + +def getNeutralGeant4Selector(name="ISF_NeutralGeant4Selector", **kwargs): + kwargs.setdefault('Charge' , 0) + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__KinematicSimSelector + return ISF__KinematicSimSelector(name, **kwargs) + +def getMuonSelector(name="ISF_MuonSelector", **kwargs): + kwargs.setdefault('ParticlePDG' , 13) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__KinematicSimSelector + return ISF__KinematicSimSelector(name, **kwargs) + +def getMuonGeant4Selector(name="ISF_MuonGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + return getMuonSelector(name, **kwargs) + +def getMuonFatrasSelector(name="ISF_MuonFatrasSelector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_FatrasSimSvc')) + return getMuonSelector(name, **kwargs) + +def getPhotonConeSelector(name="ISF_PhotonConeSelector", **kwargs): + kwargs.setdefault('ConeCreatorPDGs' , [ 22 ] ) # photons + kwargs.setdefault('ConeCreatorMinPt' , 20000. ) # 20 GeV + kwargs.setdefault('ConeSize' , 0.6 ) + kwargs.setdefault('CheckConeCreatorAncestors' , False ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__ConeSimSelector + return ISF__ConeSimSelector(name, **kwargs) + +def getPhotonConeFatrasSelector(name="ISF_PhotonConeFatrasSelector", **kwargs): + kwargs.setdefault('Simulator', getService('ISF_FatrasSimSvc')) + return getPhotonConeSelector(name, **kwargs) + +def getPhotonConeGeant4Selector(name="ISF_PhotonConeGeant4Selector", **kwargs): + kwargs.setdefault('Simulator', getService('ISF_Geant4SimSvc')) + return getPhotonConeSelector(name, **kwargs) + +def getBHadronProductsSimSelector(name="ISF_BHadronProductsSimSelector", **kwargs): + kwargs.setdefault('RelativesPDGCode' , [ 511 , 521 , 531 , 541 , + 5122, 5112, 5132, 5232, + 5212, 5222 ] ) # b hadrons + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('Relation' , 2 ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__TruthAssocSimSelector + return ISF__TruthAssocSimSelector(name, **kwargs) + +def getBHadronProductsGeant4Selector(name="ISF_BHadronProductsGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + return getBHadronProductsSimSelector(name, **kwargs) + +def getBHadronProductsFatrasSelector(name="ISF_BHadronProductsFatrasSelector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_FatrasSimSvc')) + return getBHadronProductsSimSelector(name, **kwargs) + +def getTauProductsSimSelector(name="ISF_TauProductsSimSelector", **kwargs): + kwargs.setdefault('RelativesPDGCode' , [ 15 ] ) # tau + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('Relation' , 0 ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__TruthAssocSimSelector + return ISF__TruthAssocSimSelector(name, **kwargs) + +def getTauProductsGeant4Selector(name="ISF_TauProductsGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + return getTauProductsSimSelector(name, **kwargs) + +def getZProductsSimSelector(name="ISF_ZProductsSimSelector", **kwargs): + kwargs.setdefault('RelativesPDGCode' , [ 23 ] ) # Z + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('Relation' , 0 ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__TruthAssocSimSelector + return ISF__TruthAssocSimSelector(name, **kwargs) + +def getZProductsGeant4Selector(name="ISF_ZProductsGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + return getZProductsSimSelector(name, **kwargs) + +def getHiggsLeptonsConeSimSelector(name="ISF_HiggsLeptonsConeSimSelector", **kwargs): + kwargs.setdefault('ConeCreatorPDGs' , [ 11 , 13 ] ) # e, mu + kwargs.setdefault('ConeCreatorMinPt' , 0. ) + kwargs.setdefault('ConeSize' , 0.4 ) + kwargs.setdefault('CheckConeCreatorAncestors' , True ) + kwargs.setdefault('ConeCreatorAncestor' , [ 24 , 23 ] ) # W , Z + + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('ConeCreatorAncestorRelation' , 1 ) + + + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__ConeSimSelector + return ISF__ConeSimSelector(name, **kwargs) + +def getHiggsLeptonsConeGeant4Selector(name="ISF_HiggsLeptonsConeGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + return getHiggsLeptonsConeSimSelector(name, **kwargs) + +def getElectronsMuonsConeSimSelector(name="ISF_ElectronsMuonsConeSimSelector", **kwargs): + kwargs.setdefault('ConeCreatorPDGs' , [ 11 , 13 ] ) # e, mu + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__ConeSimSelector + return ISF__ConeSimSelector(name, **kwargs) + +def getHiggsLeptonsConeGeant4CaloSelector(name="ISF_HiggsLeptonsConeGeant4CaloSelector", **kwargs): + # set tracking geometry (use Fatras for now) + kwargs.setdefault( 'ExtrapolateToCaloEntry', 1 ) + kwargs.setdefault( "TrackingGeometrySvc", getService("AtlasTrackingGeometrySvc") ) + + atlasExtrapolator = getPublicTool("AtlasExtrapolator") + atlasExtrapolator.ApplyMaterialEffects=False + kwargs.setdefault("Extrapolator" , atlasExtrapolator ) + + return getHiggsLeptonsConeGeant4Selector(name, **kwargs) + +def getWLeptonsConeGeant4Selector(name="ISF_WLeptonsConeGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + kwargs.setdefault('ConeCreatorMinPt' , 0. ) + kwargs.setdefault('ConeSize' , 0.4 ) + kwargs.setdefault('CheckConeCreatorAncestors' , True ) + kwargs.setdefault('ConeCreatorAncestor' , [ 24 ] ) # W + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('ConeCreatorAncestorRelation' , 0 ) + return getElectronsMuonsConeSimSelector(name, **kwargs) + +def getZLeptonsDirectionConeGeant4Selector(name="ISF_ZLeptonsDirectionConeGeant4Selector", **kwargs): + # this selector picks all particles with a mometum direction + # within DeltaR<ConeSize relative to the Z decay leopton directions + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + kwargs.setdefault('ConeCreatorMinPt' , 0. ) + kwargs.setdefault('ConeSize' , 0.4 ) + kwargs.setdefault('CheckConeCreatorAncestors' , True ) + kwargs.setdefault('ConeCreatorAncestor' , [ 23 ] ) # Z + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('ConeCreatorAncestorRelation' , 0 ) + return getElectronsMuonsConeSimSelector(name, **kwargs) + +def getZLeptonsPositionConeGeant4Selector(name="ISF_ZLeptonsPositionConeGeant4Selector", **kwargs): + # this selector picks all particles with a position inside a cone + # around the Z decay leptons directions + kwargs.setdefault('CheckParticlePosition' , True ) + return getZLeptonsDirectionConeGeant4Selector(name, **kwargs) + +def getJPsiLeptonsConeGeant4Selector(name="ISF_JPsiLeptonsConeGeant4Selector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc')) + kwargs.setdefault('ConeCreatorMinPt' , 0. ) + kwargs.setdefault('ConeSize' , 0.4 ) + kwargs.setdefault('CheckConeCreatorAncestors' , True ) + kwargs.setdefault('ConeCreatorAncestor' , [ 443 ] ) # W + # see HepMC manual for HepMC::GenVertex::particle iterator + # 0=parents, 1=family, 2=ancestors, 3=relatives + kwargs.setdefault('ConeCreatorAncestorRelation' , 0 ) + return getElectronsMuonsConeSimSelector(name, **kwargs) + +def getWithinEta5FastCaloSimSelector(name="ISF_WithinEta5FastCaloSimSelector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_FastCaloSimSvc')) + kwargs.setdefault('MinPosEta' , -5.0 ) + kwargs.setdefault('MaxPosEta' , 5.0 ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__KinematicSimSelector + return ISF__KinematicSimSelector(name, **kwargs) + +def getEtaGreater5ParticleKillerSimSelector(name="ISF_EtaGreater5ParticleKillerSimSelector", **kwargs): + kwargs.setdefault('Simulator' , getService('ISF_ParticleKillerSvc')) + kwargs.setdefault('MinPosEta' , -5.0 ) + kwargs.setdefault('MaxPosEta' , 5.0 ) + kwargs.setdefault('InvertCuts' , True ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__KinematicSimSelector + return ISF__KinematicSimSelector(name, **kwargs) + +def getSubDetStickyGeant4SimSelector(name="ISF_SubDetStickyGeant4SimSelector", **kwargs): + kwargs.setdefault('PrevSimSvc' , getService('ISF_Geant4SimSvc') ) + kwargs.setdefault('RequiresUnchangedGeoID' , True ) + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc') ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__HistorySimSelector + return ISF__HistorySimSelector(name, **kwargs) + +def getGlobalStickyGeant4SimSelector(name="ISF_GlobalStickyGeant4SimSelector", **kwargs): + kwargs.setdefault('PrevSimSvc' , getService('ISF_Geant4SimSvc') ) + kwargs.setdefault('RequiresUnchangedGeoID' , False ) + kwargs.setdefault('Simulator' , getService('ISF_Geant4SimSvc') ) + from ISF_SimulationSelectors.ISF_SimulationSelectorsConf import ISF__HistorySimSelector + return ISF__HistorySimSelector(name, **kwargs) + diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..401fb3c15a1f64bd89f3955750f5f34e57ab7422 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/ConeSimSelector.cxx @@ -0,0 +1,294 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// ConeSimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// class include +#include "ISF_SimulationSelectors/ConeSimSelector.h" +// ISF includes +#include "ISF_Event/ISFParticle.h" +#include "ISF_Event/HepMCHelper.h" +#include "ISF_HepMC_Event/HepMC_TruthBinding.h" + +// Trk +#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h" + +#include "TrkExInterfaces/IExtrapolator.h" + +#include "TrkGeometry/TrackingGeometry.h" +#include "TrkParameters/TrackParameters.h" +#include "TrkParameters/TrackParameters.h" +#include "TrkEventPrimitives/PdgToParticleHypothesis.h" + +/** Constructor **/ +ISF::ConeSimSelector::ConeSimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p), + ConeParticleCuts(), + m_absPDGVector(), + m_checkRelatives(false), + m_relativesVec(), + m_relatives(), + m_relationProp(), + m_relation(HepMC::parents), + m_trackingGeometry(0), + m_trackingGeometrySvc("TrackingGeometrySvc/AtlasTrackingGeometrySvc",n), + m_trackingGeometryName("AtlasTrackingGeometry"), + m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), + m_extrapolateToCalo(false), + m_caloEntrance(0), + m_pdgToParticleHypothesis(new Trk::PdgToParticleHypothesis()) +{ + declareInterface<ISF::ISimulationSelector>(this); + + // cone options + declareProperty( "ConeCreatorPDGs", + m_absPDGVector, + "Register cones around particles with this PDG code" ); + declareProperty( "ConeCreatorMinPt", + m_cut_minPt, + "Register cones around particles with this minimum pT" ); + declareProperty( "ConeSize", + m_cut_coneSize2, + "Size of cone around initial particles." ); + declareProperty( "CheckParticlePosition", + m_cut_checkPosition, + "Choose if particle position (or momentum direction) has to be within cone." ); + + + declareProperty( "CheckConeCreatorAncestors", + m_checkRelatives, + "on/off switch to check ancestor particles for cone creation (eg. cone only around e from Z decay)" ); + declareProperty( "ConeCreatorAncestor", + m_relativesVec, + "Only ISFParticles which have specified 'Relation' to the given PDGCode are selected." ); + // as defined in the HepMC manual HepMC::GenVertex::particle iterator + declareProperty( "ConeCreatorAncestorRelation", + m_relationProp, + "Relation to the given PDG codes: 0=parents, 1=family, 2=ancestors, 3=relatives." ); + + declareProperty( "TrackingGeometrySvc", + m_trackingGeometrySvc, + "TrackingGeometrySvc used for track extrapolation" ); + declareProperty( "Extrapolator", + m_extrapolator, + "Extrapolator used for track extrapolation" ); + declareProperty( "ExtrapolateToCaloEntry", + m_extrapolateToCalo, + "Extrapolate particles to calorimeter entry layer and build cone there" ); +} + + +/** Destructor **/ +ISF::ConeSimSelector::~ConeSimSelector() +{ + delete m_pdgToParticleHypothesis; +} + + +// Athena algtool's Hooks +StatusCode ISF::ConeSimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + + // store the square of the cone size (faster comparison) + m_cut_coneSize2 *= m_cut_coneSize2; + // convert std::vector to std::set for faster searching + m_cut_absPdgs.insert( m_absPDGVector.begin(), m_absPDGVector.end() ); + + // check relatives for cone creating particle, in case vector is filled + if ( m_checkRelatives) { + // convert std::vector to std::set for faster searching + m_relatives.insert( m_relativesVec.begin(), m_relativesVec.end() ); + // convert the 'Relation' Python property into a HepMC data type + m_relation = HepMCHelper::convertIteratorRange( m_relationProp); + } + + StatusCode sc = StatusCode::SUCCESS; + + if ( m_extrapolateToCalo ){ + sc = m_extrapolator.retrieve(); + if (sc.isFailure()){ + ATH_MSG_FATAL( "Could not get " << m_extrapolator ); + return StatusCode::FAILURE; + } + } + + ATH_MSG_VERBOSE( "Initialize successful" ); + return sc; +} + + +StatusCode ISF::ConeSimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + + ATH_MSG_VERBOSE("Finalize successful"); + return StatusCode::SUCCESS; +} + + + +void ISF::ConeSimSelector::beginEvent() +{ + ATH_MSG_VERBOSE("beginEvent being called. Resetting the cone container."); + + ConeSimSelector::resetCones(); +} + + +void ISF::ConeSimSelector::endEvent() +{ + ATH_MSG_VERBOSE("endEvent being called."); +} + + +void ISF::ConeSimSelector::update(const ISFParticle& particle) { + + // this method will determine whether or not to create a cone around the given particle + + ATH_MSG_VERBOSE("Checking whether cone will be created around particle: " << particle); + + // check relatives if required + if ( m_checkRelatives ) { + // get the truth binding (as HepMC) + const HepMC_TruthBinding *truth = dynamic_cast<HepMC_TruthBinding*>( particle.truthBinding() ); + + if (truth) { + // get GenParticle from truth binding + const HepMC::GenParticle &genParticle = truth->truthParticle(); + + // test whether any of the pdg codes is found in the genParticle history + const HepMC::GenParticle *relative = HepMCHelper::findRealtiveWithPDG( genParticle, m_relation, m_relatives); + + if (relative) { + ATH_MSG_VERBOSE("Current particle has valid relative particle:" + << " (pdg=" << relative->pdg_id() << "," + << " barcode=" << relative->barcode() << ")." + << " Will now check whether cone cuts apply" ); + } + else { + // cone conditions not fulfilled + return; + } + } // has truth association + } // check relatives + + // do a quick check to see whether passes minimum cuts before extrapolating + bool passes=checkParticle(particle); + double eta=particle.momentum().eta(); + double phi=particle.momentum().phi(); + + if ( passes ) { + ATH_MSG_VERBOSE("Passes minimum cuts"); + + if ( m_extrapolateToCalo ) { + + if( m_extrapolator.empty() ) { + ATH_MSG_ERROR( "Problem with extrapolator!" ); + return; + } + + if ( !m_caloEntrance ) { + if ( !m_trackingGeometry ) { + if ( !retrieveTrackingGeometry() ) { + ATH_MSG_ERROR( "Problem with TrackingGeometrySvc!" ); + return; + } + } + m_caloEntrance = m_trackingGeometry->trackingVolume("InDet::Containers::EntryVolume"); + if (!m_caloEntrance) ATH_MSG_FATAL("Failed to retrieve calo entrance!"); + } + + // create objects from ISFParticle needed for extrapolation + Trk::CurvilinearParameters par(particle.position(),particle.momentum(),particle.charge()); + + int absPdg = abs(particle.pdgCode()); + //bool photon = (absPdg == 22); + //bool geantino = (absPdg == 999); + //bool charged = photon || geantino ? false : (particle.charge()*particle.charge() > 0) ; + + Trk::ParticleHypothesis particleHypo = + m_pdgToParticleHypothesis->convert(particle.pdgCode(),particle.charge()); + if ( absPdg == 999 ) particleHypo = Trk::geantino; + + // extrapolate to calorimeter entry + const Trk::TrackParameters* extrapolatedPars = + m_extrapolator->extrapolateToVolume(par,*m_caloEntrance,Trk::alongMomentum,particleHypo); + + // get momentum from extrapolatedPars + const Amg::Vector3D& extrapolatedMomentum = extrapolatedPars->momentum(); + + // check if passes cuts + passes = ConeParticleCuts::checkAndRegisterCone(particle,extrapolatedMomentum); + eta=extrapolatedMomentum.eta(); + phi=extrapolatedMomentum.phi(); + + ATH_MSG_DEBUG("Initial position: (" + <<particle.position().x()<<"," + <<particle.position().y()<<"," + <<particle.position().z()<<"), final position: (" + <<extrapolatedPars->position().x()<<"," + <<extrapolatedPars->position().y()<<"," + <<extrapolatedPars->position().z()<<")"); + + ATH_MSG_DEBUG("Initial eta/phi: (" + <<particle.momentum().eta()<<"/" + <<particle.momentum().phi()<<"), final eta/phi: (" + <<extrapolatedPars->momentum().eta()<<"/" + <<extrapolatedPars->momentum().phi()<<")"); + + // cleanup + delete extrapolatedPars; + } + else { + passes = ConeParticleCuts::checkAndRegisterCone(particle); + eta=particle.momentum().eta(); + phi=particle.momentum().phi(); + } + + if (passes) { + ATH_MSG_DEBUG("Particle (eta=" << eta << ", " + << " phi=" << phi << "," + << " pdg=" << particle.pdgCode() << "," + << " barcode=" << particle.barcode() << ")" + << " has passed all cuts. A new simulation cone around it has been created"); + } + } + + + if (!passes) { + ATH_MSG_VERBOSE("Particle (eta=" << eta << ", " + << " phi=" << phi << "," + << " pdg=" << particle.pdgCode() << "," + << " barcode=" << particle.barcode() << ")" + << " did not pass all cuts. NO new simulation cone has been created"); + } +} + + +/** check whether given particle passes all cuts -> will be used for routing decision*/ +bool ISF::ConeSimSelector::passSelectorCuts(const ISFParticle& isfpart) const +{ + bool passes = ISF::ConeParticleCuts::insideCone( isfpart ); + return passes; +} + +bool ISF::ConeSimSelector::retrieveTrackingGeometry() const +{ + if ( m_trackingGeometry ) return true; + if ( m_trackingGeometrySvc.empty() ) return false; + MsgStream log(msgSvc(),name()); + StatusCode sc = m_trackingGeometrySvc.retrieve(); + if ( sc.isFailure() ){ + log << MSG::WARNING << " failed to retrieve geometry Svc " << m_trackingGeometrySvc << endreq; + return false; + } + log << MSG::INFO << " geometry Svc " << m_trackingGeometrySvc << " retrieved " << endreq; + + m_trackingGeometry = m_trackingGeometrySvc->trackingGeometry(); + if ( !m_trackingGeometry ) return false; + return true; +} diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/DefaultSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/DefaultSimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9b088df08f96d8eeed1b6a4f5f8c5b9eab9f64c3 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/DefaultSimSelector.cxx @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// DefaultSimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// class include +#include "ISF_SimulationSelectors/DefaultSimSelector.h" +// HepMC includes +#include "ISF_Event/ISFParticle.h" +// Units includes +#include "GaudiKernel/SystemOfUnits.h" + +/** Constructor **/ +ISF::DefaultSimSelector::DefaultSimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p) +{ + declareInterface<ISF::ISimulationSelector>(this); +} + +/** Destructor **/ +ISF::DefaultSimSelector::~DefaultSimSelector() +{ +} + +// Athena algtool's Hooks +StatusCode ISF::DefaultSimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + return StatusCode::SUCCESS; +} + +StatusCode ISF::DefaultSimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + return StatusCode::SUCCESS; +} + +/** check whether given particle passes all cuts -> will be used for routing decision*/ +bool ISF::DefaultSimSelector::passSelectorCuts(const ISFParticle& /*particle*/) const +{ + return true; +} + diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/HistorySimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/HistorySimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b351681337d67a7a7fc3f2d4a3f50d757134aa51 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/HistorySimSelector.cxx @@ -0,0 +1,81 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// HistorySimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// class include +#include "ISF_SimulationSelectors/HistorySimSelector.h" + +// ISF includes +#include "ISF_Event/ISFParticle.h" + +/** Constructor **/ +ISF::HistorySimSelector::HistorySimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p), + m_prevSimSvcHandle("UnspecifiedSimulationService", n), + m_prevSimSvcID(ISF::fUndefinedSimID), + m_checkSameGeoID(false) +{ + declareInterface<ISF::ISimulationSelector>(this); + + declareProperty( "PrevSimSvc", + m_prevSimSvcHandle, + "Check if particle was recently simulated by the given SimSvc." ); + + declareProperty( "RequiresUnchangedGeoID", + m_checkSameGeoID, + "Check if GeoID of particle did not change." ); + +} + +/** Destructor **/ +ISF::HistorySimSelector::~HistorySimSelector() +{ +} + +// Athena algtool's Hooks +StatusCode ISF::HistorySimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + + // retrieve SimulationService + if ( m_prevSimSvcHandle.retrieve().isFailure() ) { + ATH_MSG_FATAL( m_prevSimSvcHandle.propertyName() << ": Failed to retrieve service " << m_prevSimSvcHandle.type()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO( m_prevSimSvcHandle.propertyName() << ": Retrieved service " << m_prevSimSvcHandle.type()); + + ATH_MSG_VERBOSE("Initialize successful"); + return StatusCode::SUCCESS; +} + + +StatusCode ISF::HistorySimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + + ATH_MSG_VERBOSE("Finalize successful"); + return StatusCode::SUCCESS; +} + +void ISF::HistorySimSelector::beginEvent() +{ + // get the simSvcID from the simulation service + if (m_prevSimSvcID==ISF::fUndefinedSimID) { + m_prevSimSvcID = m_prevSimSvcHandle->simSvcID(); + if (m_prevSimSvcID==ISF::fUndefinedSimID) + ATH_MSG_ERROR( m_prevSimSvcHandle.propertyName() << + " does not return a proper SimSvcID! Unable to make valid routing decisions" ); + } +} + +bool ISF::HistorySimSelector::passSelectorCuts(const ISFParticle& particle) const { + // pass selector cuts if particle was previously processed by the given SimSvcID + bool pass = (particle.prevSimID() == m_prevSimSvcID); + if (pass && m_checkSameGeoID) pass = particle.prevGeoID() == particle.nextGeoID(); + + return pass; +} diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/KinematicSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/KinematicSimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4426d9c775ccce37e62a3471d96d1e4ba33d9178 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/KinematicSimSelector.cxx @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// KinematicSimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// class include +#include "ISF_SimulationSelectors/KinematicSimSelector.h" + +/** Constructor **/ +ISF::KinematicSimSelector::KinematicSimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p), + KinematicParticleCuts() +{ + declareInterface<ISF::ISimulationSelector>(this); + + declareProperty("MinPosEta", m_cut_minPosEta , "Minimum Position Pseudorapidity" ); + declareProperty("MaxPosEta", m_cut_maxPosEta , "Maximum Position Pseudorapidity" ); + declareProperty("MinMomEta", m_cut_minMomEta , "Minimum Momentum Pseudorapidity" ); + declareProperty("MaxMomEta", m_cut_maxMomEta , "Maximum Momentum Pseudorapidity" ); + declareProperty("MinMom", m_cut_minMom2 , "Minimum Particle Momentum" ); + declareProperty("MaxMom", m_cut_maxMom2 , "Maximum Particle Moemntum" ); + declareProperty("Charge", m_cut_charge , "Particle Charge" ); + declareProperty("ParticlePDG", m_cut_pdg , "Particle PDG Code" ); +} + +/** Destructor **/ +ISF::KinematicSimSelector::~KinematicSimSelector() +{ +} + +// Athena algtool's Hooks +StatusCode ISF::KinematicSimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + + // compute and store the square of the momentum cuts (faster comparisons) + if ( !(m_cut_minMom2<0.)) m_cut_minMom2 *= m_cut_minMom2; + if ( !(m_cut_maxMom2<0.)) m_cut_maxMom2 *= m_cut_maxMom2; + + return StatusCode::SUCCESS; +} + + +StatusCode ISF::KinematicSimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + return StatusCode::SUCCESS; +} + +bool ISF::KinematicSimSelector::passSelectorCuts(const ISFParticle& particle) const { + return ISF::KinematicParticleCuts::pass(particle); +} diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/PileupSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/PileupSimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ff80a721139a7b0420e8765167d857d03b75bd3a --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/PileupSimSelector.cxx @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PileupSimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// class include +#include "ISF_SimulationSelectors/PileupSimSelector.h" +// HepMC includes +#include "ISF_Event/ISFParticle.h" +// Units includes +#include "GaudiKernel/SystemOfUnits.h" + +/** Constructor **/ +ISF::PileupSimSelector::PileupSimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p) +{ + declareInterface<ISF::ISimulationSelector>(this); +} + +/** Destructor **/ +ISF::PileupSimSelector::~PileupSimSelector() +{ +} + +// Athena algtool's Hooks +StatusCode ISF::PileupSimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + return StatusCode::SUCCESS; +} + +StatusCode ISF::PileupSimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + return StatusCode::SUCCESS; +} + +/** check whether given particle passes all cuts -> will be used for routing decision*/ +bool ISF::PileupSimSelector::passSelectorCuts(const ISFParticle& particle) const +{ + Barcode::ParticleBarcode barcode = particle.barcode(); + + int bcid = m_bitcalculator.GetBCID( barcode ); + + ATH_MSG_VERBOSE( "[fatras pileupselector] barcode = " << barcode << " bcid = " << bcid + << " extra = " << ( particle.getUserInformation()!=0 ? particle.getUserInformation()->getExtraBC() : -1 ) ); + + //if ( bcid!=0 ) { return false; } + + return true; +} + diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/RandomSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/RandomSimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3e53f1635f0d38b1cb5c7c4a3f5a3687ed971c63 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/RandomSimSelector.cxx @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// RandomSimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +// class include +#include "ISF_SimulationSelectors/RandomSimSelector.h" +// HepMC includes +#include "ISF_Event/ISFParticle.h" +// Units includes +#include "GaudiKernel/SystemOfUnits.h" + +#include "TRandom.h" + +/** Constructor **/ +ISF::RandomSimSelector::RandomSimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p), + m_random(0) +{ + declareInterface<ISF::ISimulationSelector>(this); + + m_random = new TRandom(); +} + +/** Destructor **/ +ISF::RandomSimSelector::~RandomSimSelector() +{ + if (m_random!=NULL) delete m_random; +} + +// Athena algtool's Hooks +StatusCode ISF::RandomSimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + return StatusCode::SUCCESS; +} + +StatusCode ISF::RandomSimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + return StatusCode::SUCCESS; +} + +/** check whether given particle passes all cuts -> will be used for routing decision*/ +bool ISF::RandomSimSelector::passSelectorCuts(const ISFParticle& particle) const +{ + bool pass = (m_random->Uniform()<0.5); + + ATH_MSG_VERBOSE("[fatras randomselector] barcode = " << particle.barcode() << " pass = " << pass); + + return pass; +} + diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1603117dfdfceead55261504ea0fadf56bd46768 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/TruthAssocSimSelector.cxx @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TruthAssocSimSelector.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// class include +#include "ISF_SimulationSelectors/TruthAssocSimSelector.h" + +// ISF includes +#include "ISF_Event/ISFParticle.h" +#include "ISF_Event/HepMCHelper.h" +#include "ISF_HepMC_Event/HepMC_TruthBinding.h" + +/** Constructor **/ +ISF::TruthAssocSimSelector::TruthAssocSimSelector(const std::string& t, const std::string& n, const IInterface* p) : + ISimulationSelector(t,n,p), + m_relativesVec(), + m_relatives(), + m_relationProp(0), + m_relation(HepMC::parents) +{ + declareInterface<ISF::ISimulationSelector>(this); + + declareProperty( "RelativesPDGCode", + m_relativesVec, + "Only ISFParticles which have specified 'Relation' to the given PDGCode are selected." ); + + // as defined in the HepMC manual HepMC::GenVertex::particle iterator + declareProperty( "Relation", + m_relationProp, + "Relation to the given PDG codes: 0=parents, 1=family, 2=ancestors, 3=relatives." ); + +} + +/** Destructor **/ +ISF::TruthAssocSimSelector::~TruthAssocSimSelector() +{ +} + +// Athena algtool's Hooks +StatusCode ISF::TruthAssocSimSelector::initialize() +{ + ATH_MSG_VERBOSE("Initializing ..."); + + // convert std::vector to std::set for faster searching + m_relatives.insert( m_relativesVec.begin(), m_relativesVec.end() ); + + // convert the 'Relation' Python property into a HepMC data type + m_relation = HepMCHelper::convertIteratorRange( m_relationProp); + + ATH_MSG_VERBOSE("Initialize successful"); + return StatusCode::SUCCESS; +} + + +StatusCode ISF::TruthAssocSimSelector::finalize() +{ + ATH_MSG_VERBOSE("Finalizing ..."); + + ATH_MSG_VERBOSE("Finalize successful"); + return StatusCode::SUCCESS; +} + + +bool ISF::TruthAssocSimSelector::passSelectorCuts(const ISFParticle& particle) const { + // get the truth binding (as HepMC) + const HepMC_TruthBinding *truth = dynamic_cast<HepMC_TruthBinding*>( particle.truthBinding() ); + if (truth) { + // get GenParticle from truth binding + const HepMC::GenParticle &genParticle = truth->truthParticle(); + + // test whether any of the pdg codes is found in the genParticle history + const HepMC::GenParticle *relative = HepMCHelper::findRealtiveWithPDG( genParticle, m_relation, m_relatives); + + // in case a relative was found + if (relative) { + // some output + ATH_MSG_VERBOSE("Particle (eta=" << particle.momentum().eta() << ", " + << " phi=" << particle.momentum().phi() << "," + << " pdg=" << particle.pdgCode() << "," + << " barcode=" << particle.barcode() << ")" + << " passes due relative particle" + << " (pdg=" << relative->pdg_id() << "," + << " barcode=" << relative->barcode() << ")" ); + // selector cuts passed + return true; + } + } + + // selector cuts not passed + return false; +} + diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/components/ISF_SimulationSelectors_entries.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/components/ISF_SimulationSelectors_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5f42a1b1eaca1570b421eeb3a004f80e666d812e --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/components/ISF_SimulationSelectors_entries.cxx @@ -0,0 +1,27 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" +#include "ISF_SimulationSelectors/DefaultSimSelector.h" +#include "ISF_SimulationSelectors/KinematicSimSelector.h" +#include "ISF_SimulationSelectors/TruthAssocSimSelector.h" +#include "ISF_SimulationSelectors/HistorySimSelector.h" +#include "ISF_SimulationSelectors/ConeSimSelector.h" +#include "ISF_SimulationSelectors/PileupSimSelector.h" +#include "ISF_SimulationSelectors/RandomSimSelector.h" + +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , DefaultSimSelector ) +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , KinematicSimSelector ) +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , TruthAssocSimSelector ) +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , HistorySimSelector ) +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , ConeSimSelector ) +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , PileupSimSelector ) +DECLARE_NAMESPACE_TOOL_FACTORY( ISF , RandomSimSelector ) + +DECLARE_FACTORY_ENTRIES( ISF_SimulationSelectors ) { + DECLARE_NAMESPACE_TOOL( ISF , DefaultSimSelector ) + DECLARE_NAMESPACE_TOOL( ISF , KinematicSimSelector ) + DECLARE_NAMESPACE_TOOL( ISF , TruthAssocSimSelector ) + DECLARE_NAMESPACE_TOOL( ISF , HistorySimSelector ) + DECLARE_NAMESPACE_TOOL( ISF , ConeSimSelector ) + DECLARE_NAMESPACE_TOOL( ISF , PileupSimSelector ) + DECLARE_NAMESPACE_TOOL( ISF , RandomSimSelector ) +} + diff --git a/Simulation/ISF/ISF_SimulationSelectors/src/components/ISF_SimulationSelectors_load.cxx b/Simulation/ISF/ISF_SimulationSelectors/src/components/ISF_SimulationSelectors_load.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9a1b39cff1638598ef12357fbe6bec67acdeb792 --- /dev/null +++ b/Simulation/ISF/ISF_SimulationSelectors/src/components/ISF_SimulationSelectors_load.cxx @@ -0,0 +1,5 @@ + +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES( ISF_SimulationSelectors ) +