diff --git a/Generators/GeneratorFilters/GeneratorFilters/xAODMultiMuonFilter.h b/Generators/GeneratorFilters/GeneratorFilters/xAODMultiMuonFilter.h index 3fce960fb74059d61c88331273a386544d6ac01f..074e7ee35b24229e77d60e337bda94a43994710e 100644 --- a/Generators/GeneratorFilters/GeneratorFilters/xAODMultiMuonFilter.h +++ b/Generators/GeneratorFilters/GeneratorFilters/xAODMultiMuonFilter.h @@ -6,24 +6,24 @@ #define GENERATORFILTERS_XAODMULTIMUONFILTER_H #include "GeneratorModules/GenFilter.h" -#include "xAODTruth/TruthParticle.h" +#include "xAODTruth/TruthParticleContainer.h" /// Filters and looks for muons /// @author I Hinchliffe, December 2001 /// @author G. Watts, Sep 2006 class xAODMultiMuonFilter : public GenFilter { public: + using GenFilter::GenFilter; - xAODMultiMuonFilter(const std::string& name, ISvcLocator* pSvcLocator); - virtual StatusCode filterInitialize(); - virtual StatusCode filterEvent(); + virtual StatusCode filterInitialize() override final; + virtual StatusCode filterEvent() override final; private: SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthMuons"}; - DoubleProperty m_Ptmin{this, "Ptcut", 10000.}; - DoubleProperty m_EtaRange{this, "Etacut", 10.0}; - IntegerProperty m_NMuons{this, "NMuons", 2}; + Gaudi::Property<double> m_Ptmin{this, "Ptcut", 10000.}; + Gaudi::Property<double> m_EtaRange{this, "Etacut", 10.0}; + Gaudi::Property<int> m_NMuons{this, "NMuons", 2}; }; diff --git a/Generators/GeneratorFilters/GeneratorFilters/xAODMuonFilter.h b/Generators/GeneratorFilters/GeneratorFilters/xAODMuonFilter.h index 74e35984936c6b554a31b778b82e2e7d9bdea617..60d062b463f9a2fd80f5ee3f06aa119e5a1264cd 100644 --- a/Generators/GeneratorFilters/GeneratorFilters/xAODMuonFilter.h +++ b/Generators/GeneratorFilters/GeneratorFilters/xAODMuonFilter.h @@ -6,22 +6,22 @@ #define GENERATORFILTERS_XAODMUONFILTER_H #include "GeneratorModules/GenFilter.h" -#include "xAODTruth/TruthParticle.h" +#include "xAODTruth/TruthParticleContainer.h" /// Filters and looks for muons /// @author I Hinchliffe, December 2001 /// @author G. Watts, Sep 2006 class xAODMuonFilter : public GenFilter { public: + using GenFilter::GenFilter; - xAODMuonFilter(const std::string& name, ISvcLocator* pSvcLocator); - virtual StatusCode filterInitialize(); - virtual StatusCode filterEvent(); + virtual StatusCode filterInitialize() override final; + virtual StatusCode filterEvent() override final; private: SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthMuons"}; - DoubleProperty m_Ptmin{this, "Ptcut", 10000.}; - DoubleProperty m_EtaRange{this, "Etacut", 10.0}; + Gaudi::Property<double> m_Ptmin{this, "Ptcut", 10000.}; + Gaudi::Property<double> m_EtaRange{this, "Etacut", 10.0}; }; diff --git a/Generators/GeneratorFilters/GeneratorFilters/xAODParentChildFilter.h b/Generators/GeneratorFilters/GeneratorFilters/xAODParentChildFilter.h index 826db1c0c9e2dac6cce0b3183a0c574ffc52ce82..e652b9e8779f0cbed0d5ecf1e32163b6e2dfe664 100644 --- a/Generators/GeneratorFilters/GeneratorFilters/xAODParentChildFilter.h +++ b/Generators/GeneratorFilters/GeneratorFilters/xAODParentChildFilter.h @@ -5,20 +5,16 @@ #define GENERATORFILTERSXAODPARENTCHILDFILTER_H #include "GeneratorModules/GenFilter.h" -#include "xAODTruth/TruthParticle.h" #include "xAODTruth/TruthParticleContainer.h" -#include "xAODTruth/TruthParticleAuxContainer.h" -#include "xAODTruth/TruthEvent.h" -#include "xAODTruth/TruthEventContainer.h" /// Allows the user to search for any given decay Parent -> Child + X /// @author B K Gjelsten, March 2006 class xAODParentChildFilter : public GenFilter { public: + using GenFilter::GenFilter; - xAODParentChildFilter(const std::string& name, ISvcLocator* pSvcLocator); - virtual StatusCode filterInitialize(); - virtual StatusCode filterEvent(); + virtual StatusCode filterInitialize() override final; + virtual StatusCode filterEvent() override final; private: diff --git a/Generators/GeneratorFilters/GeneratorFilters/xAODParentTwoChildrenFilter.h b/Generators/GeneratorFilters/GeneratorFilters/xAODParentTwoChildrenFilter.h index 81f26dc1c0df7a58060694a5c2a37f101cdf2abd..e9bbe91e02aabaa516c91c2d09b8c8f76049e7b3 100644 --- a/Generators/GeneratorFilters/GeneratorFilters/xAODParentTwoChildrenFilter.h +++ b/Generators/GeneratorFilters/GeneratorFilters/xAODParentTwoChildrenFilter.h @@ -6,31 +6,26 @@ #define GENERATORFILTERS_XAODPARENTTWOCHILDRENFILTER_H #include "GeneratorModules/GenFilter.h" -#include "xAODTruth/TruthParticle.h" #include "xAODTruth/TruthParticleContainer.h" -#include "xAODTruth/TruthParticleAuxContainer.h" -#include "xAODTruth/TruthVertexContainer.h" -#include "xAODTruth/TruthEvent.h" -#include "xAODTruth/TruthEventContainer.h" /// Allows the user to search for any given decay Parent -> Child1 + anti(Child1) AND Parent -> Child2 + anti(Child2)... /// @author Chaouki Boulahouache, Oct 2008 class xAODParentTwoChildrenFilter : public GenFilter { public: + using GenFilter::GenFilter; - xAODParentTwoChildrenFilter(const std::string& name, ISvcLocator* pSvcLocator); - virtual StatusCode filterInitialize(); - virtual StatusCode filterEvent(); + virtual StatusCode filterInitialize() override final; + virtual StatusCode filterEvent() override final; private: - SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthGen"}; - Gaudi::Property<double> m_PtMinParent{this,"PtMinParent",0.,"Min parent Pt"}; - Gaudi::Property<std::vector<int>> m_PDGParent{this,"PDGParent",0,"PDG ID of parents"}; - Gaudi::Property<double> m_EtaRangeParent{this,"EtaRangeParent",10.0,"Parent eta range"}; - Gaudi::Property<std::vector<int>> m_PDGChild{this,"PDGChild",0,"PDG ID of child"}; - Gaudi::Property<double> m_PtMinChild{this,"PtMinChild",0.,"Min child Pt"}; - Gaudi::Property<double> m_EtaRangeChild{this,"EtaRangeChild",0.,"Child eta range"}; + SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthGen"}; + Gaudi::Property<double> m_PtMinParent{this,"PtMinParent",0.,"Min parent Pt"}; + Gaudi::Property<std::vector<int>> m_PDGParent{this,"PDGParent",0,"PDG ID of parents"}; + Gaudi::Property<double> m_EtaRangeParent{this,"EtaRangeParent",10.0,"Parent eta range"}; + Gaudi::Property<std::vector<int>> m_PDGChild{this,"PDGChild",0,"PDG ID of child"}; + Gaudi::Property<double> m_PtMinChild{this,"PtMinChild",0.,"Min child Pt"}; + Gaudi::Property<double> m_EtaRangeChild{this,"EtaRangeChild",0.,"Child eta range"}; }; diff --git a/Generators/GeneratorFilters/GeneratorFilters/xAODParticleDecayFilter.h b/Generators/GeneratorFilters/GeneratorFilters/xAODParticleDecayFilter.h index 15649e3cf52baf531e701b8a1a46e8bfe4df53af..38cccb357b25f914c3bbc4ce4595b61188db026d 100644 --- a/Generators/GeneratorFilters/GeneratorFilters/xAODParticleDecayFilter.h +++ b/Generators/GeneratorFilters/GeneratorFilters/xAODParticleDecayFilter.h @@ -1,43 +1,42 @@ /* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ - + #ifndef XAODxAODParticleDecayFILTER_H #define XAODxAODParticleDecayFILTER_H #include "GeneratorModules/GenFilter.h" -#include "xAODTruth/TruthEventContainer.h" - -/** -Class to filter events based on the decay of a parent particle into a set of children particles. -User specifies the parent particle pdg ID and a list of children particle pdg IDs to filter on. -It was designed with the single particle gun generator in mind, but should in principle -work in any sample. -It has been tested, when generating 10k events, to give filter efficiencies consistent with -the expected branching ratios from the PDG in the cases of w(782)->pi+pi-pi0, w(782)->pi0 + gamma +#include "xAODTruth/TruthParticleContainer.h" + +/** + Class to filter events based on the decay of a parent particle into a set of children particles. + User specifies the parent particle pdg ID and a list of children particle pdg IDs to filter on. + It was designed with the single particle gun generator in mind, but should in principle + work in any sample. + It has been tested, when generating 10k events, to give filter efficiencies consistent with + the expected branching ratios from the PDG in the cases of w(782)->pi+pi-pi0, w(782)->pi0 + gamma */ class xAODParticleDecayFilter : public GenFilter { public: + using GenFilter::GenFilter; - xAODParticleDecayFilter(const std::string& name, ISvcLocator* pSvcLocator); - StatusCode filterInitialize() override; - StatusCode filterFinalize() override; - StatusCode filterEvent() override; + virtual StatusCode filterInitialize() override final; + virtual StatusCode filterEvent() override final; private: -SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthGen"}; + SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthGen"}; -/** Particle ID of parent particle */ -Gaudi::Property<unsigned int> m_pdgIdParent{this,"ParentPdgId",0,"Particle ID of parent particle"}; + /** Particle ID of parent particle */ + Gaudi::Property<unsigned int> m_pdgIdParent{this,"ParentPdgId",0,"Particle ID of parent particle"}; -/** Particle IDs of children of parent particle */ -Gaudi::Property<std::vector<int> > m_pdgIdChildren{this,"ChildrenPdgIds",std::vector<int>(),"Particle IDs of children of parent particle"}; + /** Particle IDs of children of parent particle */ + Gaudi::Property<std::vector<int> > m_pdgIdChildren{this,"ChildrenPdgIds",std::vector<int>(),"Particle IDs of children of parent particle"}; -/** Toggle whether we check the charge of children particles */ -Gaudi::Property<bool> m_checkCharge{this,"CheckCharge",true,"Toggle whether we check the charge of children particles"}; + /** Toggle whether we check the charge of children particles */ + Gaudi::Property<bool> m_checkCharge{this,"CheckCharge",true,"Toggle whether we check the charge of children particles"}; }; #endif diff --git a/Generators/GeneratorFilters/src/xAODMultiMuonFilter.cxx b/Generators/GeneratorFilters/src/xAODMultiMuonFilter.cxx index 1a3bf9e23ce1ce8a5a11bad08d8e6cae1099b7d0..c5e332a1fcea9fb1c8119ef4b67835e32e430b57 100644 --- a/Generators/GeneratorFilters/src/xAODMultiMuonFilter.cxx +++ b/Generators/GeneratorFilters/src/xAODMultiMuonFilter.cxx @@ -3,31 +3,19 @@ */ #include "GeneratorFilters/xAODMultiMuonFilter.h" -#include "xAODTruth/TruthParticle.h" -#include "xAODTruth/TruthParticleContainer.h" -#include "xAODTruth/TruthParticleAuxContainer.h" #include "TruthUtils/HepMCHelpers.h" -xAODMultiMuonFilter::xAODMultiMuonFilter(const std::string& name, ISvcLocator* pSvcLocator) - : GenFilter(name,pSvcLocator) -{ -} - - StatusCode xAODMultiMuonFilter::filterInitialize() { - ATH_CHECK(m_truthPartContKey.initialize()); + CHECK(m_truthPartContKey.initialize()); return StatusCode::SUCCESS; } -StatusCode xAODMultiMuonFilter::filterEvent() { +StatusCode xAODMultiMuonFilter::filterEvent() { // Retrieve TruthMuons container SG::ReadHandle<xAOD::TruthParticleContainer> xTruthParticleContainer{m_truthPartContKey}; - if (!xTruthParticleContainer.isValid()) { - ATH_MSG_ERROR("No TruthParticle collection with name " << m_truthPartContKey.key() << " found in StoreGate!"); - return StatusCode::FAILURE; - } + CHECK(xTruthParticleContainer.isValid()); int numMuons = 0; for (const xAOD::TruthParticle* part : *xTruthParticleContainer) { if (MC::isStable(part) && MC::isMuon(part)) //muon diff --git a/Generators/GeneratorFilters/src/xAODMuonFilter.cxx b/Generators/GeneratorFilters/src/xAODMuonFilter.cxx index 164652278913692803636e16940eb966b6650455..17d60fd43a23bd72216486c42c4d98ff4814ada4 100644 --- a/Generators/GeneratorFilters/src/xAODMuonFilter.cxx +++ b/Generators/GeneratorFilters/src/xAODMuonFilter.cxx @@ -3,31 +3,18 @@ */ #include "GeneratorFilters/xAODMuonFilter.h" -#include "xAODTruth/TruthParticle.h" -#include "xAODTruth/TruthParticleContainer.h" -#include "xAODTruth/TruthParticleAuxContainer.h" #include "TruthUtils/HepMCHelpers.h" -xAODMuonFilter::xAODMuonFilter(const std::string& name, ISvcLocator* pSvcLocator) - : GenFilter(name,pSvcLocator) -{ -} - - StatusCode xAODMuonFilter::filterInitialize() { - ATH_CHECK(m_truthPartContKey.initialize()); + CHECK(m_truthPartContKey.initialize()); return StatusCode::SUCCESS; } - StatusCode xAODMuonFilter::filterEvent() { // Retrieve TruthMuons container SG::ReadHandle<xAOD::TruthParticleContainer> xTruthParticleContainer{m_truthPartContKey}; - if (!xTruthParticleContainer.isValid()) { - ATH_MSG_ERROR("No TruthParticle collection with name " << m_truthPartContKey.key() << " found in StoreGate!"); - return StatusCode::FAILURE; - } + CHECK(xTruthParticleContainer.isValid()); for (const xAOD::TruthParticle* part : *xTruthParticleContainer) { if (MC::isStable(part) && MC::isMuon(part)) //muon diff --git a/Generators/GeneratorFilters/src/xAODParentChildFilter.cxx b/Generators/GeneratorFilters/src/xAODParentChildFilter.cxx index 56d19adb264cb1e973c2bf163808f13bcfd1fba7..07d2a0cacda0592373b4b5dff1fff788d524aab1 100644 --- a/Generators/GeneratorFilters/src/xAODParentChildFilter.cxx +++ b/Generators/GeneratorFilters/src/xAODParentChildFilter.cxx @@ -3,16 +3,10 @@ */ #include "GeneratorFilters/xAODParentChildFilter.h" - -xAODParentChildFilter::xAODParentChildFilter(const std::string& name, ISvcLocator* pSvcLocator) - : GenFilter(name,pSvcLocator) -{ - -} - +#include "xAODTruth/TruthVertex.h" StatusCode xAODParentChildFilter::filterInitialize() { - ATH_CHECK(m_truthPartContKey.initialize()); + CHECK(m_truthPartContKey.initialize()); 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_INFO("PDGParent["<<i<<"] = " << m_PDGParent[i]); @@ -29,14 +23,11 @@ StatusCode xAODParentChildFilter::filterInitialize() { StatusCode xAODParentChildFilter::filterEvent() { - + // Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and // duplicated barcode ones SG::ReadHandle<xAOD::TruthParticleContainer> xTruthParticleContainer{m_truthPartContKey}; - if (!xTruthParticleContainer.isValid()) { - ATH_MSG_ERROR("No TruthParticle collection with name " << m_truthPartContKey.key() << " found in StoreGate!"); - return StatusCode::FAILURE; - } + CHECK(xTruthParticleContainer.isValid()); // Loop over all particles in the event and build up the grid for (const xAOD::TruthParticle* pitr : *xTruthParticleContainer) { @@ -48,16 +39,16 @@ StatusCode xAODParentChildFilter::filterEvent() { && (pitr->m() >= m_MassMinParent) && (pitr->m() < m_MassMaxParent) && std::abs(pitr->eta()) < m_EtaRangeParent)) { - + // Check if has end_vertex (skips initial protons) if (!pitr->decayVtx()) continue; - + const xAOD::TruthVertex* decayVertex = pitr->decayVtx(); int num_outgoing_particles = decayVertex->nOutgoingParticles(); for (int iOutPart = 0; iOutPart< num_outgoing_particles; iOutPart++) { - const xAOD::TruthParticle* thisChild = decayVertex->outgoingParticle(iOutPart); - int okPDGChild = 0; + const xAOD::TruthParticle* thisChild = decayVertex->outgoingParticle(iOutPart); + int okPDGChild = 0; for (int i=0; i < int(m_PDGChild.size()); i++) if (std::abs(thisChild->pdgId()) == m_PDGChild[i]) okPDGChild=1; if ( thisChild->pdgId() != pitr->pdgId() && (m_PDGChild[0] == 0 || okPDGChild) @@ -68,7 +59,7 @@ StatusCode xAODParentChildFilter::filterEvent() { } } }// TruthParticles loop - + setFilterPassed(false); return StatusCode::SUCCESS; } diff --git a/Generators/GeneratorFilters/src/xAODParentTwoChildrenFilter.cxx b/Generators/GeneratorFilters/src/xAODParentTwoChildrenFilter.cxx index 7e3af5d499e6e03b3c18310afbda6a34ec056571..363a8a65ba26fe20466ec032df810cdbee6fff51 100644 --- a/Generators/GeneratorFilters/src/xAODParentTwoChildrenFilter.cxx +++ b/Generators/GeneratorFilters/src/xAODParentTwoChildrenFilter.cxx @@ -5,17 +5,10 @@ #include "GeneratorFilters/xAODParentTwoChildrenFilter.h" #include "TruthUtils/HepMCHelpers.h" #include "CxxUtils/BasicTypes.h" -#include "xAODTruth/TruthVertexContainer.h" - -xAODParentTwoChildrenFilter::xAODParentTwoChildrenFilter(const std::string& name, ISvcLocator* pSvcLocator) - : GenFilter(name,pSvcLocator) -{ - -} - +#include "xAODTruth/TruthVertex.h" StatusCode xAODParentTwoChildrenFilter::filterInitialize() { - ATH_CHECK(m_truthPartContKey.initialize()); + CHECK(m_truthPartContKey.initialize()); 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]); @@ -41,10 +34,7 @@ StatusCode xAODParentTwoChildrenFilter::filterEvent() { // Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and // duplicated barcode ones SG::ReadHandle<xAOD::TruthParticleContainer> xTruthParticleContainer{m_truthPartContKey}; - if (!xTruthParticleContainer.isValid()) { - ATH_MSG_ERROR("No TruthParticle collection with name " << m_truthPartContKey.key() << " found in StoreGate!"); - return StatusCode::FAILURE; - } + CHECK(xTruthParticleContainer.isValid()); // Loop over all particles in the event and build up the grid for (const xAOD::TruthParticle* pitr : *xTruthParticleContainer) { diff --git a/Generators/GeneratorFilters/src/xAODParticleDecayFilter.cxx b/Generators/GeneratorFilters/src/xAODParticleDecayFilter.cxx index d4fc1698fa11ac6f0f4e9d47b2872022be97a450..9adb1e6789919ecc43971879b59db9ce9db8c665 100644 --- a/Generators/GeneratorFilters/src/xAODParticleDecayFilter.cxx +++ b/Generators/GeneratorFilters/src/xAODParticleDecayFilter.cxx @@ -3,28 +3,18 @@ */ #include "GeneratorFilters/xAODParticleDecayFilter.h" - -xAODParticleDecayFilter::xAODParticleDecayFilter(const std::string &name, ISvcLocator *pSvcLocator) - : GenFilter(name, pSvcLocator) -{ -} +#include "xAODTruth/TruthVertex.h" StatusCode xAODParticleDecayFilter::filterInitialize() { ATH_MSG_INFO("xAODParticleDecayFilter::filterInitialize()"); // initialize the ReadHandleKey - ATH_CHECK(m_truthPartContKey.initialize()); + CHECK(m_truthPartContKey.initialize()); return StatusCode::SUCCESS; } -StatusCode xAODParticleDecayFilter::filterFinalize() -{ - ATH_MSG_INFO("xAODParticleDecayFilter::filterFinalize()"); - return StatusCode::SUCCESS; -} - StatusCode xAODParticleDecayFilter::filterEvent() { @@ -47,10 +37,7 @@ StatusCode xAODParticleDecayFilter::filterEvent() // Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and // duplicated barcode ones SG::ReadHandle<xAOD::TruthParticleContainer> xTruthParticleContainer{m_truthPartContKey}; - if (!xTruthParticleContainer.isValid()) { - ATH_MSG_ERROR("No TruthParticle collection with name " << m_truthPartContKey.key() << " found in StoreGate!"); - return StatusCode::FAILURE; - } + CHECK(xTruthParticleContainer.isValid()); // Loop over all particles in the event for (const xAOD::TruthParticle* particle : *xTruthParticleContainer) {