41constexpr char const* kNTupleFileName =
"ntpl001_staff.root";
45 ifstream fin(
gROOT->GetTutorialDir() +
"/tree/cernstaff.dat");
46 assert(fin.is_open());
49 auto model = RNTupleModel::Create();
53 auto fldCategory = model->MakeField<
int>(
"Category");
54 auto fldFlag = model->MakeField<
unsigned int>(
"Flag");
55 auto fldAge = model->MakeField<
int>(
"Age");
56 auto fldService = model->MakeField<
int>(
"Service");
57 auto fldChildren = model->MakeField<
int>(
"Children");
58 auto fldGrade = model->MakeField<
int>(
"Grade");
59 auto fldStep = model->MakeField<
int>(
"Step");
60 auto fldHrweek = model->MakeField<
int>(
"Hrweek");
61 auto fldCost = model->MakeField<
int>(
"Cost");
62 auto fldDivision = model->MakeField<std::string>(
"Division");
63 auto fldNation = model->MakeField<std::string>(
"Nation");
67 auto ntuple = RNTupleWriter::Recreate(std::move(model),
"Staff", kNTupleFileName);
70 while (std::getline(fin, record)) {
71 std::istringstream iss(record);
72 iss >> *fldCategory >> *fldFlag >> *fldAge >> *fldService >> *fldChildren >> *fldGrade >> *fldStep >> *fldHrweek
73 >> *fldCost >> *fldDivision >> *fldNation;
83 auto model = RNTupleModel::Create();
86 std::shared_ptr<int> fldAge = model->MakeField<
int>(
"Age");
89 auto ntuple = RNTupleReader::Open(std::move(model),
"Staff", kNTupleFileName);
94 std::cout <<
"The first entry in JSON format:" << std::endl;
98 auto c =
new TCanvas(
"c",
"", 200, 10, 700, 500);
99 TH1I h(
"h",
"Age Distribution CERN, 1988", 100, 0, 100);
102 for (
auto entryId : *ntuple) {
104 ntuple->LoadEntry(entryId);
111void ntpl001_staff() {
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)