Skip to content
Snippets Groups Projects
Commit 2de25796 authored by Emily Anne Thompson's avatar Emily Anne Thompson
Browse files

Migrate RpvEgammaIDTool to use DataHandles

parent 844fc91f
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!39666Migrate LongLivedParticleDPDMaker to R22
......@@ -18,6 +18,8 @@
// DerivationFramework includes
#include "DerivationFrameworkInterfaces/IAugmentationTool.h"
#include "xAODEgamma/EgammaContainer.h"
#include "StoreGate/ReadHandleKey.h"
namespace DerivationFramework {
......@@ -46,7 +48,7 @@ namespace DerivationFramework {
private:
std::vector<std::string> m_qualFlags;
std::string m_collName;
SG::ReadHandleKey<xAOD::EgammaContainer> m_collName { this, "CollectionName", "ElectronCollection", ""};
std::string m_sgPrefix;
};
......
......@@ -22,12 +22,10 @@ DerivationFramework::RpvEgammaIDTool::RpvEgammaIDTool( const std::string& t,
const std::string& n,
const IInterface* p ) :
AthAlgTool(t,n,p),
m_collName("ElectronCollection"),
m_sgPrefix("")
{
declareInterface<DerivationFramework::IAugmentationTool>(this);
declareProperty("SelectionVariables",m_qualFlags);
declareProperty("CollectionName", m_collName);
declareProperty("SGPrefix", m_sgPrefix);
}
......@@ -43,6 +41,7 @@ StatusCode DerivationFramework::RpvEgammaIDTool::initialize()
return StatusCode::FAILURE;
}
ATH_MSG_VERBOSE("initialize() ...");
ATH_CHECK(m_collName.initialize());
return StatusCode::SUCCESS;
}
StatusCode DerivationFramework::RpvEgammaIDTool::finalize()
......@@ -56,17 +55,25 @@ StatusCode DerivationFramework::RpvEgammaIDTool::addBranches() const
{
// Retrieve data
const xAOD::EgammaContainer* egammas = evtStore()->retrieve< const xAOD::EgammaContainer >( m_collName );
if( ! egammas ) {
SG::ReadHandle<xAOD::EgammaContainer> egammas(m_collName);
if( !egammas.isValid() ) {
ATH_MSG_ERROR("Couldn't retrieve e-gamma container with key: " << m_collName);
return StatusCode::FAILURE;
}
// Make vectors for the cut results
std::vector<std::vector<int>* > allSelectionResults;
for (std::vector<std::string>::const_iterator strItr = m_qualFlags.begin(); strItr!=m_qualFlags.end(); ++strItr) {
std::vector<int> *passEgamma = new std::vector<int>();
allSelectionResults.push_back(passEgamma);
std::vector<SG::WriteHandle<std::vector<int> > > allSelectionResults;
unsigned int itr(0);
for (std::vector<std::string>::const_iterator strItr = m_qualFlags.begin(); strItr!=m_qualFlags.end(); ++strItr, ++itr) {
std::string sgKey("");
if (m_sgPrefix=="") {
sgKey = *strItr;
} else {
sgKey = m_sgPrefix+*strItr;
}
SG::WriteHandle< std::vector<int> > tmp(sgKey);
allSelectionResults.push_back(tmp);
ATH_CHECK(allSelectionResults[itr].record(std::make_unique< std::vector<int> >()));
}
// Loop over egammas, set decisions
for (xAOD::EgammaContainer::const_iterator eIt = egammas->begin(); eIt!=egammas->end(); ++eIt) {
......@@ -83,21 +90,6 @@ StatusCode DerivationFramework::RpvEgammaIDTool::addBranches() const
}
}
// Write decision to SG for access by downstream algs
unsigned int itr(0);
for (std::vector<std::string>::const_iterator strItr = m_qualFlags.begin(); strItr!=m_qualFlags.end(); ++strItr, ++itr) {
std::string sgKey("");
if (m_sgPrefix=="") {
sgKey = *strItr;
} else {
sgKey = m_sgPrefix+*strItr;
}
if (evtStore()->contains<std::vector<int> >(sgKey)) {
ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << sgKey << " which already exists. Please use a different key");
return StatusCode::FAILURE;
}
CHECK(evtStore()->record(allSelectionResults[itr],sgKey));
}
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