RNTuple on-disk collections can be used in struct-of-arrays (SoA) memory layout. An RNTuple SoA class consists of persistent members of type RVec corresponding to and underlying record type, as shown in this tutorial.
NOTE: The RNTuple SoA I/O is still experimental at this point. Functionality and interface are subject to changes.
#include <iostream>
#include <memory>
constexpr const char *kFileName = "ntpl020_soa.root";
};
float fX;
float fY;
};
void Write()
{
for (
auto nPoints : {100, 500, 1000, 10000}) {
}
}
void Read()
{
auto canvas =
new TCanvas(
"c",
"", 1200, 1200);
canvas->Divide(2, 2);
for (
auto i :
reader->GetEntryRange()) {
auto memory = std::make_unique<float[]>(
N * 2);
canvas->cd(i + 1);
graph->SetTitle((std::to_string(
N) +
" Points").c_str());
graph->SetMarkerStyle(29);
graph->SetMarkerSize(1);
graph->SetMarkerColor(
kRed);
graph->Draw("AP");
float approxPI = 4.0 *
static_cast<float>(
hits) /
static_cast<float>(
N);
std::cout <<
"Approximated PI with " <<
N <<
" points to " <<
approxPI << std::endl;
}
canvas->Update();
}
{
cl->CreateAttributeMap();
cl->GetAttributeMap()->AddProperty("rntuple.SoARecord", "PointRecord");
Write();
Read();
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
R__EXTERN TRandom * gRandom
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
Factory method to resurrect a field from the stored on-disk type information.
static std::unique_ptr< RNTupleModel > CreateBare()
Creates a "bare model", i.e. an RNTupleModel with no default entry.
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter backed by storage, overwriting it if one with the same URI exists.
A "std::vector"-like collection of values implementing handy operation to analyse them.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1[.
T Sum(const RVec< T > &v, const T zero=T(0))
Sum elements of an RVec.