31constexpr const char *kFileName =
"ntpl020_soa.root";
32constexpr const char *kNTupleName =
"ntpl";
56 auto entry =
writer->GetModel().CreateBareEntry();
58 for (
auto nPoints : {100, 500, 1000, 10000}) {
60 auto memory = std::make_unique<float[]>(nPoints * 2);
68 entry->BindRawPtr(
"points", &
points);
81 auto canvas =
new TCanvas(
"c",
"", 1200, 1200);
85 auto viewSize = reader->GetCollectionView(
"points");
87 auto viewSoA = reader->GetView(
"points", &
points,
"PointSoA");
89 for (
auto i : reader->GetEntryRange()) {
90 const auto N = viewSize(i);
91 auto memory = std::make_unique<float[]>(
N * 2);
99 auto *graph =
new TGraph(
N, &memory[0], &memory[
N]);
100 graph->SetTitle((std::to_string(
N) +
" Points").c_str());
101 graph->SetMarkerStyle(29);
102 graph->SetMarkerSize(1);
103 graph->SetMarkerColor(
kRed);
105 auto *circle =
new TEllipse(0.5, 0.5, 0.5, 0.5);
106 circle->SetFillStyle(0);
107 circle->SetLineColor(
kBlue);
108 circle->SetLineWidth(4);
116 float approxPI = 4.0 *
static_cast<float>(hits) /
static_cast<float>(
N);
117 std::cout <<
"Approximated PI with " <<
N <<
" points to " << approxPI << std::endl;
129 cl->CreateAttributeMap();
130 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.
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.