#include <iostream>
#include <string>
#include "TFile.h"
#include "TDirectory.h"
#include "TList.h"
#include "TKey.h"
#include "TH1D.h"
Go to the source code of this file.
|
void | descend (TDirectory *d, int level, int maxdepth, const std::vector< std::string > &labels) |
|
int | usage (std::ostream &s, int argc, char **argv) |
|
int | main (int argc, char **argv) |
|
double | hsum (TH1 *h) |
| sum the bin contents including the over and underflow bins More...
|
|
- Author
- mark sutton
- Date
- Fri 11 Jan 2019 07:41:26 CET
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Definition in file chains.cxx.
◆ descend()
void descend |
( |
TDirectory * |
d, |
|
|
int |
level, |
|
|
int |
maxdepth, |
|
|
const std::vector< std::string > & |
labels |
|
) |
| |
Definition at line 107 of file chains.cxx.
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;
◆ hsum()
sum the bin contents including the over and underflow bins
Definition at line 101 of file chains.cxx.
103 for (
int i=0 ;
i<=
h->GetNbinsX()+1 ;
i++ )
d +=
h->GetBinContent(
i);
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 55 of file chains.cxx.
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;
◆ usage()
int usage |
( |
std::ostream & |
s, |
|
|
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
should never be the case
Definition at line 29 of file chains.cxx.
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";
◆ always_descend
bool always_descend = false |
◆ fast
◆ histogram
std::string histogram = "" |
◆ verbose
very lazy!!! should not use unnessecary global variables !!!!
Definition at line 50 of file chains.cxx.