Byte count too large error while copying histogram

Hi. I have two root files containing TH3F histograms.
Interior.root
Exterior.root

I want to copy the TH3F histograms from both the above files to a new file Combined.root
I was able to do so earlier when the histograms had fewer bins but recently I modified the histograms to have almost twice the number of bins and now I get this error.

Error in <TBufferFile::CheckByteCount>: object of class TH3F read too many bytes: 1162592650 instead of 88850826
Warning in <TBufferFile::CheckByteCount>: TH3F::Streamer() not in sync with data on file Interior.root, fix Streamer()
Error in <TBufferFile::WriteByteCount>: bytecount too large (more than 1073741822)

Is there a way to fix this?


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.16.00
Platform: Ubuntu
Compiler: Not Provided


ROOT Forum → Search → 1073741822

I read through the search results and a lot of replies point out to the 1Gb limit of the RooDataSet.
Maybe I am too much of a newbie but I have not explicitly used RooDataSet.

Here is the code I used to merge the histograms

int main(){
  TString fileName = "Combined.root";

  TFile *outFile = new TFile(fileName,"recreate");
  

  TString dir = "/path/to/file";
  
  TString inFileNameTH3Dint = "Interior.root";
  TString inFileNameTH3Dintextended = "Exterior.root";

  TH3F* mapint = nullptr;
  TH3F* mapintextended = nullptr;

  TFile* fileTH3Dint = TFile::Open(dir+inFileNameTH3Dint);
  fileTH3Dint->GetObject("IntHistName",mapint);
  mapint->SetNameTitle("IntHistName","IntHistName");
  

  TFile* fileTH3Dintextended = TFile::Open(dir+inFileNameTH3Dintextended);  
  fileTH3Dintextended->GetObject("IntExtendedHistName",mapintextended);  
  mapintextended->SetNameTitle("IntExtendedHistName","IntExtendedHistName");



  outFile->cd();
  mapint->Write();
  mapintextended->Write();
 
 
  outFile->Close();
  cout<<"root -l "<<fileName<<endl;
}

Additionally, when I try to open the root file Combined.root I get this error and warning message but I am able to slice and plot the histogram using Project3D. So I am not really sure what’s going on.

root [1] TH3F *h1 = (TH3F*) _file0->Get("IntExtendedHistName")
Error in <TBufferFile::CheckByteCount>: object of class TH3F read too many bytes: 1162592650 instead of 88850826
Warning in <TBufferFile::CheckByteCount>: TH3F::Streamer() not in sync with data on file Combined.root, fix Streamer()
(TH3F *) 0x556b6b08e300

Apologies for inconvenience.

Hi @rushabhgala,

Alternatively, you should be able to use hadd to merge your .root files. In regards to the warning that you are facing, I am inviting @pcanal to this topic, as I’m sure he can shed some light on this.

Cheers,
J.

Maybe you are facing this bug (check which ROOT versions produced your files, which versions you use to read them, and do not use the versions known to be broken):