You can do something like:
TH1::AddDirectory(kFALSE);
TFile *f0 = TFile::Open("file0.root"); TH1 *h1 = (TH1*)f0->Get("h1"); TH1 *h2 = (TH1*)f0->Get("h2"); TH1 *h3 = (TH1*)f0->Get("h3");
for (int_t i=1;i<N;i++) { TFile *f = TFile::Open(Form("file%d.root",i)); TH1 *h1a = (TH1*)f->Get("h1"); h1->Add(h1a); delete h1a; TH1 *h2a = (TH1*)f->Get("h2"); h2->Add(h2a); delete h2a; TH1 *h3a = (TH1*)f->Get("h3"); h13>Add(h3a); delete h3a;delete f;
h1->Write(); h2->Write(); h3->Write();
Rene Brun
navneet kumar wrote:
> Dear Rooters,
> I have some root files having some histograms and ntuples .
> But i want to add only 3 histograms from all root files(
> having same name)
> leaving everything else .
> Can anybody suggest ?
>
>
> Thanks
>
> Regards
> Navneet
>
> --
> *******************************************
> Navneet Kumar
> Research Scholar
> Department Of Physics
> Panjab University
> Chandigarh-160014
> ****************************************
> E-mail: naviblustar_at_yahoo.co.in <mailto:naviblustar_at_yahoo.co.in>
> knavneet.pu_at_gmail.com <mailto:knavneet.pu_at_gmail.com>
> nav_at_rcf.rhic.bnl.gov <mailto:nav_at_rcf.rhic.bnl.gov>
> Phone : 631-344-1152
> : 631-344-5268
> ******************************************
Received on Thu Nov 01 2007 - 09:32:22 CET
This archive was generated by hypermail 2.2.0 : Thu Nov 01 2007 - 17:50:02 CET