ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 161 of file ColumnarPhysliteTest.cxx.

Constructor & Destructor Documentation

◆ BranchReader() [1/2]

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

Definition at line 169 of file ColumnarPhysliteTest.cxx.

170  : m_branchName (val_branchName)
171  {
172  if (m_branchName.find ("Aux.") != std::string::npos)
173  m_isStatic = true;
174  }

◆ ~BranchReader()

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

Definition at line 176 of file ColumnarPhysliteTest.cxx.

177  {
178  delete m_data;
179  }

◆ 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
inline

Definition at line 189 of file ColumnarPhysliteTest.cxx.

190  {
191  return m_branchName;
192  }

◆ columnName()

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

Definition at line 194 of file ColumnarPhysliteTest.cxx.

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

◆ connectTree()

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

Definition at line 218 of file ColumnarPhysliteTest.cxx.

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

◆ containerName()

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

Definition at line 206 of file ColumnarPhysliteTest.cxx.

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

◆ entrySize()

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

Definition at line 246 of file ColumnarPhysliteTest.cxx.

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

◆ getCachedEntry()

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

Definition at line 241 of file ColumnarPhysliteTest.cxx.

242  {
243  return *m_data;
244  }

◆ getEntry()

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

Definition at line 230 of file ColumnarPhysliteTest.cxx.

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

◆ numBaskets()

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

Definition at line 262 of file ColumnarPhysliteTest.cxx.

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

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

185  {
186  m_isStatic = isStatic;
187  }

◆ uncompressedSize()

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

Definition at line 253 of file ColumnarPhysliteTest.cxx.

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

Member Data Documentation

◆ m_branch

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

Definition at line 164 of file ColumnarPhysliteTest.cxx.

◆ m_branchName

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

Definition at line 163 of file ColumnarPhysliteTest.cxx.

◆ m_data

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

Definition at line 166 of file ColumnarPhysliteTest.cxx.

◆ m_isStatic

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

Definition at line 165 of file ColumnarPhysliteTest.cxx.


The documentation for this class was generated from the following file:
columnar::TestUtils::BranchReader::m_data
T * m_data
Definition: ColumnarPhysliteTest.cxx:166
index
Definition: index.py:1
columnar::TestUtils::BranchReader::m_branch
TBranch * m_branch
Definition: ColumnarPhysliteTest.cxx:164
tree
TChain * tree
Definition: tile_monitor.h:30
columnar::TestUtils::BranchReader::m_branchName
std::string m_branchName
Definition: ColumnarPhysliteTest.cxx:163
MuonR4::to_string
std::string to_string(const SectorProjector proj)
Definition: MsTrackSeeder.cxx:74
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
columnar::TestUtils::BranchReader::m_isStatic
bool m_isStatic
Definition: ColumnarPhysliteTest.cxx:165
columnar::TestUtils::BranchReader::columnName
std::string columnName() const
Definition: ColumnarPhysliteTest.cxx:194