ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
xAODRootAccess
Root
EventTVirtualEvent.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
//
3
// File holding the implementation of the xAOD::Event functions that implement
4
// the TVirtualEvent interface.
5
//
6
7
// Local include(s).
8
#include "
xAODRootAccess/Event.h
"
9
10
#include "
xAODRootAccess/TActiveStore.h
"
11
#include "
xAODRootAccess/TStore.h
"
12
#include "
xAODRootAccess/tools/TVirtualManager.h
"
13
#include "
xAODRootAccess/tools/Utils.h
"
14
15
namespace
xAOD
{
16
27
SG::sgkey_t
Event::getHash
(
const
std::string& key)
const
{
28
29
// For empty keys let's finish quickly.
30
if
(key ==
""
) {
31
return
0;
32
}
33
34
// If the key is used in the input file, let's use the same hash for
35
// the output file as well.
36
if
(
m_inputEventFormat
.exists(key)) {
37
return
m_inputEventFormat
.get(key)->hash();
38
}
39
40
// If it's a new key, make a new hash for it from scratch:
41
return
Utils::hash
(key);
42
}
43
51
SG::sgkey_t
Event::getKey
(
const
void
* obj)
const
{
52
53
// Make use of the getName function.
54
return
getHash
(
getName
(obj));
55
}
56
64
const
std::string&
Event::getName
(
const
void
* obj)
const
{
65
66
// First look among the output objects.
67
for
(
const
auto
& [key, manager] :
m_outputObjects
) {
68
// Check if this is our object.
69
if
(manager->object() == obj) {
70
// If it is, let's return right away.
71
return
key;
72
}
73
}
74
75
// Now look among the input objects.
76
for
(
const
auto
& [key, manager] :
m_inputObjects
) {
77
// Check if this is our object.
78
if
(manager->object() == obj) {
79
// If it is, let's return.
80
return
key;
81
}
82
}
83
84
// If it's not there either, check if it's in an active TStore object:
85
const
TStore
* store =
TActiveStore::store
();
86
if
(store && store->contains(obj)) {
87
// Get the name from the store then:
88
return
store->getName(obj);
89
}
90
91
// We didn't find the object in the event...
92
ATH_MSG_WARNING
(
"Didn't find object with pointer \""
<< obj
93
<<
"\" in the event"
);
94
static
const
std::string dummy;
95
return
dummy;
96
}
97
105
const
std::string&
Event::getName
(
SG::sgkey_t
hash)
const
{
106
107
// If the branch is known from the input:
108
if
(
m_inputEventFormat
.exists(hash)) {
109
return
m_inputEventFormat
.get(hash)->branchName();
110
}
111
112
// If the branch is known on the output:
113
if
(
m_outputEventFormat
&&
m_outputEventFormat
->exists(hash)) {
114
return
m_outputEventFormat
->get(hash)->branchName();
115
}
116
117
// If this is an object in the active store:
118
const
TStore
* store =
TActiveStore::store
();
119
if
(store && store->contains(hash)) {
120
return
store->getName(hash);
121
}
122
123
// If it is unknown:
124
static
const
std::string dummy;
125
return
dummy;
126
}
127
138
void
*
Event::getOutputObject
(
SG::sgkey_t
key,
const
std::type_info& ti) {
139
140
// Get a string name for this key.
141
const
std::string&
name
=
getName
(key);
142
if
(
name
.empty()) {
143
return
nullptr
;
144
}
145
146
// Forward the call to the function using an std::string key.
147
static
const
bool
METADATA =
false
;
148
return
getOutputObject
(
name
, ti, METADATA);
149
}
150
162
const
void
*
Event::getInputObject
(
SG::sgkey_t
key,
const
std::type_info& ti,
163
bool
silent) {
164
165
// Get a string name for this key:
166
const
std::string&
name
=
getName
(key);
167
if
(
name
.empty() && (silent ==
false
)) {
168
ATH_MSG_WARNING
(
"Key 0x"
<< std::hex << key <<
" unknown"
);
169
return
nullptr
;
170
}
171
172
// Forward the call to the function using an std::string key:
173
static
const
bool
METADATA =
false
;
174
return
getInputObject
(
name
, ti, silent, METADATA);
175
}
176
177
}
// namespace xAOD
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
Utils.h
Event.h
TActiveStore.h
TStore.h
TVirtualManager.h
xAOD::Event::m_inputEventFormat
EventFormat m_inputEventFormat
Format of the current input file.
Definition
Event.h:355
xAOD::Event::name
const std::string & name() const override
Get the name of the instance.
Definition
EventIProxyDict.cxx:315
xAOD::Event::getInputObject
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent) override
Function for retrieving an input object in a non-template way.
Definition
EventTVirtualEvent.cxx:162
xAOD::Event::getName
const std::string & getName(const void *obj) const override
Function returning the key describing a known object.
Definition
EventTVirtualEvent.cxx:64
xAOD::Event::m_inputObjects
Object_t m_inputObjects
Collection of all the managed input objects.
Definition
Event.h:342
xAOD::Event::getKey
SG::sgkey_t getKey(const void *obj) const override
Function returning the hash describing a known object.
Definition
EventTVirtualEvent.cxx:51
xAOD::Event::getOutputObject
void * getOutputObject(SG::sgkey_t key, const std::type_info &ti) override
Function for retrieving an output object in a non-template way.
Definition
EventTVirtualEvent.cxx:138
xAOD::Event::getHash
SG::sgkey_t getHash(const std::string &key) const override
Function returning the hash describing an object name.
Definition
EventTVirtualEvent.cxx:27
xAOD::Event::m_outputEventFormat
EventFormat * m_outputEventFormat
Format of the current output file.
Definition
Event.h:357
xAOD::Event::m_outputObjects
Object_t m_outputObjects
Collection of all the managed output object.
Definition
Event.h:347
xAOD::TActiveStore::store
static TStore * store()
Access the currently active TStore object.
Definition
TActiveStore.cxx:16
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition
TStore.h:45
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition
sgkey_t.h:32
xAOD::Utils::hash
SG::sgkey_t hash(const std::string &name)
This function provides a hashed version of the key (branch) names used in the xAOD file,...
Definition
Control/xAODRootAccess/Root/Utils.cxx:125
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
Generated on
for ATLAS Offline Software by
1.17.0