ATLAS Offline Software
Loading...
Searching...
No Matches
RoiWriter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4//
5// @file RoiWriter.cxx
6//
7// @author M.Sutton
8// @author F. Winklmeier
9//
10
11// EDM include(s):
14
15// Athena include(s):
18
19// Local include(s):
20#include "RoiWriter.h"
22
23namespace {
24 // Prefix of the AOD container:
25 static const std::string prefix = "HLT_TrigRoiDescriptorCollection";
26 static const std::string newPrefix = "HLT_xAOD__RoiDescriptorStore";
27}
28
29RoiWriter::RoiWriter( const std::string& name, ISvcLocator* pSvcLocator )
30 : AthReentrantAlgorithm( name, pSvcLocator ) {
31}
32
33StatusCode RoiWriter::execute(const EventContext& ctx) const {
34
35 ATH_MSG_DEBUG( "In execute()..." );
36
37 // Get the keys of the AOD container(s):
38 std::vector< std::string > keys;
39 evtStore()->keys< TrigRoiDescriptorCollection >( keys );
40
41 // Buffer for serialisation:
42 std::vector< std::vector< uint32_t > > roiserial;
43
44 bool just_dandy = true;
45
46 // Create handle keys for use in the loop:
49 ATH_CHECK( rhk.initialize() && whk.initialize() );
50
51 // Loop over these container(s):
52 for( const std::string& key : keys ) {
53 // Update key to read from:
54 rhk = key;
55
56 // Construct the key of the new container:
57 whk = ( ( key.find( prefix ) == 0 ) ?
58 ( newPrefix + key.substr( prefix.size() ) ) :
59 key );
60
61 auto rh = SG::makeHandle(rhk, ctx);
62 auto wh = SG::makeHandle(whk, ctx);
63
66 if ( rh.isValid() ) {
67
68 // Create the "new payload" from it:
69 roiserial.clear();
70 RoiUtil::serialise( *rh, roiserial );
71
72 // Create the xAOD objects:
73 auto store = std::make_unique< xAOD::RoiDescriptorStore >();
74 auto aux = std::make_unique< xAOD::RoiDescriptorStoreAuxInfo >();
75 store->setStore( aux.get() );
76 store->setSerialised( roiserial );
77
78 // Record the new container:
79 ATH_CHECK( wh.record( std::move( store ), std::move( aux ) ) );
80 }
81 else just_dandy = false;
82 }
83
84 // Return gracefully:
85 return just_dandy ? StatusCode::SUCCESS : StatusCode::FAILURE;
86}
87
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
RoiWriter(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor.
Definition RoiWriter.cxx:29
virtual StatusCode execute(const EventContext &ctx) const override
Execute the conversion.
Definition RoiWriter.cxx:33
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Property holding a SG store/key/clid from which a WriteHandle is made.
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())