31constexpr char const *kNTupleInputName =
"ntpl";
32constexpr char const *kNTupleInputFileName =
"ntpl010_input.root";
33constexpr char const *kNTupleOutputName =
"ntpl_skim";
34constexpr char const *kNTupleOutputFileName =
"ntpl010_skim.root";
35constexpr int kNEvents = 25000;
39 auto model = RNTupleModel::Create();
41 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
42 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
43 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
44 auto fldN = model->MakeField<
float>(
"n");
46 auto writer = RNTupleWriter::Recreate(std::move(model), kNTupleInputName, kNTupleInputFileName);
49 for (
int i = 0; i < kNEvents; i++) {
56 for (
int j = 0; j < *fldN; ++j) {
59 pz = px * px + py * py;
61 fldVpx->emplace_back(px);
62 fldVpy->emplace_back(py);
63 fldVpz->emplace_back(pz);
74 auto reader = RNTupleReader::Open(kNTupleInputName, kNTupleInputFileName);
76 auto skimModel = RNTupleModel::Create();
78 for (
const auto &
value : reader->GetModel().GetDefaultEntry()) {
80 if (
value.GetField().GetFieldName() ==
"n")
84 const std::string newName =
"skim_" +
value.GetField().GetFieldName();
85 skimModel->AddField(
value.GetField().Clone(newName));
87 skimModel->GetDefaultEntry().BindValue<
void>(newName,
value.GetPtr<
void>());
91 auto ptrSkip = skimModel->MakeField<std::uint16_t>(
"skip");
93 auto writer = RNTupleWriter::Recreate(std::move(skimModel), kNTupleOutputName, kNTupleOutputFileName);
95 auto hSkip =
new TH1F(
"h",
"distribution of skipped entries", 10, 0, 10);
96 auto ptrN = reader->GetModel().GetDefaultEntry().GetPtr<
float>(
"n");
97 for (
auto numEntry : *reader) {
98 reader->LoadEntry(numEntry);
104 hSkip->Fill(*ptrSkip);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
R__EXTERN TRandom * gRandom
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.