1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "TFile.h"
#include "TKey.h"
#include "TTree.h"
#include "TError.h"
#include "TCollection.h"
#include <iostream>
void treelist()
{
std::string fname;
gErrorIgnoreLevel = kError;
std::cin >> fname;
if(fname == "quit") return;
TObject * obj;
TKey * key;
TFile * file = new TFile(fname.c_str(),"READ","Test file");
if(file) {
std::cout << "\nNames of TTree objects in file: " << fname << std::endl;
gErrorIgnoreLevel = kError;
TIter next(file->GetListOfKeys());
while( (key = (TKey*)next()) ) {
obj = key->ReadObj();
if ( (obj->InheritsFrom("TTree")) ) {
std::cout << "\t\t" << ((TTree*)obj)->GetName() << std::endl;
}
}
}
std::cout << " " << std::endl;
}
|