@@ -331,3 +331,61 @@ TEST(RHistEngine, FillTupleWeightInvalidNumberOfArguments)
331331 EXPECT_NO_THROW (engine2.Fill (std::make_tuple (1 , 2 ), RWeight (1 )));
332332 EXPECT_THROW (engine2.Fill (std::make_tuple (1 , 2 , 3 ), RWeight (1 )), std::invalid_argument);
333333}
334+
335+ TEST (RHistEngine_RBinWithError, Add)
336+ {
337+ static constexpr std::size_t Bins = 20 ;
338+ const RRegularAxis axis (Bins, 0 , Bins);
339+ RHistEngine<RBinWithError> engineA ({axis});
340+ RHistEngine<RBinWithError> engineB ({axis});
341+
342+ for (std::size_t i = 0 ; i < Bins; i++) {
343+ engineA.Fill (i, RWeight (0.2 + i * 0.03 ));
344+ engineB.Fill (i, RWeight (0.1 + i * 0.05 ));
345+ }
346+
347+ engineA.Add (engineB);
348+
349+ for (auto index : axis.GetNormalRange ()) {
350+ auto &bin = engineA.GetBinContent (index);
351+ double weightA = 0.2 + index.GetIndex () * 0.03 ;
352+ double weightB = 0.1 + index.GetIndex () * 0.05 ;
353+ EXPECT_FLOAT_EQ (bin.fSum , weightA + weightB);
354+ EXPECT_FLOAT_EQ (bin.fSum2 , weightA * weightA + weightB * weightB);
355+ }
356+ }
357+
358+ TEST (RHistEngine_RBinWithError, Fill)
359+ {
360+ static constexpr std::size_t Bins = 20 ;
361+ const RRegularAxis axis (Bins, 0 , Bins);
362+ RHistEngine<RBinWithError> engine ({axis});
363+
364+ for (std::size_t i = 0 ; i < Bins; i++) {
365+ engine.Fill (i);
366+ }
367+
368+ for (auto index : axis.GetNormalRange ()) {
369+ auto &bin = engine.GetBinContent (index);
370+ EXPECT_EQ (bin.fSum , 1 );
371+ EXPECT_EQ (bin.fSum2 , 1 );
372+ }
373+ }
374+
375+ TEST (RHistEngine_RBinWithError, FillWeight)
376+ {
377+ static constexpr std::size_t Bins = 20 ;
378+ const RRegularAxis axis (Bins, 0 , Bins);
379+ RHistEngine<RBinWithError> engine ({axis});
380+
381+ for (std::size_t i = 0 ; i < Bins; i++) {
382+ engine.Fill (i, RWeight (0.1 + i * 0.03 ));
383+ }
384+
385+ for (auto index : axis.GetNormalRange ()) {
386+ auto &bin = engine.GetBinContent (index);
387+ double weight = 0.1 + index.GetIndex () * 0.03 ;
388+ EXPECT_FLOAT_EQ (bin.fSum , weight);
389+ EXPECT_FLOAT_EQ (bin.fSum2 , weight * weight);
390+ }
391+ }
0 commit comments