Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 32 of file CondProxyProvider.cxx.

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

◆ ~CondProxyProvider()

CondProxyProvider::~CondProxyProvider ( )
virtual

Destructor.

Definition at line 40 of file CondProxyProvider.cxx.

40  {
41 }

Member Function Documentation

◆ finalize()

StatusCode CondProxyProvider::finalize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 70 of file CondProxyProvider.cxx.

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

◆ getCollectionCnv()

PoolCollectionConverter * CondProxyProvider::getCollectionCnv ( )
private

Return pointer to new PoolCollectionConverter.

Definition at line 161 of file CondProxyProvider.cxx.

161  {
162  ATH_MSG_DEBUG("Try item: \"" << *m_inputCollectionsIterator << "\" from the collection list.");
163  PoolCollectionConverter* pCollCnv = new PoolCollectionConverter(std::string("ImplicitROOT:") + APRDefaults::TTreeNames::DataHeader,
164  *m_inputCollectionsIterator,
165  m_contextId,
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 43 of file CondProxyProvider.cxx.

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

◆ loadAddresses()

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

Implementation of the loadAddresses function without any functionality.

Definition at line 150 of file CondProxyProvider.cxx.

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

◆ 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 82 of file CondProxyProvider.cxx.

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

◆ 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 155 of file CondProxyProvider.cxx.

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

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:67
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.
TokenAddress
This class provides a Generic Transient Address for POOL tokens.
Definition: TokenAddress.h:23
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:214
EventSelectorAthenaPoolUtil::registerKeys
void registerKeys(const DataHeaderElement &dhe, StoreGateSvc *store)
Register all hash keys for one DH Element.
Definition: registerKeys.cxx:22
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:233
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:207
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
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
APRDefaults::TTreeNames::DataHeader
static constexpr const char * DataHeader
Definition: APRDefaults.h:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Token::toString
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition: Token.cxx:129
LArConditionsTestConfig.poolSvc
poolSvc
Definition: LArConditionsTestConfig.py:79
CondProxyProvider::getCollectionCnv
PoolCollectionConverter * getCollectionCnv()
Return pointer to new PoolCollectionConverter.
Definition: CondProxyProvider.cxx:161
PoolCollectionConverter::initialize
StatusCode initialize()
Required by all Gaudi Services.
Definition: PoolCollectionConverter.cxx:67
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 >