17 #include "TDirectory.h"
30 if (
argc<1 )
return -1;
31 s <<
"Usage: " <<
argv[0] <<
" [OPTIONS] <file1> <file2> ... \n\n";
32 s <<
" writes names of chains from files\n\n";
34 s <<
" -a, --always \t always descend, \n";
35 s <<
" -d, --depth maxdepth \t maximum depth to descend, \n";
36 s <<
" -c, --contents histogram \t display number of entries in histogram, \n";
37 s <<
" -f, --fast \t bomb out as soon as a single chain has been found, \n";
38 s <<
" -v, --verbose \t verbose output, \n";
39 s <<
" -h, --help \t this help,\n";
57 std::vector<std::string>
args;
62 for (
int i=1 ;
i<
argc ;
i++ ) {
66 else if (
arg==
"-f" ||
arg==
"--fast" )
fast =
true;
68 else if (
arg==
"-d" ||
arg==
"--depth" ) {
72 else if (
arg==
"-c" ||
arg==
"--contents" ) {
80 std::vector<std::string>
labels;
85 for (
unsigned i=0 ;
i<
args.size() ;
i++ ) {
86 TFile
f(
args[
i].c_str() );
88 if ( !
f.IsOpen() ||
f.IsZombie() ) {
89 std::cerr <<
"Error: could not open input file: " <<
args[
i] << std::endl;
103 for (
int i=0 ;
i<=
h->GetNbinsX()+1 ;
i++ )
d +=
h->GetBinContent(
i);
113 TList*
tl =
d->GetListOfKeys();
115 if (
verbose ) std::cout <<
"list of keys " <<
tl <<
" " << (
tl ?
tl->Capacity() : 0 ) << std::endl;
119 std::string
name =
d->GetName();
123 if ( !
verbose )
if ( plevel>0 ) plevel--;
125 for (
int ip=plevel ;
ip-- ; ) std::cout <<
"\t";
127 bool displayed =
false;
131 if (
verbose ) std::cout <<
"Directory: ";
136 if ( dsize<60 ) std::cout <<
"\t";
143 for (
int i=
tl->GetSize() ;
i-- ; ) {
145 TKey* tobj = (TKey*)
tl->At(
i);
147 if ( tobj==0 )
continue;
153 if ( std::string(tobj->GetClassName()).
find(
"TDirectory")!=std::string::npos ) {
155 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
157 if ( tnd==0 )
continue;
159 std::string
dname = tnd->GetName();
170 if (
dname.find(
labels[
il])!=std::string::npos) dscnd =
true;
178 if ( std::string(tobj->GetClassName()).find(
"TH1")!=std::string::npos ||
180 std::string(tobj->GetClassName()).find(
"TProfile")!=std::string::npos ) {
182 TH1*
th = (TH1*)tobj->ReadObj();
188 std::cout <<
"\t" <<
d << std::endl;
197 if ( displayed ) std::cout << std::endl;