ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AthenaPoolAddressProviderSvc Class Reference

This class is the EventSelector and AddressProvider for event data. More...

#include <AthenaPoolAddressProviderSvc.h>

Inheritance diagram for AthenaPoolAddressProviderSvc:
Collaboration diagram for AthenaPoolAddressProviderSvc:

Public Member Functions

 AthenaPoolAddressProviderSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Standard Service Constructor. More...
 
virtual ~AthenaPoolAddressProviderSvc ()
 Destructor. More...
 
virtual StatusCode initialize () override
 Required of all Gaudi Services. More...
 
virtual StatusCode finalize () override
 Required of all Gaudi Services. More...
 
virtual StatusCode preLoadAddresses (StoreID::type storeID, IAddressProvider::tadList &tads) override
 Get all addresses from provider. More...
 
virtual StatusCode loadAddresses (StoreID::type storeID, IAddressProvider::tadList &tads) override
 Get all addresses for this event from provider. More...
 
virtual StatusCode updateAddress (StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
 Update a transient address. More...
 

Private Member Functions

StoreGateSvceventStore () const
 Return pointer to active event SG. More...
 

Private Attributes

ServiceHandle< StoreGateSvcm_metaDataStore
 
ServiceHandle< IClassIDSvc > m_clidSvc
 
Guid m_guid
 
Gaudi::Property< std::string > m_dataHeaderKey
 
Gaudi::Property< std::string > m_attrListKey
 

Detailed Description

This class is the EventSelector and AddressProvider for event data.

Definition at line 27 of file AthenaPoolAddressProviderSvc.h.

Constructor & Destructor Documentation

◆ AthenaPoolAddressProviderSvc()

AthenaPoolAddressProviderSvc::AthenaPoolAddressProviderSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Standard Service Constructor.

Definition at line 30 of file AthenaPoolAddressProviderSvc.cxx.

30  :
31  base_class(name, pSvcLocator),
32  m_metaDataStore("MetaDataStore", name),
33  m_clidSvc("ClassIDSvc", name),
34  m_guid() {
35 }

◆ ~AthenaPoolAddressProviderSvc()

AthenaPoolAddressProviderSvc::~AthenaPoolAddressProviderSvc ( )
virtual

Destructor.

Definition at line 37 of file AthenaPoolAddressProviderSvc.cxx.

37  {
38 }

Member Function Documentation

◆ eventStore()

StoreGateSvc * AthenaPoolAddressProviderSvc::eventStore ( ) const
private

Return pointer to active event SG.

Definition at line 40 of file AthenaPoolAddressProviderSvc.cxx.

40  {
42 }

◆ finalize()

StatusCode AthenaPoolAddressProviderSvc::finalize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 52 of file AthenaPoolAddressProviderSvc.cxx.

52  {
53  // Release ClassIDSvc
54  if (!m_clidSvc.release().isSuccess()) {
55  ATH_MSG_WARNING("Cannot release ClassIDSvc.");
56  }
57  // Release MetaDataStore
58  if (!m_metaDataStore.release().isSuccess()) {
59  ATH_MSG_WARNING("Cannot release MetaDataStore.");
60  }
61 
62  return(StatusCode::SUCCESS);
63 }

◆ initialize()

StatusCode AthenaPoolAddressProviderSvc::initialize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 44 of file AthenaPoolAddressProviderSvc.cxx.

44  {
45 
46  ATH_CHECK( m_metaDataStore.retrieve() );
47  ATH_CHECK( m_clidSvc.retrieve() );
48 
49  return(StatusCode::SUCCESS);
50 }

◆ loadAddresses()

StatusCode AthenaPoolAddressProviderSvc::loadAddresses ( StoreID::type  storeID,
IAddressProvider::tadList tads 
)
overridevirtual

Get all addresses for this event from provider.

Parameters
storeID[IN] store ID, this function only preloads event store addresses.
tads[OUT] list of the transient addresses which were preloaded.

Definition at line 93 of file AthenaPoolAddressProviderSvc.cxx.

94  {
95  if (storeID != StoreID::EVENT_STORE && storeID != StoreID::PILEUP_STORE) {
96  return(StatusCode::SUCCESS);
97  }
98 
99  Guid thisFile = Guid::null();
100  const DataHeader* dataHeader = nullptr;
101  if (dataHeader == nullptr) { // New file (or reading DataHeader)
102  SG::ReadHandle<DataHeader> eventDataHeader(m_dataHeaderKey.value(), eventStore()->name());
103  if (!eventDataHeader.isValid()) {
104  ATH_MSG_ERROR("Cannot retrieve DataHeader from StoreGate: " << m_dataHeaderKey);
105  return(StatusCode::FAILURE);
106  }
107  dataHeader = eventDataHeader.cptr();
108  }
109  // second data header
110  if (m_attrListKey.value() != "") {
111  const AthenaAttributeList* attrList = nullptr;
112  std::string tokenStr;
113  if (eventStore()->retrieve(attrList, m_attrListKey.value()).isSuccess()) {
114  try {
115  tokenStr = (*attrList)["eventRef_secondary"].data<std::string>();
116  ATH_MSG_DEBUG("found AthenaAttribute, name = eventRef_secondary = " << tokenStr);
117  } catch (std::exception &e) {
118  ATH_MSG_ERROR(e.what());
119  return (StatusCode::FAILURE);
120  }
121  } else {
122  ATH_MSG_ERROR("Cannot find AthenaAttribute, key = " << m_attrListKey.value());
123  return (StatusCode::FAILURE);
124  }
125  IOpaqueAddress* iop = new GenericAddress(POOL_StorageType, ClassID_traits<DataHeader>::ID(), tokenStr, "SecondaryEventSelector");
126  if (!eventStore()->recordAddress(iop).isSuccess()) {
127  ATH_MSG_ERROR("Cannot record address to StoreGate with token string: " << tokenStr);
128  return(StatusCode::FAILURE);
129  }
130  ATH_MSG_DEBUG("Created dataHeader SecondaryEventSelector");
131  }
132  ATH_MSG_DEBUG("The current Event contains: " << dataHeader->size() << " objects");
133  for (const auto& element : *dataHeader) {
134  SG::TransientAddress* tadd = element.getAddress();
135  if (tadd->clID() == ClassID_traits<DataHeader>::ID()) { // self reference
136  delete tadd; tadd = nullptr;
137  } else {
138  ATH_MSG_DEBUG("loadAddresses: DataObject address, clid = " << tadd->clID() << ", name = " << tadd->name());
139  tadd->setProvider(this, storeID);
140  tads.push_back(tadd);
141  }
143  }
144  m_guid = thisFile;
145  return(StatusCode::SUCCESS);
146 }

◆ preLoadAddresses()

StatusCode AthenaPoolAddressProviderSvc::preLoadAddresses ( StoreID::type  storeID,
IAddressProvider::tadList tads 
)
overridevirtual

Get all addresses from provider.

Called before begin event.

Parameters
storeID[IN] store ID, this function only preloads detector store addresses.
tads[OUT] list of the transient addresses which were preloaded.

Definition at line 65 of file AthenaPoolAddressProviderSvc.cxx.

66  {
67  if (storeID != StoreID::DETECTOR_STORE) {
68  return(StatusCode::SUCCESS);
69  }
70  ServiceHandle<StoreGateSvc> detectorStoreSvc("DetectorStore", name());
71  ATH_CHECK( detectorStoreSvc.retrieve() );
72 
73  SG::ReadHandle<DataHeader> dataHeader("CondProxyProvider", detectorStoreSvc->name());
74  if (!dataHeader.isValid()) {
75  ATH_MSG_DEBUG("Cannot retrieve DataHeader from DetectorStore.");
76  return(StatusCode::SUCCESS);
77  }
78  ATH_MSG_DEBUG("The current File contains: " << dataHeader->size() << " objects");
79  for (const auto& element : *dataHeader) {
80  SG::TransientAddress* tadd = element.getAddress();
81  if (tadd->clID() == ClassID_traits<DataHeader>::ID()) {
82  delete tadd; tadd = nullptr;
83  } else {
84  ATH_MSG_DEBUG("preLoadAddresses: DataObject address, clid = " << tadd->clID() << ", name = " << tadd->name());
85  tads.push_back(tadd);
86  }
87  EventSelectorAthenaPoolUtil::registerKeys(element, &*detectorStoreSvc);
88  }
89 
90  return(StatusCode::SUCCESS);
91 }

◆ updateAddress()

StatusCode AthenaPoolAddressProviderSvc::updateAddress ( StoreID::type  storeID,
SG::TransientAddress tad,
const EventContext &  ctx 
)
overridevirtual

Update a transient address.

Parameters
storeID[IN] store ID, this function only preloads event store addresses.
tad[IN] transient address to be updated.

Definition at line 148 of file AthenaPoolAddressProviderSvc.cxx.

150  {
151  return(StatusCode::FAILURE);
152 }

Member Data Documentation

◆ m_attrListKey

Gaudi::Property<std::string> AthenaPoolAddressProviderSvc::m_attrListKey
private
Initial value:
{this, "AttributeListKey", {},
"Attribute list key of a secondary input file. If non-zero, creates a new IOpaqueAddress for that file and records it."}

Definition at line 64 of file AthenaPoolAddressProviderSvc.h.

◆ m_clidSvc

ServiceHandle<IClassIDSvc> AthenaPoolAddressProviderSvc::m_clidSvc
private

Definition at line 57 of file AthenaPoolAddressProviderSvc.h.

◆ m_dataHeaderKey

Gaudi::Property<std::string> AthenaPoolAddressProviderSvc::m_dataHeaderKey
private
Initial value:
{this, "DataHeaderKey", "EventSelector",
"StoreGate key of event entry object"}

Definition at line 61 of file AthenaPoolAddressProviderSvc.h.

◆ m_guid

Guid AthenaPoolAddressProviderSvc::m_guid
private

Definition at line 58 of file AthenaPoolAddressProviderSvc.h.

◆ m_metaDataStore

ServiceHandle<StoreGateSvc> AthenaPoolAddressProviderSvc::m_metaDataStore
private

Definition at line 56 of file AthenaPoolAddressProviderSvc.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Guid::null
static const Guid & null()
NULL-Guid: static class method.
Definition: Guid.cxx:18
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::TransientAddress
Definition: TransientAddress.h:32
AthenaPoolAddressProviderSvc::m_guid
Guid m_guid
Definition: AthenaPoolAddressProviderSvc.h:58
AthenaPoolAddressProviderSvc::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
Definition: AthenaPoolAddressProviderSvc.h:57
AthenaPoolAddressProviderSvc::m_metaDataStore
ServiceHandle< StoreGateSvc > m_metaDataStore
Definition: AthenaPoolAddressProviderSvc.h:56
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:208
AthenaPoolAddressProviderSvc::m_dataHeaderKey
Gaudi::Property< std::string > m_dataHeaderKey
Definition: AthenaPoolAddressProviderSvc.h:61
EventSelectorAthenaPoolUtil::registerKeys
void registerKeys(const DataHeaderElement &dhe, StoreGateSvc *store)
Register all hash keys for one DH Element.
Definition: registerKeys.cxx:22
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StoreID::PILEUP_STORE
@ PILEUP_STORE
Definition: StoreID.h:31
DataHeader
This class provides the layout for summary information stored for data written to POOL.
Definition: DataHeader.h:124
DataHeader::size
int size() const
Definition: DataHeader.cxx:251
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:201
StoreGateSvc::currentStoreGate
static StoreGateSvc * currentStoreGate()
get current StoreGate
Definition: StoreGateSvc.cxx:69
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
calibdata.exception
exception
Definition: calibdata.py:496
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
AthenaPoolAddressProviderSvc::m_attrListKey
Gaudi::Property< std::string > m_attrListKey
Definition: AthenaPoolAddressProviderSvc.h:64
StoreID::DETECTOR_STORE
@ DETECTOR_STORE
Definition: StoreID.h:27
SG::TransientAddress::setProvider
void setProvider(IAddressProvider *provider, StoreID::type storeID)
Definition: TransientAddress.h:317
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
AthenaPoolAddressProviderSvc::eventStore
StoreGateSvc * eventStore() const
Return pointer to active event SG.
Definition: AthenaPoolAddressProviderSvc.cxx:40
ServiceHandle< StoreGateSvc >