|
ATLAS Offline Software
|
Go to the documentation of this file.
55 bool add(
const std::string&
hname, TKey* tobj ) {
57 T*
h0 = (
T*)tobj->ReadObj();
66 std::cerr <<
"object " <<
hname <<
" can't be found" << std::endl;
70 if (
h0->GetSumw2N()==0 )
h0->Sumw2();
88 std::cout <<
"h (add) " <<
h <<
" " <<
hname <<
" can't be opened" << std::endl;
94 if (
h->GetSumw2N()==0 )
h->Sumw2();
110 h0->Write(
"",TObject::kOverwrite);
126 void search(TDirectory* td=0,
const std::string&
s=
"") {
142 if (
ns!=
"" )
ns +=
"/";
149 std::cout <<
"\n" <<
depth <<
"Directory " <<
ns;
152 std::string savedepth =
depth;
163 for (
int i=
tl->GetSize() ;
i-- ; ) {
165 TKey* tobj = (TKey*)
tl->At(
i);
167 if ( tobj==0 )
continue;
173 if ( std::string(tobj->GetClassName()).find(
"TDirectory")!=std::string::npos ) {
176 TDirectory* tnd = (TDirectory*)tobj->ReadObj();
183 std::string objname =
ns;
184 if ( objname!=
"" ) objname += std::string(
"/") + tobj->GetName();
188 if ( std::string(tobj->GetClassName()).find(
"TH1")!=std::string::npos ) add<TH1>( objname, tobj );
189 if ( std::string(tobj->GetClassName()).find(
"TH2")!=std::string::npos ) add<TH2>( objname, tobj );
190 if ( std::string(tobj->GetClassName()).find(
"TProfile")!=std::string::npos ) add<TProfile>( objname, tobj );
202 std::cout <<
"\tprocessed directory in " <<
t*0.001 <<
" s from " << global_time*0.001 <<
" s";
221 if ( FILE* testfile=fopen(
s.c_str(),
"r") ) {
235 if (
files.size()<2 )
return;
237 std::cout <<
"processing" << std::endl;
241 std::cerr <<
"output file " <<
outputfile <<
" already exists" << std::endl;
245 std::cout <<
"copying file to " <<
outputfile << std::endl;
254 std::cout <<
"opening root files" << std::endl;
259 std::cout <<
"opening " <<
files[0] << std::endl;
265 std::cerr <<
"cannot open " <<
outputfile.c_str() << std::endl;
270 std::cout <<
"opening " <<
files[
ifile] << std::endl;
277 std::cerr <<
"file " <<
files[
ifile] <<
" cannot be openened" << std::endl;
294 std::cout <<
"closing the files" << std::endl;
314 s <<
"Usage: " <<
argv[0] <<
" [OPTIONS] -o output.root input1.root ... inputN.root\n\n";
315 s <<
" -o filename \tname of output (filename required)\n";
316 s <<
" -h, --help \tdisplay this help\n";
330 for (
int i=1 ;
i<
argc ;
i++ ) {
338 for (
int i=1 ;
i<
argc ;
i++ ) {
339 if ( std::string(
argv[
i])==
"--verbose" )
verbose =
true;
340 else if ( std::string(
argv[
i])==
"-o" ) {
365 if (
verbose ) std::cout <<
"timing" << std::endl;
373 std::cout <<
"\ntotal time " <<
t*0.001 <<
" s (" << (
t*0.001/60) <<
" min)" << std::endl;
void search(TDirectory *td=0, const std::string &s="")
recursive directory search for TH1 and TH2
struct timeval simpletimer_start(void)
std::string depth
tag string for intendation
std::vector< std::string > files
file names and file pointers
bool file_exists(const std::string &s)
int main(int argc, char **argv)
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...
bool add(const std::string &hname, TKey *tobj)
double simpletimer_stop(const struct timeval &start_time)
void cost(const std::string &outputfile)
int usage(std::ostream &s, int, char **argv)
std::vector< TFile * > fptr
int ir
counter of the current depth
struct timeval global_timer
glabal timer - how long have I taken so far?