ATLAS Offline Software
Loading...
Searching...
No Matches
graphics
VP1
VP1Utils
src
VP1SGContentsHelper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Implementation of class VP1SGContentsHelper //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: March 2008 //
12
// //
14
15
#include "
VP1Utils/VP1SGContentsHelper.h
"
16
#include "
VP1Base/IVP1System.h
"
17
#include "
VP1Base/VP1Msg.h
"
18
#include "
StoreGate/StoreGateSvc.h
"
//
19
#include <stdexcept>
20
#include <QStringList>
21
// //
23
24
//____________________________________________________________________
25
VP1SGContentsHelper::VP1SGContentsHelper
(
IVP1System
* sys,
const
bool
detStore )
26
:
VP1HelperClassBase
(sys,
"VP1SGContentsHelper"
),
m_sg
(sys?(detStore?sys->detectorStore():sys->storeGate()):0)
27
{
28
if
(!sys)
29
message
(
"ERROR: Received null system pointer (won't be able to get storeGate pointer either)"
);
30
else
if
(!
m_sg
)
31
message
(
"ERROR: Could not get "
+QString(detStore?
"storeGate"
:
"detectorStore"
)+
" pointer from system"
);
32
}
33
34
//____________________________________________________________________
35
VP1SGContentsHelper::VP1SGContentsHelper
(
StoreGateSvc
* sg )
36
:
VP1HelperClassBase
(0,
"VP1SGContentsHelper"
),
m_sg
(sg)
37
{
38
if
(!sg)
39
message
(
"ERROR: Received null storegate pointer"
);
40
}
41
42
//____________________________________________________________________
43
bool
VP1SGContentsHelper::contains
(
const
CLID
&
id
,
const
QString& key )
const
44
{
45
if
(
VP1Msg::verbose
())
46
messageVerbose
(
"contains(..) called for key = "
+key);
47
if
(!
m_sg
) {
48
message
(
"ERROR: Does not have StoreGate pointer - returning false."
);
49
return
false
;
50
}
51
if
(key.isEmpty()) {
52
message
(
"ERROR: Passed key is empty. Returning false."
);
53
return
false
;
54
}
55
bool
contains
=
false
;
56
bool
exception =
true
;
57
try
{
58
contains
=
m_sg
->contains(
id
,key.toStdString());
59
exception =
false
;
60
}
catch
(
const
std::runtime_error& e) {
61
exception =
true
;
62
}
63
if
(exception) {
64
message
(
"ERROR: Exception thrown during call to StoreGateSvc::contains(..). Returning false."
);
65
return
false
;
66
}
67
if
(
VP1Msg::verbose
())
68
messageVerbose
(
"contains(..) returning "
+QString(
contains
?
"true"
:
"false"
));
69
return
contains
;
70
}
71
72
//____________________________________________________________________
73
QStringList
VP1SGContentsHelper::getKeys
(
const
CLID
&
id
)
const
74
{
75
messageVerbose
(
"getKeys(..) called for CLID = "
+QString::number(
id
));
76
if
(!
m_sg
) {
77
message
(
"ERROR: Does not have StoreGate pointer - returning empty key list"
);
78
return
QStringList();
79
}
80
QStringList l;
81
82
std::vector<std::string> keys;
83
84
bool
exception =
true
;
85
try
{
86
m_sg
->keys(
id
, keys);
87
exception =
false
;
88
}
catch
(
const
std::runtime_error& e) {
89
exception =
true
;
90
}
91
if
(exception) {
92
message
(
"ERROR: Exception thrown during call to StoreGateSvc::keys(..)"
);
93
return
QStringList();
94
}
95
std::vector<std::string>::const_iterator it(keys.begin()), itE(keys.end());
96
for
(;it!=itE;++it) {
97
if
(it->empty())
98
continue
;
99
if
(
contains
(
id
,it->c_str()))
100
l << it->c_str();
101
else
if
(
VP1Msg::verbose
())
102
messageVerbose
(
"NB: StoreGateSvc::keys() included '"
+QString(it->c_str())
103
+
"' but StoreGateSvc::contains("
+QString(it->c_str())+
") returns false."
);
104
}
105
if
(
VP1Msg::verbose
()) {
106
messageVerbose
(
"returning "
+QString::number(l.count())+
" keys:"
);
107
messageVerbose
(
" => "
,l);
108
}
109
return
l;
110
}
111
112
//____________________________________________________________________
113
QList<CLID>
VP1SGContentsHelper::getPossibleCLIDs
()
const
114
{
115
messageVerbose
(
"getPossibleCLIDs(..) called"
);
116
QList<CLID> l;
117
if
(!
m_sg
) {
118
message
(
"ERROR: Does not have StoreGate pointer - returning empty key list"
);
119
return
l;
120
}
121
122
for
(
CLID
id
:
m_sg
->clids())
123
l << id;
124
return
l;
125
}
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IVP1System.h
StoreGateSvc.h
VP1Msg.h
VP1SGContentsHelper.h
IVP1System
Definition
IVP1System.h:36
StoreGateSvc
The Athena Transient Store API.
Definition
StoreGateSvc.h:122
VP1HelperClassBase::VP1HelperClassBase
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
Definition
VP1HelperClassBase.cxx:28
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition
VP1HelperClassBase.cxx:78
VP1HelperClassBase::message
void message(const QString &) const
Definition
VP1HelperClassBase.cxx:49
VP1Msg::verbose
static bool verbose()
Definition
VP1Msg.h:31
VP1SGContentsHelper::m_sg
StoreGateSvc * m_sg
Definition
VP1SGContentsHelper.h:45
VP1SGContentsHelper::VP1SGContentsHelper
VP1SGContentsHelper(IVP1System *, const bool detStore=false)
Definition
VP1SGContentsHelper.cxx:25
VP1SGContentsHelper::contains
bool contains(const QString &key) const
Definition
VP1SGContentsHelper.h:61
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition
VP1SGContentsHelper.h:55
VP1SGContentsHelper::getPossibleCLIDs
QList< CLID > getPossibleCLIDs() const
Definition
VP1SGContentsHelper.cxx:113
Generated on
for ATLAS Offline Software by
1.14.0