Skip to content
Snippets Groups Projects
Commit 1fe9a00f authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

RoiWriter: construct handles from keys

Use (and re-use) HandleKeys for the construction of Read/WriteHandles.
This allows us to pass the `EventContext` and should also be slightly
faster than the internal key creation when constructing a handle from a
plain string.
parent ac49dcff
No related branches found
No related tags found
No related merge requests found
Pipeline #11062875 failed
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
//
// @file RoiWriter.cxx
......@@ -30,7 +30,7 @@ RoiWriter::RoiWriter( const std::string& name, ISvcLocator* pSvcLocator )
: AthReentrantAlgorithm( name, pSvcLocator ) {
}
StatusCode RoiWriter::execute(const EventContext& /*ctx*/) const {
StatusCode RoiWriter::execute(const EventContext& ctx) const {
ATH_MSG_DEBUG( "In execute()..." );
......@@ -43,16 +43,23 @@ StatusCode RoiWriter::execute(const EventContext& /*ctx*/) const {
bool just_dandy = true;
// Create handle keys for use in the loop:
SG::ReadHandleKey< TrigRoiDescriptorCollection > rhk("temp");
SG::WriteHandleKey< xAOD::RoiDescriptorStore > whk("temp");
ATH_CHECK( rhk.initialize() && whk.initialize() );
// Loop over these container(s):
for( const std::string& key : keys ) {
// Update key to read from:
rhk = key;
// Construct the key of the new container:
const std::string newKey = ( ( key.find( prefix ) == 0 ) ?
( newPrefix + key.substr( prefix.size() ) ) :
key );
whk = ( ( key.find( prefix ) == 0 ) ?
( newPrefix + key.substr( prefix.size() ) ) :
key );
SG::ReadHandle< TrigRoiDescriptorCollection > rh(key);
SG::WriteHandle< xAOD::RoiDescriptorStore > wh(newKey);
auto rh = SG::makeHandle(rhk, ctx);
auto wh = SG::makeHandle(whk, ctx);
/// check object actually points to something - make sure that we do all
/// collections that we can, and not barf on the first one that might fail
......
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