23constexpr char const *kNTupleInputName =
"ntpl";
24constexpr char const *kNTupleInputFileName =
"ntpl010_input.root";
25constexpr char const *kNTupleOutputName =
"ntpl_skim";
26constexpr char const *kNTupleOutputFileName =
"ntpl010_skim.root";
27constexpr int kNEvents = 25000;
33 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
34 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
35 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
36 auto fldN = model->MakeField<
float>(
"n");
41 for (
int i = 0; i < kNEvents; i++) {
42 *fldN =
static_cast<int>(
gRandom->Rndm(1) * 15);
48 for (
int j = 0; j < *fldN; ++j) {
51 pz = px * px + py * py;
53 fldVpx->emplace_back(px);
54 fldVpy->emplace_back(py);
55 fldVpz->emplace_back(pz);
70 for (
const auto &value : reader->GetModel().GetDefaultEntry()) {
72 if (value.GetField().GetFieldName() ==
"n")
76 const std::string newName =
"skim_" + value.GetField().GetFieldName();
77 skimModel->AddField(value.GetField().Clone(newName));
79 skimModel->GetDefaultEntry().BindValue<
void>(newName, value.GetPtr<
void>());
83 auto ptrSkip = skimModel->MakeField<std::uint16_t>(
"skip");
87 auto hSkip =
new TH1F(
"h",
"distribution of skipped entries", 10, 0, 10);
88 auto ptrN = reader->GetModel().GetDefaultEntry().GetPtr<
float>(
"n");
89 for (
auto numEntry : *reader) {
90 reader->LoadEntry(numEntry);
96 hSkip->Fill(*ptrSkip);
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter backed by storage, overwriting it if one with the same URI exists.
1-D histogram with a float per channel (see TH1 documentation)