9 {
10
11 namespace bh = boost::histogram;
13 using def = bh::use_default;
14
15 using dax_t = bh::axis::regular<double>;
16 using daxn_t = bh::axis::regular<double, def, def, bh::axis::option::none_t>;
17 using iax_t = bh::axis::integer<int>;
18 using cax_t = bh::axis::category<short, def, bh::axis::option::overflow_t>;
19
20 H5::H5File out_file("hists.h5", H5F_ACC_TRUNC);
21
22
23 {
24 auto h3dw = bh::make_weighted_histogram(
25 daxn_t(1, -0.5, 0.5, "ax0"),
26 dax_t(1, -0.5, 0.5, "ax1"),
27 iax_t(-1, 1, "ax2"));
28
29
30 h3dw(0, 0, 0, bh::weight(0.5));
31
32 h3dw(0, 0, 20, bh::weight(10));
33 h5h::write_hist_to_group(out_file, h3dw, "h3dw");
34 }
35
36
37 {
38 auto h3d = bh::make_histogram(
39 daxn_t(1, -0.5, 0.5, "ax0"),
40 dax_t(1, -0.5, 0.5, "ax1"),
41 iax_t(-1, 1, "ax2"));
42 h3d(0, 0, 0);
43 h5h::write_hist_to_group(out_file, h3d, "h3d");
44 }
45
46
47 {
48 auto h3dp = bh::make_weighted_profile(
49 daxn_t(1, -0.5, 0.5, "ax0"),
50 dax_t(1, -0.5, 0.5, "ax1"),
51 iax_t(-1, 1, "ax2"));
52
53 h3dp(0, 0, 0, bh::weight(0.5), bh::sample(1.0));
54 h3dp(0, 0, 0, bh::weight(0.5), bh::sample(1.0));
55 h5h::write_hist_to_group(out_file, h3dp, "h3dp");
56 }
57
58
59 {
60 using variant = bh::axis::variant<dax_t, daxn_t, iax_t>;
61 std::vector<variant> axes {
62 daxn_t(1, -0.5, 0.5, "ax0"),
63 dax_t(1, -0.5, 0.5, "ax1"),
64 iax_t(-1, 1, "ax2")
65 };
66 auto hdyn = bh::make_weighted_histogram(axes);
67
68
69 std::vector<std::vector<double>>
vals { {0}, {0}, {0} };
70 hdyn.fill(vals, bh::weight(0.5));
71 h5h::write_hist_to_group(out_file, hdyn, "hdyn");
72 }
73
74
75 {
76
77 auto h1c = bh::make_histogram(
78 cax_t({0, 4, 5, 15}, "flavorTruthLabel") );
79 h1c(5);
80 h1c(20);
81 h5h::write_hist_to_group(out_file, h1c, "h1c");
82 }
83
84
85 return 0;
86}