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

200 {
202 if (auto index = columnName.find ("AuxDyn."); index != std::string::npos)
203 columnName.replace (index, 6, "");
204 else if (auto index = columnName.find ("Aux."); index != std::string::npos)
205 columnName.replace (index, 3, "");
206 else if (columnName.find (".") != std::string::npos)
207 throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
208 return columnName;
209 }

◆ connectTree()

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

Definition at line 223 of file ColumnarPhysliteTest.cxx.

224 {
225 m_branch = tree->GetBranch (m_branchName.c_str());
226 if (!m_branch)
227 throw std::runtime_error ("failed to get branch: " + m_branchName);
228 m_branch->SetMakeClass (1);
229 // FIX ME: I have to have some hard-coded size, see explanation
230 // below.
231 m_dataVec.resize (100);
232 if (!m_dataVec.empty())
233 m_branch->SetAddress (m_dataVec.data());
234 }

◆ containerName()

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

Definition at line 211 of file ColumnarPhysliteTest.cxx.

212 {
213 if (auto index = m_branchName.find ("AuxDyn."); index != std::string::npos)
214 return m_branchName.substr (0, index);
215 else if (auto index = m_branchName.find ("Aux."); index != std::string::npos)
216 return m_branchName.substr (0, index);
217 else if (m_branchName.find (".") == std::string::npos)
218 return m_branchName;
219 else
220 throw std::runtime_error ("branch name does not contain AuxDyn or Aux: " + m_branchName);
221 }

◆ entrySize()

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

Definition at line 260 of file ColumnarPhysliteTest.cxx.

261 {
262 if (!m_branch)
263 return std::nullopt;
264 return static_cast<float>(m_branch->GetZipBytes()) / m_branch->GetEntries();
265 }

◆ getEntry()

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

Definition at line 236 of file ColumnarPhysliteTest.cxx.

237 {
238 if (!m_branch)
239 throw std::runtime_error ("branch not connected: " + m_branchName);
240 if (m_dataVec.size() < size)
241 {
242 // FIX ME: in one of the latest releases the repointing below
243 // breaks, and causes memory corruption. so I'm now
244 // preallocating and fail rather than reallocate, and the
245 // problem goes away. maybe it should be investigated at some
246 // point, but this is a test and I already spend a fair amount
247 // of time investigating this. the harm is that this test
248 // consumes a few hundreds bytes more in memory and we may have
249 // to occasionally increase the buffer size to cover all test
250 // files and branch lengths.
251 throw std::runtime_error ("requested size exceeds buffer size for branch: " + m_branchName);
252 // m_dataVec.resize (size);
253 // m_branch->SetAddress (m_dataVec.data());
254 }
255 if (size > 0 && m_branch->GetEntry (entry) <= 0)
256 throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
257 return std::span<const T>(m_dataVec.data(), size);
258 }

◆ numBaskets()

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

Definition at line 276 of file ColumnarPhysliteTest.cxx.

277 {
278 if (!m_branch)
279 return std::nullopt;
280 return m_branch->GetListOfBaskets()->GetSize();
281 }

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

268 {
269 if (!m_branch)
270 return std::nullopt;
271 return static_cast<float>(m_branch->GetTotBytes()) / m_branch->GetEntries();
272 }

Member Data Documentation

◆ m_branch

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

Definition at line 188 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

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

Definition at line 187 of file ColumnarPhysliteTest.cxx.

◆ m_dataVec

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

Definition at line 189 of file ColumnarPhysliteTest.cxx.


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