12#define BOOST_TEST_MODULE MCH DigitTreeReader
13#define BOOST_TEST_DYN_LINK
14#include <boost/test/unit_test.hpp>
28 auto tree = std::make_unique<TTree>();
30 tree->SetName(
"o2sim");
32 std::vector<Digit>*
digits =
new std::vector<Digit>();
33 std::vector<ROFRecord>* rofs =
new std::vector<ROFRecord>();
36 tree->Branch(
"MCHROFRecords", rofs);
38 constexpr int ndigits{10};
40 for (
auto i = 0;
i < ndigits;
i++) {
41 digits->emplace_back(100,
i,
i * 10, 0);
61 TFile
f(
"toto.root",
"RECREATE");
77 TTree emptyTree(
"emptyTree",
"no branch at all");
78 BOOST_CHECK_THROW(
DigitTreeReader dtr(&emptyTree), std::invalid_argument);
88 TTree missingRofs(
"missingRofs",
"MCHDigit branch alone");
89 std::vector<o2::mch::Digit>
digits;
90 missingRofs.Branch(
"MCHDigit", &
digits);
91 BOOST_CHECK_THROW(
DigitTreeReader dtr(&missingRofs), std::invalid_argument);
96 TTree missingDigits(
"missingDigits",
"MCHROFRecords branch alone");
97 std::vector<o2::mch::ROFRecord> rofs;
98 missingDigits.Branch(
"MCHROFRecords", &rofs);
99 BOOST_CHECK_THROW(
DigitTreeReader dtr(&missingDigits), std::invalid_argument);
104 TTree invalidDigits(
"invalidDigits",
"MCHDigit branch present but of wrong type");
105 std::vector<o2::mch::ROFRecord> rofs;
106 invalidDigits.Branch(
"MCHDigit", &rofs);
107 invalidDigits.Branch(
"MCHROFRecords", &rofs);
108 invalidDigits.Fill();
109 BOOST_CHECK_THROW(
DigitTreeReader dtr(&invalidDigits), std::invalid_argument);
114 TTree invalidRofs(
"invalidRofs",
"MCHROFRecords branch present but of wrong type");
115 std::vector<o2::mch::Digit>
digits;
116 invalidRofs.Branch(
"MCHDigit", &
digits);
117 invalidRofs.Branch(
"MCHROFRecords", &
digits);
119 BOOST_CHECK_THROW(
DigitTreeReader dtr(&invalidRofs), std::invalid_argument);
124 TTree noEntry(
"noEntry",
"All branches correct but no entry");
125 std::vector<o2::mch::Digit>
digits;
126 std::vector<o2::mch::ROFRecord> rofs;
127 noEntry.Branch(
"MCHDigit", &
digits);
128 noEntry.Branch(
"MCHROFRecords", &rofs);
129 BOOST_CHECK_THROW(
DigitTreeReader dtr(&noEntry), std::invalid_argument);
134 TTree correct(
"noEntry",
"All branches correct but no entry");
135 std::vector<o2::mch::Digit>
digits;
136 std::vector<o2::mch::ROFRecord> rofs;
137 correct.Branch(
"MCHDigit", &
digits);
138 correct.Branch(
"MCHROFRecords", &rofs);
bool nextDigits(o2::mch::ROFRecord &rof, std::vector< o2::mch::Digit > &digits)
BOOST_AUTO_TEST_CASE(FlatHisto)
std::unique_ptr< TTree > createTestTree()
BOOST_CHECK_NO_THROW(algorithm::merge(target, other))
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
std::vector< Digit > digits