26constexpr char const* kNTupleMainFileName =
"ntpl006_data.root";
27constexpr char const* kNTupleFriendFileName =
"ntpl006_reco.root";
36 constexpr int kMaxTrack = 500;
38 auto modelData = RNTupleModel::Create();
39 auto fldPx = modelData->MakeField<std::vector<float>>(
"px");
40 auto fldPy = modelData->MakeField<std::vector<float>>(
"py");
41 auto fldPz = modelData->MakeField<std::vector<float>>(
"pz");
43 auto modelFriend = RNTupleModel::Create();
44 auto fldPt = modelFriend->MakeField<std::vector<float>>(
"pt");
46 auto ntupleData = RNTupleWriter::Recreate(std::move(modelData),
"data", kNTupleMainFileName);
47 auto ntupleReco = RNTupleWriter::Recreate(std::move(modelFriend),
"reco", kNTupleFriendFileName);
49 for (
int i=0; i < 1000; i++) {
51 for (
int n = 0;
n < ntracks;
n++) {
55 fldPt->emplace_back(
TMath::Sqrt(fldPx->at(
n) * fldPx->at(
n) + fldPy->at(
n) * fldPy->at(
n)));
72 std::vector<RNTupleOpenSpec> friends{{
"data", kNTupleMainFileName}, {
"reco", kNTupleFriendFileName}};
73 auto ntuple = RNTupleReader::OpenFriends(friends);
75 auto c =
new TCanvas(
"c",
"", 200, 10, 700, 500);
76 TH1F h(
"h",
"pz {pt > 3.}", 100, -15, 35);
78 auto viewPz = ntuple->GetView<
float>(
"data.pz._0");
79 auto viewPt = ntuple->GetView<
float>(
"reco.pt._0");
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 Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Double_t Rndm() override
Machine independent random number generator.
RNTupleGlobalRange GetFieldRange(const RFieldBase &field, const RPageSource &pageSource)
Helper to get the iteration space of the given field that needs to be connected to the given page sou...
Double_t Sqrt(Double_t x)
Returns the square root of x.
Used to specify the underlying RNTuples in RNTupleProcessor and RNTupleReader::OpenFriends()