12 const std::string treeName = tree->GetName();
13 if (tree->GetEntries() != expectedEntries) {
14 std::cerr <<
"Tree \'" << treeName <<
"\' should have " << expectedEntries <<
" but has " << tree->GetEntries()
19 const auto* branches = tree->GetListOfBranches();
20 for (
const auto& branch : expectedBranches) {
22 for (
int i = 0; i < branches->GetEntries(); ++i) {
23 if (branch == branches->At(i)->GetName()) {
29 std::cerr <<
"Branch \'" << branch <<
"\' was expected to be in Tree \'" << treeName
30 <<
"\' but could not be found" << std::endl;
35 if ((
unsigned)branches->GetEntries() != expectedBranches.size()) {
36 std::cerr <<
"Tree \'" << treeName <<
"\' has additional, unexpected branches" << std::endl;
45 TFile* bmFile = TFile::Open(fileName);
47 std::cerr <<
"Benchmark file \'" << fileName <<
"\' does not exist!" << std::endl;
50 if (!
verifyTree(
static_cast<TTree*
>(bmFile->Get(
"setup_times")), 1, setupBranches)) {
51 std::cerr <<
"In file \'" << fileName <<
"\' setup_times Tree does not have the expected entries" << std::endl;
55 if (!
verifyTree(
static_cast<TTree*
>(bmFile->Get(
"event_times")), expectedEvents, eventBranches)) {
56 std::cerr <<
"In file \'" << fileName <<
"\' event_times Tree does not have the expected entries" << std::endl;
68int main(
int,
char* argv[]) {
69 const StringVec writeBMSetupBranches = {
"constructor",
"finish",
"register_for_write"};
70 const StringVec writeBMEventBranches = {
"write_event"};
71 verifyBMFile(argv[1], writeBMSetupBranches, writeBMEventBranches);
73 const StringVec readBMSetupBranches = {
"constructor",
"open_file",
"close_file",
"get_entries",
74 "read_collection_ids"};
75 const StringVec readBMEventBranches = {
"read_collections",
"read_ev_md",
"read_run_md",
76 "read_coll_md",
"end_of_event",
"read_event"};
77 verifyBMFile(argv[2], readBMSetupBranches, readBMEventBranches);
void verifyBMFile(const char *fileName, const StringVec &setupBranches, const StringVec &eventBranches, int expectedEvents=nExpectedEvents)
constexpr int nExpectedEvents
std::vector< std::string > StringVec
bool verifyTree(TTree *tree, int expectedEntries, const StringVec &expectedBranches)