Skip to content
Snippets Groups Projects
Commit 538bdd04 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'fix_CellsInConeThinning' into 'master'

DataHandles in CellsInConeThinning

See merge request atlas/athena!16612
parents 1d89bb6f 866082a0
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -15,6 +15,12 @@
#include "xAODCaloEvent/CaloClusterFwd.h"
#include "xAODEgamma/EgammaFwd.h"
#include "DerivationFrameworkInterfaces/IAugmentationTool.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
#include "xAODEgamma/EgammaContainer.h"
#include "CaloEvent/CaloCellContainer.h"
#include "xAODCaloEvent/CaloCluster.h"
namespace ExpressionParsing {
class ExpressionParser;
......@@ -33,9 +39,11 @@ namespace DerivationFramework {
StatusCode addBranches() const;
private:
std::string m_SGKey;
std::string m_InputCellsSGKey;
std::string m_OutputClusterSGKey;
SG::ReadHandleKey<xAOD::EgammaContainer> m_SGKey{this, "InputSGKey", "Electrons", "SG key for input container"};
SG::ReadHandleKey<CaloCellContainer> m_InputCellsSGKey{this, "InputCellsSGKey", "AllCalo", "SG key for input cells container"};
SG::WriteHandleKey<xAOD::CaloClusterContainer> m_OutputClusterSGKey{this, "OutputClusterSGKey", "EgammaDummyClusters", "SG key for output"};
SG::WriteHandleKey<CaloClusterCellLinkContainer> m_OutputCellLinkSGKey{this, "OutputCellLinksSGKey", "EgammaDummyCellLink", "SG key for output cell links"};
std::string m_selectionString;
double m_dr;
ExpressionParsing::ExpressionParser *m_parser;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "xAODCaloEvent/CaloCluster.h"
#include "CaloUtils/CaloClusterStoreHelper.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloEvent/CaloCellLinkContainer.h"
#include "xAODEgamma/EgammaContainer.h"
#include "ExpressionEvaluation/ExpressionParser.h"
#include "ExpressionEvaluation/SGxAODProxyLoader.h"
......@@ -20,22 +17,21 @@ DerivationFramework::CellsInConeThinning::CellsInConeThinning(const std::string&
const std::string& name,
const IInterface* parent) :
AthAlgTool(type, name, parent),
m_SGKey("Electrons"),
m_InputCellsSGKey("AllCalo"),
m_OutputClusterSGKey("EgammaDummyClusters"),
m_selectionString(""),
m_dr(0.5),
m_parser(0)
{
declareInterface<DerivationFramework::IAugmentationTool>(this);
declareProperty("InputSGKey", m_SGKey="Electrons");
declareProperty("InputCellsSGKey",m_InputCellsSGKey="AllCalo");
declareProperty("OutputClusterSGKey",m_OutputClusterSGKey="dummyCluster");
declareProperty("deltaR",m_dr=0.5);
}
StatusCode DerivationFramework::CellsInConeThinning::initialize(){
ATH_CHECK(m_SGKey.initialize());
ATH_CHECK(m_InputCellsSGKey.initialize());
ATH_CHECK(m_OutputClusterSGKey.initialize());
ATH_CHECK(m_OutputCellLinkSGKey.initialize());
if (m_selectionString!="") {
ExpressionParsing::MultipleProxyLoader *proxyLoaders = new ExpressionParsing::MultipleProxyLoader();
proxyLoaders->push_back(new ExpressionParsing::SGxAODProxyLoader(evtStore()));
......@@ -59,11 +55,11 @@ StatusCode DerivationFramework::CellsInConeThinning::finalize(){
StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{
///Make new container
xAOD::CaloClusterContainer* dummyClusterContainer = CaloClusterStoreHelper::makeContainer(&*evtStore(),
m_OutputClusterSGKey,
msg());
SG::WriteHandle<xAOD::CaloClusterContainer> dclHdl(m_OutputClusterSGKey);
ATH_CHECK(CaloClusterStoreHelper::AddContainerWriteHandle(&(*evtStore()), dclHdl, msg()));
/// Input objects
const xAOD::EgammaContainer* egammas = evtStore()->retrieve< const xAOD::EgammaContainer >(m_SGKey);
SG::ReadHandle<xAOD::EgammaContainer> egHdl(m_SGKey);
const xAOD::EgammaContainer *egammas = egHdl.cptr();
if(!egammas ) {
ATH_MSG_ERROR( "Couldn't retrieve egamma container with key: " <<m_SGKey);
return StatusCode::FAILURE;
......@@ -74,7 +70,8 @@ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{
return StatusCode::SUCCESS;
}
const CaloCellContainer* cells = evtStore()->retrieve< const CaloCellContainer >(m_InputCellsSGKey);
SG::ReadHandle<CaloCellContainer> cellHdl(m_InputCellsSGKey);
const CaloCellContainer* cells = cellHdl.cptr();
if(!cells) {
ATH_MSG_ERROR( "Couldn't retrieve cell container with key: " <<m_InputCellsSGKey);
return StatusCode::FAILURE;
......@@ -94,7 +91,7 @@ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{
if(entries.at(index)==true){
xAOD::CaloCluster *dummy = CaloClusterStoreHelper::makeCluster(cells);
DerivationFramework::CellsInCone::egammaSelect(dummy,cells,eg,m_dr);
dummyClusterContainer->push_back(dummy);
dclHdl->push_back(dummy);
}
++index;
}
......@@ -104,14 +101,12 @@ StatusCode DerivationFramework::CellsInConeThinning::addBranches() const{
for (const xAOD::Egamma* eg : *egammas){
xAOD::CaloCluster *dummy = CaloClusterStoreHelper::makeCluster(cells);
DerivationFramework::CellsInCone::egammaSelect(dummy,cells,eg,m_dr);
dummyClusterContainer->push_back(dummy);
dclHdl->push_back(dummy);
}
}
///Finalize clusters
CHECK( CaloClusterStoreHelper::finalizeClusters(&*evtStore(),
dummyClusterContainer,
m_OutputClusterSGKey,
msg()));
SG::WriteHandle<CaloClusterCellLinkContainer> cellLinks(m_OutputCellLinkSGKey);
ATH_CHECK( CaloClusterStoreHelper::finalizeClusters(cellLinks, dclHdl.ptr()));
///Return
return StatusCode::SUCCESS;
}
......
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