ATLAS Offline Software
Loading...
Searching...
No Matches
SGNTUPProxyLoader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6// SGNTUPProxyLoader.cxx, (c) ATLAS Detector software
8// Author: Thomas Gillam (thomas.gillam@cern.ch)
9// ExpressionParsing library
11
13
14#define SG_GET_SCALAR(RETTYPE, TRYTYPE) do { if (m_evtStore->contains<TRYTYPE>(varname)) { \
15 const TRYTYPE *val = nullptr; \
16 StatusCode sc = m_evtStore->retrieve<TRYTYPE>((const TRYTYPE*&)val, varname); \
17 if (sc.isFailure()) { \
18 throw std::runtime_error("Couldn't retrieve (" #TRYTYPE ") " + varname); \
19 } \
20 return (RETTYPE)(*val); \
21} } while (0)
22
23#define SG_GET_VECTOR(RETTYPE, TRYTYPE) do { if (m_evtStore->contains<std::vector<TRYTYPE> >(varname)) { \
24 const std::vector<TRYTYPE> *val = nullptr; \
25 StatusCode sc = m_evtStore->retrieve<std::vector<TRYTYPE> >(val, varname); \
26 if (sc.isFailure()) { \
27 throw std::runtime_error("Couldn't retrieve (std::vector<" #TRYTYPE ">) " + varname); \
28 } \
29 std::vector<RETTYPE> temp; \
30 for (std::vector<TRYTYPE>::const_iterator it = val->begin(); it != val->end(); ++it) { \
31 temp.push_back((RETTYPE)(*it)); \
32 } \
33 return temp; \
34} } while (0)
35
36namespace ExpressionParsing {
40
42 {
43 }
44
46 {
47 if (m_evtStore->contains<int>(varname)) return VT_INT;
48 else if (m_evtStore->contains<bool>(varname)) return VT_INT;
49 else if (m_evtStore->contains<unsigned int>(varname)) return VT_INT;
50 else if (m_evtStore->contains<float>(varname)) return VT_DOUBLE;
51 else if (m_evtStore->contains<double>(varname)) return VT_DOUBLE;
52 else if (m_evtStore->contains<std::vector<int> >(varname)) return VT_VECINT;
53 else if (m_evtStore->contains<std::vector<bool> >(varname)) return VT_VECINT;
54 else if (m_evtStore->contains<std::vector<unsigned int> >(varname)) return VT_VECINT;
55 else if (m_evtStore->contains<std::vector<float> >(varname)) return VT_VECDOUBLE;
56 else if (m_evtStore->contains<std::vector<double> >(varname)) return VT_VECDOUBLE;
57 else return VT_UNK;
58 }
59
60 int SGNTUPProxyLoader::loadIntVariableFromString(const std::string &varname) const
61 {
62 SG_GET_SCALAR(int, int);
63 SG_GET_SCALAR(int, bool);
64 SG_GET_SCALAR(int, unsigned int);
65 throw std::runtime_error("Unknown int-like proxy: " + varname);
66 }
67
68 double SGNTUPProxyLoader::loadDoubleVariableFromString(const std::string &varname) const
69 {
70 SG_GET_SCALAR(double, float);
71 SG_GET_SCALAR(double, double);
72 throw std::runtime_error("Unknown double-like proxy: " + varname);
73 }
74
75 std::vector<int> SGNTUPProxyLoader::loadVecIntVariableFromString(const std::string &varname) const
76 {
77 SG_GET_VECTOR(int, int);
78 SG_GET_VECTOR(int, bool);
79 SG_GET_VECTOR(int, unsigned int);
80 throw std::runtime_error("Unknown vector<int>-like proxy: " + varname);
81 }
82
83 std::vector<double> SGNTUPProxyLoader::loadVecDoubleVariableFromString(const std::string &varname) const
84 {
85 SG_GET_VECTOR(double, float);
86 SG_GET_VECTOR(double, double);
87 throw std::runtime_error("Unknown vector<double>-like proxy: " + varname);
88 }
89}
#define SG_GET_SCALAR(RETTYPE, TRYTYPE)
#define SG_GET_VECTOR(RETTYPE, TRYTYPE)
virtual int loadIntVariableFromString(const std::string &varname) const
virtual IProxyLoader::VariableType variableTypeFromString(const std::string &varname) const
virtual double loadDoubleVariableFromString(const std::string &varname) const
virtual std::vector< int > loadVecIntVariableFromString(const std::string &varname) const
virtual std::vector< double > loadVecDoubleVariableFromString(const std::string &varname) const
Namespace holding all the expression evaluation code.