|
ATLAS Offline Software
|
Go to the documentation of this file.
12 #ifndef SG_XAOD_PROXY_LOADER_H
13 #define SG_XAOD_PROXY_LOADER_H
18 #include "GaudiKernel/ServiceHandle.h"
33 class TVirtualCollectionProxy;
105 const std::vector<std::string> &var_names,
106 const std::vector<std::string> &renounce,
107 const std::vector<const DataObjID *> &input_data_in,
108 const std::vector<const DataObjID *> &output_data_in,
109 std::vector<Gaudi::DataHandle *> &new_input_handles,
110 std::vector<Gaudi::DataHandle *> &new_output_handles);
122 const std::string &
varname)
const;
129 std::pair<RootUtils::TSMethodCall, TVirtualCollectionProxy *>
139 std::unordered_map<std::string, CxxUtils::CachedUniquePtrT<IAccessor> >::const_iterator
142 std::stringstream
msg;
143 msg <<
"No accessor stub was created for " <<
varname <<
" i.e. variable is unknown.";
144 throw std::runtime_error(
msg.str());
146 if (accessor_iter->second)
return *(accessor_iter->second);
158 template <
class T_Aux>
159 std::unique_ptr<IAccessor>
createAccessor(
const EventContext& ctx,
163 const std::string &method_name)
const;
169 template <
class T_Element_Key,
class T_Vector_Key>
178 std::stringstream
msg;
msg <<
"Conversion to " <<
typeid(T).
name() <<
" failed.";
179 throw std::runtime_error(
msg.str());
185 static bool isVector(
const std::any &anything) {
return anything.type() ==
typeid(T_Vector_Key); }
187 static bool isElement(
const std::any &anything) {
return anything.type() ==
typeid(T_Element_Key); }
189 static T_Element_Key &
elementKey(std::any &anything) {
return checkedRef(std::any_cast<T_Element_Key>(&anything)); }
191 static T_Vector_Key &
vectorKey(std::any &anything) {
return checkedRef(std::any_cast<T_Vector_Key>(&anything)); }
193 static const T_Element_Key &
elementKey(
const std::any &anything) {
return checkedRef(std::any_cast<T_Element_Key>(&anything)); }
195 static const T_Vector_Key &
vectorKey(
const std::any &anything) {
return checkedRef(std::any_cast<T_Vector_Key>(&anything)); }
208 std::unordered_map<std::string, CxxUtils::CachedUniquePtrT<IAccessor> >
m_accessor;
222 #endif // SG_XAOD_PROXY_LOADER_H
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual int loadIntVariableFromString(const std::string &varname) const
virtual IProxyLoader::VariableType variableTypeFromString(const std::string &varname) const
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
static T & checkedRef(T *a)
Return a reference for the given pointer.
Interface of an auxiliary class to pass the parent, e.g.
virtual std::vector< int > loadVecIntVariableFromString(const std::string &varname) const
virtual ~SGxAODProxyLoader()
Cached pointer with atomic update.
void splitVarnameIntoContainerAndMethod(const std::string &varname, std::string &containerName, std::string &methodName) const
static ParentHelper< T > wrapParent(T *parent)
auxiliary method to create the auxiliary class to declare new data handles with the calling AthAlgToo...
ServiceHandle< StoreGateSvc > StoreGateSvc_t
static T_Element_Key & elementKey(std::any &anything)
Get a reference to the element object referred to by any or throw an exception.
std::pair< RootUtils::TSMethodCall, TVirtualCollectionProxy * > getMethodCallAccessor(const std::string &method_name, const std::type_info &info) const
Auxiliary method to create a TMethodCall and eventually also a collection proxy to call the given met...
Property holding a SG store/key/clid from which a ReadHandle is made.
Manage index tracking and synchronization of auxiliary data.
static const T_Element_Key & elementKey(const std::any &anything)
Get a reference to the element object referred to by any or throw an exception (read only).
SGxAODProxyLoader(StoreGateSvc_t &evtStore, bool verbose=false)
std::unordered_map< std::string, CxxUtils::CachedUniquePtrT< IAccessor > > m_accessor
Association of variable names to accessors for corresponding xAOD object content.
size_t auxid_t
Identifier for a particular aux data item.
virtual std::vector< double > loadVecDoubleVariableFromString(const std::string &varname) const
static const T_Vector_Key & vectorKey(const std::any &anything)
Get a reference to the vector object referred to by any or throw an exception (read only).
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual StatusCode declare(SG::VarHandleKey &handle) override
This method needs to be implement to declare the given data handle.
Cached unique_ptr with atomic update.
Namespace holding all the expression evaluation code.
static bool isVector(const std::any &anything)
Check whether the given any is the "vector" object.
Particular map which is used to associate names to read handles of AuxElements or AuxVectorBase.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual StatusCode declare(SG::VarHandleKey &handle)=0
This method needs to be implement to declare the given data handle.
bool updateDataDependencies(SGxAODProxyLoader::IParentHelper &parent, const std::vector< std::string > &var_names, const std::vector< std::string > &renounce, const std::vector< const DataObjID * > &input_data_in, const std::vector< const DataObjID * > &output_data_in, std::vector< Gaudi::DataHandle * > &new_input_handles, std::vector< Gaudi::DataHandle * > &new_output_handles)
Create extra data dependencies arising eventually from the given variables.
ReadDecorHandleMap m_decorKeys
IAccessor & getAccessor(const EventContext &ctx, const std::string &varname) const
Get an existing or create a new accessor for the given variable name.
StoreGateSvc_t m_evtStore
A property holding a SG store/key/clid from which a VarHandle is made.
Interface of auxiliary classes to access xAOD object content.
static T_Vector_Key & vectorKey(std::any &anything)
Get a reference to the vector object referred to by any or throw an exception.
std::unique_ptr< IAccessor > createAccessor(const EventContext &ctx, const SG::ReadHandleKey< T_Aux > &key, const SG::ReadDecorHandleKey< T_Aux > *decor_key, SG::auxid_t method_id, const std::string &method_name) const
Auxiliary method to create an accessor for the given method_name.
static bool isElement(const std::any &anything)
Check whether the given any is the "element" object.
Template of an auxiliary class to declare the new handles in the parent AthAlgTool,...
virtual double loadDoubleVariableFromString(const std::string &varname) const
Handle class for reading a decoration on an object.
IAccessor & computeClassForVarname(const EventContext &ctx, std::unordered_map< std::string, CxxUtils::CachedUniquePtrT< IAccessor > >::const_iterator accessor_iter, const std::string &varname) const
Auxiliary method to create an xAOD object content accessor for the given variable name.
std::unique_ptr< IAccessor > m_emptyVectorAccessor
Special accessor to handle empty vectors Accessor are constructed at time of first evaluation.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Auxiliary class to access content of xAOD objects referred to by variables of an expressions handled ...