Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LinkColumn.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 #ifndef COLUMNAR_CORE_LINK_COLUMN_H
9 #define COLUMNAR_CORE_LINK_COLUMN_H
10 
11 #include <AthLinks/ElementLink.h>
14 
15 namespace columnar
16 {
24  template<ContainerId LT,typename ELT> struct LinkCastColumn {};
25 
26 
27 
28  // in xAOD mode we can do a straightforward conversion from
29  // ElementLink to OptObjectId, as ElementLink contains all the
30  // information about the object
31  template<ContainerId LT>
33  {
37  static constexpr bool isNativeType = false;
38  static constexpr bool useConvertInput = true;
39  static constexpr bool useConvertWithDataInput = false;
40  static ColumnInfo& updateColumnInfo (ColumnarTool<CM>& /*columnarTool*/, ColumnInfo& info) {return info;}
41 
43  {
44  if (link.isValid())
45  {
46  typename ContainerIdTraits<LT>::xAODObjectIdType *ptr = *link.cptr();
47  return OptObjectId<LT,CM> (ptr);
48  } else
49  {
50  return OptObjectId<LT,CM> ();
51  }
52  }
53  };
54 
55 
56  template<ContainerId LT,typename ELT>
58  {
62  static constexpr bool isNativeType = false;
63  static constexpr bool useConvertInput = true;
64  static constexpr bool useConvertWithDataInput = false;
65  static ColumnInfo& updateColumnInfo (ColumnarTool<CM>& /*columnarTool*/, ColumnInfo& info) {return info;}
66 
68  {
69  if (link.isValid())
70  {
71  auto *ptr = *link.cptr();
72  if (!ptr) return OptObjectId<LT,CM> ();
73  auto *ptr2 = dynamic_cast<typename ContainerIdTraits<LT>::xAODObjectIdType*>(ptr);
74  if (!ptr2) throw std::runtime_error ("link not of expected type");
75  return OptObjectId<LT,CM> (ptr2);
76  } else
77  {
78  return OptObjectId<LT,CM> ();
79  }
80  }
81  };
82 
83 
84 
85 
86 
87  // in Array mode we take an index from the underlying column and
88  // combine it with the data vector from the input to get the new
89  // OptObjectId
90  template<ContainerId LT>
92  {
96  using DataType = void **;
97  static constexpr bool isNativeType = false;
98  static constexpr bool useConvertInput = false;
99  static constexpr bool useConvertWithDataInput = true;
101  {
102  info.linkToName = columnarTool.objectName(LT);
103  return info;
104  }
105 
107  {
108  if (link == invalidObjectIndex)
109  return OptObjectId<LT,CM> ();
110  return OptObjectId<LT,CM> (data, link);
111  }
112  };
113  // I'm just inheriting the ColumnTypeTraits from OptObjectId, as the
114  // behavior is exactly the same.
115  template<ContainerId LT,typename ELT>
116  struct ColumnTypeTraits<LinkCastColumn<LT,ELT>,ColumnarModeArray> : ColumnTypeTraits<OptObjectId<LT>,ColumnarModeArray> {};
117 }
118 
119 #endif
grepfile.info
info
Definition: grepfile.py:38
columnar::ContainerIdTraits
Definition: ContainerId.h:97
columnar::ColumnTypeTraits< OptObjectId< LT >, ColumnarModeArray >::convertInput
static OptObjectId< LT > convertInput(void **data, ColumnarOffsetType link)
Definition: LinkColumn.h:106
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
OptObjectId.h
columnar::ColumnTypeTraits< OptObjectId< LT >, ColumnarModeArray >::updateColumnInfo
static ColumnInfo & updateColumnInfo(ColumnarTool< CM > &columnarTool, ColumnInfo &info)
Definition: LinkColumn.h:100
columnar::ColumnTypeTraits::useConvertWithDataInput
static constexpr bool useConvertWithDataInput
Definition: ColumnAccessor.h:99
columnar::ColumnTypeTraits::useConvertInput
static constexpr bool useConvertInput
Definition: ColumnAccessor.h:98
columnar::OptObjectId
a class representing a single optional object (electron, muons, etc.)
Definition: OptObjectId.h:24
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
columnar::ColumnTypeTraits< OptObjectId< LT >, ColumnarModeArray >::ColumnType
ColumnarOffsetType ColumnType
Definition: LinkColumn.h:94
columnar::ColumnTypeTraits< OptObjectId< LT >, ColumnarModeXAOD >::updateColumnInfo
static ColumnInfo & updateColumnInfo(ColumnarTool< CM > &, ColumnInfo &info)
Definition: LinkColumn.h:40
columnar::ColumnInfo
a struct that contains meta-information about each column that's needed to interface the column with ...
Definition: ColumnInfo.h:35
ColumnAccessor.h
columnar::ColumnTypeTraits< OptObjectId< LT >, ColumnarModeXAOD >::convertInput
static OptObjectId< LT > convertInput(const ElementLink< typename ContainerIdTraits< LT >::xAODElementLinkType > &link)
Definition: LinkColumn.h:42
columnar::ColumnTypeTraits< OptObjectId< LT >, ColumnarModeArray >::DataType
void ** DataType
Definition: LinkColumn.h:96
columnar::ColumnTypeTraits::isNativeType
static constexpr bool isNativeType
Definition: ColumnAccessor.h:97
SignEnum::LT
@ LT
Definition: SignEnums.h:17
columnar::final
CM final
Definition: ColumnAccessor.h:106
columnar::NativeColumn
a type wrapper to force AccessorTemplate to treat the type as native
Definition: ColumnAccessor.h:120
columnar::invalidObjectIndex
constexpr ColumnarOffsetType invalidObjectIndex
the value for an invalid element index
Definition: IColumnarTool.h:25
columnar::ColumnTypeTraits< LinkCastColumn< LT, ELT >, ColumnarModeXAOD >::convertInput
static OptObjectId< LT > convertInput(const ElementLink< ELT > &link)
Definition: LinkColumn.h:67
python.Dumpers.typename
def typename(t)
Definition: Dumpers.py:194
columnar::ColumnarModeArray
Definition: ColumnarDef.h:30
columnar::ColumnTypeTraits
a trait class to provide information about the column type
Definition: ColumnAccessor.h:96
columnar
Definition: ClusterDef.h:16
columnar::ColumnarTool
the base class for all columnar components
Definition: ColumnAccessorDataArray.h:17
columnar::ColumnarModeXAOD
Definition: ColumnarDef.h:15
columnar::ColumnTypeTraits< LinkCastColumn< LT, ELT >, ColumnarModeXAOD >::updateColumnInfo
static ColumnInfo & updateColumnInfo(ColumnarTool< CM > &, ColumnInfo &info)
Definition: LinkColumn.h:65
columnar::LinkCastColumn
a special column type that behaves like an OptObjectId, but applies an internal cast in xAOD mode
Definition: LinkColumn.h:24
columnar::ColumnarOffsetType
std::size_t ColumnarOffsetType
the type used for the size and offsets in the columnar data
Definition: IColumnarTool.h:20