Functions
test_dropAllEventsSubruns_verify.cxx File Reference
#include <cassert>
#include <iostream>
#include <string>
#include "TH1F.h"
#include "TFile.h"
#include "TTree.h"

Go to the source code of this file.

Functions

int check_ttree (TFile const *f, char const *name, bool const empty)
 
int test_dropAllEventsSubruns_verify (string const &suffix="")
 
int main (int argc, char **argv)
 

Function Documentation

int check_ttree ( TFile const *  f,
char const *  name,
bool const  empty 
)

Definition at line 12 of file test_dropAllEventsSubruns_verify.cxx.

13 {
14  TTree* tree = nullptr;
15  const_cast<TFile*>(f)->GetObject(name, tree);
16  assert(tree != nullptr);
17  if ((tree->GetEntries() == 0) && !empty) {
18  cerr << "Tree " << name << " from " << f->GetName() << " not supposed to be empty.\n";
19  return 1;
20  }
21  if ((tree->GetEntries() != 0) && empty) {
22  cerr << "Tree " << name << " from " << f->GetName() << " supposed to be empty.\n"
23  << " it has " << tree->GetEntries() << " entries.\n";
24  return 1;
25  }
26  return 0;
27 }
int main ( int  argc,
char **  argv 
)

Definition at line 73 of file test_dropAllEventsSubruns_verify.cxx.

74 {
75  if (argc > 1) {
77  }
78  else {
80  }
81 }
int test_dropAllEventsSubruns_verify(string const &suffix="")
int test_dropAllEventsSubruns_verify ( string const &  suffix = "")

Definition at line 30 of file test_dropAllEventsSubruns_verify.cxx.

31 {
32  bool const empty = true;
33  bool const not_empty = false;
34  string qual = suffix.empty() ? "" : string("_") + suffix;
35  string filename = string("out_dropAllEvents") + qual + string(".root");
36  TFile* f = TFile::Open(filename.c_str());
37  if (f == nullptr) {
38  return 1;
39  }
40  int passed = 0;
41  passed += check_ttree(f, "Events", empty);
42  passed += check_ttree(f, "EventMetaData", empty);
43  passed += check_ttree(f, "SubRuns", not_empty);
44  passed += check_ttree(f, "SubRunMetaData", not_empty);
45  passed += check_ttree(f, "Runs", not_empty);
46  passed += check_ttree(f, "RunMetaData", not_empty);
47  filename = string("out_dropAllEventsSubruns1") + qual + string(".root");
48  f = TFile::Open(filename.c_str());
49  if (f == nullptr) {
50  return 2;
51  }
52  passed += check_ttree(f, "Events", empty);
53  passed += check_ttree(f, "EventMetaData", empty);
54  passed += check_ttree(f, "SubRuns", empty);
55  passed += check_ttree(f, "SubRunMetaData", empty);
56  passed += check_ttree(f, "Runs", not_empty);
57  passed += check_ttree(f, "RunMetaData", not_empty);
58  filename = string("out_dropAllEventsSubruns2") + qual + string(".root");
59  f = TFile::Open(filename.c_str());
60  if (f == nullptr) {
61  return 3;
62  }
63  passed += check_ttree(f, "Events", empty);
64  passed += check_ttree(f, "EventMetaData", empty);
65  passed += check_ttree(f, "SubRuns", empty);
66  passed += check_ttree(f, "SubRunMetaData", empty);
67  passed += check_ttree(f, "Runs", not_empty);
68  passed += check_ttree(f, "RunMetaData", not_empty);
69  return passed;
70 }
std::string string
Definition: nybbler.cc:12
int check_ttree(TFile const *f, char const *name, bool const empty)