Hi,
You can try the following macro. I forgot how I got it. It will chain
your "Global" root-trees to a chain named globChain.
//----------------------------------------------------------
TChain *globChain = new TChain("Global");
TString fNameList = TString("my-files.list");
cout << ">>> Load Chain from file: " << fNameList << endl;
ifstream fList((char*)fNameList);
if (!fList)
{
cout << "!!! Can't open file " << fNameList << endl;
return;
}
char lineFromFile[255];
while(fList.getline(lineFromFile, 250))
{
TString fileName = lineFromFile;
fileName = "/exp/D0/vuanh/D0Rawdata/" + fileName;
if(globChain->Add((char*)fileName))
cout << ">> File '" << fileName << "' has been loaded" << endl;
else
cout << ">> Can't load file '" << fileName << "'" << endl;
}
cout << ">> Total number of entries: " << globChain->GetEntries() <<
endl;
fList.close();
//----------------------------------------------------------
You need to provide your file list, something like this
essai0.root
essai1.root
essai2.root
with a blank line at the end so the macro can read them all. Now you can
work with your "globChain" as it were your "Global" tree.
Tuan
On Mon, 3 Jun 2002, Anne-Sylvie Nicollerat wrote:
> Hello,
>
> I would like to know if it is possible to combine root files.
>
> I am now running on big sets of data and to go faster, I divided the
> data set in 4 different subsets. I am now running root parallely on each
> of the subsets, writing 4 different .root files.
> In the end, I would like to combine the histograms of the 4
different
> root files. A way I found was to open all the files and then add the
> histograms.
> (eg:
> f10 = new TFile("essai0.root");
> f11 = new TFile("essai1.root");
> .....
> TH1D *a1=(TH1D*) f10->Get("z0100");
> TH1D *a2=(TH1D*) f10->Get("z0101");
>
> TH1D *b1=(TH1D*) f11->Get("z0100");
> TH1D *b2=(TH1D*) f11->Get("z0101");
>
> ....
> a1->Add(b1);
> a2->Add(b2);
> .....)
>
> I was wondering if there was a possibility to do it in a more
> staightforward way (that means without needing to ask root to add
> separately all the histograms I am interested in).
> I saw that there was an Add and an Append method for a root files but
> somehow I didn't find out how it worked.
>
> Thanks a lot for your help
>
> cheers
>
> Anne-Sylvie
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET