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 200 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 215 of file ColumnarPhysliteTest.cxx.

216 {
218 if (auto index = columnName.find ("AuxDyn."); index != std::string::npos)
219 columnName.replace (index, 6, "");
220 else if (auto index = columnName.find ("Aux."); index != std::string::npos)
221 columnName.replace (index, 3, "");
222 else if (columnName.find (".") != std::string::npos)
223 throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
224 return columnName;
225 }

◆ connectTree()

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

Definition at line 239 of file ColumnarPhysliteTest.cxx.

240 {
241 m_branch = tree->GetBranch (m_branchName.c_str());
242 if (!m_branch)
243 throw std::runtime_error ("failed to get branch: " + m_branchName);
244 m_branch->SetMakeClass (1);
245 if (!m_dataVec.empty())
246 m_branch->SetAddress (m_dataVec.data());
247 }

◆ containerName()

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

Definition at line 227 of file ColumnarPhysliteTest.cxx.

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

◆ entrySize()

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

Definition at line 263 of file ColumnarPhysliteTest.cxx.

264 {
265 if (!m_branch)
266 return std::nullopt;
267 return static_cast<float>(m_branch->GetZipBytes()) / m_branch->GetEntries();
268 }

◆ getEntry()

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

Definition at line 249 of file ColumnarPhysliteTest.cxx.

250 {
251 if (!m_branch)
252 throw std::runtime_error ("branch not connected: " + m_branchName);
253 if (m_dataVec.size() < size)
254 {
255 m_dataVec.resize (size);
256 m_branch->SetAddress (m_dataVec.data());
257 }
258 if (size > 0 && m_branch->GetEntry (entry) <= 0)
259 throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
260 return std::span<const T>(m_dataVec.data(), size);
261 }

◆ numBaskets()

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

Definition at line 279 of file ColumnarPhysliteTest.cxx.

280 {
281 if (!m_branch)
282 return std::nullopt;
283 return m_branch->GetListOfBaskets()->GetSize();
284 }

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

271 {
272 if (!m_branch)
273 return std::nullopt;
274 return static_cast<float>(m_branch->GetTotBytes()) / m_branch->GetEntries();
275 }

Member Data Documentation

◆ m_branch

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

Definition at line 204 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

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

Definition at line 203 of file ColumnarPhysliteTest.cxx.

◆ m_dataVec

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

Definition at line 205 of file ColumnarPhysliteTest.cxx.


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