ATLAS Offline Software
AddressRemappingSvc.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef SGCOMPS_ADDRESSREMAPPINGSVC_H
8 #define SGCOMPS_ADDRESSREMAPPINGSVC_H 1
9 
15 #include "GaudiKernel/ClassID.h"
16 #include "GaudiKernel/ServiceHandle.h"
17 #include "Gaudi/Property.h" // no forward decl: typedef
20 #include "AthenaKernel/RCUObject.h"
21 #include "GaudiKernel/IAlgResourcePool.h"
24 #include "CxxUtils/CachedValue.h"
26 
27 #include <vector>
28 #include <string>
29 #include <mutex>
30 
31 // Forward declarations
32 class IClassIDSvc;
33 class IProxyDict;
34 class IRCUSvc;
35 
40  : public extends<AthService, Athena::IInputRename, IAddressProvider>
41 {
42 
43 public:
44 
45  // Constructor and Destructor
47  AddressRemappingSvc(const std::string& name, ISvcLocator* pSvcLocator);
49  virtual ~AddressRemappingSvc();
50 
51 public: // Non-static members
55  virtual StatusCode finalize() override;
56 
60  virtual StatusCode preLoadAddresses(StoreID::type storeID, IAddressProvider::tadList& tads) override;
61 
63  virtual StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList& tads) override;
64 
67  virtual StatusCode updateAddress(StoreID::type /*storeID*/,
69  const EventContext& ctx) override;
70 
71 
77  virtual const IInputRename::InputRenameRCU_t* inputRenameMap() const override;
78 
79 
80 private: // Data
82  ServiceHandle<IProxyDict> m_proxyDict{this,"ProxyDict","StoreGateSvc",
83  "the IProxyDict we want to apply the remapping to (by default the event store)"};
85  ServiceHandle<IAlgResourcePool> m_algResourcePool{this,"AlgResourcePool","AlgResourcePool",
86  "Algorithm resource pool service."};
87 
89  StringArrayProperty m_overwriteMaps{this,"TypeKeyOverwriteMaps",{},"","OrderedSet<std::string>"};
90  std::vector<SG::TransientAddress> m_oldTads;
91  std::vector<SG::TransientAddress> m_newTads;
92 
93  // The old and new TADS list, possibly cleaned of nonexistent CLIDs.
94  // If SkipBadRemappings is true, then for the first event, we defer
95  // preloading the TADS until loadAddresses, where we can compare them
96  // against what's in the event store.
99 
101  Gaudi::Property<std::vector<std::string> >m_typeKeyRenameMaps{this,"TypeKeyRenameMaps",{},
102  "List of renamings to apply to input objects. This is distinct from the "
103  "mappings given by TypeKeyOverwriteMaps in that objects listed under "
104  "TypeKeyOverwriteMaps are accessible by both the old and new names; "
105  "while for TypeKeyRenameMaps, only the new names are visible (so the old names "
106  "may be rewritten). Overwriting may also change the visible type of an object, "
107  "while renaming may not. Format of list elements is OLDNAME#TYPE->NEWNAME.","OrderedSet<std::string>"};
108 
114  std::unique_ptr<InputRenameRCU_t> m_inputRenames;
115 
116  Gaudi::Property<bool> m_skipBadRemappings{this,"SkipBadRemappings",false,
117  "If true, will delay the remapping setup until the first load, and will check against the given file"};
118 
119  // This mutex protects the two following members.
121  std::atomic<bool> m_haveDeletes=false;
122  std::unordered_multimap<std::string, CLID> m_deletes;
123 
124 
125 private:
126  CLID getClid(std::string type) const;
127 
129 
131  SG::TransientAddress* pTad,
132  const EventContext& ctx) const;
133 
135 
143  void addInputRenames (const InputRenameMap_t& toadd) const;
144 
145 
149  StatusCode initInputRenames ATLAS_NOT_THREAD_SAFE ();
151 
152  void initDeletes();
153  bool isDeleted (const SG::TransientAddress& tad) const;
154 };
155 #endif // !SGCOMPS_ADDRESSREMAPPINGSVC_H
Athena::RCUObject
Wrapper object controlled by RCU synchonization.
Definition: RCUObject.h:322
AddressRemappingSvc::isDeleted
bool isDeleted(const SG::TransientAddress &tad) const
Definition: AddressRemappingSvc.cxx:542
AddressRemappingSvc::~AddressRemappingSvc
virtual ~AddressRemappingSvc()
Destructor.
Definition: AddressRemappingSvc.cxx:44
AddressRemappingSvc::m_skipBadRemappings
Gaudi::Property< bool > m_skipBadRemappings
Definition: AddressRemappingSvc.h:116
RCUObject.h
read-copy-update (RCU) style synchronization for Athena.
AddressRemappingSvc::addInputRenames
void addInputRenames(const InputRenameMap_t &toadd) const
Merge in additional input rename mappings.
Definition: AddressRemappingSvc.cxx:115
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
AddressRemappingSvc::ATLAS_NOT_THREAD_SAFE
virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE() override
Required of all Gaudi services:
AddressRemappingSvc::ATLAS_NOT_THREAD_SAFE
StatusCode initInputRenames ATLAS_NOT_THREAD_SAFE()
Set up input rename mappings during initialization.
initialize
void initialize()
Definition: run_EoverP.cxx:894
AddressRemappingSvc::m_inputRenames
std::unique_ptr< InputRenameRCU_t > m_inputRenames
Definition: AddressRemappingSvc.h:114
AddressRemappingSvc::m_oldTads
std::vector< SG::TransientAddress > m_oldTads
Definition: AddressRemappingSvc.h:90
AddressRemappingSvc::m_oldTadsCleaned
CxxUtils::CachedValue< std::vector< SG::TransientAddress > > m_oldTadsCleaned
Definition: AddressRemappingSvc.h:97
SG::TransientAddress
Definition: TransientAddress.h:32
AddressRemappingSvc::m_haveDeletes
std::atomic< bool > m_haveDeletes
Definition: AddressRemappingSvc.h:121
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
AddressRemappingSvc::AddressRemappingSvc
AddressRemappingSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: AddressRemappingSvc.cxx:35
IInputRename.h
Interface to retrieve input rename map.
AddressRemappingSvc::initDeletes
void initDeletes()
Definition: AddressRemappingSvc.cxx:498
AddressRemappingSvc::getClid
CLID getClid(std::string type) const
Definition: AddressRemappingSvc.cxx:480
AddressRemappingSvc::loadAddresses
virtual StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
Implementation of the loadAddresses function without any functionality.
Definition: AddressRemappingSvc.cxx:231
AddressRemappingSvc::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
Definition: AddressRemappingSvc.h:81
AddressRemappingSvc::m_overwriteMaps
StringArrayProperty m_overwriteMaps
TypeKeyOverwriteMaps, map for type::key overwrites.
Definition: AddressRemappingSvc.h:89
AddressRemappingSvc::m_newTadsCleaned
CxxUtils::CachedValue< std::vector< SG::TransientAddress > > m_newTadsCleaned
Definition: AddressRemappingSvc.h:98
Athena::InputRenameMap_t
SG::SGKeyMap< InputRenameEntry > InputRenameMap_t
Definition: InputRenameMap.h:32
AddressRemappingSvc::renameTads
StatusCode renameTads(IAddressProvider::tadList &tads) const
Scan TAD list and carry out any requested renamings.
Definition: AddressRemappingSvc.cxx:365
AddressRemappingSvc::m_algResourcePool
ServiceHandle< IAlgResourcePool > m_algResourcePool
Definition: AddressRemappingSvc.h:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CxxUtils::CachedValue
Cached value with atomic update.
Definition: CachedValue.h:55
AddressRemappingSvc::InputRenameMap_t
Athena::InputRenameMap_t InputRenameMap_t
Map of sgkey->sgkey for input renames.
Definition: AddressRemappingSvc.h:112
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
AddressRemappingSvc::m_RCUSvc
ServiceHandle< Athena::IRCUSvc > m_RCUSvc
Definition: AddressRemappingSvc.h:84
AddressRemappingSvc::m_deletes
std::unordered_multimap< std::string, CLID > m_deletes
Definition: AddressRemappingSvc.h:122
CachedValue.h
Cached value with atomic update.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AddressRemappingSvc::preLoadAddressesConst
StatusCode preLoadAddressesConst(StoreID::type storeID, IAddressProvider::tadList &tads) const
Definition: AddressRemappingSvc.cxx:190
AddressRemappingSvc::m_proxyDict
ServiceHandle< IProxyDict > m_proxyDict
Definition: AddressRemappingSvc.h:82
StoreID::type
type
Definition: StoreID.h:24
AddressRemappingSvc::preLoadAddresses
virtual StatusCode preLoadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
Get all addresses from provider.
Definition: AddressRemappingSvc.cxx:185
TransientAddress.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AddressRemappingSvc::updateAddressConst
StatusCode updateAddressConst(StoreID::type, SG::TransientAddress *pTad, const EventContext &ctx) const
Definition: AddressRemappingSvc.cxx:319
AddressRemappingSvc::m_typeKeyRenameMaps
Gaudi::Property< std::vector< std::string > > m_typeKeyRenameMaps
Property: list of requested input renames.
Definition: AddressRemappingSvc.h:101
AddressRemappingSvc::inputRenameMap
virtual const IInputRename::InputRenameRCU_t * inputRenameMap() const override
Retrieve a pointer to the input rename map.
Definition: AddressRemappingSvc.cxx:491
IAddressProvider::tadList
std::list< SG::TransientAddress * > tadList
Definition: IAddressProvider.h:32
AddressRemappingSvc::updateAddress
virtual StatusCode updateAddress(StoreID::type, SG::TransientAddress *pTad, const EventContext &ctx) override
Update a transient address.
Definition: AddressRemappingSvc.cxx:313
AddressRemappingSvc::loadAddressesConst
StatusCode loadAddressesConst(IAddressProvider::tadList &tads) const
Definition: AddressRemappingSvc.cxx:241
AthService.h
IAddressProvider.h
AddressRemappingSvc
Definition: AddressRemappingSvc.py:1
checker_macros.h
Define macros for attributes used to control the static checker.
AddressRemappingSvc::m_deletesMutex
std::mutex m_deletesMutex
Definition: AddressRemappingSvc.h:120
AddressRemappingSvc::finalize
virtual StatusCode finalize() override
Required of all Gaudi services:
Definition: AddressRemappingSvc.cxx:175
Athena::IInputRename::InputRenameRCU_t
RCUObject< InputRenameMap_t > InputRenameRCU_t
Definition: IInputRename.h:38
ServiceHandle< IClassIDSvc >
AddressRemappingSvc::m_newTads
std::vector< SG::TransientAddress > m_newTads
Definition: AddressRemappingSvc.h:91