ATLAS Offline Software
Public Types | 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 Types

typedef std::list< SG::TransientAddress * > tadList
 
typedef tadList::iterator tadListIterator
 

Public Member Functions

 CondProxyProvider (const std::string &name, ISvcLocator *pSvcLocator)
 Standard Service Constructor. More...
 
virtual ~CondProxyProvider ()
 Destructor. More...
 
virtual StatusCode initialize ()
 Required of all Gaudi Services. More...
 
virtual StatusCode finalize ()
 Required of all Gaudi Services. More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 Does this object satisfy a given interface? See Gaudi documentation for details. More...
 
virtual StatusCode preLoadAddresses (StoreID::type storeID, IAddressProvider::tadList &tads)
 Get all addresses from provider. More...
 
virtual StatusCode loadAddresses (StoreID::type storeID, IAddressProvider::tadList &tads)
 Implementation of the loadAddresses function without any functionality. More...
 
virtual StatusCode updateAddress (StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx)
 Update a transient address. More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
 DeclareInterfaceID (IAddressProvider, 1, 0)
 

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.

Member Typedef Documentation

◆ tadList

typedef std::list<SG::TransientAddress*> IAddressProvider::tadList
inherited

Definition at line 32 of file IAddressProvider.h.

◆ tadListIterator

typedef tadList::iterator IAddressProvider::tadListIterator
inherited

Definition at line 33 of file IAddressProvider.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  ::AthService(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

◆ DeclareInterfaceID()

IAddressProvider::DeclareInterfaceID ( IAddressProvider  ,
,
 
)
inherited

◆ finalize()

StatusCode CondProxyProvider::finalize ( )
virtual

Required of all Gaudi Services.

Definition at line 78 of file CondProxyProvider.cxx.

78  {
79  if (m_poolCollectionConverter != 0) {
80  m_poolCollectionConverter->disconnectDb().ignore();
81  delete m_poolCollectionConverter; m_poolCollectionConverter = 0;
82  }
83  // Release AthenaPoolCnvSvc
84  if (!m_athenaPoolCnvSvc.release().isSuccess()) {
85  ATH_MSG_WARNING("Cannot release AthenaPoolCnvSvc.");
86  }
87  return(::AthService::finalize());
88 }

◆ getCollectionCnv()

PoolCollectionConverter * CondProxyProvider::getCollectionCnv ( )
private

Return pointer to new PoolCollectionConverter.

Definition at line 178 of file CondProxyProvider.cxx.

178  {
179  ATH_MSG_DEBUG("Try item: \"" << *m_inputCollectionsIterator << "\" from the collection list.");
180  PoolCollectionConverter* pCollCnv = new PoolCollectionConverter("ImplicitROOT",
181  *m_inputCollectionsIterator,
182  m_contextId,
183  "",
184  m_athenaPoolCnvSvc->getPoolSvc());
185  if (!pCollCnv->initialize().isSuccess()) {
186  // Close previous collection.
187  delete pCollCnv; pCollCnv = 0;
188  ATH_MSG_ERROR("Unable to open: " << *m_inputCollectionsIterator);
189  }
190  return(pCollCnv);
191 }

◆ initialize()

StatusCode CondProxyProvider::initialize ( )
virtual

Required of all Gaudi Services.

Definition at line 42 of file CondProxyProvider.cxx.

42  {
43  ATH_MSG_INFO("Initializing " << name());
44  if (!::AthService::initialize().isSuccess()) {
45  ATH_MSG_FATAL("Cannot initialize AthService base class.");
46  return(StatusCode::FAILURE);
47  }
48  // Check for input collection
49  if (m_inputCollectionsProp.value().size() == 0) {
50  return(StatusCode::FAILURE);
51  }
52  // Retrieve AthenaPoolCnvSvc
53  if (!m_athenaPoolCnvSvc.retrieve().isSuccess()) {
54  ATH_MSG_FATAL("Cannot get AthenaPoolCnvSvc.");
55  return(StatusCode::FAILURE);
56  }
57  // Get PoolSvc and connect as "Conditions"
58  IPoolSvc *poolSvc = m_athenaPoolCnvSvc->getPoolSvc();
59  m_contextId = poolSvc->getInputContext("Conditions");
61  if (!status.isSuccess()) {
62  ATH_MSG_FATAL("Cannot connect to Database.");
63  return(StatusCode::FAILURE);
64  }
65  for( const auto &inp : m_inputCollectionsProp.value() ) {
66  ATH_MSG_INFO("Inputs: " << inp);
67  }
68  // Initialize
69  m_inputCollectionsIterator = m_inputCollectionsProp.value().begin();
70  // Create an m_poolCollectionConverter to read the objects in
71  m_poolCollectionConverter = getCollectionCnv();
72  if (m_poolCollectionConverter == 0) {
73  return(StatusCode::FAILURE);
74  }
75  return(StatusCode::SUCCESS);
76 }

◆ loadAddresses()

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

Implementation of the loadAddresses function without any functionality.

Reimplemented from IAddressProvider.

Definition at line 167 of file CondProxyProvider.cxx.

168  {
169  return(StatusCode::SUCCESS);
170 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ preLoadAddresses()

StatusCode CondProxyProvider::preLoadAddresses ( StoreID::type  storeID,
IAddressProvider::tadList tads 
)
virtual

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.

Reimplemented from IAddressProvider.

Definition at line 94 of file CondProxyProvider.cxx.

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

◆ queryInterface()

StatusCode CondProxyProvider::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Does this object satisfy a given interface? See Gaudi documentation for details.

Definition at line 90 of file CondProxyProvider.cxx.

90  {
91  return(::AthService::queryInterface(riid, ppvInterface));
92 }

◆ updateAddress()

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

Update a transient address.

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

Implements IAddressProvider.

Definition at line 172 of file CondProxyProvider.cxx.

174  {
175  return(StatusCode::FAILURE);
176 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

PoolCollectionConverter* m_poolCollectionConverter CondProxyProvider::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 61 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 68 of file CondProxyProvider.h.

◆ m_athenaPoolCnvSvc

ServiceHandle<IAthenaPoolCnvSvc> CondProxyProvider::m_athenaPoolCnvSvc
private

Definition at line 59 of file CondProxyProvider.h.

◆ m_contextId

unsigned int CondProxyProvider::m_contextId
private

Definition at line 62 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 66 of file CondProxyProvider.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AthService::AthService
AthService()
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
IPoolSvc
This class provides the interface to the LCG POOL persistency software.
Definition: IPoolSvc.h:36
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
initialize
void initialize()
Definition: run_EoverP.cxx:894
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:40
CondProxyProvider::m_contextId
unsigned int m_contextId
Definition: CondProxyProvider.h:62
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DataHeader::size
int size() const
Definition: DataHeader.cxx:251
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
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
CondProxyProvider::m_athenaPoolCnvSvc
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
Definition: CondProxyProvider.h:59
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:192
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:178
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:67
merge.status
status
Definition: merge.py:17
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 >