ATLAS Offline Software
Loading...
Searching...
No Matches
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
15
16#include <stdexcept>
17#include <iostream>
18#include <sstream>
19
20namespace ExpressionParsing {
22 m_varnameToProxyLoader(proxyCache_t::Updater_t())
23 {
24 }
25
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
38 {
39 for (const auto &proxyLoader : m_proxyLoaders) {
40 proxyLoader->reset();
41 }
42 }
43
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}
virtual double loadDouble(const EventContext &ctx, const std::string &varname) const override
IProxyLoader * push_back(std::unique_ptr< IProxyLoader > proxyLoader)
virtual std::pair< IAccessor::VariableType, const IAccessor & > getAccessorFromString(const EventContext &ctx, const std::string &varname) const override
std::vector< std::unique_ptr< IProxyLoader > > m_proxyLoaders
virtual std::vector< double > loadVec(const EventContext &ctx, const std::string &varname) const override
virtual IAccessor::VariableType variableType(const std::string &var_name) const override
virtual std::vector< int > loadVecInt(const EventContext &ctx, const std::string &varname) const override
virtual int loadInt(const EventContext &ctx, const std::string &varname) const override
CxxUtils::ConcurrentStrMap< const IAccessor *, CxxUtils::SimpleUpdater > proxyCache_t
Namespace holding all the expression evaluation code.
MsgStream & msg
Definition testRead.cxx:32