ATLAS Offline Software
Loading...
Searching...
No Matches
columnar::TestUtils::BranchReader< T > Class Template Referencefinal
Collaboration diagram for columnar::TestUtils::BranchReader< T >:

Public Member Functions

 BranchReader (const std::string &val_branchName)
 ~BranchReader () noexcept
 BranchReader (const BranchReader &)=delete
BranchReaderoperator= (const BranchReader &)=delete
void setIsStatic (bool isStatic)
const std::string & branchName () const
std::string columnName () const
std::string containerName () const
void connectTree (TTree *tree)
const T & getEntry (Long64_t entry)
const T & getCachedEntry () const
std::optional< float > entrySize () const
std::optional< float > uncompressedSize () const
std::optional< unsigned > numBaskets ()

Private Attributes

std::string m_branchName
TBranch * m_branch = nullptr
bool m_isStatic = std::is_pod_v<T>
T * m_data {new T()}

Detailed Description

template<typename T>
class columnar::TestUtils::BranchReader< T >

Definition at line 163 of file ColumnarPhysliteTest.cxx.

Constructor & Destructor Documentation

◆ BranchReader() [1/2]

template<typename T>
columnar::TestUtils::BranchReader< T >::BranchReader ( const std::string & val_branchName)
inline

◆ ~BranchReader()

template<typename T>
columnar::TestUtils::BranchReader< T >::~BranchReader ( )
inlinenoexcept

Definition at line 178 of file ColumnarPhysliteTest.cxx.

◆ BranchReader() [2/2]

template<typename T>
columnar::TestUtils::BranchReader< T >::BranchReader ( const BranchReader< T > & )
delete

Member Function Documentation

◆ branchName()

template<typename T>
const std::string & columnar::TestUtils::BranchReader< T >::branchName ( ) const
inlinenodiscard

Definition at line 191 of file ColumnarPhysliteTest.cxx.

192 {
193 return m_branchName;
194 }

◆ columnName()

template<typename T>
std::string columnar::TestUtils::BranchReader< T >::columnName ( ) const
inlinenodiscard

Definition at line 196 of file ColumnarPhysliteTest.cxx.

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

◆ connectTree()

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

Definition at line 220 of file ColumnarPhysliteTest.cxx.

221 {
222 m_branch = tree->GetBranch (m_branchName.c_str());
223 if (!m_branch)
224 throw std::runtime_error ("failed to get branch: " + m_branchName);
225 m_branch->SetMakeClass (1);
226 if (m_isStatic)
227 m_branch->SetAddress (m_data);
228 else
229 m_branch->SetAddress (&m_data);
230 }

◆ containerName()

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

Definition at line 208 of file ColumnarPhysliteTest.cxx.

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

◆ entrySize()

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

Definition at line 248 of file ColumnarPhysliteTest.cxx.

249 {
250 if (!m_branch)
251 return std::nullopt;
252 return static_cast<float>(m_branch->GetZipBytes()) / m_branch->GetEntries();
253 }

◆ getCachedEntry()

template<typename T>
const T & columnar::TestUtils::BranchReader< T >::getCachedEntry ( ) const
inline

Definition at line 243 of file ColumnarPhysliteTest.cxx.

244 {
245 return *m_data;
246 }

◆ getEntry()

template<typename T>
const T & columnar::TestUtils::BranchReader< T >::getEntry ( Long64_t entry)
inline

Definition at line 232 of file ColumnarPhysliteTest.cxx.

233 {
234 if (!m_branch)
235 throw std::runtime_error ("branch not connected: " + m_branchName);
236 if (m_branch->GetEntry (entry) <= 0)
237 throw std::runtime_error ("failed to get entry " + std::to_string (entry) + " for branch: " + m_branchName);
238 if (m_data == nullptr)
239 throw std::runtime_error ("got nullptr reading data for branch: " + m_branchName);
240 return *m_data;
241 }

◆ numBaskets()

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

Definition at line 264 of file ColumnarPhysliteTest.cxx.

265 {
266 if (!m_branch)
267 return std::nullopt;
268 return m_branch->GetListOfBaskets()->GetSize();
269 }

◆ operator=()

template<typename T>
BranchReader & columnar::TestUtils::BranchReader< T >::operator= ( const BranchReader< T > & )
delete

◆ setIsStatic()

template<typename T>
void columnar::TestUtils::BranchReader< T >::setIsStatic ( bool isStatic)
inline

Definition at line 186 of file ColumnarPhysliteTest.cxx.

187 {
189 }

◆ uncompressedSize()

template<typename T>
std::optional< float > columnar::TestUtils::BranchReader< T >::uncompressedSize ( ) const
inline

Definition at line 255 of file ColumnarPhysliteTest.cxx.

256 {
257 if (!m_branch)
258 return std::nullopt;
259 return static_cast<float>(m_branch->GetTotBytes()) / m_branch->GetEntries();
260 }

Member Data Documentation

◆ m_branch

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

Definition at line 166 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

template<typename T>
std::string columnar::TestUtils::BranchReader< T >::m_branchName
private

Definition at line 165 of file ColumnarPhysliteTest.cxx.

◆ m_data

template<typename T>
T* columnar::TestUtils::BranchReader< T >::m_data {new T()}
private

Definition at line 168 of file ColumnarPhysliteTest.cxx.

168{new T()};

◆ m_isStatic

template<typename T>
bool columnar::TestUtils::BranchReader< T >::m_isStatic = std::is_pod_v<T>
private

Definition at line 167 of file ColumnarPhysliteTest.cxx.


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