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 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

std::unique_ptr< PoolCollectionConvertergetCollectionCnv ()
 Return pointer to new PoolCollectionConverter. More...
 

Private Attributes

ServiceHandle< IAthenaPoolCnvSvcm_athenaPoolCnvSvc {this, "ConversionService", "AthenaPoolCnvSvc"}
 
unsigned int m_contextId
 
Gaudi::Property< std::vector< std::string > > 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 {}
 

Detailed Description

This class is the AddressProvider for conditions data.

Definition at line 31 of file CondProxyProvider.h.

Constructor & Destructor Documentation

◆ CondProxyProvider()

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

Standard Service Constructor.

Definition at line 33 of file CondProxyProvider.cxx.

33  :
34  base_class(name, pSvcLocator),
36  {
37 }

◆ ~CondProxyProvider()

CondProxyProvider::~CondProxyProvider ( )
virtual

Destructor.

Definition at line 39 of file CondProxyProvider.cxx.

39  {
40 }

Member Function Documentation

◆ getCollectionCnv()

std::unique_ptr< PoolCollectionConverter > CondProxyProvider::getCollectionCnv ( )
private

Return pointer to new PoolCollectionConverter.

Definition at line 144 of file CondProxyProvider.cxx.

144  {
145  ATH_MSG_DEBUG("Try item: \"" << *m_inputCollectionsIterator << "\" from the collection list.");
146  auto pCollCnv = std::make_unique<PoolCollectionConverter>(std::string("ImplicitCollection:") + APRDefaults::TTreeNames::DataHeader,
148  m_contextId,
149  m_athenaPoolCnvSvc->getPoolSvc());
150  if (!pCollCnv->initialize().isSuccess()) {
151  // Close previous collection.
152  pCollCnv.reset();
153  ATH_MSG_ERROR("Unable to open: " << *m_inputCollectionsIterator);
154  }
155  return(pCollCnv);
156 }

◆ 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
61  return StatusCode::SUCCESS;
62 }

◆ loadAddresses()

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

Implementation of the loadAddresses function without any functionality.

Definition at line 133 of file CondProxyProvider.cxx.

134  {
135  return StatusCode::SUCCESS;
136 }

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

65  {
66  if (storeID != StoreID::DETECTOR_STORE) {
67  return StatusCode::SUCCESS;
68  }
69  ServiceHandle<StoreGateSvc> detectorStoreSvc("DetectorStore", name());
70  // Retrieve DetectorStoreSvc
71  ATH_CHECK( detectorStoreSvc.retrieve() );
72 
73  // Create an poolCollectionConverter to read the objects in
74  std::unique_ptr<PoolCollectionConverter> poolCollectionConverter = getCollectionCnv();
75  if (!poolCollectionConverter) {
76  return StatusCode::FAILURE;
77  }
78  // Create DataHeader iterators
79  pool::ICollectionCursor* headerIterator = &poolCollectionConverter->selectAll();
80 
81  for (int verNumber = 0; verNumber < 100; verNumber++) {
82  if (!headerIterator->next()) {
83  poolCollectionConverter->disconnectDb().ignore();
84  poolCollectionConverter.reset();
87  // Create PoolCollectionConverter for input file
88  poolCollectionConverter = getCollectionCnv();
89  if (!poolCollectionConverter) {
90  return StatusCode::FAILURE;
91  }
92  // Get DataHeader iterator
93  headerIterator = &poolCollectionConverter->selectAll();
94  if (!headerIterator->next()) {
95  return StatusCode::FAILURE;
96  }
97  } else {
98  break;
99  }
100  }
101  SG::VersionedKey myVersKey(name(), verNumber);
102  auto token = std::make_unique<Token>();
103  token->fromString(headerIterator->eventRef().toString());
105  (new TokenAddress(pool::POOL_StorageType.type(), ClassID_traits<DataHeader>::ID(), "", myVersKey, m_contextId, std::move(token)));
106  if (!detectorStoreSvc->recordAddress(std::move(tokenAddr)).isSuccess()) {
107  ATH_MSG_ERROR("Cannot record DataHeader.");
108  return StatusCode::FAILURE;
109  }
110  }
111  std::list<SG::ObjectWithVersion<DataHeader> > allVersions;
112  if (!detectorStoreSvc->retrieveAllVersions(allVersions, name()).isSuccess()) {
113  ATH_MSG_DEBUG("Cannot retrieve DataHeader from DetectorStore.");
114  return StatusCode::SUCCESS;
115  }
116  for (const auto& version : allVersions) {
117  SG::ReadHandle<DataHeader> dataHeader = version.dataObject;
118  ATH_MSG_DEBUG("The current File contains: " << dataHeader->size() << " objects");
119  for (const auto& element : *dataHeader) {
120  SG::TransientAddress* tadd = element.getAddress(pool::POOL_StorageType.type());
121  if (tadd->clID() == ClassID_traits<DataHeader>::ID()) {
122  delete tadd; tadd = 0;
123  } else {
124  ATH_MSG_DEBUG("preLoadAddresses: DataObject address, clid = " << tadd->clID() << ", name = " << tadd->name());
125  tads.push_back(tadd);
126  }
127  EventSelectorAthenaPoolUtil::registerKeys(element, &*detectorStoreSvc);
128  }
129  }
130  return StatusCode::SUCCESS;
131 }

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

