// DataHeaderList_t.cxx #include "dataset_atlaspool/DataHeaderList.h" #include #include #include "dataset_util/ssystem.h" #include "dataset_util/FileFinder.h" #include "dataset_util/getcwd.h" using std::string; using std::cout; using std::endl; using dset::DataHeaderList; // Display messsage. void msg(string txt) { cout << "*** " << txt << endl; } int DataHeaderList_t() { msg("Begin testing DataHeaderList"); system("rm -f LArSimTest.root"); msg("Create invalid list"); DataHeaderList dhl0("nosuchfile"); cout << dhl0 << endl; assert( ! dhl0.is_valid() ); assert( dhl0.error() != 0 ); msg("Find the event collection file"); FileFinder fnd(getcwd(), 5, -1); //string lname = "aod.root"; //string collname = "hits"; string basename = "LArSimTest"; //string basename = "pool_tutorial_1"; string collname = ""; string lname = basename + ".root"; cout << lname << endl; string fullname = fnd.find(lname); assert( fullname.size() ); cout << fullname << endl; ssystem("cp " + fullname + " ."); msg("Create header list"); DataHeaderList dhl(fullname); cout << dhl << endl; assert( dhl.is_valid() ); assert( dhl.error() == 0 ); msg("Fetch iterator"); DataHeaderList::Iterator idh = dhl.iterator(); int ievt = 0; while ( idh.next() ) { assert( idh.isValid() ); ++ievt; cout << " Event " << ievt << " has " << idh->size() << " entries" << endl; } assert( ievt > 0 ); return 0; } #ifdef CTEST_MAIN int main() { return DataHeaderList_t(); } #endif