From c6790e21073b14467c65b97421f549a9fab8d081 Mon Sep 17 00:00:00 2001 From: Mark Hodgkinson <mhodgkin@aiatlas025.cern.ch> Date: Wed, 22 Jul 2020 14:38:57 +0200 Subject: [PATCH] Fill in initialize and execute of PFNeutralFlowElementCreatorAlgorithm --- .../PFNeutralFlowElementCreatorAlgorithm.cxx | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/Reconstruction/eflowRec/src/PFNeutralFlowElementCreatorAlgorithm.cxx b/Reconstruction/eflowRec/src/PFNeutralFlowElementCreatorAlgorithm.cxx index b89214ad46ad..12c47037798e 100644 --- a/Reconstruction/eflowRec/src/PFNeutralFlowElementCreatorAlgorithm.cxx +++ b/Reconstruction/eflowRec/src/PFNeutralFlowElementCreatorAlgorithm.cxx @@ -1,15 +1,61 @@ #include "eflowRec/PFNeutralFlowElementCreatorAlgorithm.h" +#include "xAODPFlow/FlowElementAuxContainer.h" + PFNeutralFlowElementCreatorAlgorithm::PFNeutralFlowElementCreatorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) -{ -} +{} StatusCode PFNeutralFlowElementCreatorAlgorithm::initialize(){ + + ATH_CHECK(m_eflowCaloObjectContainerReadHandleKey.initialize()); + ATH_CHECK(m_neutralFEContainerWriteHandleKey.initialize()); + if(!m_LCMode) { + ATH_CHECK(m_neutralFEContainerWriteHandleKey_nonModified.initialize()); + } + return StatusCode::SUCCESS; } StatusCode PFNeutralFlowElementCreatorAlgorithm::execute(const EventContext& ctx) const { + + ATH_MSG_DEBUG("Executing"); + + /* Create Neutral PFOs from all eflowCaloObjects */ + SG::ReadHandle<eflowCaloObjectContainer> eflowCaloObjectContainerReadHandle(m_eflowCaloObjectContainerReadHandleKey,ctx); + + // Always create at least one FlowElement container & aux + auto neutralFEContainer = std::make_unique<xAOD::FlowElementContainer>(); + auto neutralFEContainerAux = std::make_unique<xAOD::FlowElementAuxContainer>(); + neutralFEContainer->setStore(neutralFEContainerAux.get()); + // The non-modified container is only used for LC FlowElements + std::unique_ptr<xAOD::FlowElementContainer> neutralFEContainer_nonModified(nullptr); + std::unique_ptr<xAOD::FlowElementAuxContainer> neutralFEContainerAux_nonModified(nullptr); + if(m_LCMode) { + neutralFEContainer_nonModified = std::make_unique<xAOD::FlowElementContainer>(); + neutralFEContainerAux_nonModified = std::make_unique<xAOD::FlowElementAuxContainer>(); + neutralFEContainer->setStore(neutralFEContainerAux_nonModified.get()); + } + + ATH_MSG_DEBUG("Looping over eflowCaloObjects"); + // Create FlowElements and fill the containers + for (auto thisEflowCaloObject : *eflowCaloObjectContainerReadHandle) { + if( createNeutralFlowElement(*thisEflowCaloObject, neutralFEContainer.get(), neutralFEContainer_nonModified.get()).isFailure() ) { + ATH_MSG_WARNING("Problem encountered while creating neutral FlowElements"); + return StatusCode::SUCCESS; + } + } + + // Record the output containers + SG::WriteHandle<xAOD::FlowElementContainer> neutralFEContainerWriteHandle(m_neutralFEContainerWriteHandleKey,ctx); + std::sort(neutralFEContainer->begin(), neutralFEContainer->end(), [] (const xAOD::FlowElement* fe1, const xAOD::FlowElement* fe2) {return fe1->pt()>fe2->pt();}); + ATH_CHECK( neutralFEContainerWriteHandle.record(std::move(neutralFEContainer),std::move(neutralFEContainerAux)) ); + if(m_LCMode) { + std::sort(neutralFEContainer_nonModified->begin(), neutralFEContainer_nonModified->end(), [] (const xAOD::FlowElement* fe1, const xAOD::FlowElement* fe2) {return fe1->pt()>fe2->pt();}); + SG::WriteHandle<xAOD::FlowElementContainer> neutralFEContainerWriteHandle_nonModified(m_neutralFEContainerWriteHandleKey,ctx); + ATH_CHECK( neutralFEContainerWriteHandle_nonModified.record(std::move(neutralFEContainer_nonModified),std::move(neutralFEContainerAux_nonModified)) ); + } + return StatusCode::SUCCESS; } -- GitLab