55int main(
int argc,
char** argv ) {
57 std::vector<std::string> args;
62 for (
int i=1 ; i<argc ; i++ ) {
63 std::string arg = argv[i];
64 if ( arg==
"-h" || arg==
"--help" )
return usage( std::cout, argc, argv );
65 else if ( arg==
"-v" || arg==
"--verbose" )
verbose =
true;
66 else if ( arg==
"-f" || arg==
"--fast" )
fast =
true;
68 else if ( arg==
"-d" || arg==
"--depth" ) {
69 if ( ++i<argc )
maxdepth = std::atoi(argv[i]);
70 else return usage( std::cout, argc, argv );
72 else if ( arg==
"-c" || arg==
"--contents" ) {
74 else return usage( std::cout, argc, argv );
77 else args.push_back(std::move(arg));
80 std::vector<std::string> labels;
81 labels.push_back(
"L2_");
82 labels.push_back(
"EF_");
83 labels.push_back(
"HLT_");
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;
107void descend( TDirectory* d,
int level,
int maxdepth,
const std::vector<std::string>& labels ) {
109 if (
verbose ) std::cout <<
"level " << level <<
"\tmaxdepth " <<
maxdepth << std::endl;
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";
141 if (
verbose ) std::cout <<
"level " << level <<
"\tmaxdepth " <<
maxdepth << std::endl;
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();
169 for (
unsigned il=labels.size() ; il-- ; ) {
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();
184 if ( th && std::string(th->GetName()) ==
histogram ) {
186 double ddd =
hsum( th );
188 std::cout <<
"\t" << ddd << std::endl;
197 if ( displayed ) std::cout << std::endl;