37constexpr char const* kNTupleFileName =
"ntpl002_vector.root";
40constexpr int kUpdateGuiFreq = 1000;
43constexpr int kNEvents = 25000;
49 auto model = RNTupleModel::Create();
53 std::shared_ptr<std::vector<float>> fldVpx = model->MakeField<std::vector<float>>(
"vpx");
54 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
55 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
56 auto fldVrand = model->MakeField<std::vector<float>>(
"vrand");
60 auto ntuple = RNTupleWriter::Recreate(std::move(model),
"F", kNTupleFileName);
62 TH1F hpx(
"hpx",
"This is the px distribution", 100, -4, 4);
65 auto c1 =
new TCanvas(
"c1",
"Dynamic Filling Example", 200, 10, 700, 500);
68 for (
int i = 0; i < kNEvents; i++) {
77 for (
int j = 0; j < npx; ++j) {
85 fldVpx->emplace_back(px);
86 fldVpy->emplace_back(py);
87 fldVpz->emplace_back(pz);
88 fldVrand->emplace_back(random);
92 if (i && (i % kUpdateGuiFreq) == 0) {
93 if (i == kUpdateGuiFreq) hpx.Draw();
114 auto model = RNTupleModel::Create();
117 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
121 auto ntuple = RNTupleReader::Open(std::move(model),
"F", kNTupleFileName);
126 std::cout <<
"Entry number 42 in JSON format:" << std::endl;
130 TCanvas *
c2 =
new TCanvas(
"c2",
"Dynamic Filling Example", 200, 10, 700, 500);
131 TH1F h(
"h",
"This is the px distribution", 100, -4, 4);
135 for (
auto entryId : *ntuple) {
136 ntuple->LoadEntry(entryId);
138 for (
auto px : *fldVpx) {
142 if (entryId && (entryId % kUpdateGuiFreq) == 0) {
143 if (entryId == kUpdateGuiFreq)
h.Draw();
R__EXTERN TRandom * gRandom
R__EXTERN TSystem * gSystem
The RNTupleModel encapulates the schema of an ntuple.
An RNTuple that is used to read data from storage.
An RNTuple that gets filled with entries (data) and writes them to storage.
1-D histogram with a float per channel (see TH1 documentation)
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Double_t Rndm() override
Machine independent random number generator.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).