ATLAS Offline Software
Loading...
Searching...
No Matches
PoolCollectionConverter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
11#include "PoolSvc/IPoolSvc.h"
13
14// Pool
18
19// Gaudi
20#include "GaudiKernel/StatusCode.h"
21
22#include <exception>
23#include <format>
24
25//______________________________________________________________________________
26PoolCollectionConverter::PoolCollectionConverter(const std::string& collectionType,
27 const std::string& inputCollection,
28 unsigned int contextId,
29 const IPoolSvc* svc) :
30 m_collectionType(collectionType),
32 m_inputCollection(inputCollection),
33 m_contextId(contextId),
34 m_poolSvc(svc),
35 m_poolCollection(nullptr),
36 m_collectionCursor(nullptr),
38}
39//______________________________________________________________________________
47//______________________________________________________________________________
49 // Find out if the user specified a container
50 const std::string collectionType = m_collectionType;
51 std::string::size_type p_colon = collectionType.rfind(':');
52 if (p_colon != std::string::npos) {
53 m_inputContainer = collectionType.substr(p_colon + 1);
54 m_collectionType = collectionType.substr(0, p_colon);
55 }
56 if (m_collectionType == "ImplicitCollection") {
57 // Check if already prefixed
58 if (m_inputCollection.starts_with( "PFN:")
59 || m_inputCollection.starts_with( "LFN:")
60 || m_inputCollection.starts_with( "FID:")) {
61 // Already prefixed
63 } else {
64 // Prefix with PFN:
65 m_connection = std::format("PFN:{}", m_inputCollection);
66 }
67 try {
68 m_poolCollection = m_poolSvc->createCollection("RootCollection", m_connection, m_inputCollection, m_contextId);
69 } catch (std::exception &e) {
70 m_poolCollection = nullptr;
71 }
72 if (m_poolCollection == nullptr) {
73 // Now set where to look in the implicit file
74 m_inputCollection = std::format("{}(DataHeader)", m_inputContainer);
75 }
76 }
77 try {
78 if (m_poolCollection == nullptr) {
80 }
81 if (m_poolCollection == nullptr && m_collectionType == "ImplicitCollection") {
82 m_inputCollection = std::format("{}_DataHeader", m_inputContainer);
84 }
85 } catch (std::exception &e) {
86 return StatusCode::RECOVERABLE;
87 }
88 return StatusCode::SUCCESS;
89}
90//______________________________________________________________________________
92 if (m_poolCollection == nullptr) {
93 return StatusCode::SUCCESS;
94 }
95 if (m_poolCollection->description().type() == "ImplicitCollection") {
96 return m_poolSvc->disconnectDb(m_connection);
97 }
98 return StatusCode::SUCCESS;
99}
100//______________________________________________________________________________
102 return m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE;
103}
104//______________________________________________________________________________
This file contains the class definition for the IPoolSvc interface class.
This file contains the class definition for the PoolCollectionConverter class.
This file contains the class definition for the Token class (migrated from POOL).
This class provides the interface to the LCG POOL persistency software.
Definition IPoolSvc.h:35
StatusCode disconnectDb()
Disconnect Database.
pool::ICollectionCursor * m_collectionCursor
pool::ICollection * m_poolCollection
StatusCode isValid() const
Check whether has valid pool::ICollection*.
PoolCollectionConverter(const std::string &collectionType, const std::string &inputCollection, unsigned int contextId, const IPoolSvc *svc)
Constructor.
pool::ICollectionCursor & selectAll()
virtual ~PoolCollectionConverter()
Destructor.
StatusCode initialize()
Required by all Gaudi Services.
An interface used to navigate the result of a query on a collection.