diff --git a/Reconstruction/PFlow/PFlowUtils/CMakeLists.txt b/Reconstruction/PFlow/PFlowUtils/CMakeLists.txt index 25c65842a97cfa702a7089026c85f026ccaa35ef..ee5a65eff160d5017f601c43e5762d5232599fd7 100644 --- a/Reconstruction/PFlow/PFlowUtils/CMakeLists.txt +++ b/Reconstruction/PFlow/PFlowUtils/CMakeLists.txt @@ -15,9 +15,10 @@ endif() # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC - Control/AthToolSupport/AsgTools + Control/AthToolSupport/AsgTools Event/xAOD/xAODPFlow PRIVATE + Control/AthContainers Event/xAOD/xAODJet ${extra_deps} ) diff --git a/Reconstruction/PFlow/PFlowUtils/src/CombinePFO.cxx b/Reconstruction/PFlow/PFlowUtils/src/CombinePFO.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1e3a1a37c063d3811b1bb5975e7b10b8a2405851 --- /dev/null +++ b/Reconstruction/PFlow/PFlowUtils/src/CombinePFO.cxx @@ -0,0 +1,37 @@ +#include "CombinePFO.h" +#include "AthContainers/ConstDataVector.h" +#include "xAODCore/ShallowCopy.h" + +CombinePFO::CombinePFO(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator) {} + +StatusCode CombinePFO::initialize(){ + + ATH_CHECK(m_PFOContainerReadHandleKeyA.initialize()); + ATH_CHECK(m_PFOContainerReadHandleKeyB.initialize()); + ATH_CHECK(m_PFOContainerWriteHandleKey.initialize()); + + return StatusCode::SUCCESS; +} + +StatusCode CombinePFO::execute(){ + + SG::WriteHandle<xAOD::PFOContainer> PFOContainerWriteHandle(m_PFOContainerWriteHandleKey); + + ATH_CHECK(PFOContainerWriteHandle.record(std::make_unique<xAOD::PFOContainer>(SG::VIEW_ELEMENTS))); + + SG::ReadHandle<xAOD::PFOContainer> PFOContainerReadHandleA(m_PFOContainerReadHandleKeyA); + SG::ReadHandle<xAOD::PFOContainer> PFOContainerReadHandleB(m_PFOContainerReadHandleKeyB); + + std::pair< xAOD::PFOContainer*, xAOD::ShallowAuxContainer* > shallowCopyOfPFOContainerA = xAOD::shallowCopyContainer(*PFOContainerReadHandleA); + std::pair< xAOD::PFOContainer*, xAOD::ShallowAuxContainer* > shallowCopyOfPFOContainerB = xAOD::shallowCopyContainer(*PFOContainerReadHandleB); + + PFOContainerWriteHandle->assign(shallowCopyOfPFOContainerA.first->begin(),shallowCopyOfPFOContainerA.first->end()); + PFOContainerWriteHandle->insert(PFOContainerWriteHandle->end(),shallowCopyOfPFOContainerB.first->begin(),shallowCopyOfPFOContainerB.first->end()); + + return StatusCode::SUCCESS; + +} + +StatusCode CombinePFO::finalize(){ + return StatusCode::SUCCESS; +} diff --git a/Reconstruction/PFlow/PFlowUtils/src/CombinePFO.h b/Reconstruction/PFlow/PFlowUtils/src/CombinePFO.h new file mode 100644 index 0000000000000000000000000000000000000000..32c29bccaa511d4745593b253973b787b0b7372a --- /dev/null +++ b/Reconstruction/PFlow/PFlowUtils/src/CombinePFO.h @@ -0,0 +1,33 @@ +#ifndef COMBINEPFO_H +#define COMBINEPFO_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "xAODPFlow/PFOContainer.h" + +class CombinePFO : public AthAlgorithm { + +public: + /** Default constructor */ + CombinePFO(const std::string& name, ISvcLocator* pSvcLocator); + + /** Default destructor */ + ~CombinePFO() {}; + + /** Gaudi AthAlgorithm hooks */ + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + +private: + + /** ReadHandleKey for first PFOContainer to be combined */ + SG::ReadHandleKey<xAOD::PFOContainer> m_PFOContainerReadHandleKeyA{this,"PFOInputContainerNameA","JetETMissLCNeutralParticleFlowObjects","ReadHandleKey for xAOD::PFOContainer"}; + + /** ReadHandleKey for second PFOContainer to be combined */ + SG::ReadHandleKey<xAOD::PFOContainer> m_PFOContainerReadHandleKeyB{this,"PFOInputContainerNameB","JetETMissLCNeutralParticleFlowObjectsNonModified","ReadHandleKey for xAOD::PFOContainer"}; + + /** WriteHandleKey for PFOContainer, which is VIEW container combining containers A and B referenced above */ + SG::WriteHandleKey<xAOD::PFOContainer> m_PFOContainerWriteHandleKey{this,"PFOOutputContainerName","JetETMissLCCombinedNeutralParticleFlowObjects","WriteHandleKey for xAOD::PFOContainer"}; + +}; +#endif diff --git a/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx b/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx index 52de5c889e0e6bbf2119fb2c50635dc6b21ace44..54efb890a95a914bd46adac41762fe73e74dba30 100644 --- a/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx +++ b/Reconstruction/PFlow/PFlowUtils/src/components/PFlowUtils_entries.cxx @@ -1,8 +1,9 @@ #include "PFlowUtils/RetrievePFOTool.h" #include "PFlowUtils/WeightPFOTool.h" #include "../ParticleFlowEventFilter_r207.h" +#include "../CombinePFO.h" DECLARE_COMPONENT( CP::RetrievePFOTool ) DECLARE_COMPONENT( CP::WeightPFOTool ) DECLARE_COMPONENT( ParticleFlowEventFilter_r207 ) - +DECLARE_COMPONENT( CombinePFO )