36constexpr char const* kNTupleFileName =
"ntpl002_vector.root";
39constexpr int kUpdateGuiFreq = 1000;
42constexpr int kNEvents = 25000;
48 auto model = RNTupleModel::Create();
52 std::shared_ptr<std::vector<float>> fldVpx = model->MakeField<std::vector<float>>(
"vpx");
53 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
54 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
55 auto fldVrand = model->MakeField<std::vector<float>>(
"vrand");
59 auto ntuple = RNTupleWriter::Recreate(std::move(model),
"F", kNTupleFileName);
61 TH1F hpx(
"hpx",
"This is the px distribution", 100, -4, 4);
64 auto c1 =
new TCanvas(
"c1",
"Dynamic Filling Example", 200, 10, 700, 500);
67 for (
int i = 0; i < kNEvents; i++) {
76 for (
int j = 0; j < npx; ++j) {
84 fldVpx->emplace_back(px);
85 fldVpy->emplace_back(py);
86 fldVpz->emplace_back(pz);
87 fldVrand->emplace_back(random);
91 if (i && (i % kUpdateGuiFreq) == 0) {
92 if (i == kUpdateGuiFreq) hpx.Draw();
113 auto model = RNTupleModel::Create();
116 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
120 auto ntuple = RNTupleReader::Open(std::move(model),
"F", kNTupleFileName);
125 std::cout <<
"Entry number 42 in JSON format:" << std::endl;
129 TCanvas *
c2 =
new TCanvas(
"c2",
"Dynamic Filling Example", 200, 10, 700, 500);
130 TH1F h(
"h",
"This is the px distribution", 100, -4, 4);
134 for (
auto entryId : *ntuple) {
135 ntuple->LoadEntry(entryId);
137 for (
auto px : *fldVpx) {
141 if (entryId && (entryId % kUpdateGuiFreq) == 0) {
142 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).