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

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

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

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

◆ getEntry()

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

Definition at line 251 of file ColumnarPhysliteTest.cxx.

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

◆ numBaskets()

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

Definition at line 291 of file ColumnarPhysliteTest.cxx.

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

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

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

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: