26const std::string kPrimaryNTupleName =
"mainNTuple";
27const std::string kMainNTuplePath =
"main_ntuple.root";
28const std::string kAuxNTupleName =
"auxNTuple";
29const std::string kAuxNTuplePath =
"aux_ntuple.root";
32constexpr int kNEvents = 10000;
34void WritePrimary(std::string_view ntupleName, std::string_view ntupleFileName)
38 auto fldI = model->MakeField<std::uint32_t>(
"i");
39 auto fldVpx = model->MakeField<
float>(
"vpx");
44 for (
int i = 0; i < kNEvents; i += 5) {
51 std::cout <<
"Wrote " <<
writer->GetNEntries() <<
" to the primary RNTuple" << std::endl;
54void WriteAux(std::string_view ntupleName, std::string_view ntupleFileName)
58 auto fldI = model->MakeField<std::uint32_t>(
"i");
59 auto fldVpy = model->MakeField<
float>(
"vpy");
63 for (
int i = 0; i < kNEvents; ++i) {
70 std::cout <<
"Wrote " <<
writer->GetNEntries() <<
" to the auxiliary RNTuple" << std::endl;
75 auto c =
new TCanvas(
"c",
"RNTupleJoinProcessor Example", 200, 10, 700, 500);
76 TH1F hPy(
"h",
"This is the px + py distribution", 100, -4, 4);
91 auto px = processor->RequestField<
float>(
"vpx");
93 auto py = processor->RequestField<
float>(kAuxNTupleName +
".vpy");
96 for (
const auto &idx : *processor) {
98 processor->LoadEntry(idx);
102 std::cout <<
"Processed a total of " << processor->GetNEntriesProcessed() <<
" entries" << std::endl;
107void ntpl015_processor_join()
109 WritePrimary(kPrimaryNTupleName, kMainNTuplePath);
110 WriteAux(kAuxNTupleName, kAuxNTuplePath);
R__EXTERN TRandom * gRandom
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)
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...
std::unique_ptr< RNTupleProcessor > CreateRNTupleJoinProcessor(RNTupleInputSpec primaryNTuple, RNTupleInputSpec auxNTuple, const std::vector< std::string > &joinFields, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.