Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | List of all members
columnar::PhysliteTestHelpers::ColumnDataSplitLink Struct Referencefinal

an implementation of PhysliteTestHelpers::IColumnData that reads a split ElementLink More...

Inheritance diagram for columnar::PhysliteTestHelpers::ColumnDataSplitLink:
Collaboration diagram for columnar::PhysliteTestHelpers::ColumnDataSplitLink:

Public Member Functions

 ColumnDataSplitLink (const std::string &val_columnName, const std::string &val_branchBaseName)
 
virtual bool connect (TTree *tree, std::unordered_map< std::string, const PhysliteTestHelpers::IColumnData * > &sizeColumns, std::unordered_map< std::string, ColumnInfo > &requestedColumns) override
 
virtual std::size_t getSize () const override
 
virtual void setData (ColumnarToolWrapperData &tool, Long64_t entry) override
 

Public Attributes

std::string columnName
 
std::string branchBaseName
 
std::string offsetName
 
const PhysliteTestHelpers::IColumnDatasizeColumn = nullptr
 
const PhysliteTestHelpers::IColumnDatatargetSizeColumn = nullptr
 
std::array< ColumnarOffsetType, 2 > offsets = {0, 0}
 
std::vector< ColumnarOffsetTypedataCopy
 
TBranch * mainBranch = nullptr
 
TBranch * indexBranch = nullptr
 
TLeaf * indexLeaf = nullptr
 
Benchmark benchmarkUnpack
 
Benchmark benchmark
 

Detailed Description

an implementation of PhysliteTestHelpers::IColumnData that reads a split ElementLink

I'm not sure this is the best way of doing it. Ideally I'd read the branches directly, but that was crashing, so I'm relying on TLeaf instead. This is not ideal, but it works for now.

Definition at line 288 of file ColumnarPhysliteTest.cxx.

Constructor & Destructor Documentation

◆ ColumnDataSplitLink()

columnar::PhysliteTestHelpers::ColumnDataSplitLink::ColumnDataSplitLink ( const std::string &  val_columnName,
const std::string &  val_branchBaseName 
)
inline

Definition at line 303 of file ColumnarPhysliteTest.cxx.

304  : columnName (val_columnName), branchBaseName (val_branchBaseName), benchmarkUnpack (columnName + " (unpack)"), benchmark (columnName) {}

Member Function Documentation

◆ connect()

virtual bool columnar::PhysliteTestHelpers::ColumnDataSplitLink::connect ( TTree *  tree,
std::unordered_map< std::string, const PhysliteTestHelpers::IColumnData * > &  sizeColumns,
std::unordered_map< std::string, ColumnInfo > &  requestedColumns 
)
inlineoverridevirtual

Implements columnar::PhysliteTestHelpers::IColumnData.

Definition at line 306 of file ColumnarPhysliteTest.cxx.

307  {
308  auto iter = requestedColumns.find (columnName);
309  if (iter == requestedColumns.end())
310  return false;
311 
312  mainBranch = tree->GetBranch (branchBaseName.c_str());
313  if (!mainBranch)
314  throw std::runtime_error ("failed to get branch: " + branchBaseName);
315  indexBranch = tree->GetBranch ((branchBaseName + ".m_persIndex").c_str());
316  if (!indexBranch)
317  throw std::runtime_error ("failed to get branch: " + (branchBaseName + ".m_persIndex"));
318  indexLeaf = indexBranch->GetLeaf ((branchBaseName + ".m_persIndex").c_str());
319 
320  offsetName = iter->second.offsetName;
321  if (offsetName.empty())
322  throw std::runtime_error ("missing offset column for: " + columnName);
323 
324  if (!iter->second.linkToName.empty())
325  {
326  auto linkIter = sizeColumns.find (iter->second.linkToName);
327  if (linkIter == sizeColumns.end())
328  throw std::runtime_error ("missing link column for: " + columnName);
329  targetSizeColumn = linkIter->second;
330  }
331 
332  if (auto sizeIter = sizeColumns.find (offsetName); sizeIter != sizeColumns.end())
333  sizeColumn = sizeIter->second;
334  else
335  sizeColumns.emplace (offsetName, this);
336 
337  requestedColumns.erase (iter);
338 
339  iter = requestedColumns.find (offsetName);
340  if (iter == requestedColumns.end())
341  offsetName.clear();
342  else
343  requestedColumns.erase (iter);
344 
345  return true;
346  }

◆ getSize()

virtual std::size_t columnar::PhysliteTestHelpers::ColumnDataSplitLink::getSize ( ) const
inlineoverridevirtual

Implements columnar::PhysliteTestHelpers::IColumnData.

Definition at line 348 of file ColumnarPhysliteTest.cxx.

349  {
350  return offsets[1];
351  }

◆ setData()

