Skip to content

Commit

Permalink
Updated scripts for RNTuple v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Nov 14, 2024
1 parent abbc613 commit c433859
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
First, download `Run2012BC_DoubleMuParked_Muons.root` from [here](https://opendata.cern.ch/record/12341). Then, run the following commands in ROOT.

```cpp
auto importer = ROOT::Experimental::RNTupleImporter::Create("./Run2012BC_DoubleMuParked_Muons.root", "Events", "./Run2012BC_DoubleMuParked_Muons_rntuple_1000evts.root");
auto importer = ROOT::Experimental::RNTupleImporter::Create("./Run2012BC_DoubleMuParked_Muons.root", "Events", "./Run2012BC_DoubleMuParked_Muons_1000evts_rntuple_v1.root");
auto c = importer.get();
c->SetMaxEntries(1000);
c->Import()
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_1jag_int_float.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ R__LOAD_LIBRARY(ROOTNTuple);
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_1jag_int_float() {
std::string rootFileName{"test_ntuple_1jag_int_float.root"};
std::string rootFileName{"test_1jag_int_float_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto v_int = model->MakeField<std::vector<int>>("one_v_integers");
auto v_float = model->MakeField<std::vector<float>>("two_v_floats");
Expand Down
2 changes: 1 addition & 1 deletion dev/make-root/rntuple_atomic_bitset.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_atomic_bitset() {
std::string rootFileName{"test_ntuple_atomic_bitset.root"};
std::string rootFileName{"test_atomic_bitset_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto atomic_int_field = model->MakeField<std::atomic<int>>("atomic_int");
auto bitset_field = model->MakeField<std::bitset<42>>("bitset");
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_bit.C
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_bit() {
std::string rootFileName{"test_ntuple_bit.root"};
std::string rootFileName{"test_bit_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto bit_field = model->MakeField<bool>("one_bit");
auto ntuple =
Expand Down
5 changes: 3 additions & 2 deletions dev/make-root/rntuple_emptystruct_invalidvar.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ struct EmptyStruct {};
struct StructForVariant {
int i;
StructForVariant() = default;
StructForVariant(int ii) : i(ii) {};
StructForVariant(const StructForVariant &) { throw std::runtime_error("copy ctor"); }
StructForVariant &operator=(const StructForVariant &) = default;
};

void rntuple_emptystruct_invalidvar() {
std::string rootFileName{"test_ntuple_emptystruct_invalidvar.root"};
std::string rootFileName{"test_emptystruct_invalidvar_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto empty_struct_field = model->MakeField<EmptyStruct>("empty_struct");
auto variant_field = model->MakeField<std::variant<int,StructForVariant>>("variant");
Expand All @@ -33,7 +34,7 @@ void rntuple_emptystruct_invalidvar() {
*variant_field = 1; // valid state
ntuple->Fill();

*variant_field = { 1 }; // valid state
variant_field->emplace<StructForVariant>(2); // valid state
ntuple->Fill();

try {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions dev/make-root/rntuple_index_multicluster.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ using RNTupleWriteOptions = ROOT::Experimental::RNTupleWriteOptions;

void rntuple_index_multicluster() {
auto options = RNTupleWriteOptions();
options.SetApproxUnzippedPageSize(512);
options.SetMaxUnzippedPageSize(512);
options.SetApproxZippedClusterSize(1000);
options.SetMaxUnzippedClusterSize(1024);

std::string rootFileName{"test_ntuple_index_multicluster.root"};
std::string rootFileName{"test_index_multicluster_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto int_vector = model->MakeField<std::vector<int16_t>>("int_vector");
auto ntuple =
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_int_5e4.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_int_5e4() {
std::string rootFileName{"test_ntuple_int_5e4.root"};
std::string rootFileName{"test_int_5e4_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto int_field = model->MakeField<int>("one_integers");
auto ntuple =
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_int_float.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_int_float() {
std::string rootFileName{"test_ntuple_int_float.root"};
std::string rootFileName{"test_int_float_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto int_field = model->MakeField<int>("one_integers");
auto float_field = model->MakeField<float>("two_floats");
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_int_multicluster.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_int_multicluster() {
std::string rootFileName{"test_ntuple_int_multicluster.root"};
std::string rootFileName{"test_int_multicluster_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto int_field = model->MakeField<int16_t>("one_integers");
auto ntuple =
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_int_vfloat_tlv_vtlv.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
Expand All @@ -17,7 +18,7 @@ struct LV{
};

void rntuple_int_vfloat_tlv_vtlv() {
std::string rootFileName{"test_ntuple_int_vfloat_tlv_vtlv.root"};
std::string rootFileName{"test_int_vfloat_tlv_vtlv_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto int_field = model->MakeField<int>("one_integers");
auto v_float_field = model->MakeField<std::vector<float>>("two_v_floats");
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_split_3e4.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
using RNTupleWriter = ROOT::Experimental::RNTupleWriter;

void rntuple_split_3e4() {
std::string rootFileName{"test_ntuple_split_3e4.root"};
std::string rootFileName{"test_split_3e4_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto splitint_field = model->MakeField<int32_t>("one_int32");
auto splitint_field2 = model->MakeField<uint32_t>("two_uint32");
Expand Down
3 changes: 2 additions & 1 deletion dev/make-root/rntuple_stl_containers.C
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ R__LOAD_LIBRARY(ROOTNTuple)
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RRawFile.hxx>

using RNTupleModel = ROOT::Experimental::RNTupleModel;
Expand All @@ -25,7 +26,7 @@ struct LV{
};

void rntuple_stl_containers() {
std::string rootFileName{"test_ntuple_stl_containers.root"};
std::string rootFileName{"test_stl_containers_rntuple_v1.root"};
auto model = RNTupleModel::Create();
auto string = model->MakeField<std::string>("string");
auto vector_int32 = model->MakeField<std::vector<int32_t>>("vector_int32");
Expand Down

0 comments on commit c433859

Please sign in to comment.