ATLAS Offline Software
Loading...
Searching...
No Matches
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 273 of file ColumnarPhysliteTest.cxx.

Constructor & Destructor Documentation

◆ BranchReaderArray() [1/2]

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

◆ 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
inlinenodiscard

Definition at line 288 of file ColumnarPhysliteTest.cxx.

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

◆ connectTree()

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

Definition at line 312 of file ColumnarPhysliteTest.cxx.

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

◆ containerName()

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

Definition at line 300 of file ColumnarPhysliteTest.cxx.

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

◆ entrySize()

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

Definition at line 336 of file ColumnarPhysliteTest.cxx.

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

◆ getEntry()

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

Definition at line 322 of file ColumnarPhysliteTest.cxx.

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

◆ numBaskets()

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

Definition at line 352 of file ColumnarPhysliteTest.cxx.

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

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

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

Member Data Documentation

◆ m_branch

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

Definition at line 277 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

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

Definition at line 276 of file ColumnarPhysliteTest.cxx.

◆ m_dataVec

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

Definition at line 278 of file ColumnarPhysliteTest.cxx.


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