Merge of TTrees of one root file

Hi all,

I am trying to merge TTrees of one root file, and then to write the merged TTrees in a new root file.
Apparently I am able to write the output file, but it is unreadable ! When I try to draw some variable I receive
millions of error messages as

Error in TFile::ReadBuffer: error reading all requested bytes from file patrizia/pidcalib.root, got 0 of 103467

These are the lines of code that I am using …

  TFile *filePIDricci = TFile::Open("riccardo/pidcalib.root");

  TTree *muPlus  = (TTree*)filePIDricci->Get("Jpsi_MuPTuple/DecayTree");  
  TTree *muMinus = (TTree*)filePIDricci->Get("Jpsi_MuMTuple/DecayTree");
  TList *listmu = new TList;
  listmu->Add(muPlus);
  listmu->Add(muMinus);

  TFile *filePIDpatty = new TFile("patrizia/pidcalib.root","NEW");
  TTree *muons = new TTree;
  muons = TTree::MergeTrees(listmu);
 

  TTree *piPlus  = (TTree*)filePIDricci->Get("DSt_PiPTuple/DecayTree");  
  TTree *piMinus = (TTree*)filePIDricci->Get("DSt_PiMTuple/DecayTree");
  TList *listpi = new TList;
  listpi->Add(piPlus);
  listpi->Add(piMinus);
  TTree *pions = new TTree;
  pions = TTree::MergeTrees(listpi);
 
  listmu->SetName("muPlus_muMinus/DecayTree");
  listpi->SetName("piPlus_piMinus/DecayTree");

  listmu->Write();
  listpi->Write();  
  filePIDpatty->Close();

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.