ATLAS Offline Software
Loading...
Searching...
No Matches
columnar::TestUtils::ColumnarTestToolHandle Class Referencefinal

a handle to a columnar tool for running tests More...

#include <ColumnarMemoryTest.h>

Collaboration diagram for columnar::TestUtils::ColumnarTestToolHandle:

Public Member Functions

 ColumnarTestToolHandle (asg::AsgTool &val_tool)
void renameContainers (const std::vector< std::pair< std::string, std::string > > &renames)
 rename the columns the tool uses
void initialize ()
 initialize the tool
void applySystematicVariation (const std::string &sysName)
 set the tool to apply the given systematic variation
std::vector< ColumnInfo > getColumnInfo () const
 get the expected column info
std::vector< std::string > getColumnNames () const
 get the expected column names
std::vector< std::string > getRecommendedSystematics () const
 get the recommended systematics
ToolColumnVectorMap & getToolWrapper ()
 get the tool wrapper
const ToolColumnVectorMap & getToolWrapper () const
const ColumnVectorHeader & getColumnHeader () const
 get the column header
IColumnarTool * getTool ()
 get the contained tool

Private Attributes

IColumnarTool * m_tool = nullptr
CP::ISystematicsTool * m_systTool = nullptr
std::shared_ptr< ColumnVectorHeader > m_columnHeader
std::shared_ptr< ToolColumnVectorMap > m_toolWrapper

Detailed Description

a handle to a columnar tool for running tests

This used to be shared with the python bindings, but there are sufficient differences between testing and python bindings to split the two.

Definition at line 60 of file ColumnarMemoryTest.h.

Constructor & Destructor Documentation

◆ ColumnarTestToolHandle()

columnar::TestUtils::ColumnarTestToolHandle::ColumnarTestToolHandle ( asg::AsgTool & val_tool)
explicit

Public Members

Definition at line 43 of file ColumnarMemoryTest.cxx.

45 {
46 m_tool = dynamic_cast<IColumnarTool*> (&val_tool);
47 if (m_tool == nullptr)
48 throw std::runtime_error ("tool does not implement IColumnarTool");
49 m_systTool = dynamic_cast<CP::ISystematicsTool*> (m_tool);
50 }

Member Function Documentation

◆ applySystematicVariation()

void columnar::TestUtils::ColumnarTestToolHandle::applySystematicVariation ( const std::string & sysName)

set the tool to apply the given systematic variation

Definition at line 76 of file ColumnarMemoryTest.cxx.

78 {
79 // by convention setting a systematic on a non-systematics tool
80 // will do nothing
81 if (m_systTool == nullptr)
82 return;
83 if (!m_systTool->applySystematicVariation (CP::SystematicSet (sysName)).isSuccess())
84 throw std::runtime_error ("failed to apply systematic variation");
85 }

◆ getColumnHeader()

const ColumnVectorHeader & columnar::TestUtils::ColumnarTestToolHandle::getColumnHeader ( ) const
inlinenodiscard

get the column header

Definition at line 92 of file ColumnarMemoryTest.h.

92 {
93 return *m_columnHeader;}
std::shared_ptr< ColumnVectorHeader > m_columnHeader

◆ getColumnInfo()

std::vector< ColumnInfo > columnar::TestUtils::ColumnarTestToolHandle::getColumnInfo ( ) const
nodiscard

get the expected column info

Definition at line 89 of file ColumnarMemoryTest.cxx.

91 {
92 if (!m_toolWrapper)
93 throw std::runtime_error ("tool not initialized");
94 return m_tool->getColumnInfo ();
95 }
std::shared_ptr< ToolColumnVectorMap > m_toolWrapper

◆ getColumnNames()

std::vector< std::string > columnar::TestUtils::ColumnarTestToolHandle::getColumnNames ( ) const

get the expected column names

Definition at line 99 of file ColumnarMemoryTest.cxx.

101 {
102 if (!m_toolWrapper)
103 throw std::runtime_error ("tool not initialized");
104 return m_toolWrapper->getColumnNames ();
105 }

◆ getRecommendedSystematics()

std::vector< std::string > columnar::TestUtils::ColumnarTestToolHandle::getRecommendedSystematics ( ) const

get the recommended systematics

Definition at line 109 of file ColumnarMemoryTest.cxx.

111 {
112 if (!m_systTool)
113 return {""};
114 std::vector<std::string> result;
115 for (auto& sys : CP::make_systematics_vector (m_systTool->recommendedSystematics()))
116 result.push_back (sys.name());
117 return result;
118 }
std::vector< CP::SystematicSet > make_systematics_vector(const SystematicSet &systematics)
utility functions for working with systematics

◆ getTool()

IColumnarTool * columnar::TestUtils::ColumnarTestToolHandle::getTool ( )
nodiscard

get the contained tool

Definition at line 142 of file ColumnarMemoryTest.cxx.

144 {
145 return m_tool;
146 }

◆ getToolWrapper() [1/2]

ToolColumnVectorMap & columnar::TestUtils::ColumnarTestToolHandle::getToolWrapper ( )
nodiscard

get the tool wrapper

Definition at line 122 of file ColumnarMemoryTest.cxx.

124 {
125 if (!m_toolWrapper)
126 throw std::runtime_error ("tool not initialized");
127 return *m_toolWrapper;
128 }

◆ getToolWrapper() [2/2]

const ToolColumnVectorMap & columnar::TestUtils::ColumnarTestToolHandle::getToolWrapper ( ) const
nodiscard

Definition at line 132 of file ColumnarMemoryTest.cxx.

134 {
135 if (!m_toolWrapper)
136 throw std::runtime_error ("tool not initialized");
137 return *m_toolWrapper;
138 }

◆ initialize()

void columnar::TestUtils::ColumnarTestToolHandle::initialize ( )

initialize the tool

Definition at line 67 of file ColumnarMemoryTest.cxx.

69 {
70 m_columnHeader = std::make_shared<ColumnVectorHeader> ();
71 m_toolWrapper = std::make_shared<ToolColumnVectorMap> (*m_columnHeader, *m_tool);
72 }

◆ renameContainers()

void columnar::TestUtils::ColumnarTestToolHandle::renameContainers ( const std::vector< std::pair< std::string, std::string > > & renames)

rename the columns the tool uses

Definition at line 54 of file ColumnarMemoryTest.cxx.

56 {
58 if (m_toolWrapper)
59 {
60 m_columnHeader = std::make_shared<ColumnVectorHeader> ();
61 m_toolWrapper = std::make_shared<ToolColumnVectorMap> (*m_columnHeader, *m_tool);
62 }
63 }
void renameContainers(IColumnarTool &tool, const std::vector< std::pair< std::string, std::string > > &renames)
rename containers in the columnar tool

Member Data Documentation

◆ m_columnHeader

std::shared_ptr<ColumnVectorHeader> columnar::TestUtils::ColumnarTestToolHandle::m_columnHeader
private

Definition at line 108 of file ColumnarMemoryTest.h.

◆ m_systTool

CP::ISystematicsTool* columnar::TestUtils::ColumnarTestToolHandle::m_systTool = nullptr
private

Definition at line 106 of file ColumnarMemoryTest.h.

◆ m_tool

IColumnarTool* columnar::TestUtils::ColumnarTestToolHandle::m_tool = nullptr
private

Private Members

Definition at line 105 of file ColumnarMemoryTest.h.

◆ m_toolWrapper

std::shared_ptr<ToolColumnVectorMap> columnar::TestUtils::ColumnarTestToolHandle::m_toolWrapper
private

Definition at line 109 of file ColumnarMemoryTest.h.


The documentation for this class was generated from the following files: