ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
columnar::TestUtils::BranchReaderArray< T > Class Template Referencefinal
Collaboration diagram for columnar::TestUtils::BranchReaderArray< T >:

Public Member Functions

 BranchReaderArray (const std::string &val_branchName)
 
 BranchReaderArray (const BranchReaderArray &)=delete
 
BranchReaderArrayoperator= (const BranchReaderArray &)=delete
 
std::string columnName () const
 
std::string containerName () const
 
void connectTree (TTree *tree)
 
std::span< const T > getEntry (Long64_t entry, std::size_t size)
 

Public Attributes

std::string m_branchName
 
TBranch * m_branch = nullptr
 
std::vector< T > m_dataVec
 

Detailed Description

template<typename T>
class columnar::TestUtils::BranchReaderArray< T >

Definition at line 210 of file ColumnarPhysliteTest.cxx.

Constructor & Destructor Documentation

◆ BranchReaderArray() [1/2]

template<typename T >
columnar::TestUtils::BranchReaderArray< T >::BranchReaderArray ( const std::string &  val_branchName)
inline

Definition at line 218 of file ColumnarPhysliteTest.cxx.

219  : m_branchName (val_branchName)
220  {}

◆ BranchReaderArray() [2/2]

template<typename T >
columnar::TestUtils::BranchReaderArray< T >::BranchReaderArray ( const BranchReaderArray< T > &  )
delete

Member Function Documentation

◆ columnName()

template<typename T >
std::string columnar::TestUtils::BranchReaderArray< T >::columnName ( ) const
inline

Definition at line 225 of file ColumnarPhysliteTest.cxx.

226  {
227  std::string columnName = m_branchName;
228  if (auto index = columnName.find ("AuxDyn."); index != std::string::npos)
229  columnName.replace (index, 6, "");
230  else if (auto index = columnName.find ("Aux."); index != std::string::npos)
231  columnName.replace (index, 3, "");
232  else if (columnName.find (".") != std::string::npos)
233  throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
234  return columnName;
235  }

◆ connectTree()

template<typename T >
void columnar::TestUtils::BranchReaderArray< T >::connectTree ( TTree *  tree)
inline

Definition at line 249 of file ColumnarPhysliteTest.cxx.

250  {
251  m_branch = tree->GetBranch (m_branchName.c_str());
252  if (!m_branch)
253  throw std::runtime_error ("failed to get branch: " + m_branchName);
254  m_branch->SetMakeClass (1);
255  if (!m_dataVec.empty())
256  m_branch->SetAddress (m_dataVec.data());
257  }

◆ containerName()

template<typename T >
std::string columnar::TestUtils::BranchReaderArray< T >::containerName ( ) const
inline

Definition at line 237 of file ColumnarPhysliteTest.cxx.

238  {
239  if (auto index = m_branchName.find ("AuxDyn."); index != std::string::npos)
240  return m_branchName.substr (0, index);
241  else if (auto index = m_branchName.find ("Aux."); index != std::string::npos)
242  return m_branchName.substr (0, index);
243  else if (m_branchName.find (".") == std::string::npos)
244  return m_branchName;
245  else
246  throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
247  }

◆ getEntry()

template<typename T >
std::span<const T> columnar::TestUtils::BranchReaderArray< T >::getEntry ( Long64_t  entry,
std::size_t  size 
)
inline

Definition at line 259 of file ColumnarPhysliteTest.cxx.

260  {
261  if (!m_branch)
262  throw std::runtime_error ("branch not connected: " + m_branchName);
263  if (m_dataVec.size() < size)
264  {
265  m_dataVec.resize (size);
266  m_branch->SetAddress (m_dataVec.data());
267  }
268  if (size > 0 && m_branch->GetEntry (entry) <= 0)
269  throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
270  return std::span<const T>(m_dataVec.data(), size);
271  }

◆ operator=()

template<typename T >
BranchReaderArray& columnar::TestUtils::BranchReaderArray< T >::operator= ( const BranchReaderArray< T > &  )
delete

Member Data Documentation

◆ m_branch

template<typename T >
TBranch* columnar::TestUtils::BranchReaderArray< T >::m_branch = nullptr

Definition at line 214 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

template<typename T >
std::string columnar::TestUtils::BranchReaderArray< T >::m_branchName

Definition at line 213 of file ColumnarPhysliteTest.cxx.

◆ m_dataVec

template<typename T >
std::vector<T> columnar::TestUtils::BranchReaderArray< T >::m_dataVec

Definition at line 215 of file ColumnarPhysliteTest.cxx.


The documentation for this class was generated from the following file:
columnar::TestUtils::BranchReaderArray::m_branch
TBranch * m_branch
Definition: ColumnarPhysliteTest.cxx:214
columnar::TestUtils::BranchReaderArray::columnName
std::string columnName() const
Definition: ColumnarPhysliteTest.cxx:225
index
Definition: index.py:1
tree
TChain * tree
Definition: tile_monitor.h:30
columnar::TestUtils::BranchReaderArray::m_dataVec
std::vector< T > m_dataVec
Definition: ColumnarPhysliteTest.cxx:215
columnar::size
std::size_t size() const noexcept
Definition: ObjectRange.h:166
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
columnar::TestUtils::BranchReaderArray::m_branchName
std::string m_branchName
Definition: ColumnarPhysliteTest.cxx:213