-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwrite.C
More file actions
42 lines (34 loc) · 1.05 KB
/
write.C
File metadata and controls
42 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriteOptions.hxx>
#include <ROOT/RNTupleWriter.hxx>
using ROOT::Experimental::RNTupleModel;
using ROOT::Experimental::RNTupleWriteOptions;
using ROOT::Experimental::RNTupleWriter;
#include <bitset>
#include <memory>
#include <string_view>
void write(std::string_view filename = "types.bitset.root") {
auto model = RNTupleModel::Create();
auto Bitset1 = model->MakeField<std::bitset<1>>("Bitset1");
auto Bitset64 = model->MakeField<std::bitset<64>>("Bitset64");
auto Bitset65 = model->MakeField<std::bitset<65>>("Bitset65");
RNTupleWriteOptions options;
options.SetCompression(0);
auto writer =
RNTupleWriter::Recreate(std::move(model), "ntpl", filename, options);
// First entry: ascending bits set
Bitset1->set(0);
Bitset64->set(1);
Bitset65->set(2);
writer->Fill();
// Second entry: all bits set
Bitset1->set();
Bitset64->set();
Bitset65->set();
writer->Fill();
// Third entry: no bits set
Bitset1->reset();
Bitset64->reset();
Bitset65->reset();
writer->Fill();
}