22#include <ROOT/RNTuple.hxx>
44constexpr char const* kNTupleFileName =
"ntpl001_staff.root";
48 ifstream fin(
gROOT->GetTutorialDir() +
"/tree/cernstaff.dat");
49 assert(fin.is_open());
52 auto model = RNTupleModel::Create();
56 auto fldCategory = model->MakeField<
int>(
"Category");
57 auto fldFlag = model->MakeField<
unsigned int>(
"Flag");
58 auto fldAge = model->MakeField<
int>(
"Age");
59 auto fldService = model->MakeField<
int>(
"Service");
60 auto fldChildren = model->MakeField<
int>(
"Children");
61 auto fldGrade = model->MakeField<
int>(
"Grade");
62 auto fldStep = model->MakeField<
int>(
"Step");
63 auto fldHrweek = model->MakeField<
int>(
"Hrweek");
64 auto fldCost = model->MakeField<
int>(
"Cost");
65 auto fldDivision = model->MakeField<std::string>(
"Division");
66 auto fldNation = model->MakeField<std::string>(
"Nation");
70 auto ntuple = RNTupleWriter::Recreate(std::move(model),
"Staff", kNTupleFileName);
73 while (std::getline(fin, record)) {
74 std::istringstream iss(record);
75 iss >> *fldCategory >> *fldFlag >> *fldAge >> *fldService >> *fldChildren >> *fldGrade >> *fldStep >> *fldHrweek
76 >> *fldCost >> *fldDivision >> *fldNation;
86 auto model = RNTupleModel::Create();
89 std::shared_ptr<int> fldAge = model->MakeField<
int>(
"Age");
92 auto ntuple = RNTupleReader::Open(std::move(model),
"Staff", kNTupleFileName);
97 std::cout <<
"The first entry in JSON format:" << std::endl;
101 auto c =
new TCanvas(
"c",
"", 200, 10, 700, 500);
102 TH1I h(
"h",
"Age Distribution CERN, 1988", 100, 0, 100);
105 for (
auto entryId : *ntuple) {
107 ntuple->LoadEntry(entryId);
114void ntpl001_staff() {
#define R__LOAD_LIBRARY(LIBRARY)
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 an int per channel (see TH1 documentation)}