34constexpr const char *kFileName =
"ntpl020_soa.root";
35constexpr const char *kNTupleName =
"ntpl";
59 auto entry =
writer->GetModel().CreateBareEntry();
61 for (
auto nPoints : {100, 500, 1000, 10000}) {
63 auto memory = std::make_unique<float[]>(nPoints * 2);
66 gRandom->RndmArray(2 * nPoints, memory.get());
71 entry->BindRawPtr(
"points", &
points);
84 auto canvas =
new TCanvas(
"c",
"", 1200, 1200);
88 auto viewSize = reader->GetCollectionView(
"points");
90 auto viewSoA = reader->GetView(
"points", &
points,
"PointSoA");
92 for (
auto i : reader->GetEntryRange()) {
93 const auto N = viewSize(i);
94 auto memory = std::make_unique<float[]>(
N * 2);
102 auto *graph =
new TGraph(
N, &memory[0], &memory[
N]);
103 graph->SetTitle((std::to_string(
N) +
" Points").c_str());
104 graph->SetMarkerStyle(29);
105 graph->SetMarkerSize(1);
106 graph->SetMarkerColor(
kRed);
108 auto *circle =
new TEllipse(0.5, 0.5, 0.5, 0.5);
109 circle->SetFillStyle(0);
110 circle->SetLineColor(
kBlue);
111 circle->SetLineWidth(4);
119 float approxPI = 4.0 *
static_cast<float>(hits) /
static_cast<float>(
N);
120 std::cout <<
"Approximated PI with " <<
N <<
" points to " << approxPI << std::endl;
132 cl->CreateAttributeMap();
133 cl->GetAttributeMap()->AddProperty(
"rntuple.SoARecord",
"PointRecord");
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.
T Sum(const RVec< T > &v, const T zero=T(0))
Sum elements of an RVec.