ATLAS Offline Software
MultipleProxyLoader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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 
14 
15 #include <stdexcept>
16 #include <iostream>
17 #include <sstream>
18 
19 namespace ExpressionParsing {
21  m_varnameToProxyLoader(proxyCache_t::Updater_t())
22  {
23  }
24 
26  {
27  }
28 
29 
31  {
32  m_proxyLoaders.push_back(proxyLoader);
33  }
34 
36  {
37  for (const auto &proxyLoader : m_proxyLoaders) {
38  proxyLoader->reset();
39  }
40  }
41 
43  {
44  auto itr = m_varnameToProxyLoader.find(varname);
45  if (itr != m_varnameToProxyLoader.end()) {
46  return itr->second->variableTypeFromString(varname);
47  }
48 
50  for (const auto &proxyLoader : m_proxyLoaders) {
51  try {
52  result = proxyLoader->variableTypeFromString(varname);
53  if (result == VT_UNK) continue;
54  } catch (const std::runtime_error &) {
55  continue;
56  }
57  m_varnameToProxyLoader.emplace(varname, proxyLoader);
58  return result;
59  }
60  std::stringstream msg;
61  msg << "MultipleProxyLoader: unable to find valid proxy loader for " << varname << "."
62  << " If it is an xAOD element or container which is read from the input file"
63  << " this problem may occur if it is not accessed anywhere in the job via read handles."
64  << " The problem can be mitigated by providing the missing information in the property "
65  << " ExtraDataForDynamicConsumers of the sequence which has the property "
66  << " ProcessDynamicDataDependencies set to True."
67  << " The property takes a list of strings of the form \'type/container-name\' e.g."
68  << " \'xAOD::TrackParticleContainer/InDetTrackParticles\'.";
69  throw std::runtime_error(msg.str());
70  }
71 
73  {
74  return m_varnameToProxyLoader.at(varname)->loadIntVariableFromString(varname);
75  }
76 
78  {
79  return m_varnameToProxyLoader.at(varname)->loadDoubleVariableFromString(varname);
80  }
81 
82  std::vector<int> MultipleProxyLoader::loadVecIntVariableFromString(const std::string &varname) const
83  {
84  return m_varnameToProxyLoader.at(varname)->loadVecIntVariableFromString(varname);
85  }
86 
87  std::vector<double> MultipleProxyLoader::loadVecDoubleVariableFromString(const std::string &varname) const
88  {
89  return m_varnameToProxyLoader.at(varname)->loadVecDoubleVariableFromString(varname);
90  }
91 }
ExpressionParsing::MultipleProxyLoader::loadIntVariableFromString
virtual int loadIntVariableFromString(const std::string &varname) const
Definition: MultipleProxyLoader.cxx:72
get_generator_info.result
result
Definition: get_generator_info.py:21
ExpressionParsing::MultipleProxyLoader::variableTypeFromString
virtual IProxyLoader::VariableType variableTypeFromString(const std::string &varname) const
Definition: MultipleProxyLoader.cxx:42
ExpressionParsing::MultipleProxyLoader::loadDoubleVariableFromString
virtual double loadDoubleVariableFromString(const std::string &varname) const
Definition: MultipleProxyLoader.cxx:77
ExpressionParsing::IProxyLoader
Definition: IProxyLoader.h:19
ExpressionParsing::IProxyLoader::VariableType
VariableType
Definition: IProxyLoader.h:21
ExpressionParsing::MultipleProxyLoader::proxyCache_t
CxxUtils::ConcurrentStrMap< IProxyLoader *, CxxUtils::SimpleUpdater > proxyCache_t
Definition: MultipleProxyLoader.h:43
ExpressionParsing::IProxyLoader::VT_UNK
@ VT_UNK
Definition: IProxyLoader.h:21
ExpressionParsing::MultipleProxyLoader::~MultipleProxyLoader
virtual ~MultipleProxyLoader()
Definition: MultipleProxyLoader.cxx:25
ExpressionParsing::MultipleProxyLoader::reset
virtual void reset()
Definition: MultipleProxyLoader.cxx:35
ExpressionParsing
Namespace holding all the expression evaluation code.
Definition: ExpressionParser.h:26
ExpressionParsing::MultipleProxyLoader::push_back
void push_back(IProxyLoader *proxyLoader)
Definition: MultipleProxyLoader.cxx:30
ExpressionParsing::MultipleProxyLoader::MultipleProxyLoader
MultipleProxyLoader()
Definition: MultipleProxyLoader.cxx:20
ExpressionParsing::MultipleProxyLoader::loadVecIntVariableFromString
virtual std::vector< int > loadVecIntVariableFromString(const std::string &varname) const
Definition: MultipleProxyLoader.cxx:82
ExpressionParsing::MultipleProxyLoader::loadVecDoubleVariableFromString
virtual std::vector< double > loadVecDoubleVariableFromString(const std::string &varname) const
Definition: MultipleProxyLoader.cxx:87
MultipleProxyLoader.h
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ExpressionParsing::MultipleProxyLoader::m_proxyLoaders
std::vector< IProxyLoader * > m_proxyLoaders
Definition: MultipleProxyLoader.h:41