virtual void columnar::PhysliteTestHelpers::ColumnDataSplitLink::setData ( ColumnarToolWrapperData tool,
Long64_t  entry 
)
inlineoverridevirtual

Implements columnar::PhysliteTestHelpers::IColumnData.

Definition at line 353 of file ColumnarPhysliteTest.cxx.

354  {
355  benchmark.startTimer ();
356  mainBranch->GetEntry (entry);
357  indexBranch->GetEntry (entry);
358  benchmark.stopTimer ();
359 
360  benchmarkUnpack.startTimer ();
361  offsets[1] = indexLeaf->GetLen();
362  dataCopy.resize (offsets[1]);
363  for (std::size_t i = 0; i < dataCopy.size(); ++i)
364  {
365  auto value = indexLeaf->GetTypedValue<UInt_t> (i);
367  dataCopy[i] = value;
368  else
370  }
371  tool.setColumn (columnName, dataCopy.size(), dataCopy.data());
372  if (!offsetName.empty())
373  {
374  offsets[1] = dataCopy.size();
375  tool.setColumn (offsetName, offsets.size(), offsets.data());
376  }
377  if (sizeColumn && sizeColumn->getSize() != dataCopy.size())
378  throw std::runtime_error ("size mismatch: " + columnName);
379  if (targetSizeColumn)
380  {
381  const auto targetSize = targetSizeColumn->getSize();
382  for (auto& item : dataCopy)
383  {
384  if (item != invalidObjectIndex && item >= targetSize)
385  throw std::runtime_error ("link out of range: " + columnName + " " + std::to_string (item) + " " + std::to_string (targetSize) + " " + std::to_string (std::numeric_limits<UInt_t>::max()));
386  }
387  }
388  benchmarkUnpack.stopTimer ();
389  }

Member Data Documentation

◆ benchmark

Benchmark columnar::PhysliteTestHelpers::ColumnDataSplitLink::benchmark

Definition at line 301 of file ColumnarPhysliteTest.cxx.

◆ benchmarkUnpack

Benchmark columnar::PhysliteTestHelpers::ColumnDataSplitLink::benchmarkUnpack

Definition at line 300 of file ColumnarPhysliteTest.cxx.

◆ branchBaseName

std::string columnar::PhysliteTestHelpers::ColumnDataSplitLink::branchBaseName

Definition at line 291 of file ColumnarPhysliteTest.cxx.

◆ columnName

std::string columnar::PhysliteTestHelpers::ColumnDataSplitLink::columnName

Definition at line 290 of file ColumnarPhysliteTest.cxx.

◆ dataCopy

std::vector<ColumnarOffsetType> columnar::PhysliteTestHelpers::ColumnDataSplitLink::dataCopy

Definition at line 296 of file ColumnarPhysliteTest.cxx.

◆ indexBranch

TBranch* columnar::PhysliteTestHelpers::ColumnDataSplitLink::indexBranch = nullptr

Definition at line 298 of file ColumnarPhysliteTest.cxx.

◆ indexLeaf

TLeaf* columnar::PhysliteTestHelpers::ColumnDataSplitLink::indexLeaf = nullptr

Definition at line 299 of file ColumnarPhysliteTest.cxx.

◆ mainBranch

TBranch* columnar::PhysliteTestHelpers::ColumnDataSplitLink::mainBranch = nullptr

Definition at line 297 of file ColumnarPhysliteTest.cxx.

◆ offsetName

std::string columnar::PhysliteTestHelpers::ColumnDataSplitLink::offsetName

Definition at line 292 of file ColumnarPhysliteTest.cxx.

◆ offsets

std::array<ColumnarOffsetType, 2> columnar::PhysliteTestHelpers::ColumnDataSplitLink::offsets = {0, 0}

Definition at line 295 of file ColumnarPhysliteTest.cxx.

◆ sizeColumn

const PhysliteTestHelpers::IColumnData* columnar::PhysliteTestHelpers::ColumnDataSplitLink::sizeColumn = nullptr

Definition at line 293 of file ColumnarPhysliteTest.cxx.

◆ targetSizeColumn

const PhysliteTestHelpers::IColumnData* columnar::PhysliteTestHelpers::ColumnDataSplitLink::targetSizeColumn = nullptr

Definition at line 294 of file ColumnarPhysliteTest.cxx.


The documentation for this struct was generated from the following file:
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
tree
TChain * tree
Definition: tile_monitor.h:30
athena.value
value
Definition: athena.py:124
lumiFormat.i
int i
Definition: lumiFormat.py:85
columnar::PhysliteTestHelpers::IColumnData::getSize
virtual std::size_t getSize() const =0
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
columnar::invalidObjectIndex
constexpr ColumnarOffsetType invalidObjectIndex
the value for an invalid element index
Definition: IColumnarTool.h:25
item
Definition: ItemListSvc.h:43