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 202 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 217 of file ColumnarPhysliteTest.cxx.

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

◆ connectTree()

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

Definition at line 240 of file ColumnarPhysliteTest.cxx.

241 {
242 m_branch = tree->GetBranch (m_branchName.c_str());
243 if (!m_branch)
244 throw std::runtime_error ("failed to get branch: " + m_branchName);
245 m_branch->SetMakeClass (1);
246 // FIX ME: I have to have some hard-coded size, see explanation
247 // below.
248 m_dataVec.resize (100);
249 if (!m_dataVec.empty())
250 m_branch->SetAddress (m_dataVec.data());
251 }

◆ containerName()

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

Definition at line 229 of file ColumnarPhysliteTest.cxx.

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

◆ entrySize()

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

Definition at line 277 of file ColumnarPhysliteTest.cxx.

278 {
279 if (!m_branch)
280 return std::nullopt;
281 return static_cast<float>(m_branch->GetZipBytes()) / m_branch->GetEntries();
282 }

◆ getEntry()

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

Definition at line 253 of file ColumnarPhysliteTest.cxx.

254 {
255 if (!m_branch)
256 throw std::runtime_error ("branch not connected: " + m_branchName);
257 if (m_dataVec.size() < size)
258 {
259 // FIX ME: in one of the latest releases the repointing below
260 // breaks, and causes memory corruption. so I'm now
261 // preallocating and fail rather than reallocate, and the
262 // problem goes away. maybe it should be investigated at some
263 // point, but this is a test and I already spend a fair amount
264 // of time investigating this. the harm is that this test
265 // consumes a few hundreds bytes more in memory and we may have
266 // to occasionally increase the buffer size to cover all test
267 // files and branch lengths.
268 throw std::runtime_error ("requested size exceeds buffer size for branch: " + m_branchName);
269 // m_dataVec.resize (size);
270 // m_branch->SetAddress (m_dataVec.data());
271 }
272 if (size > 0 && m_branch->GetEntry (entry) <= 0)
273 throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
274 return std::span<const T>(m_dataVec.data(), size);
275 }

◆ numBaskets()

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

Definition at line 293 of file ColumnarPhysliteTest.cxx.

294 {
295 if (!m_branch)
296 return std::nullopt;
297 return m_branch->GetListOfBaskets()->GetSize();
298 }

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

285 {
286 if (!m_branch)
287 return std::nullopt;
288 return static_cast<float>(m_branch->GetTotBytes()) / m_branch->GetEntries();
289 }

Member Data Documentation

◆ m_branch

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

Definition at line 206 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

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

Definition at line 205 of file ColumnarPhysliteTest.cxx.

◆ m_dataVec

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

Definition at line 207 of file ColumnarPhysliteTest.cxx.


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