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

This class is the AddressProvider for conditions data. More...

#include <CondProxyProvider.h>

Inheritance diagram for CondProxyProvider:
Collaboration diagram for CondProxyProvider:

Public Member Functions

 CondProxyProvider (const std::string &name, ISvcLocator *pSvcLocator)
 Standard Service Constructor. More...
 
virtual ~CondProxyProvider ()
 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
 Implementation of the loadAddresses function without any functionality. More...
 
virtual StatusCode updateAddress (StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
 Update a transient address. More...
 

Private Member Functions

PoolCollectionConvertergetCollectionCnv ()
 Return pointer to new PoolCollectionConverter. More...
 

Private Attributes

ServiceHandle< IAthenaPoolCnvSvcm_athenaPoolCnvSvc
 
PoolCollectionConverter *m_poolCollectionConverter ATLAS_THREAD_SAFE
 
unsigned int m_contextId
 
StringArrayProperty m_inputCollectionsProp { this, "InputCollections", {}, "Files to read", "OrderedSet<std::string>" }
 InputCollections, vector with names of the input collections. More...
 
std::vector< std::string >::const_iterator m_inputCollectionsIterator ATLAS_THREAD_SAFE
 

Detailed Description

This class is the AddressProvider for conditions data.

Definition at line 30 of file CondProxyProvider.h.

Constructor & Destructor Documentation

◆ CondProxyProvider()

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

Standard Service Constructor.

Definition at line 31 of file CondProxyProvider.cxx.

31  :
32  base_class(name, pSvcLocator),
33  m_athenaPoolCnvSvc("AthenaPoolCnvSvc", name),
34  m_poolCollectionConverter(0),
36  {
37 }

◆ ~CondProxyProvider()

CondProxyProvider::~CondProxyProvider ( )
virtual

Destructor.

Definition at line 39 of file CondProxyProvider.cxx.

39  {
40 }

Member Function Documentation

◆ finalize()

StatusCode CondProxyProvider::finalize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 69 of file CondProxyProvider.cxx.

69  {
70  if (m_poolCollectionConverter != 0) {
71  m_poolCollectionConverter->disconnectDb().ignore();
72  delete m_poolCollectionConverter; m_poolCollectionConverter = 0;
73  }
74  // Release AthenaPoolCnvSvc
75  if (!m_athenaPoolCnvSvc.release().isSuccess()) {
76  ATH_MSG_WARNING("Cannot release AthenaPoolCnvSvc.");
77  }
78  return(StatusCode::SUCCESS);
79 }

◆ getCollectionCnv()

PoolCollectionConverter * CondProxyProvider::getCollectionCnv ( )
private

Return pointer to new PoolCollectionConverter.

Definition at line 160 of file CondProxyProvider.cxx.

160  {
161  ATH_MSG_DEBUG("Try item: \"" << *m_inputCollectionsIterator << "\" from the collection list.");
162  PoolCollectionConverter* pCollCnv = new PoolCollectionConverter("ImplicitROOT",
163  *m_inputCollectionsIterator,
164  m_contextId,
165  "",
166  m_athenaPoolCnvSvc->getPoolSvc());
167  if (!pCollCnv->initialize().isSuccess()) {
168  // Close previous collection.
169  delete pCollCnv; pCollCnv = 0;
170  ATH_MSG_ERROR("Unable to open: " << *m_inputCollectionsIterator);
171  }
172  return(pCollCnv);
173 }

◆ initialize()

StatusCode CondProxyProvider::initialize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 42 of file CondProxyProvider.cxx.

42  {
43  ATH_MSG_INFO("Initializing " << name());
44  // Check for input collection
45  if (m_inputCollectionsProp.value().size() == 0) {
46  return(StatusCode::FAILURE);
47  }
48  // Retrieve AthenaPoolCnvSvc
49  ATH_CHECK( m_athenaPoolCnvSvc.retrieve() );
50 
51  // Get PoolSvc and connect as "Conditions"
52  IPoolSvc *poolSvc = m_athenaPoolCnvSvc->getPoolSvc();
53  m_contextId = poolSvc->getInputContext("Conditions");
55 
56  for( const auto &inp : m_inputCollectionsProp.value() ) {
57  ATH_MSG_INFO("Inputs: " << inp);
58  }
59  // Initialize
60  m_inputCollectionsIterator = m_inputCollectionsProp.value().begin();
61  // Create an m_poolCollectionConverter to read the objects in
62  m_poolCollectionConverter = getCollectionCnv();
63  if (m_poolCollectionConverter == 0) {
64  return(StatusCode::FAILURE);
65  }
66  return(StatusCode::SUCCESS);
67 }

◆ loadAddresses()

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

Implementation of the loadAddresses function without any functionality.

Definition at line 149 of file CondProxyProvider.cxx.

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

◆ preLoadAddresses()

StatusCode CondProxyProvider::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 81 of file CondProxyProvider.cxx.

82  {
83  if (storeID != StoreID::DETECTOR_STORE) {
84  return(StatusCode::SUCCESS);
85  }
86  ServiceHandle<StoreGateSvc> detectorStoreSvc("DetectorStore", name());
87  // Retrieve DetectorStoreSvc
88  ATH_CHECK( detectorStoreSvc.retrieve() );
89 
90  if (m_poolCollectionConverter == nullptr) {
91  return StatusCode::FAILURE;
92  }
93 
94  // Create DataHeader iterators
95  pool::ICollectionCursor* headerIterator = &m_poolCollectionConverter->executeQuery();
96  for (int verNumber = 0; verNumber < 100; verNumber++) {
97  if (!headerIterator->next()) {
98  m_poolCollectionConverter->disconnectDb().ignore();
99  delete m_poolCollectionConverter; m_poolCollectionConverter = 0;
100  ++m_inputCollectionsIterator;
101  if (m_inputCollectionsIterator != m_inputCollectionsProp.value().end()) {
102  // Create PoolCollectionConverter for input file
103  m_poolCollectionConverter = getCollectionCnv();
104  if (m_poolCollectionConverter == 0) {
105  return(StatusCode::FAILURE);
106  }
107  // Get DataHeader iterator
108  headerIterator = &m_poolCollectionConverter->executeQuery();
109  if (!headerIterator->next()) {
110  return(StatusCode::FAILURE);
111  }
112  } else {
113  break;
114  }
115  }
116  SG::VersionedKey myVersKey(name(), verNumber);
117  Token* token = new Token;
118  token->fromString(headerIterator->eventRef().toString());
119  TokenAddress* tokenAddr = new TokenAddress(POOL_StorageType, ClassID_traits<DataHeader>::ID(), "", myVersKey, m_contextId, token);
120  if (!detectorStoreSvc->recordAddress(tokenAddr).isSuccess()) {
121  ATH_MSG_ERROR("Cannot record DataHeader.");
122  return(StatusCode::FAILURE);
123  }
124  }
125  std::list<SG::ObjectWithVersion<DataHeader> > allVersions;
126  if (!detectorStoreSvc->retrieveAllVersions(allVersions, name()).isSuccess()) {
127  ATH_MSG_DEBUG("Cannot retrieve DataHeader from DetectorStore.");
128  return(StatusCode::SUCCESS);
129  }
130  for (std::list<SG::ObjectWithVersion<DataHeader> >::iterator iter = allVersions.begin();
131  iter != allVersions.end(); ++iter) {
132  SG::ReadHandle<DataHeader> dataHeader = iter->dataObject;
133  ATH_MSG_DEBUG("The current File contains: " << dataHeader->size() << " objects");
134  for (const auto& element : *dataHeader) {
135  SG::TransientAddress* tadd = element.getAddress();
136  if (tadd->clID() == ClassID_traits<DataHeader>::ID()) {
137  delete tadd; tadd = 0;
138  } else {
139  ATH_MSG_DEBUG("preLoadAddresses: DataObject address, clid = " << tadd->clID() << ", name = " << tadd->name());
140  tads.push_back(tadd);
141  }
142  EventSelectorAthenaPoolUtil::registerKeys(element, &*detectorStoreSvc);
143  }
144  }
145 
146  return(StatusCode::SUCCESS);
147 }

◆ updateAddress()

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

Update a transient address.

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

Definition at line 154 of file CondProxyProvider.cxx.

156  {
157  return(StatusCode::FAILURE);
158 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

PoolCollectionConverter* m_poolCollectionConverter CondProxyProvider::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 59 of file CondProxyProvider.h.

◆ ATLAS_THREAD_SAFE [2/2]

std::vector<std::string>::const_iterator m_inputCollectionsIterator CondProxyProvider::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 66 of file CondProxyProvider.h.

◆ m_athenaPoolCnvSvc

ServiceHandle<IAthenaPoolCnvSvc> CondProxyProvider::m_athenaPoolCnvSvc
private

Definition at line 57 of file CondProxyProvider.h.

◆ m_contextId

unsigned int CondProxyProvider::m_contextId
private

Definition at line 60 of file CondProxyProvider.h.

◆ m_inputCollectionsProp

StringArrayProperty CondProxyProvider::m_inputCollectionsProp { this, "InputCollections", {}, "Files to read", "OrderedSet<std::string>" }
private

InputCollections, vector with names of the input collections.

Definition at line 64 of file CondProxyProvider.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IPoolSvc
This class provides the interface to the LCG POOL persistency software.
Definition: IPoolSvc.h:35
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PoolCollectionConverter
This class provides an interface to POOL collections.
Definition: PoolCollectionConverter.h:27
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::TransientAddress
Definition: TransientAddress.h:32
pool::ICollectionCursor::next
virtual bool next()=0
Advances the cursor to the next row of the query result set.
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
TokenAddress
This class provides a Generic Transient Address for POOL tokens.
Definition: TokenAddress.h:21
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:208
EventSelectorAthenaPoolUtil::registerKeys
void registerKeys(const DataHeaderElement &dhe, StoreGateSvc *store)
Register all hash keys for one DH Element.
Definition: registerKeys.cxx:22
Token::fromString
Token & fromString(const std::string &from)
Build from the string representation of a token.
Definition: Token.cxx:133
IPoolSvc::kInputStream
@ kInputStream
Definition: IPoolSvc.h:39
CondProxyProvider::m_contextId
unsigned int m_contextId
Definition: CondProxyProvider.h:60
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DataHeader::size
int size() const
Definition: DataHeader.cxx:251
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::VersionedKey
a StoreGateSvc key with a version number. Notice that StoreGate does not order multiple instances of ...
Definition: SGVersionedKey.h:31
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:201
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondProxyProvider::m_athenaPoolCnvSvc
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
Definition: CondProxyProvider.h:57
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
StoreID::DETECTOR_STORE
@ DETECTOR_STORE
Definition: StoreID.h:27
pool::ICollectionCursor
Definition: ICollectionCursor.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Token::toString
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition: Token.cxx:114
LArConditionsTestConfig.poolSvc
poolSvc
Definition: LArConditionsTestConfig.py:79
CondProxyProvider::getCollectionCnv
PoolCollectionConverter * getCollectionCnv()
Return pointer to new PoolCollectionConverter.
Definition: CondProxyProvider.cxx:160
PoolCollectionConverter::initialize
StatusCode initialize()
Required by all Gaudi Services.
Definition: PoolCollectionConverter.cxx:69
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
pool::ITransaction::READ
@ READ
Definition: ITransaction.h:29
CondProxyProvider::m_inputCollectionsProp
StringArrayProperty m_inputCollectionsProp
InputCollections, vector with names of the input collections.
Definition: CondProxyProvider.h:65
pool::ICollectionCursor::eventRef
virtual const Token & eventRef() const =0
Returns the event reference Token for the current row.
SG::ObjectWithVersion
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Definition: SGVersionedKey.h:17
ServiceHandle< StoreGateSvc >