27const std::string kPrimaryNTupleName =
"mainNTuple";
28const std::string kMainNTuplePath =
"main_ntuple.root";
29const std::string kAuxNTupleName =
"auxNTuple";
30const std::string kAuxNTuplePath =
"aux_ntuple.root";
33constexpr int kNEvents = 10000;
35void WritePrimary(std::string_view ntupleName, std::string_view ntupleFileName)
39 auto fldI = model->MakeField<std::uint32_t>(
"i");
40 auto fldVpx = model->MakeField<
float>(
"vpx");
45 for (
int i = 0; i < kNEvents; i += 5) {
52 std::cout <<
"Wrote " <<
writer->GetNEntries() <<
" to the primary RNTuple" << std::endl;
55void WriteAux(std::string_view ntupleName, std::string_view ntupleFileName)
59 auto fldI = model->MakeField<std::uint32_t>(
"i");
60 auto fldVpy = model->MakeField<
float>(
"vpy");
64 for (
int i = 0; i < kNEvents; ++i) {
71 std::cout <<
"Wrote " <<
writer->GetNEntries() <<
" to the auxiliary RNTuple" << std::endl;
76 auto c =
new TCanvas(
"c",
"RNTupleJoinProcessor Example", 200, 10, 700, 500);
77 TH1F hPy(
"h",
"This is the px + py distribution", 100, -4, 4);
87 RNTupleProcessor::CreateJoin({kPrimaryNTupleName, kMainNTuplePath}, {kAuxNTupleName, kAuxNTuplePath}, {
"i"});
92 auto px = processor->RequestField<
float>(
"vpx");
94 auto py = processor->RequestField<
float>(kAuxNTupleName +
".vpy");
97 for (
auto _ : *processor) {
101 std::cout <<
"Processed a total of " << processor->GetNEntriesProcessed() <<
" entries" << std::endl;
106void ntpl015_processor_join()
108 WritePrimary(kPrimaryNTupleName, kMainNTuplePath);
109 WriteAux(kAuxNTupleName, kAuxNTuplePath);
Specification of the name and location of an RNTuple, used for creating a new RNTupleProcessor.
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
static std::unique_ptr< RNTupleModel > Create()
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)