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)
 
std::optional< float > entrySize () const
 
std::optional< float > uncompressedSize () const
 
std::optional< unsigned > numBaskets ()
 

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 271 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 279 of file ColumnarPhysliteTest.cxx.

280  : m_branchName (val_branchName)
281  {}

◆ 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 286 of file ColumnarPhysliteTest.cxx.

287  {
288  std::string columnName = m_branchName;
289  if (auto index = columnName.find ("AuxDyn."); index != std::string::npos)
290  columnName.replace (index, 6, "");
291  else if (auto index = columnName.find ("Aux."); index != std::string::npos)
292  columnName.replace (index, 3, "");
293  else if (columnName.find (".") != std::string::npos)
294  throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
295  return columnName;
296  }

◆ connectTree()

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

Definition at line 310 of file ColumnarPhysliteTest.cxx.

311  {
312  m_branch = tree->GetBranch (m_branchName.c_str());
313  if (!m_branch)
314  throw std::runtime_error ("failed to get branch: " + m_branchName);
315  m_branch->SetMakeClass (1);
316  if (!m_dataVec.empty())
317  m_branch->SetAddress (m_dataVec.data());
318  }

◆ containerName()

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

Definition at line 298 of file ColumnarPhysliteTest.cxx.

299  {
300  if (auto index = m_branchName.find ("AuxDyn."); index != std::string::npos)
301  return m_branchName.substr (0, index);
302  else if (auto index = m_branchName.find ("Aux."); index != std::string::npos)
303  return m_branchName.substr (0, index);
304  else if (m_branchName.find (".") == std::string::npos)
305  return m_branchName;
306  else
307  throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
308  }

◆ entrySize()

template<typename T >
std::optional<float> columnar::TestUtils::BranchReaderArray< T >::entrySize ( ) const
inline

Definition at line 334 of file ColumnarPhysliteTest.cxx.

335  {
336  if (!m_branch)
337  return std::nullopt;
338  return static_cast<float>(m_branch->GetZipBytes()) / m_branch->GetEntries();
339  }

◆ getEntry()

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

Definition at line 320 of file ColumnarPhysliteTest.cxx.

321  {
322  if (!m_branch)
323  throw std::runtime_error ("branch not connected: " + m_branchName);
324  if (m_dataVec.size() < size)
325  {
326  m_dataVec.resize (size);
327  m_branch->SetAddress (m_dataVec.data());
328  }
329  if (size > 0 && m_branch->GetEntry (entry) <= 0)
330  throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
331  return std::span<const T>(m_dataVec.data(), size);
332  }

◆ numBaskets()

template<typename T >
std::optional<unsigned> columnar::TestUtils::BranchReaderArray< T >::numBaskets ( )
inline

Definition at line 350 of file ColumnarPhysliteTest.cxx.

351  {
352  if (!m_branch)
353  return std::nullopt;
354  return m_branch->GetListOfBaskets()->GetSize();
355  }

◆ operator=()

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

◆ uncompressedSize()

template<typename T >
std::optional<float> columnar::TestUtils::BranchReaderArray< T >::uncompressedSize ( ) const
inline

Definition at line 341 of file ColumnarPhysliteTest.cxx.

342  {
343  if (!m_branch)
344  return std::nullopt;
345  return static_cast<float>(m_branch->GetTotBytes()) / m_branch->GetEntries();
346  }

Member Data Documentation

◆ m_branch

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

Definition at line 275 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

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

Definition at line 274 of file ColumnarPhysliteTest.cxx.

◆ m_dataVec

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

Definition at line 276 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:275
columnar::TestUtils::BranchReaderArray::columnName
std::string columnName() const
Definition: ColumnarPhysliteTest.cxx:286
index
Definition: index.py:1
tree
TChain * tree
Definition: tile_monitor.h:30
MuonR4::to_string
std::string to_string(const SectorProjector proj)
Definition: MsTrackSeeder.cxx:66
columnar::TestUtils::BranchReaderArray::m_dataVec
std::vector< T > m_dataVec
Definition: ColumnarPhysliteTest.cxx:276
columnar::size
std::size_t size() const noexcept
Definition: ObjectRange.h:170
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
columnar::TestUtils::BranchReaderArray::m_branchName
std::string m_branchName
Definition: ColumnarPhysliteTest.cxx:274