Project
Loading...
Searching...
No Matches
TableTreeHelpers.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_TABLETREEHELPERS_H_
12#define O2_FRAMEWORK_TABLETREEHELPERS_H_
13
14#include <arrow/buffer.h>
15#include <arrow/io/interfaces.h>
16#include <arrow/record_batch.h>
17#include "TFile.h"
18#include "TTreeReader.h"
19#include "TTreeReaderValue.h"
20#include "TTreeReaderArray.h"
22#include <arrow/dataset/file_base.h>
23#include <memory>
24
25// =============================================================================
26namespace o2::framework
27{
28// -----------------------------------------------------------------------------
29// TableToTree allows to save the contents of a given arrow::Table into
30// a TTree
31// ColumnToBranch is used by GenericTableToTree
32//
33// To write the contents of a table ta to a tree tr on file f do:
34// . GenericTableToTree t2t(ta, f,treename);
35// . t2t.addBranches();
36// OR t2t.addBranch(column.get(), field.get()), ...;
37// . t2t.process();
38//
40 EDataType type;
41 char suffix[3];
42 int size;
43};
44
45auto arrowTypeFromROOT(EDataType type, int size);
46auto basicROOTTypeFromArrow(arrow::Type::type id);
47
49{
50 public:
51 ColumnToBranch(TTree* tree, std::shared_ptr<arrow::ChunkedArray> const& column, std::shared_ptr<arrow::Field> const& field);
54 void at(const int64_t* pos);
55 [[nodiscard]] int fieldSize() const { return mFieldSize; }
56 [[nodiscard]] int columnEntries() const { return mColumn->length(); }
57 [[nodiscard]] char const* branchName() const { return mBranchName.c_str(); }
58
59 private:
60 void accessChunk();
61 void nextChunk();
62
63 std::string mBranchName;
64 TBranch* mBranch = nullptr;
65 TBranch* mSizeBranch = nullptr;
66 arrow::ChunkedArray* mColumn = nullptr;
67 int64_t mFirstIndex = 0;
68 int mCurrentChunk = 0;
69 int mListSize = 1;
70 ROOTTypeInfo mElementType;
71 arrow::Type::type mFieldType;
72 std::vector<uint8_t> cache;
73 std::shared_ptr<arrow::Array> mCurrentArray = nullptr;
74 int64_t mChunkLength = 0;
75 int mFieldSize = 0;
76};
77
79{
80 public:
81 TableToTree(std::shared_ptr<arrow::Table> const& table, TFile* file, const char* treename);
82
83 std::shared_ptr<TTree> process();
84 void addBranch(std::shared_ptr<arrow::ChunkedArray> const& column, std::shared_ptr<arrow::Field> const& field);
85 void addAllBranches();
86
87 private:
88 arrow::Table* mTable;
89 int64_t mRows = 0;
90 std::shared_ptr<TTree> mTree;
91 std::vector<std::unique_ptr<ColumnToBranch>> mColumnReaders;
92};
93
94// -----------------------------------------------------------------------------
95} // namespace o2::framework
96
97// =============================================================================
98#endif // O2_FRAMEWORK_TABLETREEHELPERS_H_
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
uint16_t pos
Definition RawData.h:3
ColumnToBranch(ColumnToBranch &&other)=delete
ColumnToBranch(ColumnToBranch const &other)=delete
void at(const int64_t *pos)
char const * branchName() const
void addBranch(std::shared_ptr< arrow::ChunkedArray > const &column, std::shared_ptr< arrow::Field > const &field)
std::shared_ptr< TTree > process()
GLsizeiptr size
Definition glcorearb.h:659
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
auto basicROOTTypeFromArrow(arrow::Type::type id)
auto arrowTypeFromROOT(EDataType type, int size)
VectorOfTObjectPtrs other
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))