ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
CommonTools
ExpressionEvaluation
Root
MultipleProxyLoader.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// MultipleProxyLoader.cxx, (c) ATLAS Detector software
8
// Author: Thomas Gillam (thomas.gillam@cern.ch)
9
// ExpressionParsing library
11
12
13
#include "
ExpressionEvaluation/MultipleProxyLoader.h
"
14
#include "
AthContainers/CurrentContext.h
"
15
16
#include <stdexcept>
17
#include <iostream>
18
#include <sstream>
19
20
namespace
ExpressionParsing
{
21
MultipleProxyLoader::MultipleProxyLoader
() :
22
m_varnameToProxyLoader(
proxyCache_t
::Updater_t())
23
{
24
}
25
26
MultipleProxyLoader::~MultipleProxyLoader
()
27
{
28
}
29
30
31
IProxyLoader
*
MultipleProxyLoader::push_back
(std::unique_ptr<IProxyLoader> proxyLoader)
32
{
33
m_proxyLoaders
.push_back(std::move(proxyLoader));
34
return
m_proxyLoaders
.back().get();
35
}
36
37
void
MultipleProxyLoader::reset
()
38
{
39
for
(
const
auto
&proxyLoader :
m_proxyLoaders
) {
40
proxyLoader->reset();
41
}
42
}
43
44
IAccessor::VariableType
MultipleProxyLoader::variableType
(
const
std::string &varname)
const
{
45
const
EventContext& ctx = Gaudi::Hive::currentContext();
46
std::pair< IProxyLoader::VariableType, const IAccessor &>
47
ret =
getAccessorFromString
(ctx, varname);
48
return
ret.first;
49
}
50
51
std::pair<IAccessor::VariableType, const IAccessor & >
52
MultipleProxyLoader::getAccessorFromString
(
const
EventContext &ctx,
const
std::string &varname)
const
53
{
54
auto
itr = m_varnameToProxyLoader.find(varname);
55
if
(itr != m_varnameToProxyLoader.end()) {
56
return
{itr->second->variableType(varname),*itr->second};
57
}
58
59
for
(
const
auto
&proxyLoader :
m_proxyLoaders
) {
60
try
{
61
std::pair<IAccessor::VariableType, const IAccessor &>
62
result = proxyLoader->getAccessorFromString(ctx, varname);
63
if
(result.first ==
VT_UNK
)
continue
;
64
if
(result.first !=
VT_VECEMPTY
) {
65
// do not cache the result for an "empty vector", since in such cases there is
66
// not enough information available to decide the correct accessor.
67
m_varnameToProxyLoader.emplace(varname, &result.second);
68
}
69
return
result;
70
}
catch
(
const
std::runtime_error &) {
71
continue
;
72
}
73
}
74
std::stringstream
msg
;
75
msg
<<
"MultipleProxyLoader: unable to find valid proxy loader for "
<< varname <<
"."
76
<<
" If it is an xAOD element or container which is read from the input file"
77
<<
" this problem may occur if it is not accessed anywhere in the job via read handles."
78
<<
" The problem can be mitigated by providing the missing information in the property "
79
<<
" ExtraDataForDynamicConsumers of the sequence which has the property "
80
<<
" ProcessDynamicDataDependencies set to True."
81
<<
" The property takes a list of strings of the form \'type/container-name\' e.g."
82
<<
" \'xAOD::TrackParticleContainer/InDetTrackParticles\'."
;
83
throw
std::runtime_error(
msg
.str());
84
}
85
86
int
MultipleProxyLoader::loadInt
(
const
EventContext& ctx,
const
std::string &varname)
const
87
{
88
return
m_varnameToProxyLoader.at(varname)->loadInt(ctx,varname);
89
}
90
91
double
MultipleProxyLoader::loadDouble
(
const
EventContext& ctx,
const
std::string &varname)
const
92
{
93
return
m_varnameToProxyLoader.at(varname)->loadDouble(ctx,varname);
94
}
95
96
std::vector<int>
MultipleProxyLoader::loadVecInt
(
const
EventContext& ctx,
const
std::string &varname)
const
97
{
98
return
m_varnameToProxyLoader.at(varname)->loadVecInt(ctx,varname);
99
}
100
101
std::vector<double>
MultipleProxyLoader::loadVec
(
const
EventContext& ctx,
const
std::string &varname)
const
102
{
103
return
m_varnameToProxyLoader.at(varname)->loadVec(ctx,varname);
104
}
105
}
CurrentContext.h
MultipleProxyLoader.h
ExpressionParsing::IAccessor::VariableType
VariableType
Definition
IAccessor.h:19
ExpressionParsing::IAccessor::VT_VECEMPTY
@ VT_VECEMPTY
Definition
IAccessor.h:19
ExpressionParsing::IAccessor::VT_UNK
@ VT_UNK
Definition
IAccessor.h:19
ExpressionParsing::IProxyLoader
Definition
IProxyLoader.h:21
ExpressionParsing::MultipleProxyLoader::loadDouble
virtual double loadDouble(const EventContext &ctx, const std::string &varname) const override
Definition
MultipleProxyLoader.cxx:91
ExpressionParsing::MultipleProxyLoader::push_back
IProxyLoader * push_back(std::unique_ptr< IProxyLoader > proxyLoader)
Definition
MultipleProxyLoader.cxx:31
ExpressionParsing::MultipleProxyLoader::getAccessorFromString
virtual std::pair< IAccessor::VariableType, const IAccessor & > getAccessorFromString(const EventContext &ctx, const std::string &varname) const override
Definition
MultipleProxyLoader.cxx:52
ExpressionParsing::MultipleProxyLoader::~MultipleProxyLoader
virtual ~MultipleProxyLoader()
Definition
MultipleProxyLoader.cxx:26
ExpressionParsing::MultipleProxyLoader::m_proxyLoaders
std::vector< std::unique_ptr< IProxyLoader > > m_proxyLoaders
Definition
MultipleProxyLoader.h:44
ExpressionParsing::MultipleProxyLoader::loadVec
virtual std::vector< double > loadVec(const EventContext &ctx, const std::string &varname) const override
Definition
MultipleProxyLoader.cxx:101
ExpressionParsing::MultipleProxyLoader::variableType
virtual IAccessor::VariableType variableType(const std::string &var_name) const override
Definition
MultipleProxyLoader.cxx:44
ExpressionParsing::MultipleProxyLoader::reset
virtual void reset() override
Definition
MultipleProxyLoader.cxx:37
ExpressionParsing::MultipleProxyLoader::loadVecInt
virtual std::vector< int > loadVecInt(const EventContext &ctx, const std::string &varname) const override
Definition
MultipleProxyLoader.cxx:96
ExpressionParsing::MultipleProxyLoader::loadInt
virtual int loadInt(const EventContext &ctx, const std::string &varname) const override
Definition
MultipleProxyLoader.cxx:86
ExpressionParsing::MultipleProxyLoader::proxyCache_t
CxxUtils::ConcurrentStrMap< const IAccessor *, CxxUtils::SimpleUpdater > proxyCache_t
Definition
MultipleProxyLoader.h:46
ExpressionParsing::MultipleProxyLoader::MultipleProxyLoader
MultipleProxyLoader()
Definition
MultipleProxyLoader.cxx:21
ExpressionParsing
Namespace holding all the expression evaluation code.
Definition
ExpressionParser.h:26
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0