Macro to add histogram files This macro is kept for didactical purposes only: use instead the executable $ROOTSYS/bin/hadd !
This macro will add histograms from a list of root files and write them to a target root file. The target file is newly created and must not be identical to one of the source files. This code is based on the hadd.C example by Rene Brun and Dirk Geppert, which had a problem with directories more than one level deep. The macro from Sven has been enhanced by Anne-Sylvie Nicollerat Anne-.nosp@m.Sylv.nosp@m.ie.Ni.nosp@m.coll.nosp@m.erat@.nosp@m.cern.nosp@m..ch to automatically add Trees (via a chain of trees).
#include <string.h>
void hadd() {
}
MergeRootfile( Target, FileList );
}
path.Remove( 0, 2 );
first_source->
cd( path );
while ( (key = (
TKey*)nextkey())) {
if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue;
first_source->
cd( path );
while ( nextsource ) {
if (key2) {
delete h2;
}
nextsource = (
TFile*)sourcelist->
After( nextsource );
}
}
const char* obj_name= obj->
GetName();
globChain =
new TChain(obj_name);
while ( nextsource ) {
nextsource = (
TFile*)sourcelist->
After( nextsource );
}
cout <<
"Found subdirectory " << obj->
GetName() << endl;
MergeRootfile( newdir, sourcelist );
} else {
cout << "Unknown object type, name: "
}
if ( obj ) {
else
obj->
Write( key->GetName() );
}
}
}
- Author
- Sven A. Schmidt, sven..nosp@m.schm.nosp@m.idt@c.nosp@m.ern..nosp@m.ch, 13.2.2001
Definition in file hadd.C.