140  {
141  return StatusCode::FAILURE;
142 }

Member Data Documentation

◆ m_athenaPoolCnvSvc

ServiceHandle<IAthenaPoolCnvSvc> CondProxyProvider::m_athenaPoolCnvSvc {this, "ConversionService", "AthenaPoolCnvSvc"}
private

Definition at line 56 of file CondProxyProvider.h.

◆ m_contextId

unsigned int CondProxyProvider::m_contextId
private

Definition at line 57 of file CondProxyProvider.h.

◆ m_inputCollectionsIterator

std::vector<std::string>::const_iterator CondProxyProvider::m_inputCollectionsIterator {}
private

Definition at line 63 of file CondProxyProvider.h.

◆ m_inputCollectionsProp

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

InputCollections, vector with names of the input collections.

Definition at line 61 of file CondProxyProvider.h.


The documentation for this class was generated from the following files:
CondProxyProvider::getCollectionCnv
std::unique_ptr< PoolCollectionConverter > getCollectionCnv()
Return pointer to new PoolCollectionConverter.
Definition: CondProxyProvider.cxx:144
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
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
PoolCollectionConverter::selectAll
pool::ICollectionCursor & selectAll()
Definition: PoolCollectionConverter.cxx:110
SG::TransientAddress
Definition: TransientAddress.h:34
CxxUtils::RefCountedPtr
Simple smart pointer for Gaudi-style refcounted objects.
Definition: RefCountedPtr.h:39
pool::ICollectionCursor::next
virtual bool next()=0
Advances the cursor to the next row of the query result set.
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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:57
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DataHeader::size
int size() const
Definition: DataHeader.cxx:245
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:56
StoreID::DETECTOR_STORE
@ DETECTOR_STORE
Definition: StoreID.h:27
pool::ICollectionCursor
Definition: ICollectionCursor.h:22
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:134
LArConditionsTestConfig.poolSvc
poolSvc
Definition: LArConditionsTestConfig.py:80
get_generator_info.version
version
Definition: get_generator_info.py:33
PoolCollectionConverter::disconnectDb
StatusCode disconnectDb()
Disconnect Database.
Definition: PoolCollectionConverter.cxx:96
pool::ITransaction::READ
@ READ
Definition: ITransaction.h:29
CondProxyProvider::m_inputCollectionsProp
Gaudi::Property< std::vector< std::string > > m_inputCollectionsProp
InputCollections, vector with names of the input collections.
Definition: CondProxyProvider.h:62
pool::ICollectionCursor::eventRef
virtual const Token & eventRef() const =0
Returns the event reference Token for the current row.
CondProxyProvider::m_inputCollectionsIterator
std::vector< std::string >::const_iterator m_inputCollectionsIterator
Definition: CondProxyProvider.h:63
ServiceHandle< StoreGateSvc >