forked from root-project/rntuple-validation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite.C
More file actions
38 lines (31 loc) · 1008 Bytes
/
Copy pathwrite.C
File metadata and controls
38 lines (31 loc) · 1008 Bytes
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
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriteOptions.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <bitset>
#include <memory>
#include <string_view>
void write(std::string_view filename = "types.bitset.root") {
auto model = ROOT::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");
ROOT::RNTupleWriteOptions options;
options.SetCompression(0);
auto writer = ROOT::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();
}