Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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):
16 #include "StoreGate/ReadHandle.h"
17 #include "StoreGate/WriteHandle.h"
18 
19 // Local include(s):
20 #include "RoiWriter.h"
22 
23 namespace {
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 
29 RoiWriter::RoiWriter( const std::string& name, ISvcLocator* pSvcLocator )
30  : AthReentrantAlgorithm( name, pSvcLocator ) {
31 }
32 
33 StatusCode 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;
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 
SGTest::store
TestStore store
Definition: TestStore.cxx:23
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
RoiWriter::RoiWriter
RoiWriter(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor.
Definition: RoiWriter.cxx:29
SG::ReadHandleKey< TrigRoiDescriptorCollection >
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
WriteHandle.h
Handle class for recording to StoreGate.
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
RoiWriter::execute
virtual StatusCode execute(const EventContext &ctx) const override
Execute the conversion.
Definition: RoiWriter.cxx:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
parseDir.wh
wh
Definition: parseDir.py:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
RoiDescriptorStore.h
RoiWriter.h
TrigRoiDescriptorCollection
Definition: TrigRoiDescriptorCollection.h:21
RoiSerialise.h
RoiDescriptorStoreAuxInfo.h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
ReadHandle.h
Handle class for reading from StoreGate.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37