An error from clonetree

fit_Bs2jpsaiohi_prompt_sw_jpsi.C (11.5 KB)

copytree is ok !
Error in TBufferFile::WriteByteCount: bytecount too large (more than 1073741822)
Error in TBufferFile::WriteByteCount: bytecount too large (more than 1073741822)
Error in TBufferFile::CheckByteCount: object of class TObjArray read too many bytes: 1674128446 instead of 600386622
Warning in TBufferFile::CheckByteCount: TObjArray::Streamer() not in sync with data, fix Streamer(),
i have no idea about this, can you help me?

Hi Liuwe,

In order to help you we would need more information. For example, the ROOT version you used, the OS you are running on, the parameters you passed to the macro, etc. In summary, everything that is relevant to reproduce the issue.
The file you sent is more than 300 lines and is not self-contained. Please focus on creating a Minimal Reproducible Example that demonstrates the issue.

Best,
Lukas

example.c (2.0 KB)

(working) [root@DESKTOP-ADTHE2U unbiased]# root -l 'example.c("S24c4_down_BsToJpsiPhi_prompt_unbiased_cut_BDT0.root","S24c4_down_BsToJpsiPhi_prompt_unbiased_cut_BDT0_sw.root","sig_sw",2960,3240)'
root [0]
Processing example.c("S24c4_down_BsToJpsiPhi_prompt_unbiased_cut_BDT0.root","S24c4_down_BsToJpsiPhi_prompt_unbiased_cut_BDT0_sw.root","sig_sw",2960,3240)...
copytree is ok !
Error in <TBufferFile::WriteByteCount>: bytecount too large (more than 1073741822)
Error in <TBufferFile::WriteByteCount>: bytecount too large (more than 1073741822)
Error in <TBufferFile::CheckByteCount>: object of class TObjArray read too many bytes: 1674128446 instead of 600386622
Warning in <TBufferFile::CheckByteCount>: TObjArray::Streamer() not in sync with data, fix Streamer()

ROOT version is ROOT 6.30/04. I am running on Centos7. But the root file is too big, i can not upload it.

Does the error show up on other (perhaps smaller) input files too?
Please wrap code or output in ``` for better readability. I edited your post to illustrate.

#include <map>
#include <RooRealProxy.h>
#include <vector>
#include "RooAbsReal.h"
#include "RooAbsCategory.h"
#include <iostream>
#include <stdlib.h>
#include <RooChebychev.h>
#include <fstream>
#include "TObject.h"
#include "TCut.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TFile.h"
#include "TTree.h"
#include "TPostScript.h"
#include "TCanvas.h"
#include "TNtuple.h"
#include "TChain.h"
#include "TVector3.h"
#include "TLorentzVector.h"
#include "TPaveText.h"
#include "RooAbsPdf.h"
#include "RooFFTConvPdf.h"
#include "RooRealVar.h"
#include "RooNovosibirsk.h"
#include "RooCBShape.h"
#include "RooGaussian.h"
#include "RooChebychev.h"
#include "RooExtendPdf.h"
#include "RooDataSet.h"
#include "RooArgList.h"
#include "RooStats/SPlot.h"
#include "RooAddPdf.h"
#include "RooPlot.h"
#include "RooHist.h"
#include "RooNLLVar.h"
#include "RooMinimizer.h"

using namespace RooFit;

void  example(const char *input_rootname, const char *out_rootname, const char *output_weight,  double Mass_mini, double Mass_maxi){

  // read in mass information
  TChain *chain = new TChain();
  std::string chain_name = std::string(input_rootname)+"/DecayTree";
  chain->Add(chain_name.c_str());

  double Jpsi_M;
  chain -> SetBranchAddress("Jpsi_DTF_PV_MASS", &Jpsi_M);

  std::string mass_low_str = to_string(Mass_mini);
  std::string mass_hig_str = to_string(Mass_maxi);
  string mass_cut = "Jpsi_DTF_PV_MASS>"+mass_low_str+"&&Jpsi_DTF_PV_MASS<"+mass_hig_str;
  TTree* ch_new = chain->CopyTree(mass_cut.c_str());
  cout << "copytree is ok !" <<endl;

  TFile *rootfile  = new TFile(out_rootname,"recreate");
  TTree *DecayTree = new TTree("DecayTree","decay tree");

  DecayTree = ch_new->CloneTree(0);
  double sig_sw;
  std::string out_weight_form = std::string(output_weight) + "/D";
  DecayTree->Branch(output_weight,&sig_sw,out_weight_form.c_str());

  int Number_chain = ch_new->GetEntries();
  for(int i=0;i<Number_chain;i++){
           DecayTree->Fill();
                 }
  cout<<"-----"<<endl;
  rootfile->cd();
  DecayTree->Write();
  rootfile->Close();


}

Thanks to your help, I learned a new editing method!
When I’m only using half the amount of data, this problem doesn’t come up anymore. But I want to use as much data as I can. I suspect the problem may be due to clonetree.

Thank you @liuwe.
@pcanal could you please have a look at this issue?

This seems to indicate that you reach the current maximum number of baskets in a single TTree (more than 50 millions baskets). You will need to split the TTree accross multiple files.

If I split TTree into multiple parts, can I use all the data when doing sWeight?
for example,

                 double sig_sw;
                 RooStats::SPlot *splot = new RooStats::SPlot("splot","splot",*data,signex,RooArgSet(*ns,*nb));
                 splot->Print();
                 data->Print("v");

                 TTree* ch_new = chain->CopyTree(mass_cut.c_str());
                 TTree *DecayTree = new TTree("DecayTree","decay tree");
                 DecayTree = ch_new->CloneTree(0);
                 std::string out_weight_form = std::string(output_weight) + "/D";
                 DecayTree->Branch(output_weight,&sig_sw,out_weight_form.c_str());

                 int Number_chain = ch_new->GetEntries();
                 for(int i=0;i<Number_chain;i++){
                         ch_new->GetEntry(i);
                         sig_sw  = splot->GetSWeight( i, ns->GetName() );
                          DecayTree->Fill();
                 }

the data is all data.

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

Try:

                 double sig_sw;
                 RooStats::SPlot *splot = new RooStats::SPlot("splot","splot",*data,signex,RooArgSet(*ns,*nb));
                 splot->Print();
                 data->Print("v");

                 TTree* ch_new = chain->CopyTree(mass_cut.c_str());
                 TTree *DecayTree = new TTree("DecayTree","decay tree");
                 // DecayTree = ch_new->CloneTree(0);
                 std::string out_weight_form = std::string(output_weight) + "/D";
                 DecayTree->Branch(output_weight,&sig_sw,out_weight_form.c_str());

                 int Number_chain = ch_new->GetEntries();
                 for(int i=0;i<Number_chain;i++){
                   ch_new->GetEntry(i);
                   sig_sw  = splot->GetSWeight( i, ns->GetName() );
                   DecayTree->Fill();
                 }
                 // Now you can do:
                 ch_new->AddFriend(DecayTree);