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
BranchReaderArray & operator= (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 144 of file ColumnReaderTTree.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 159 of file ColumnReaderTTree.cxx.

160 {
162 if (auto index = columnName.find("AuxDyn."); index != std::string::npos)
163 columnName.replace(index, 6, "");
164 else if (auto index = columnName.find("Aux."); index != std::string::npos)
165 columnName.replace(index, 3, "");
166 else if (columnName.find(".") != std::string::npos)
167 throw std::runtime_error("branch name does not contain AuxDyn or Aux: " + m_branchName);
168 return columnName;
169 }

◆ connectTree()

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

Definition at line 182 of file ColumnReaderTTree.cxx.

183 {
184 m_branch = tree->GetBranch (m_branchName.c_str());
185 if (!m_branch)
186 throw std::runtime_error ("failed to get branch: " + m_branchName);
187 m_branch->SetMakeClass (1);
188 // FIX ME: I have to have some hard-coded size, see explanation
189 // below.
190 m_dataVec.resize (100);
191 if (!m_dataVec.empty())
192 m_branch->SetAddress (m_dataVec.data());
193 }

◆ containerName()

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

Definition at line 171 of file ColumnReaderTTree.cxx.

172 {
173 if (auto index = m_branchName.find("AuxDyn."); index != std::string::npos)
174 return m_branchName.substr(0, index);
175 else if (auto index = m_branchName.find("Aux."); index != std::string::npos)
176 return m_branchName.substr(0, index);
177 else if (m_branchName.find(".") == std::string::npos)
178 return m_branchName;
179 else
180 throw std::runtime_error("branch name does not contain AuxDyn or Aux: " + m_branchName);
181 }

◆ entrySize()

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

Definition at line 219 of file ColumnReaderTTree.cxx.

220 {
221 if (!m_branch)
222 return std::nullopt;
223 return static_cast<float>(m_branch->GetZipBytes()) / m_branch->GetEntries();
224 }

◆ getEntry()

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

Definition at line 195 of file ColumnReaderTTree.cxx.

196 {
197 if (!m_branch)
198 throw std::runtime_error ("branch not connected: " + m_branchName);
199 if (m_dataVec.size() < size)
200 {
201 // FIX ME: in one of the latest releases the repointing below
202 // breaks, and causes memory corruption. so I'm now
203 // preallocating and fail rather than reallocate, and the
204 // problem goes away. maybe it should be investigated at some
205 // point, but this is a test and I already spend a fair amount
206 // of time investigating this. the harm is that this test
207 // consumes a few hundreds bytes more in memory and we may have
208 // to occasionally increase the buffer size to cover all test
209 // files and branch lengths.
210 throw std::runtime_error ("requested size exceeds buffer size for branch: " + m_branchName);
211 // m_dataVec.resize (size);
212 // m_branch->SetAddress (m_dataVec.data());
213 }
214 if (size > 0 && m_branch->GetEntry (entry) <= 0)
215 throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
216 return std::span<const T>(m_dataVec.data(), size);
217 }

◆ numBaskets()

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

Definition at line 235 of file ColumnReaderTTree.cxx.

236 {
237 if (!m_branch)
238 return std::nullopt;
239 return m_branch->GetListOfBaskets()->GetSize();
240 }

◆ 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 226 of file ColumnReaderTTree.cxx.

227 {
228 if (!m_branch)
229 return std::nullopt;
230 return static_cast<float>(m_branch->GetTotBytes()) / m_branch->GetEntries();
231 }

Member Data Documentation

◆ m_branch

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

Definition at line 148 of file ColumnReaderTTree.cxx.

◆ m_branchName

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

Definition at line 147 of file ColumnReaderTTree.cxx.

◆ m_dataVec

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

Definition at line 149 of file ColumnReaderTTree.cxx.


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