00001
00002
00003
00004
00006 #ifndef FOURMOMUTILS_XAODHELPERS_H
00007 #define FOURMOMUTILS_XAODHELPERS_H
00008
00024
00025 #include "AthContainers/AuxElement.h"
00026
00027
00028 namespace xAOD
00029 {
00030 namespace Helpers
00031 {
00032
00033 class _importHelper { };
00034
00035
00036 #define GET_VAL( FUNCNAME, VALTYPE, PERSVALTYPE ) \
00037 inline bool FUNCNAME( const SG::AuxElement& auxEle, const std::string& varName ) { \
00038 SG::AuxElement::ConstAccessor<PERSVALTYPE> acc(varName); \
00039 return static_cast<VALTYPE>( acc(auxEle) ); \
00040 }
00041
00043 GET_VAL( getBool, bool, char )
00044 GET_VAL( getInt, int, int )
00045 GET_VAL( getUInt, unsigned int, unsigned int )
00046 GET_VAL( getFloat, float, float )
00047 GET_VAL( getDouble, double, double )
00048
00049
00050
00051
00052 #define SET_VAL( FUNCNAME, VALTYPE, PERSVALTYPE ) \
00053 inline bool FUNCNAME( SG::AuxElement& auxEle, const std::string& varName, VALTYPE val ) { \
00054 SG::AuxElement::Accessor<PERSVALTYPE> acc(varName); \
00055 if ( acc.isAvailable(auxEle) && !(acc.isAvailableWritable(auxEle)) ) { \
00056 return false; \
00057 } \
00058 acc(auxEle) = static_cast<PERSVALTYPE>(val); \
00059 return true; \
00060 }
00061
00063 SET_VAL(setBool, bool, char )
00064 SET_VAL(setInt, int, int )
00065 SET_VAL(setUInt, unsigned int, unsigned int )
00066 SET_VAL(setFloat, float, float)
00067 SET_VAL(setDouble, double, double)
00068
00069
00070
00071
00072 #define DECO_VAL( FUNCNAME, VALTYPE, PERSVALTYPE ) \
00073 inline bool FUNCNAME( const SG::AuxElement& auxEle, const std::string& varName, VALTYPE val ) { \
00074 SG::AuxElement::Decorator<PERSVALTYPE> deco(varName); \
00075 if ( deco.isAvailable(auxEle) && !(deco.isAvailableWritable(auxEle)) ) { \
00076 return false; \
00077 } \
00078 deco(auxEle) = static_cast<PERSVALTYPE>(val); \
00079 return true; \
00080 }
00081
00083 SET_VAL(decoBool, bool, char )
00084 SET_VAL(decoInt, int, int )
00085 SET_VAL(decoUInt, unsigned int, unsigned int )
00086 SET_VAL(decoFloat, float, float)
00087 SET_VAL(decoDouble, double, double)
00088
00089 }
00090
00091 }
00092
00093
00094 #endif // FOURMOMUTILS_XAODHELPERS_H