ATLAS Offline Software
Loading...
Searching...
No Matches
xAODHelpers.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// xAODHelpers.h
8// Header file for xAOD helper functions
9// Author: karsten.koeneke@cern.ch
11#ifndef FOURMOMUTILS_XAODHELPERS_H
12#define FOURMOMUTILS_XAODHELPERS_H
13
27
28
29// EDM includes
31
32
33namespace xAOD
34{
35 namespace Helpers
36 {
37
38 class _importHelper { /* dummy */ };
39
40// Define a pre-processor macro for the implementations of all these methods
41#define GET_VAL( FUNCNAME, VALTYPE, PERSVALTYPE ) \
42 inline bool FUNCNAME( const SG::AuxElement& auxEle, const std::string& varName ) { \
43 SG::AuxElement::ConstAccessor<PERSVALTYPE> acc(varName); \
44 return static_cast<VALTYPE>( acc(auxEle) ); \
45 }
46
48 GET_VAL( getBool, bool, char )
49 GET_VAL( getInt, int, int )
50 GET_VAL( getUInt, unsigned int, unsigned int )
51 GET_VAL( getFloat, float, float )
52 GET_VAL( getDouble, double, double )
53
54
55
56// Define a pre-processor macro for the implementations of all these methods
57#define SET_VAL( FUNCNAME, VALTYPE, PERSVALTYPE ) \
58 inline bool FUNCNAME( SG::AuxElement& auxEle, const std::string& varName, VALTYPE val ) { \
59 SG::AuxElement::Accessor<PERSVALTYPE> acc(varName); \
60 if ( acc.isAvailable(auxEle) && !(acc.isAvailableWritable(auxEle)) ) { \
61 return false; \
62 } \
63 acc(auxEle) = static_cast<PERSVALTYPE>(val); \
64 return true; \
65 }
66
68 SET_VAL(setBool, bool, char )
69 SET_VAL(setInt, int, int )
70 SET_VAL(setUInt, unsigned int, unsigned int )
71 SET_VAL(setFloat, float, float)
72 SET_VAL(setDouble, double, double)
73
74
75
76// Define a pre-processor macro for the implementations of all these methods
77#define DECO_VAL( FUNCNAME, VALTYPE, PERSVALTYPE ) \
78 inline bool FUNCNAME( const SG::AuxElement& auxEle, const std::string& varName, VALTYPE val ) { \
79 SG::AuxElement::Decorator<PERSVALTYPE> deco(varName); \
80 if ( deco.isAvailable(auxEle) && !(deco.isAvailableWritable(auxEle)) ) { \
81 return false; \
82 } \
83 deco(auxEle) = static_cast<PERSVALTYPE>(val); \
84 return true; \
85 }
86
88 SET_VAL(decoBool, bool, char )
89 SET_VAL(decoInt, int, int )
90 SET_VAL(decoUInt, unsigned int, unsigned int )
91 SET_VAL(decoFloat, float, float)
92 SET_VAL(decoDouble, double, double)
93
94 } //> namespace Helpers
95
96} // End: namespace xAOD
97
98
99#endif // FOURMOMUTILS_XAODHELPERS_H
Base class for elements of a container that can have aux data.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
#define SET_VAL(FUNCNAME, VALTYPE, PERSVALTYPE)
Access to get a variable of the different types.
Definition xAODHelpers.h:57
#define GET_VAL(FUNCNAME, VALTYPE, PERSVALTYPE)
Definition xAODHelpers.h:41