Chain of converted .rz files

I would like to chain together some .rz files I’ve converted to root files. The structure of the files is as follows:

root [0] TFile f(“jetweb_hrw61_19130.root”)
root [1]
TFile** jetweb_hrw61_19130.root HBOOK file: /data2/pryan/ntuples/jetweb/iproc/jetweb_hrw61_19130.rz converted to ROOT
TFile* jetweb_hrw61_19130.root HBOOK file: /data2/pryan/ntuples/jetweb/iproc/jetweb_hrw61_19130.rz converted to ROOT
KEY: TH1F h_1;1 $Date: 2003/10/03 08:26:35

I have tried using the following code to chain them together

  char* inFile = "jetweb_hrw61_19130.root";
  TChain* chain_ptr = new TChain("h_1","Chain of h_1");
  chain_ptr ->  Add(inFile);
  // Get total number of entries in chain
  Int_t nentries = Int_t(chain_ptr -> GetEntriesFast() );
  cout << nentries << "\n";

  // Loop over all events in Chain
   for (Int_t jentry=0; jentry<nentries; jentry++) {
     cout << "J " << jentry << "\n";
   } //for

The output for nentries is 1234567890

Is it possible to use TChain on these files since they don’t contain a TTree but instead TH1? If not, what is the easiest way to combine the files without reading each file in individually with TFile? And if so, is there a problem taking the directory RAPGAP into account when chaining?

Thanks a lot!!


Hi Pat,
use $ROOTSYS/bin/hadd to add the TH1F from the different files. See “hadd -h”. It also takes care of histos and trees in TDirectories.