!if the object is a tree, it is stored in globChain...
75 TString path( (
char*)strstr( target->GetPath(),
":" ) );
78 TFile *first_source = (TFile*)sourcelist->First();
79 first_source->cd( path );
80 TDirectory *current_sourcedir = gDirectory;
83 TChain *globChain = 0;
84 TIter nextkey( current_sourcedir->GetListOfKeys() );
86 while ( (key = (TKey*)nextkey())) {
89 first_source->cd( path );
90 TObject *obj = key->ReadObj();
92 if ( obj->IsA()->InheritsFrom(
"TH1" ) ) {
100 TFile *nextsource = (TFile*)sourcelist->After( first_source );
101 while ( nextsource ) {
104 nextsource->cd( path );
105 TH1 *
h2 = (TH1*)gDirectory->Get( h1->GetName() );
112 nextsource = (TFile*)sourcelist->After( nextsource );
115 else if ( obj->IsA()->InheritsFrom(
"TTree" ) ) {
118 const char* obj_name= obj->GetName();
120 globChain =
new TChain(obj_name);
121 globChain->Add(first_source->GetName());
122 TFile *nextsource = (TFile*)sourcelist->After( first_source );
125 while ( nextsource ) {
127 globChain->Add(nextsource->GetName());
128 nextsource = (TFile*)sourcelist->After( nextsource );
131 }
else if ( obj->IsA()->InheritsFrom(
"TDirectory" ) ) {
134 cout <<
"Found subdirectory " << obj->GetName() << endl;
138 TDirectory *newdir = target->mkdir( obj->GetName(), obj->GetTitle() );
148 cout <<
"Unknown object type, name: "
149 << obj->GetName() <<
" title: " << obj->GetTitle() << endl;
160 if(obj->IsA()->InheritsFrom(
"TTree" ))
161 globChain->Write( key->GetName() );
163 obj->Write( key->GetName() );
void MergeRootfile(TDirectory *target, TList *sourcelist)