I have some problems using TChain::Merge() method.
Here there is my little script to merge files containing TTree “h_9000”
void MergeFiles()
{
TChain ch2("h9000");
Char_t *var = new Char_t[20];
for (int run = 28; run <45; run++)
{
sprintf(var,"runE%d.root", run);
ch2.Add(var);
cout<<run<<endl;
}
ch2.Merge("runE.root");
}
This is the error message at the end :
Error: Symbol #include is not defined in current scope MergeFiles.C:37:
Error: Symbol exception is not defined in current scope MergeFiles.C:37:
Syntax Error: #include MergeFiles.C:37:
Error: Symbol G__exception is not defined in current scope MergeFiles.C:37:
Error: type G__exception not defined FILE:/home/usert/7Bedata/Root/./MergeFiles.C LINE:37
*** Interpreter error recovered ***
You’re right, but I’ve simply deleted some comments.
void MergeFiles()
{
TChain ch2("h9000");
Char_t *var = new Char_t[50];
for (int run = 28; run <45; run++)
{
sprintf(var,"runE%d.root", run);
ch2.Add(var);
cout<<"File 'runE"<<run<<".root' added to the merge"<<endl;
}
ch2.Merge("runE_prova.root");
}
Error: Symbol #include is not defined in current scope MergeFiles.C:15:
Error: Symbol exception is not defined in current scope MergeFiles.C:15:
Syntax Error: #include MergeFiles.C:15:
Error: Symbol G__exception is not defined in current scope MergeFiles.C:15:
Error: type G__exception not defined FILE:/home/usert/7Bedata/Root/./MergeFiles.C LINE:15
*** Interpreter error recovered ***
As you can see the problems are at line 15, before “ch2.Merge(…)”.
I have an output file but I’m not that is really a good file.
Try again after compiling your script (add #include “TChain.h” and use .L MergeFiles.C+), if the problem is not related to CINT this should give us more precise information.
Also you may want to consider just using the executable hadd to do the work: