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);
123 std::cout << ntuple->GetInfo();
126 TCanvas *
c2 =
new TCanvas(
"c2",
"Dynamic Filling Example", 200, 10, 700, 500);
127 TH1F h(
"h",
"This is the px distribution", 100, -4, 4);
131 for (
auto entryId : *ntuple) {
132 ntuple->LoadEntry(entryId);
134 for (
auto px : *fldVpx) {
138 if (entryId && (entryId % kUpdateGuiFreq) == 0) {
139 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.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
virtual Double_t Rndm()
Machine independent random number generator.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).