ATLAS Offline Software
RoiWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  // Loop over these container(s):
47  for( const std::string& key : keys ) {
48 
49  // Construct the key of the new container:
50  const std::string newKey = ( ( key.find( prefix ) == 0 ) ?
51  ( newPrefix + key.substr( prefix.size() ) ) :
52  key );
53 
56 
59  if ( rh.isValid() ) {
60 
61  // Create the "new payload" from it:
62  roiserial.clear();
63  RoiUtil::serialise( *rh, roiserial );
64 
65  // Create the xAOD objects:
66  auto store = std::make_unique< xAOD::RoiDescriptorStore >();
67  auto aux = std::make_unique< xAOD::RoiDescriptorStoreAuxInfo >();
68  store->setStore( aux.get() );
69  store->setSerialised( roiserial );
70 
71  // Record the new container:
72  ATH_CHECK( wh.record( std::move( store ), std::move( aux ) ) );
73  }
74  else just_dandy = false;
75  }
76 
77  // Return gracefully:
78  return just_dandy ? StatusCode::SUCCESS : StatusCode::FAILURE;
79 }
80 
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
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
RoiWriter::RoiWriter
RoiWriter(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor.
Definition: RoiWriter.cxx:29
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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.
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::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
RoiDescriptorStore.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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