29const std::string kMainNTupleName =
"mainNTuple";
30const std::string kMainNTuplePath =
"main_ntuple.root";
31const std::string kAuxNTupleName =
"auxNTuple";
32const std::string kAuxNTuplePath =
"aux_ntuple.root";
35constexpr int kNEvents = 10000;
37void WriteMain(std::string_view ntupleName, std::string_view ntupleFileName)
39 auto model = RNTupleModel::Create();
41 auto fldI = model->MakeField<std::uint32_t>(
"i");
42 auto fldVpx = model->MakeField<
float>(
"vpx");
44 auto ntuple = RNTupleWriter::Recreate(std::move(model), ntupleName, ntupleFileName);
47 for (
int i = 0; i < kNEvents; i += 5) {
54 std::cout <<
"Wrote " << ntuple->GetNEntries() <<
" to the main RNTuple" << std::endl;
57void WriteAux(std::string_view ntupleName, std::string_view ntupleFileName)
59 auto model = RNTupleModel::Create();
61 auto fldI = model->MakeField<std::uint32_t>(
"i");
62 auto fldVpy = model->MakeField<
float>(
"vpy");
64 auto ntuple = RNTupleWriter::Recreate(std::move(model), ntupleName, ntupleFileName);
66 for (
int i = 0; i < kNEvents; ++i) {
73 std::cout <<
"Wrote " << ntuple->GetNEntries() <<
" to the auxiliary RNTuple" << std::endl;
78 auto c =
new TCanvas(
"c",
"RNTupleJoinProcessor Example", 200, 10, 700, 500);
79 TH1F hPy(
"h",
"This is the px + py distribution", 100, -4, 4);
84 std::vector<RNTupleOpenSpec> ntuples = {{kMainNTupleName, kMainNTuplePath}, {kAuxNTupleName, kAuxNTuplePath}};
90 auto processor = RNTupleProcessor::CreateJoin(ntuples, {
"i"});
93 for (
const auto &entry : *processor) {
95 px = *entry.GetPtr<
float>(
"vpx");
97 py = *entry.GetPtr<
float>(kAuxNTupleName +
".vpy");
102 std::cout <<
"Processed a total of " << processor->GetNEntriesProcessed() <<
" entries" << std::endl;
107void ntpl015_processor_join()
109 WriteMain(kMainNTupleName, kMainNTuplePath);
110 WriteAux(kAuxNTupleName, kAuxNTuplePath);
R__EXTERN TRandom * gRandom
The RNTupleModel encapulates the schema of an ntuple.
Interface for iterating over entries of RNTuples and vertically concatenated RNTuples (chains).
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...
Used to specify the underlying RNTuples in RNTupleProcessor.